index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <page title="优惠券" ref="pageRef" nav-color="#fff">
  3. <view class="list" v-if="list && list.length > 0">
  4. <view
  5. class="cell"
  6. v-for="(item, index) in list"
  7. :key="index"
  8. :class="{ grayscale: item.status !== 1 }"
  9. @click="item.status === 1 ? showAward(item) : ''"
  10. :style="{ backgroundImage: 'url(' + ossurl.mine.couponBg + ')' }"
  11. >
  12. <view class="flex-align relative" style="height: 188rpx">
  13. <view class="left">
  14. <view class="">
  15. <text class="font8">¥</text>
  16. <text class="bold marginL2" style="font-size: 72rpx">
  17. {{ item.amount }}
  18. </text>
  19. </view>
  20. <view class="font4 tip">
  21. <text v-if="item.fullAmount > 0">满{{ item.fullAmount }}可用</text>
  22. <text v-else>无门槛</text>
  23. </view>
  24. </view>
  25. <view class="flex1 right">
  26. <view class="font8 bold">{{ item.name }}</view>
  27. <view class="font3 time" v-if="item.expireTime">
  28. {{ formatTime(item.expireTime) }}过期
  29. </view>
  30. <!-- <view class="font2" style="opacity: 0.8" @click="spread(item)">
  31. 使用规则
  32. <text
  33. class="lg"
  34. :class="[item.spread ? 'cuIcon-fold' : 'cuIcon-unfold']"
  35. ></text>
  36. </view> -->
  37. </view>
  38. </view>
  39. <view class="rule" v-if="item.spread">
  40. {{ item.description }}
  41. </view>
  42. </view>
  43. </view>
  44. <empty v-else :top="200" />
  45. </page>
  46. </template>
  47. <script>
  48. import empty from '@/components/empty'
  49. import loginMixin from '@/mixin/login'
  50. import ossurl from '@/utils/ossurl'
  51. export default {
  52. mixins: [loginMixin],
  53. components: { empty },
  54. data() {
  55. return {
  56. ossurl,
  57. list: []
  58. }
  59. },
  60. mounted() {
  61. setTimeout(() => {
  62. this.getData()
  63. }, 100)
  64. },
  65. methods: {
  66. init() {
  67. this.getData()
  68. },
  69. async getData() {
  70. const res = await this.$service.wallet.coupons()
  71. this.list = res
  72. },
  73. showAward(item) {
  74. if (item.scene === 'LUCK') {
  75. this.$router.switchTab('award')
  76. } else if (item.scene === 'MALL') {
  77. this.$router.switchTab('vip')
  78. } else if (item.scene === 'TRADE') {
  79. wx.navigateToMiniProgram({
  80. appId: 'wxda349435734e3acc'
  81. })
  82. }
  83. },
  84. spread(item) {
  85. this.$set(item, 'spread', !item.spread)
  86. },
  87. formatTime(val) {
  88. let time = val
  89. time = time.slice(0, 10)
  90. return time
  91. }
  92. }
  93. }
  94. </script>
  95. <style></style>
  96. <style lang="scss" scoped>
  97. .list {
  98. padding: 34rpx 20rpx;
  99. }
  100. .cell {
  101. position: relative;
  102. background-size: 100% 100%;
  103. height: 176rpx;
  104. margin-bottom: 20rpx;
  105. .left {
  106. width: 190rpx;
  107. color: #000000;
  108. text-align: center;
  109. .tip {
  110. font-size: 24rpx;
  111. font-family: Source Han Sans, Source Han Sans;
  112. font-weight: 350;
  113. color: rgba(0, 0, 0, 0.3);
  114. }
  115. }
  116. .right {
  117. color: #000;
  118. padding-left: 50rpx;
  119. .time {
  120. font-size: 24rpx;
  121. font-family: Source Han Sans, Source Han Sans;
  122. font-weight: 350;
  123. color: rgba(0, 0, 0, 0.3);
  124. margin-top: 8rpx;
  125. }
  126. }
  127. .rule {
  128. background: #333333;
  129. border-bottom-right-radius: 8rpx;
  130. border-bottom-left-radius: 8rpx;
  131. padding: 16rpx 30rpx;
  132. color: #888888;
  133. font-size: 24rpx;
  134. }
  135. }
  136. </style>