discountCard.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="content">
  3. <view class="teamTop">
  4. <view class="sumCount">可使用优惠券</view>
  5. </view>
  6. <!-- 列表 -->
  7. <view class="itemContent">
  8. <view v-for="(item,index) in itemData" :key="index">
  9. <view class="item">
  10. <!-- 第一块 -->
  11. <view class="topView" @click="ckCoupon(item)">
  12. <view class="leftView">
  13. <view class="moneyView">
  14. <view>¥</view>
  15. <view class="money">{{item.ActMoney}}</view>
  16. </view>
  17. <view class="condition" v-if="item.WhereMoney != 0">满{{item.WhereMoney}}元可用</view>
  18. <view class="condition" v-else>满任意金额可用</view>
  19. </view>
  20. <view class="rightView">
  21. <view class="cardName">{{item.ActName}}</view>
  22. <!-- 时间截取 -->
  23. <view class="valid">有效期:{{item.StartTime.slice(0,item.StartTime.length-8)}}至 {{item.EndTime.slice(0,item.EndTime.length-8)}}</view>
  24. </view>
  25. </view>
  26. <!-- 第二快 -->
  27. <view class="bottomView">
  28. <view>发放门店:{{item.ShopName}}</view>
  29. <view @click="goDiscountDetail(item)">查看详情</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 上拉 加载更多 -->
  35. <view class="noMore" v-if="noMoreShow">没有更多数据</view>
  36. <!-- 无数据空白页 -->
  37. <nodata v-if="itemData.length==0"></nodata>
  38. </view>
  39. </template>
  40. <script>
  41. import nodata from '../../components/nodata/nodata.vue'
  42. export default {
  43. components: {
  44. nodata,
  45. },
  46. data() {
  47. return {
  48. itemData: [],
  49. page: 1,
  50. noMoreShow: false,
  51. payMoney:'',
  52. }
  53. },
  54. onLoad(opt) {
  55. this.page = 1
  56. if(opt.payMoney){
  57. this.payMoney=opt.payMoney;
  58. this.myOrderCoupon()
  59. }else{
  60. this.getItemData()
  61. }
  62. },
  63. methods: {
  64. ckCoupon(item){
  65. console.log(item);
  66. uni.setStorage({
  67. key: 'couponData',
  68. data: item,
  69. success: function () {
  70. uni.navigateBack({
  71. delta:1
  72. })
  73. }
  74. });
  75. },
  76. myOrderCoupon(){
  77. uni.showLoading({
  78. title: '加载中'
  79. })
  80. this.$http('miniApp/maintainOrder/myOrderCoupon', {
  81. money:this.payMoney,
  82. page:this.page,
  83. limit:10,
  84. },'GET').then(res => {
  85. uni.hideLoading();
  86. var list = res.data.Items
  87. // 处理 undefined和null转为空白字符串
  88. list.forEach((item, index) => {
  89. for (const key in item) {
  90. item[key] = this.$praseStrEmpty(item[key])
  91. }
  92. })
  93. if (this.page == 1) {
  94. this.itemData = list
  95. } else {
  96. this.itemData = this.itemData.concat(list)
  97. }
  98. if (list.length < 10) {
  99. this.noMoreShow = false
  100. } else {
  101. this.noMoreShow = true
  102. }
  103. })
  104. },
  105. goDiscountDetail(item) {
  106. uni.navigateTo({
  107. url: 'discountDetail?couponId=' + item.CouponID,
  108. })
  109. },
  110. getItemData() {
  111. uni.showLoading({
  112. title: '加载中'
  113. })
  114. let url = 'miniAppMyBMemberCar/listMiniAppCouponPage',
  115. params = {
  116. page: this.page,
  117. limit: 20,
  118. }
  119. this.$http(url, params, 'GET').then(res => {
  120. uni.hideLoading();
  121. var list = res.data.Items
  122. // 处理 undefined和null转为空白字符串
  123. list.forEach((item, index) => {
  124. for (const key in item) {
  125. item[key] = this.$praseStrEmpty(item[key])
  126. }
  127. })
  128. if (this.page == 1) {
  129. this.itemData = list
  130. } else {
  131. this.itemData = this.itemData.concat(list)
  132. }
  133. if (list.length < 10) {
  134. this.noMoreShow = false
  135. } else {
  136. this.noMoreShow = true
  137. }
  138. })
  139. },
  140. },
  141. // 下拉刷新 上拉加载更多
  142. onPullDownRefresh() {
  143. this.page = 1
  144. if(opt.payMoney){
  145. this.myOrderCoupon()
  146. }else{
  147. this.getItemData()
  148. }
  149. //this.getItemData()
  150. setTimeout(function() {
  151. uni.stopPullDownRefresh();
  152. }, 1000);
  153. },
  154. onReachBottom() {
  155. this.page++;
  156. if(opt.payMoney){
  157. this.myOrderCoupon()
  158. }else{
  159. this.getItemData()
  160. }
  161. },
  162. }
  163. </script>
  164. <style scoped>
  165. .content {
  166. background: #F4F5F7;
  167. min-height: 100vh;
  168. }
  169. .teamTop {
  170. position: fixed;
  171. top: 0rpx;
  172. left: 0rpx;
  173. background-color: #F4F5F7;
  174. width: 100%;
  175. height: 77rpx;
  176. }
  177. .sumCount {
  178. padding: 20rpx 24rpx;
  179. color: #999999;
  180. font-size: 26rpx;
  181. }
  182. .itemContent {
  183. padding: 55rpx 20rpx 24rpx;
  184. }
  185. .item {
  186. margin: 20rpx 0rpx;
  187. background-color: #FFFFFF;
  188. border-radius: 10rpx;
  189. }
  190. .topView {
  191. display: flex;
  192. justify-content: flex-start;
  193. padding: 22rpx 0rpx;
  194. margin-left: 22rpx;
  195. margin-right: 22rpx;
  196. border-bottom: 1rpx #CCCCCC dashed;
  197. align-items: center;
  198. }
  199. .leftView,
  200. .rightView {
  201. margin-right: 40rpx;
  202. }
  203. .moneyView {
  204. display: flex;
  205. justify-content: flex-start;
  206. color: #FF4F00;
  207. align-items: baseline;
  208. }
  209. .money {
  210. font-size: 56rpx;
  211. }
  212. .condition {
  213. font-size: 22rpx;
  214. color: #999999;
  215. }
  216. .cardName {
  217. font-size: 30rpx;
  218. font-weight: bold;
  219. color: #333333;
  220. margin-top: 10rpx;
  221. margin-bottom: 15rpx;
  222. }
  223. .valid {
  224. font-size: 26rpx;
  225. color: #999999;
  226. }
  227. .bottomView {
  228. display: flex;
  229. justify-content: space-between;
  230. padding: 20rpx 24rpx;
  231. font-size: 24rpx;
  232. color: #666666;
  233. }
  234. .noMore {
  235. text-align: center;
  236. line-height: 50rpx;
  237. color: #999999;
  238. font-size: 28rpx;
  239. }
  240. </style>