1
xuxueyang
2024-07-31 7e247648201b208cfb5a5901803f784b7dbda948
sub_pages/customer/shop/shop.vue
@@ -82,8 +82,7 @@
            <view class="component-shop-item flex" v-for="(item,index) of list" :key="index"
               @click.stop="toDetail(item)">
               <view class="img">
                  <image class="img img100"
                     :src="item.cover" lazy-load>
                  <image class="img img100" :src="item.cover" lazy-load>
                  </image>
                  <view class="level">
                     {{item.levelStr||''}}
@@ -120,7 +119,9 @@
                     <view class="icons flex">
                        <uni-icons v-if="item.shopnum&&item.shopnum>=1" type="minus" size="32"
                           @click.stop="addnum(item,-1)"></uni-icons>
                        <view class="curnums" v-if="item.shopnum&&item.shopnum>=1">{{ item.shopnum }}</view>
                        <view class="curnums" @click="updateItemNum(item)" v-if="item.shopnum&&item.shopnum>=1">
                           {{ item.shopnum }}
                        </view>
                        <uni-icons v-if="!item.shopnum||item.shopnum<=99" type="plus-filled" size="32"
                           @click.stop="addnum(item,1)"></uni-icons>
                     </view>
@@ -210,6 +211,7 @@
         }
      },
      methods: {
         async getDetail() {
            {
               this.$message.showLoading()
@@ -280,7 +282,8 @@
               if(!this.catgoryTree){
                  this.$message.showLoading()
                  const {
                     code,data
                     code,
                     data
                  } = await this.$http.request('get', `/api/customer/flower/category/tree`, {
                     data: {
                        supplierId: this.dto.supplierId || this.dto.id
@@ -308,7 +311,29 @@
         buttonSearchFlow() {
         },
         async updateItemNum(item) {
            const res = await this.$message.confirm('', {
               editable: true,
               title: '请输入想要购买的数量'
            })
            if (res.content && res.confirm) {
               // 发送请求
               var t = parseInt(res.content)
               if (isNaN(t) || t < 0) {
                  this.$message.showToast('数目需要大于等于0')
               } else {
                  if (!item.stock || t > item.stock) {
                     this.$message.showToast('库存不足无法修改')
                     return
                  }
                  this.addnum(item, (t - item.shopnum))
               }
            } else {
            }
         },
         async addnum(item, addnum) {
            if (!this.currentInfo.id) {
               await this.$message.confirm('请前往登录')
@@ -324,7 +349,7 @@
               item.stock = 0
            }
            if (item.shopnum + addnum > item.stock) {
               this.$message.showToast('库存不足,无法添加')
               this.$message.showToast('库存不足,无法修改')
               return
            }
            if (item.shopnum + addnum >= 0) {
@@ -335,7 +360,7 @@
            this.$message.showLoading()
            const {
               code
            } = await http.request('post', '/api/customer/flower/cart/change-num', {
            } = await this.$http.request('post', '/api/customer/flower/cart/change-num', {
               data: {
                  id: item.id,
                  num: addnum
@@ -378,10 +403,12 @@
               padding-left: 20rpx;
            }
         }
         .brand-info-1{
            // padding: 40rpx 30rpx;
            
         }
         .brand-info-3 {
            padding: 40rpx 30rpx;