xiaohaizhao 2 yıl önce
ebeveyn
işleme
8996c4d83e
1 değiştirilmiş dosya ile 9 ekleme ve 8 silme
  1. 9 8
      packageA/activity/selectProduct/cart/index.js

+ 9 - 8
packageA/activity/selectProduct/cart/index.js

@@ -95,12 +95,10 @@ Page({
 				allBrandList,
 				isGet: true
 			});
-			if (wx.getStorageSync('shopping1')) {
-				this.setData({
-					...wx.getStorageSync('shopping1')
-				});
-				this.computeSum();
-			}
+			if (wx.getStorageSync('shopping1')) this.setData({
+				...wx.getStorageSync('shopping1')
+			});
+			this.computeSum();
 		})
 	},
 	clickBut(e) {
@@ -218,6 +216,7 @@ Page({
 		if (sa_brandid && sa_brandid != item.sa_brandid) return;
 		if (results.length == 0) {
 			results.push(item.sa_shoppingcartid);
+			resultsList.push(item)
 			sa_brandid = item.sa_brandid;
 		} else {
 			let index = results.findIndex(v => v == item.sa_shoppingcartid)
@@ -245,13 +244,15 @@ Page({
 	/* 计算总价/产品领域分类 */
 	computeSum() {
 		let results = this.data.results,
-			resultsList = this.data.resultsList,
+			resultsList = [],
 			sum = 0,
 			classList = [];
 		if (results.length) results = results.filter(v => {
 			let item = this.data.list.find(va => va.sa_shoppingcartid == v);
+
 			if (item) {
 				sum = currency(sum).add(currency(item.qty).multiply(item.gradeprice)).value;
+				resultsList.push(item)
 				/* 领域分类 */
 				let index = classList.findIndex(value => value.type == item.tradefield_shoppingcart);
 				if (index == -1) {
@@ -270,7 +271,6 @@ Page({
 		let sa_brandid = results.length ? this.data.sa_brandid : null;
 		wx.setStorageSync('shopping1', {
 			results,
-			resultsList,
 			sa_brandid
 		})
 		let isAll = false;
@@ -283,6 +283,7 @@ Page({
 			isAll,
 			results,
 			sa_brandid,
+			resultsList,
 			classList
 		});
 	},