coupon.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="container">
  3. <view class="tabs">
  4. <view :class="['tab', tabActive == 1 ? 'active' : '']" @click="tabClick(1)">可使用</view>
  5. <view :class="['tab', tabActive == 2 ? 'active' : '']" style="margin-left: 10px" @click="tabClick(2)">
  6. 已使用
  7. </view>
  8. <view :class="['tab', tabActive == 3 ? 'active' : '']" style="margin-left: 10px" @click="tabClick(3)">
  9. 已过期
  10. </view>
  11. </view>
  12. <view :class="['card', item.status != 0 ? 'grey' : '']" v-for="(item, index) in list">
  13. <view class="leftIcon"></view>
  14. <view class="left">
  15. <span style="font-size: 18px">{{ item.discount }}</span>
  16. </view>
  17. <view class="right">
  18. <view class="row title">
  19. {{ item.name }}
  20. </view>
  21. <view class="row endTime">{{ item.endTime }}到期</view>
  22. <view class="row desc">
  23. {{ item.desc }}
  24. </view>
  25. </view>
  26. </view>
  27. <noData v-if="list.length == 0" />
  28. </view>
  29. </template>
  30. <script>
  31. import noData from '@/component/noData.vue'
  32. import { couponListApi } from '@/api/coupon.js'
  33. export default {
  34. components: {
  35. noData,
  36. },
  37. onLoad() {
  38. this.$nextTick(() => {
  39. this.getList()
  40. })
  41. },
  42. data() {
  43. return {
  44. tabActive: 1,
  45. list: [],
  46. params: {
  47. limit: 999,
  48. page: 1,
  49. status: 0,
  50. },
  51. }
  52. },
  53. methods: {
  54. tabClick(index) {
  55. this.tabActive = index
  56. if (index == 1) {
  57. this.params.status = 0
  58. } else if (index == 2) {
  59. this.params.status = 1
  60. } else {
  61. this.params.status = 2
  62. }
  63. this.getList()
  64. },
  65. getList() {
  66. // wx.showLoading()
  67. couponListApi(this.params).then(res => {
  68. console.log(res, '我的优惠券')
  69. this.list = res.data.list
  70. // wx.hideLoading()
  71. })
  72. },
  73. },
  74. }
  75. </script>
  76. <style scoped lang="scss">
  77. .tabs {
  78. display: flex;
  79. margin-bottom: 10px;
  80. .tab {
  81. width: 68px;
  82. height: 24px;
  83. font-size: 14px;
  84. background: #fff;
  85. border-radius: 4px;
  86. line-height: 24px;
  87. text-align: center;
  88. }
  89. .active {
  90. background: #fea200;
  91. color: #fff;
  92. }
  93. }
  94. .container {
  95. background: #eaeaea;
  96. padding: 10px;
  97. .card {
  98. background: #fff;
  99. border-radius: 8px;
  100. overflow: hidden;
  101. display: flex;
  102. margin-bottom: 10px;
  103. .leftIcon {
  104. height: auto;
  105. width: 8px;
  106. background: #ff2c43;
  107. }
  108. .left {
  109. width: 80px;
  110. display: inline-flex;
  111. justify-content: center;
  112. align-items: center;
  113. color: #ff2c43;
  114. font-weight: 600;
  115. }
  116. .right {
  117. padding: 10px;
  118. .row {
  119. margin-bottom: 4px;
  120. font-size: 12px;
  121. }
  122. .title {
  123. font-size: 14px;
  124. font-weight: 600;
  125. }
  126. .endTime {
  127. color: #ff2c43;
  128. }
  129. .desc {
  130. margin-top: 5px;
  131. color: #8c8c8c;
  132. }
  133. }
  134. }
  135. }
  136. </style>