coupon-pick.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <app-layout>
  3. <view class="page">
  4. <!-- <view class="mb-24 tip">注: 优惠券只能抵消商品金额,不能抵消运费。</view> -->
  5. <view class="mb-24 tip">注: 优惠券只能抵用报名金额</view>
  6. <view class="mb-24">
  7. <app-button @click="setData(0)" type="general" round color="#999">不使用优惠券</app-button>
  8. </view>
  9. <template v-if="list !== null">
  10. <view v-if="!list.length" class="no-data">暂无可用优惠券</view>
  11. <view v-else class="main-center dir-top-nowrap list">
  12. <view v-for="(item,index) in list"
  13. :key="index"
  14. @click="setData(item.id)"
  15. class="dir-left-nowrap item"
  16. :style="'background-image: url(' + couponBackground + ')'">
  17. <view class="box-grow-0 cross-center item-left">
  18. <view>
  19. <view v-if="item.type==1">{{item.discount}}折</view>
  20. <view v-else>¥{{item.sub_price}}</view>
  21. <view class="desc">满{{item.coupon_min_price}}元可用</view>
  22. <view style="font-size: 10px" v-if="item.discount_limit">优惠上限:¥{{item.discount_limit}}</view>
  23. </view>
  24. </view>
  25. <view class="box-grow-1 cross-center item-right">
  26. <view>
  27. <view>{{item.coupon_data.name}}</view>
  28. <view class="date-time">{{item.start_time}}~{{item.end_time}}</view>
  29. <view class="scope" v-if="item.coupon_data.appoint_type == 3">全场通用</view>
  30. <view class="scope" v-else>限品类</view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. </view>
  37. </app-layout>
  38. </template>
  39. <script>
  40. import {mapState} from 'vuex';
  41. import AppLoading from '../../components/basic-component/app-loading/app-loading.vue';
  42. export default {
  43. name: 'coupon-pick',
  44. components: {AppLoading},
  45. data() {
  46. return {
  47. mchIndex: null,
  48. list: null,
  49. };
  50. },
  51. computed: {
  52. ...mapState({
  53. couponBackground: state => state.mallConfig.__wxapp_img.mall.coupon_enable_bg,
  54. }),
  55. },
  56. onLoad(options) {
  57. console.log('onLoad->', options);
  58. this.mchIndex = options.mchIndex;
  59. this.loadData();
  60. },
  61. methods: {
  62. loadData() {
  63. uni.showLoading({
  64. mask: true,
  65. title: '加载中',
  66. });
  67. this.$request({
  68. url: this.$api.order.usable_coupon_list,
  69. method: 'post',
  70. data: {
  71. form_data: JSON.stringify(this.$store.state.orderSubmit.formData.list[this.mchIndex]),
  72. }
  73. }).then(response => {
  74. uni.hideLoading();
  75. if (response.code === 0) {
  76. this.list = response.data.list;
  77. } else {
  78. }
  79. }).catch(e => {
  80. uni.hideLoading();
  81. });
  82. },
  83. setData(data) {
  84. const formData = this.$store.state.orderSubmit.formData;
  85. formData.list[this.mchIndex].user_coupon_id = data;
  86. this.$store.commit('orderSubmit/mutSetFormData', formData);
  87. uni.navigateBack();
  88. },
  89. }
  90. }
  91. </script>
  92. <style scoped lang="scss">
  93. .mb-24 {
  94. margin-bottom: #{24rpx};
  95. }
  96. .page {
  97. padding: #{24rpx};
  98. .tip {
  99. font-size: $uni-font-size-general-one;
  100. color: $uni-general-color-two;
  101. }
  102. .no-data {
  103. padding: #{100rpx};
  104. text-align: center;
  105. color: $uni-general-color-three;
  106. background: $uni-weak-color-two;
  107. border-radius: #{16rpx};
  108. }
  109. }
  110. .list {
  111. .item {
  112. background-size: 100% 100%;
  113. width: 100%;
  114. height: #{152rpx};
  115. margin-bottom: #{24rpx};
  116. .item-left {
  117. width: 28.45%;
  118. overflow: hidden;
  119. text-align: center;
  120. color: #fff;
  121. view {
  122. width: 100%;
  123. }
  124. .desc {
  125. font-size: $uni-font-size-weak-one;
  126. padding-top: #{12rpx};
  127. }
  128. }
  129. .item-right {
  130. padding: #{24rpx};
  131. .date-time {
  132. font-size: $uni-font-size-weak-two;
  133. color: $uni-general-color-two;
  134. }
  135. .scope {
  136. font-size: $uni-font-size-weak-two;
  137. color: $uni-general-color-one;
  138. }
  139. }
  140. }
  141. }
  142. </style>