coupon.vue 2.6 KB

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