coupon.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view>
  3. <view>
  4. <scroll-view scroll-x class="bg-white nav text-center" style="height: 100vh;">
  5. <view :class="index==TabCur?'cu-item text-blue cur':'cu-item'" v-for="(item,index) in list" :key="index" @click="tabSelect"
  6. :data-id="index" style="">
  7. {{item.name}}
  8. <text v-if="index == 0">({{notUsedList.length}})</text>
  9. <text v-if="index == 1">({{usedList.length}})</text>
  10. <text v-if="index == 2">({{invalidList.length}})</text>
  11. </view>
  12. <view class="coupon-List" v-if="TabCur == 0">
  13. <!-- <view style="text-align: right;">
  14. <text>使用规则 ></text>
  15. </view> -->
  16. <view class="margin-top-sm">
  17. <view class="cu-list menu-avatar padding-tb-sm bg-white">
  18. <view class="cu-item" v-for="(item,index) in notUsedList" :key="index" @click="gotoinfo(item)">
  19. <view class="cu-avatar round lg" :style="'background-image:url('+imghost+item.icon+');background-color: #fff;'">
  20. </view>
  21. <view class="content">
  22. <view class="text-grey">
  23. <text class="text-cut">{{item.name}}</text>
  24. </view>
  25. <view class="text-gray text-sm flex">
  26. <text class="text-cut">{{item.title}}</text>
  27. </view>
  28. <view class="text-gray text-sm flex">
  29. <text class="" v-if="item.expire_type==2">有效期:{{formatDate(item.start_time*1000)}}-{{formatDate(item.end_time*1000)}}</text>
  30. <text class="" v-else>{{formatDate(item.expire_time*1000)}} 到期</text>
  31. </view>
  32. </view>
  33. <view class="action">
  34. <!-- <view class="text-grey text-xs">22:20</view>
  35. <view class="cuIcon-notice_forbid_fill text-gray"></view> -->
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view v-else-if="TabCur == 1">
  42. <view class="margin-top-sm">
  43. <view class="cu-list menu-avatar padding-tb-sm bg-white">
  44. <view class="cu-item" v-for="(item,index) in usedList" :key="index">
  45. <view class="cu-avatar round lg" :style="'background-image:url('+imghost+item.icon+');'">
  46. </view>
  47. <view class="content">
  48. <view class="text-grey">
  49. <text class="text-cut">{{item.name}}</text>
  50. </view>
  51. <view class="text-gray text-sm flex">
  52. <text class="text-cut">{{item.title}}</text>
  53. </view>
  54. <view class="text-gray text-sm flex">
  55. <text class="text-cut">有效期:{{formatDate(item.start_time*1000)}}-{{formatDate(item.end_time*1000)}}</text>
  56. </view>
  57. </view>
  58. <view class="action">
  59. <!-- <view class="text-grey text-xs">22:20</view>
  60. <view class="cuIcon-notice_forbid_fill text-gray"></view> -->
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view v-else="TabCur == 2">
  67. <view class="margin-top-sm">
  68. <view class="cu-list menu-avatar padding-tb-sm bg-white">
  69. <view class="cu-item" v-for="(item,index) in invalidList" :key="index">
  70. <view class="cu-avatar round lg" :style="'background-image:url('+imghost+item.icon+');'">
  71. </view>
  72. <view class="content">
  73. <view class="text-grey">
  74. <text class="text-cut">{{item.name}}</text>
  75. </view>
  76. <view class="text-gray text-sm flex">
  77. <text class="text-cut">{{item.title}}</text>
  78. </view>
  79. <view class="text-gray text-sm flex">
  80. <text class="text-cut">有效期:{{formatDate(item.start_time*1000)}}-{{formatDate(item.end_time*1000)}}</text>
  81. </view>
  82. </view>
  83. <view class="action">
  84. <!-- <view class="text-grey text-xs">22:20</view>
  85. <view class="cuIcon-notice_forbid_fill text-gray"></view> -->
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </scroll-view>
  92. </view>
  93. </view>
  94. </template>
  95. <script>
  96. export default {
  97. mounted() {
  98. this.getCouponList()
  99. this.imghost = this.$imgHost
  100. },
  101. data() {
  102. return {
  103. notUsed: 1, //未使用
  104. used: 2, //已使用
  105. invalid: 3, //过期
  106. TabCur: 0,
  107. list: [{
  108. name: '未使用',
  109. }, {
  110. name: '已使用',
  111. }, {
  112. name: '已过期',
  113. }],
  114. // 因为内部的滑动机制限制,请将tabs组件和swiper组件的current用不同变量赋值
  115. current: 0, // tabs组件的current值,表示当前活动的tab选项
  116. swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
  117. pageindex: 1,
  118. couponList: [],
  119. notUsedList: [],
  120. usedList: [],
  121. invalidList: [],
  122. show: false,
  123. imghost: ""
  124. };
  125. },
  126. methods: {
  127. tabSelect(e) {
  128. this.TabCur = e.currentTarget.dataset.id
  129. },
  130. getCouponList: async function() {
  131. let res = await this.$request.post("/api/v1/coupon/userCouponList", {
  132. page: this.pageindex
  133. })
  134. if (res.status == 0) {
  135. this.notUsedList = res.data.data.filter(item => {
  136. if (item.status == 1) {
  137. return item
  138. }
  139. })
  140. this.usedList = res.data.data.filter(item => {
  141. if (item.status == 2) {
  142. return item
  143. }
  144. })
  145. this.invalidList = res.data.data.filter(item => {
  146. if (item.status == 3) {
  147. return item
  148. }
  149. })
  150. console.log(this.notUsedList)
  151. }
  152. },
  153. gotoinfo(item) {
  154. console.log(item)
  155. uni.navigateTo({
  156. url: "coupon_details?data=" + JSON.stringify(item)
  157. })
  158. }
  159. },
  160. onShow() {
  161. }
  162. };
  163. </script>
  164. <style>
  165. .coupon-List {
  166. height: 100%;
  167. width: 100%;
  168. /* background-color: #f9f9f9; */
  169. padding: 20rpx 20rpx 0 20rpx;
  170. }
  171. /*卡片*/
  172. .u-card-wrap {
  173. background-color: $u-bg-color;
  174. padding: 1px;
  175. }
  176. .u-body-item {
  177. font-size: 32rpx;
  178. color: #333;
  179. padding: 20rpx 10rpx;
  180. }
  181. .u-body-item image {
  182. width: 120rpx;
  183. flex: 0 0 120rpx;
  184. height: 120rpx;
  185. border-radius: 8rpx;
  186. margin-left: 12rpx;
  187. }
  188. </style>