From 7e247648201b208cfb5a5901803f784b7dbda948 Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期三, 31 七月 2024 01:54:17 +0800
Subject: [PATCH] 1

---
 sub_pages/customer/trade/list.vue |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/sub_pages/customer/trade/list.vue b/sub_pages/customer/trade/list.vue
index 74f6d23..b884fef 100644
--- a/sub_pages/customer/trade/list.vue
+++ b/sub_pages/customer/trade/list.vue
@@ -224,6 +224,7 @@
 			if (this.query.category) {
 				await this.getDetail()
 			}
+			this.refreshShopNum()
 
 			// await this.getList('post')
 			// this.
@@ -236,8 +237,14 @@
 			this.page.current = 1
 			await this.getList('post')
 			uni.stopPullDownRefresh()
+		},
+		onShow(){
+			this.refreshShopNum()
 		},
-		methods: {
+		methods: {
+			async refreshShopNum() {
+				this.shoptotal = await this.$store.dispatch('countShopping');
+			},
 			async getDetail() {
 				this.$message.showLoading()
 				//获取到分类的详情信息
@@ -335,7 +342,7 @@
 					item.shopnum = 0
 				}
 				if (item.shopnum + addnum > item.stock) {
-					this.$message.showToast('库存不足,无法添加')
+					this.$message.showToast('库存不足,无法修改')
 					return
 				}
 				
@@ -347,7 +354,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
@@ -355,9 +362,12 @@
 				})
 				this.$message.hideLoading()
 				if (code === 0) {
-					item.shopnum += addnum
+					item.shopnum += addnum
+					this.$forceUpdate()
+					
+					this.refreshShopNum()
+					
 				}
-				this.$forceUpdate()
 			},
 		}
 	}

--
Gitblit v1.9.3