coupon.vue 2.4 KB

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