coupon.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view class="container">
  3. <!-- 顶部导航栏 -->
  4. <view class="top-tab">
  5. <u-tabs class="tab" :list="list" @click="handlerChangeTab1" :activeStyle="{
  6. color: '#fff',
  7. fontWeight: 'bold',
  8. transform: 'scale(1.05)',
  9. }" :inactiveStyle="{
  10. color: '#fff',
  11. transform: 'scale(1)',
  12. }" itemStyle="height: 34px; width:27%;" lineColor="#D89A4C"></u-tabs>
  13. </view>
  14. <!-- 优惠券的可用和失效 -->
  15. <view class="use">
  16. <u-tabs :list="list2" lineWidth="60" lineColor="#347caf" :scrollable="false" :activeStyle="{
  17. color: '#347caf',
  18. fontWeight: 'bold',
  19. transform: 'scale(1.05)',
  20. }" :inactiveStyle="{
  21. color: '#b7b6b8',
  22. transform: 'scale(1)',
  23. }" itemStyle="padding-left: 90rpx; padding-right: 80rpx; height: 120rpx;" @change="handlerSelectTab" />
  24. </view>
  25. <!-- 优惠券可用 -->
  26. <view class="couponUse" v-show="lable_type == 0" :key="index" v-for="(item, index) of init_list">
  27. <view class="useLeft">
  28. <view>{{ item.couponVO.name }}</view>
  29. <text>到期时间 : {{ item.couponVO.dueTime }}</text>
  30. </view>
  31. <view class="useRight">
  32. <view class="text">{{ 10 - item.couponVO.reduce }}<text>折</text></view>
  33. <view>折扣</view>
  34. <view class="gouUse" @click='handlerToUsed(item)'>去使用</view>
  35. </view>
  36. </view>
  37. <u-empty v-if="total == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
  38. </u-empty>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. getUserAcceptCouponsList
  44. } from '@/api/client/mine.js';
  45. export default {
  46. data() {
  47. return {
  48. list: [{
  49. id: 1,
  50. name: '满减',
  51. type: 'REDUCE',
  52. },
  53. {
  54. id: 2,
  55. name: '折扣',
  56. type: 'DISCOUNT',
  57. },
  58. {
  59. id: 3,
  60. name: '赠送',
  61. type: 'GIVE',
  62. },
  63. ],
  64. list2: [{
  65. name: '可用',
  66. type: 'UNUSED',
  67. },
  68. {
  69. name: '失效',
  70. type: 'CLOSED',
  71. },
  72. ],
  73. lable_type: 0, // 是否可用
  74. queryParams: {
  75. size: '10', //分页信息 取值范围: 页码,分页大小
  76. type: 'REDUCE', //优惠券类型 允许值: GIVE(赠送), REDUCE(满减), DISCOUNT(折扣)
  77. status: 'UNUSED', // 用户优惠券状态 UNUSED(未使用), USED(已使用), EXPIRED(已过期), CLOSED(作废)
  78. },
  79. init_list: [], //初始化列表
  80. total: 0,
  81. };
  82. },
  83. mounted() {
  84. this.handlerInitCouponList();
  85. },
  86. methods: {
  87. // 初始化优惠卷列表
  88. handlerInitCouponList() {
  89. getUserAcceptCouponsList(this.queryParams).then(res => {
  90. this.init_list = res.data;
  91. this.init_list.map(rs=>{
  92. rs.couponVO.dueTime = this.handlerGetTime(rs.couponVO.expiration)
  93. })
  94. this.total = res.data.total;
  95. });
  96. },
  97. handlerGetTime(e){
  98. // 1707148800000
  99. let time = new Date(e)
  100. let year = time.getFullYear()
  101. let month = time.getMonth() + 1
  102. let date = time.getDate()
  103. if (month < 10) {
  104. month = '0' + month
  105. }
  106. if (date < 10) {
  107. date = '0' + date
  108. }
  109. return year + '-' + month + '-' + date
  110. },
  111. // 选择顶部导航栏
  112. handlerChangeTab1(e) {
  113. this.queryParams.type = e.type;
  114. this.handlerInitCouponList();
  115. },
  116. // 点击选择下层tab栏 选择是否可用
  117. handlerSelectTab(e) {
  118. this.lable_type = e.index;
  119. this.queryParams.status = e.type;
  120. this.handlerInitCouponList();
  121. },
  122. // 点击去使用
  123. handlerToUsed(item){
  124. uni.navigateTo({
  125. url:`/pagesHome/marketer/index?id=${item.couponVO.merchantId}`
  126. })
  127. }
  128. },
  129. };
  130. </script>
  131. <style lang="scss" scoped>
  132. .container {
  133. height: 100vh;
  134. background-color: #efefef;
  135. .top-tab {
  136. width: 100%;
  137. background-color: #347caf;
  138. padding: 20rpx 0;
  139. }
  140. .use {
  141. padding: 0 140rpx;
  142. }
  143. /* 优惠券可用 */
  144. .couponUse {
  145. margin: 20rpx 30rpx;
  146. height: 200rpx;
  147. display: flex;
  148. background-color: #fff;
  149. box-sizing: border-box;
  150. .useLeft {
  151. width: 380rpx;
  152. padding: 20rpx;
  153. >view {
  154. font-size: 40rpx;
  155. margin: 20rpx;
  156. color: #333;
  157. }
  158. >text {
  159. font-size: 28rpx;
  160. color: #5f5f5f;
  161. }
  162. }
  163. .useRight {
  164. height: 100%;
  165. padding: 10rpx;
  166. color: #fff;
  167. text-align: center;
  168. box-sizing: border-box;
  169. width: calc(100% - 380rpx);
  170. background-color: #347caf;
  171. .text {
  172. font-size: 50rpx;
  173. >text {
  174. margin-left: 5rpx;
  175. font-size: 24rpx;
  176. }
  177. }
  178. .gouUse {
  179. width: 180rpx;
  180. height: 60rpx;
  181. line-height: 60rpx;
  182. color: #347caf;
  183. margin: 16rpx 0 0 60rpx;
  184. background-color: #fff;
  185. }
  186. }
  187. }
  188. .couponDisUse {
  189. .useRight {
  190. background-color: #cecece;
  191. .gouUse {
  192. color: #cecece;
  193. }
  194. }
  195. }
  196. }
  197. </style>