xuxueyang
2024-09-12 1e2cca44dd7b4cc30f60435d22bc58574f2fd4f0
sub_pages/customer/coupon/coupon-self.vue
@@ -9,7 +9,7 @@
         <no-data v-if="!list||list.length==0" style="width: 100%;"></no-data>
         <view v-for="(item,index) of list" :key="index" class="coupont-item" :class="[query.status]"
            @click="selectCoupon(item)">
            @click.stop="selectCoupon(item)">
            <view class="flex container img100">
               <view class="info-price">
                  <view class="price1">
@@ -18,9 +18,15 @@
                  <view class="price2">{{item.minOrderAmount?(`满¥${item.minOrderAmount}可用`):'无门槛'}}</view>
               </view>
               <view class="info flex1">
                  <view class="title">
                  <view class="title flex">
                     {{item.couponName||'-'}}
                     <radio :checked="cache_coupon.id===item.id" v-if="source==='shopping'" class="select-coupon"></radio>
                  <!--    <radio  :checked="cache_coupon.id===item.id"
                     v-if="source==='shopping'"
                        class="select-coupon"></radio> -->
                     <view :style="{ 'margin-right': '20rpx'}" v-if="source==='shopping'"
                          class="component-radio m-l-a" :class="[cache_coupon.id===item.id?'cur':'']">
                     </view>
                  </view>
                  <view class="time">
@@ -71,13 +77,17 @@
               status: 'unused'
            },
            list: [],
            source: ''
            source: '',
            paymoney: -1
         }
      },
      async onLoad(options) {
         if (options.source) {
            this.source = options.source || ''
         }
         if (options.paymoney) {
            this.paymoney = parseFloat(options.paymoney).toFixed(2)
         }
         if (this.source === 'shopping') {
            //只展示可用的
@@ -98,6 +108,39 @@
      methods: {
         async selectCoupon(item) {
            if (this.source == 'shopping') {
               if (this.cache_coupon.id === item.id) {
                  await this.$message.confirm('是否取消使用此优惠券')
                  await this.$store.dispatch('cache_coupon_select', {})
                  uni.navigateBack()
                  return
               }
               console.log('paymoney',this.paymoney)
               if (this.paymoney >= 0) {
                  //判断是否可以选择使用
                  if (item.couponDiscountType === 'zero') {
                     // if (this.cache_coupon.couponDiscountValue > this.paymoney) {
                     //    this.$message.showToast('订单价格小于优惠券优惠额度')
                     //    return
                     // }
                  } else if (item.minOrderAmount && item.minOrderAmount > 0) {
                     // if (this.cache_coupon.minOrderAmount > this.paymoney) {
                     //    this.$message.showToast('订单价格')
                     //    return
                     // }
                     if (this.paymoney < item.minOrderAmount) {
                        this.$message.showToast('订单价格不满足使用条件')
                        this.$nextTick(()=>{
                           this.$forceUpdate()
                        })
                        return
                     }
                  } else {
                     // if (this.cache_coupon.couponDiscountValue > this.paymoney) {
                     //    this.$message.showToast('订单价格小于优惠券优惠额度')
                     //    return
                     // }
                  }
               }
               await this.$store.dispatch('cache_coupon_select', item)
               uni.navigateBack()
            }