coupon.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="page-container">
  3. <!-- <u-navbar title="我的卡券" :autoBack="true" placeholder border></u-navbar> -->
  4. <view class="tabs-box">
  5. <u-tabs :list="tabList" @click="tabChange" lineColor="#03C8BE"
  6. activeStyle="color: #03C8BE; font-weight: bold;"
  7. itemStyle="width: 25%; height: 90rpx;"
  8. ></u-tabs>
  9. </view>
  10. <view class="list-container">
  11. <view v-for="(item, index) in filteredList" :key="index"
  12. :class="['coupon-card', { 'is-disabled': item.status !== 'unused' }]">
  13. <view class="left-content">
  14. <view class="coupon-title">{{ item.title }}</view>
  15. <view class="coupon-time">
  16. <view v-if="item.discountType == 3">满{{ item.thresholdAmount }}减{{ item.discountValue }}</view>
  17. <view v-else>满{{ item.thresholdAmount }}可用</view>
  18. <view>有效期至{{ item.expirationTimeString }}</view>
  19. </view>
  20. <view class="coupon-type">
  21. <text>现金券*1</text>
  22. <view class="detail-link" @click.stop="toggleDetail(index)">
  23. 详细信息 <u-icon :name="item.showDetail ? 'arrow-up-fill' : 'arrow-down-fill'" size="20rpx" color="#999"></u-icon>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="right-action">
  28. <view class="amount-box" v-if="item.discountType == 3">
  29. <text class="unit">¥</text>
  30. <text class="val">{{ item.discountValue }}</text>
  31. </view>
  32. <view class="amount-box" v-else>
  33. <text class="val">{{ item.rebValue }}</text>
  34. <text class="unit">折</text>
  35. </view>
  36. <view v-if="item.status === 'unused'" class="action-btn active">立即使用</view>
  37. <view v-else-if="item.status === 'used'" class="action-btn disabled">已使用</view>
  38. <view v-else class="action-btn disabled">已失效</view>
  39. </view>
  40. <view v-if="item.showDetail" class="detail-info">
  41. <view>限项目:仅可购买服务项目(不含秒杀,升级,续购项目和车费)</view>
  42. <view>限手机:仅登录手机号为{{ item.phone }}使用</view>
  43. </view>
  44. </view>
  45. <u-empty v-if="filteredList.length === 0" mode="coupon" marginTop="100"></u-empty>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import {
  51. getCoupon
  52. } from '@/api/index';
  53. export default {
  54. data() {
  55. return {
  56. currentTab: 0,
  57. tabList: [
  58. { name: '全部', value: 'all' },
  59. { name: '待使用', value: 'unused' },
  60. { name: '已使用', value: 'used' },
  61. { name: '已失效', value: 'expired' }
  62. ],
  63. // 模拟卡券数据
  64. couponList: [
  65. { id: 1, title: '仅项目费用满498可使用', rebValue: '40', expirationTimeString: '2026-01-24 23:59:59', status: 'unused', phone: '180****9382', showDetail: false },
  66. { id: 2, title: '仅项目费用满398可使用', rebValue: '30', expirationTimeString: '2026-01-24 23:59:59', status: 'used', phone: '180****9382', showDetail: false },
  67. { id: 3, title: '仅项目费用满298可使用', rebValue: '20', expirationTimeString: '2026-01-24 23:59:59', status: 'expired', phone: '180****9382', showDetail: false },
  68. { id: 4, title: '仅项目费用满198可使用', rebValue: '10', expirationTimeString: '2026-01-24 23:59:59', status: 'unused', phone: '180****9382', showDetail: false }
  69. ]
  70. };
  71. },
  72. computed: {
  73. // 根据Tab过滤列表
  74. filteredList() {
  75. const tabValue = this.tabList[this.currentTab].value;
  76. if (tabValue === 'all') return this.couponList;
  77. return this.couponList.filter(item => item.status === tabValue);
  78. }
  79. },
  80. onShow() {
  81. // this.getData();
  82. },
  83. methods: {
  84. getData() {
  85. let params = {
  86. openid: uni.getStorageSync('wx_copenid')
  87. }
  88. getCoupon(params).then(res => {
  89. if (res.data.code == 200) {
  90. this.couponList = res.data.data;
  91. }
  92. });
  93. },
  94. tabChange(item) {
  95. this.currentTab = item.index;
  96. },
  97. toggleDetail(index) {
  98. this.filteredList[index].showDetail = !this.filteredList[index].showDetail;
  99. }
  100. }
  101. };
  102. </script>
  103. <style lang="scss" scoped>
  104. .page-container {
  105. min-height: 100vh;
  106. background-color: #f8f8f8;
  107. .tabs-box {
  108. background-color: #fff;
  109. padding-bottom: 10rpx;
  110. }
  111. .list-container {
  112. padding: 20rpx 24rpx;
  113. }
  114. }
  115. .coupon-card {
  116. margin-bottom: 24rpx;
  117. position: relative;
  118. border-radius: 16rpx;
  119. background-color: #fff;
  120. display: flex;
  121. flex-wrap: wrap;
  122. overflow: hidden;
  123. transition: opacity 0.3s;
  124. &.is-disabled {
  125. opacity: 0.65;
  126. filter: grayscale(20%);
  127. }
  128. .left-content {
  129. flex: 1;
  130. padding: 30rpx;
  131. border-right: 2rpx dashed #eee;
  132. .coupon-title {
  133. font-size: 30rpx;
  134. font-weight: bold;
  135. color: #333;
  136. margin-bottom: 10rpx;
  137. }
  138. .coupon-time {
  139. font-size: 22rpx;
  140. color: #999;
  141. margin-bottom: 20rpx;
  142. }
  143. .coupon-type {
  144. font-size: 26rpx;
  145. color: #333;
  146. display: flex;
  147. align-items: center;
  148. .detail-link {
  149. color: #999;
  150. margin-left: auto;
  151. display: flex;
  152. align-items: center;
  153. }
  154. }
  155. }
  156. .right-action {
  157. width: 220rpx;
  158. padding: 20rpx;
  159. display: flex;
  160. align-items: center;
  161. flex-direction: column;
  162. justify-content: center;
  163. background-color: #E8FBFA;
  164. .amount-box {
  165. color: #03C8BE;
  166. margin-bottom: 16rpx;
  167. .unit {
  168. font-size: 24rpx;
  169. margin-right: 4rpx;
  170. }
  171. .val {
  172. font-size: 50rpx;
  173. font-weight: bold;
  174. }
  175. }
  176. .action-btn {
  177. width: 140rpx;
  178. height: 54rpx;
  179. border-radius: 40rpx;
  180. font-size: 24rpx;
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. &.active {
  185. background-color: #03C8BE;
  186. color: #fff;
  187. }
  188. &.disabled {
  189. background-color: transparent;
  190. border: 2rpx solid #03C8BE;
  191. color: #03C8BE;
  192. }
  193. }
  194. }
  195. .detail-info {
  196. width: 100%;
  197. font-size: 22rpx;
  198. color: #999;
  199. line-height: 1.6;
  200. padding: 24rpx;
  201. background-color: #fafafa;
  202. border-top: 1rpx solid #eee;
  203. }
  204. }
  205. </style>