index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="page-wrap">
  3. <view class="tabs-panel">
  4. <view :class="{ item: true, active: tabActive === item }" v-for="(item, index) in tabList" :key="index" @click="tabActive = item">
  5. {{ item }}
  6. </view>
  7. </view>
  8. <!-- 未使用 -->
  9. <view class="coupon-panel">
  10. <view class="item" v-for="(item, index) in couponList" :key="index" @click="handleOpenCouponDetail">
  11. <view class="name">{{ item.coupon.name }}</view>
  12. <view class="desc">使用范围:{{ item.coupon.productIds || item.coupon.categoryIds ? '指定产品品类可用' : '所有产品品类可用' }}</view>
  13. <view class="desc">使用条件:{{ item.coupon.line ? `满${item.coupon.line}元可用` : '无限制' }}</view>
  14. <view class="desc">有效日期:{{ item.coupon.endTime ? '至 ' + item.coupon.endTime : '无限制' }}</view>
  15. <view class="side">
  16. <view class="price">{{ item.coupon.showMoney }}</view>
  17. {{ item.coupon.line ? `满${item.coupon.line}元可用` : '使用无限制' }}
  18. </view>
  19. <!-- <view class="side">
  20. <image class="state-1" src="@/static/img_coupon_state_1.png"></image>
  21. </view> -->
  22. </view>
  23. </view>
  24. <button class="foot-btn" @click="handleOpenCouponCenter()">去领券中心看看</button>
  25. </view>
  26. </template>
  27. <script>
  28. import couponService from '@/api/coupon.js';
  29. export default {
  30. data() {
  31. return {
  32. tabActive: '未使用',
  33. tabList: ['未使用', '已使用', '已失效'],
  34. couponList: []
  35. };
  36. },
  37. watch: {
  38. tabActive() {
  39. this.getCouponList();
  40. }
  41. },
  42. onLoad() {
  43. this.getCouponList();
  44. },
  45. onShow() {
  46. this.getCouponList();
  47. },
  48. onPullDownRefresh() {
  49. this.getCouponList();
  50. },
  51. methods: {
  52. // 获取优惠券列表
  53. async getCouponList() {
  54. const { tabActive } = this;
  55. const { rows } = await couponService.getUserCouponList(tabActive === '已失效' ? '已过期' : tabActive);
  56. this.couponList = rows;
  57. uni.pageScrollTo({ scrollTop: 0 });
  58. uni.stopPullDownRefresh();
  59. },
  60. handleOpenCouponDetail() {
  61. uni.navigateTo({
  62. url: 'detail'
  63. });
  64. },
  65. handleOpenCouponCenter() {
  66. uni.navigateTo({
  67. url: 'center'
  68. });
  69. }
  70. }
  71. };
  72. </script>
  73. <style lang="scss" scoped>
  74. @import 'index.scss';
  75. </style>