Просмотр исходного кода

商城首页商品库存显示问题

skyblued 3 лет назад
Родитель
Сommit
ce6889e6fe

+ 1 - 1
src/views/shop-mall/components/tab-list/index.tsx

@@ -157,7 +157,7 @@ export default defineComponent({
             this.addGoodsShow = false
           }}
         >
-          <AddGoodsCart item={this.selectGoodsItem} />
+          <AddGoodsCart show={this.addGoodsShow} item={this.selectGoodsItem} />
         </Popup>
       </div>
     )

+ 1 - 0
src/views/shop-mall/goods-detail/index.tsx

@@ -382,6 +382,7 @@ export default defineComponent({
           }}
         >
           <AddGoodsCart
+            show={this.addGoodsShow}
             onGetCartCount={() => this.getCartCount()}
             item={this.selectGoodsItem}
             defaultRadio={this.radio}

+ 11 - 5
src/views/shop-mall/modal/add-goods-cart/index.tsx

@@ -19,6 +19,10 @@ import request from '@/helpers/request'
 export default defineComponent({
   name: 'add-goods-cart',
   props: {
+    show: {
+      type: Boolean,
+      default: false,
+    },
     item: {
       type: Object,
       default: {}
@@ -37,11 +41,13 @@ export default defineComponent({
     }
   },
   watch:{
-    item(){
-      this.totalData = {}
-      this.total = 1
-      this.radio = ''
-      this.setList()
+    show(val){ // 添加购物车显示
+      if (val){
+        this.totalData = {}
+        this.total = 1
+        this.radio = ''
+        this.setList()
+      }
     }
   },
   data() {