lilei 4 年之前
父节点
当前提交
fe423504c9
共有 3 个文件被更改,包括 17 次插入8 次删除
  1. 1 1
      components/uni-coods/uni-coods.vue
  2. 15 6
      pages/cart/cart.vue
  3. 1 1
      pages/goods/goodsDetail.vue

+ 1 - 1
components/uni-coods/uni-coods.vue

@@ -88,7 +88,7 @@
 							})
 							})
 							// 刷新购物车数据
 							// 刷新购物车数据
 							uni.$emit('getCartList')
 							uni.$emit('getCartList')
-						},100)
+						},50)
 					}else{
 					}else{
 						uni.hideLoading()
 						uni.hideLoading()
 					}
 					}

+ 15 - 6
pages/cart/cart.vue

@@ -185,19 +185,31 @@
 			this.getCartList()
 			this.getCartList()
 		},
 		},
 		methods: {
 		methods: {
+			// 计算购物车数量
+			getCarCount(){
+				let arr = this.$store.state.vuex_cartList || []
+				let count = 0
+				arr.map(item=>{
+					count = count + item.shoppingCartGoodsList.length
+				})
+				this.$u.vuex('vuex_cartNums', count)
+			},
 			// 查询购物车
 			// 查询购物车
 			getCartList(){
 			getCartList(){
 				getCartList({}).then(res => {
 				getCartList({}).then(res => {
 					if(res.status == 200){
 					if(res.status == 200){
 						this.$u.vuex('vuex_cartList', res.data)
 						this.$u.vuex('vuex_cartList', res.data)
 						this.cartList = JSON.parse(JSON.stringify(res.data))
 						this.cartList = JSON.parse(JSON.stringify(res.data))
-						uni.$emit('getCarCount')
+						this.getCarCount()
 						// 默认全选
 						// 默认全选
 						if(!this.isEdit){
 						if(!this.isEdit){
 							this.checkAllChange()
 							this.checkAllChange()
 						}
 						}
 					}
 					}
 					this.loading = false
 					this.loading = false
+					setTimeout(()=>{
+						uni.hideLoading()
+					},500)
 				})
 				})
 			},
 			},
 			// 去选商品
 			// 去选商品
@@ -357,14 +369,11 @@
 				})
 				})
 				deleteGoodsFormCart({idList:ids}).then(res => {
 				deleteGoodsFormCart({idList:ids}).then(res => {
 					if(res.status == 200){
 					if(res.status == 200){
-						uni.showToast({
-							title:"删除成功",
-							icon:"none"
-						})
 						// 刷新购物车
 						// 刷新购物车
 						this.getCartList()
 						this.getCartList()
+					}else{
+						uni.hideLoading()
 					}
 					}
-					uni.hideLoading()
 				})
 				})
 			},
 			},
 			// 删除商品
 			// 删除商品

+ 1 - 1
pages/goods/goodsDetail.vue

@@ -124,7 +124,7 @@
 							})
 							})
 							// 刷新购物车数据
 							// 刷新购物车数据
 							uni.$emit('getCartList')
 							uni.$emit('getCartList')
-						},100)
+						},50)
 					}else{
 					}else{
 						uni.hideLoading()
 						uni.hideLoading()
 					}
 					}