xuxueyang
2024-09-26 05bd41aab8c9dba2cf7afcd78493415761f11d9d
sub_pages/customer/coupon/good-all.vue
@@ -49,15 +49,18 @@
         <view class="good-container p15 flex">
            <view v-for="(item,index) of list" :key="index" class="good-item" @click="toDetail(item)">
               <image class="cover" :src="item.cover" :lazy-load="true" mode="scaleToFill"
                  :class="[dto.stock===0?'component-stock-zero':'']">
                  :class="[item.stock===0?'component-stock-zero':'']">
               </image>
               <view class="title">
                  {{item.name}}
               </view>
               <view class="flex score-info">
                  <view><span class="score">{{item.point||'-'}}</span>积分</view>
                  <view class="button m-l-a m-r-0" @click.stop="exchange('good',item)">兑换</view>
                  <view>
                     <view><span class="score">{{item.point||'-'}}</span> 积分</view>
                     <view class="desc-gray">库存:<span class="">{{item.stock||'0'}}</span></view>
                  </view>
                  <view class="button m-l-a m-r-0 m-t-20" @click.stop="exchange('good',item)">兑换</view>
               </view>
            </view>
         </view>
@@ -85,8 +88,12 @@
                     <view class="t-red">
                        {{item.point||'0'}}积分
                     </view>
                     <view class="button m-l-a m-r-15" @click="exchange('coupon',item)">
                        兑换
                     <view class="m-l-10 desc-gray">
                        库存:{{item.couponAmount||'0'}}
                     </view>
                     <view class="button m-l-a m-r-15" :class="[item.couponAmount===0?'over':'']"
                        @click="exchange('coupon',item)">
                        {{item.couponAmount===0?'已售磬':'兑换'}}
                     </view>
                  </view>
               </view>
@@ -101,7 +108,7 @@
<script>
   export default {
      computed: {
         self_point() {
            if (this.currentInfo.currentPoint) {
               if (this.currentInfo.currentPoint >= 10000) {
@@ -110,7 +117,7 @@
                  return this.currentInfo.currentPoint
               }
            }
            return 0
         }
      },
@@ -122,6 +129,10 @@
            this.refreshList()
         },
         async exchange(type, item) {
            if (item.stock === 0 || item.couponAmount === 0) {
               this.$message.showToast('库存为0,无法兑换')
               return
            }
            var api = ''
            if (type == 'good') {
               api = '/api/customer/point/goods/exchange'
@@ -146,7 +157,14 @@
               //刷新积分               
               this.$store.dispatch('getCurrentInfo');
               await this.$message.showToast('兑换成功')
               if (type == 'good') {
                  item.stock -= 1
                  this.$forceUpdate()
               }
               if (type == 'coupon') {
                  item.couponAmount -= 1
                  this.$forceUpdate()
               }
            }
         },
         toDetail(item) {
@@ -209,11 +227,12 @@
         this.listApi = '/api/customer/point/goods/list'
         this.getList()
      },
      onPullDownRefresh() {
      async onPullDownRefresh() {
         //刷新积分和刷新商品
         this.$store.dispatch('getCurrentInfo');
         // this.list = []
         this.refreshList()
         await this.refreshList()
         uni.stopPullDownRefresh()
      },
      onReachBottom() {
@@ -275,6 +294,11 @@
               text-align: center;
               line-height: 46rpx;
            }
            .button.over {
               color: #747374;
               border: 2rpx solid #747374;
            }
         }
         .good-item:nth-child(2n+1) {