coupon-list.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="coupon-list">
  3. <view v-for="(item, index) in list" :key="index" class="m-t-20">
  4. <view :class="'coupon-item flex ' + (btnType == 1 || btnType == 2 ? 'gray': '')">
  5. <view class="price white flex-col col-center">
  6. <view class="xl">
  7. <price-format :first-size="60" :second-size="50" :subscript-size="34" :price="item.money"
  8. :weight="500" />
  9. </view>
  10. <view class="sm text-center">{{item.condition_type_desc}}</view>
  11. </view>
  12. <view class="info m-l-20">
  13. <view class="lg m-b-20">{{item.coupon_name}}</view>
  14. <view class="xs lighter m-b-20">{{item.user_time_desc}}</view>
  15. <view class="xs lighter">{{item.use_scene_desc}}</view>
  16. </view>
  17. <button type="primary" :class="'btn br60 white xs ' + (btnType != 3 ? 'plain': '')"
  18. @tap="onHandle(item.id)">
  19. {{getBtn}}
  20. </button>
  21. <image v-if="item.is_get" class="receive" src="/static/images/coupon_receive.png"></image>
  22. </view>
  23. <view style="padding: 14rpx 20rpx" class="bg-white" v-if="item.use_goods_desc" @tap="onShowTips(index)">
  24. <view class="flex row-between">
  25. <view class="xs">使用说明</view>
  26. <u-icon :class="showTips[index] ? 'rotate' : ''" name="arrow-down" />
  27. </view>
  28. <view v-show="showTips[index]" class="m-t-10 xs">{{item.use_goods_desc}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. getCoupon
  36. } from '@/api/activity';
  37. export default {
  38. data() {
  39. return {
  40. showTips: []
  41. };
  42. },
  43. props: {
  44. list: {
  45. type: Array,
  46. default: () => []
  47. },
  48. btnType: {
  49. // 0 去使用 1已使用 2已过期 3领取
  50. type: Number
  51. }
  52. },
  53. watch: {
  54. list: {
  55. handler: function(val) {
  56. let arr = val.map(item => {
  57. return 0;
  58. });
  59. this.showTips = arr
  60. },
  61. immediate: true,
  62. deep: true
  63. }
  64. },
  65. computed: {},
  66. computed: {
  67. getBtn() {
  68. var text = ''
  69. switch (this.btnType) {
  70. case 0:
  71. text = '去使用';
  72. break;
  73. case 1:
  74. text = '已使用';
  75. break;
  76. case 2:
  77. text = '已过期';
  78. break;
  79. case 3:
  80. text = '领取';
  81. break;
  82. }
  83. return text
  84. }
  85. },
  86. methods: {
  87. onHandle(id) {
  88. this.id = id;
  89. const {
  90. btnType
  91. } = this;
  92. switch (btnType) {
  93. case 0:
  94. uni.switchTab({
  95. url: '/pages/index/index'
  96. });
  97. break;
  98. case 1:
  99. // text = '去使用';
  100. break;
  101. case 2:
  102. // text = '已使用';
  103. break;
  104. case 3:
  105. this.getCouponFun();
  106. break;
  107. }
  108. },
  109. onShowTips(index) {
  110. const {
  111. showTips
  112. } = this;
  113. this.showTips[index] = showTips[index] ? 0 : 1
  114. // 拷贝数组
  115. this.showTips = Object.assign([], this.showTips);
  116. },
  117. getCouponFun() {
  118. if (!this.isLogin) return this.$Router.push('/pages/login/login')
  119. getCoupon(this.id).then(res => {
  120. if (res.code == 1) {
  121. this.$toast({
  122. title: res.msg
  123. })
  124. setTimeout(() => {
  125. this.$emit('refresh');
  126. },1500)
  127. }
  128. });
  129. }
  130. }
  131. };
  132. </script>
  133. <style lang="scss">
  134. .coupon-list {
  135. padding: 0 24rpx;
  136. overflow: hidden;
  137. .coupon-item {
  138. position: relative;
  139. height: 200rpx;
  140. background-image: url(../../static/images/coupon_bg.png);
  141. background-size: 100% 100%;
  142. &.gray {
  143. background-image: url(../../static/images/coupon_bg_grey.png);
  144. .btn {
  145. &.plain {
  146. color: #CCCCCC;
  147. }
  148. }
  149. }
  150. .price {
  151. width: 200rpx;
  152. }
  153. .btn {
  154. line-height: 52rpx;
  155. height: 52rpx;
  156. position: absolute;
  157. right: 20rpx;
  158. bottom: 20rpx;
  159. width: 120rpx;
  160. text-align: center;
  161. padding: 0;
  162. &.plain {
  163. background-color: #fff;
  164. color: $-color-primary;
  165. border: 1px solid currentColor;
  166. }
  167. }
  168. .receive {
  169. position: absolute;
  170. right: 30rpx;
  171. top: 0rpx;
  172. width: 99rpx;
  173. height: 77rpx;
  174. }
  175. }
  176. .icon {
  177. transition: all 0.4s;
  178. }
  179. .rotate {
  180. transform: rotateZ(-180deg);
  181. }
  182. }
  183. </style>