coupon.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <app-layout>
  3. <view class="coupon-head-btn">
  4. <app-button @click="pickCoupon(-1)" color="#999999" background="#FFFFFF" round>不使用优惠券</app-button>
  5. </view>
  6. <view class="coupon-box">
  7. <view class="coupon-item-container" v-for="(v,k) in list" :key="k">
  8. <app-form-id @click="pickCoupon(v)">
  9. <view class="coupon-item">
  10. <image :src="appImg.coupon_enable_bg" class="coupon-bg"></image>
  11. <view class="dir-left-nowrap">
  12. <view class="box-grow-0 cross-center box-left">
  13. <view class="box-discount">
  14. <view v-if="v.type==1">{{v.discount}}折</view>
  15. <view v-if="v.type==2">¥{{v.sub_price}}</view>
  16. <view class="box-use">满{{v.coupon_min_price}}可用</view>
  17. </view>
  18. </view>
  19. <view class="box-grow-1 cross-center coupon-right">
  20. <view>
  21. <view class="coupon-name t-omit">{{v.coupon_data.name}}</view>
  22. <view class="box-time">
  23. <view>{{v.start_time}}~{{v.end_time}}</view>
  24. </view>
  25. <view>仅限当面付活动使用</view>
  26. </view>
  27. <icon v-if="coupon_id == v.id" class="icon-coupon-select"></icon>
  28. </view>
  29. </view>
  30. </view>
  31. </app-form-id>
  32. </view>
  33. </view>
  34. </app-layout>
  35. </template>
  36. <script>
  37. import {mapState} from 'vuex';
  38. export default {
  39. name: "coupon",
  40. components: {},
  41. computed: {
  42. ...mapState({
  43. appImg: state => state.mallConfig.__wxapp_img.mall,
  44. }),
  45. },
  46. data() {
  47. return {
  48. list: [],
  49. page_loading: true,
  50. coupon_id: 0,
  51. price: '',
  52. }
  53. },
  54. onLoad(options) {
  55. const self = this;
  56. [self.coupon_id, self.price] = [options.coupon_id, options.price];
  57. self.$showLoading({text: '加载中'});
  58. self.$request({
  59. url: self.$api.scan_code_pay.coupons,
  60. data: {
  61. price: options.price,
  62. },
  63. method: 'post',
  64. }).then(e => {
  65. self.$hideLoading();
  66. if (e.code === 0) {
  67. self.list = e.data.coupon_list;
  68. } else {
  69. uni.showToast({icon: 'none', title: e.msg});
  70. }
  71. }).catch(e => {
  72. self.$hideLoading();
  73. });
  74. },
  75. methods: {
  76. pickCoupon(userCoupon) {
  77. this.$store.commit('scanCode/mutSetUserCoupon', userCoupon);
  78. uni.navigateBack({delta: 1});
  79. },
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. page {
  85. background: #fff;
  86. }
  87. </style>
  88. <style scoped lang="scss">
  89. .coupon-head-btn {
  90. padding: #{24rpx};
  91. }
  92. .coupon-box {
  93. padding: #{24rpx} #{34rpx} 0 #{34rpx};
  94. .box-left {
  95. height: #{152rpx};
  96. position: relative;
  97. .box-discount {
  98. text-align: center;
  99. color: #fff;
  100. width: #{194rpx};
  101. }
  102. .box-use {
  103. font-size: #{20rpx};
  104. padding-top: #{16rpx};
  105. }
  106. }
  107. }
  108. .coupon-item-container {
  109. margin-bottom: #{24rpx};
  110. }
  111. .coupon-item-container:last-child {
  112. margin-bottom: 0;
  113. }
  114. .coupon-item {
  115. position: relative;
  116. overflow: hidden;
  117. }
  118. .coupon-bg {
  119. position: absolute;
  120. left: 0;
  121. top: 0;
  122. width: 100%;
  123. height: 100%;
  124. z-index: 0;
  125. }
  126. .coupon-right {
  127. position: relative;
  128. }
  129. .coupon-right > view {
  130. padding: 0 #{30rpx};
  131. overflow: hidden;
  132. color: #666666;
  133. font-size: #{20rpx};
  134. }
  135. .coupon-right .icon-coupon-select {
  136. position: absolute;
  137. right: 0;
  138. top: 0;
  139. height: #{70rpx};
  140. width: #{70rpx};
  141. z-index: 1;
  142. background-image: url("../../../static/image/icon/coupon-select.png");
  143. background-size: 100% auto;
  144. background-repeat: no-repeat;
  145. }
  146. .coupon-right .box-time {
  147. padding: #{12rpx} 0;
  148. }
  149. .coupon-right .coupon-name {
  150. color: #353535;
  151. font-size: #{32rpx};
  152. }
  153. </style>