|
|
@@ -40,14 +40,28 @@ Component({
|
|
|
title: res.msg,
|
|
|
icon: "none"
|
|
|
})
|
|
|
+
|
|
|
+ let list = [],
|
|
|
+ allBrandList = [];
|
|
|
+ list = res.data.map(v => {
|
|
|
+ v.showPrice = CNY(v.oldprice)
|
|
|
+ let obj = allBrandList.find(s => s.sa_brandid == v.sa_brandid);
|
|
|
+ if (obj) {
|
|
|
+ obj.results.push(v.sa_shoppingcartid)
|
|
|
+ } else {
|
|
|
+ allBrandList.push({
|
|
|
+ brandname: v.brandname,
|
|
|
+ sa_brandid: v.sa_brandid,
|
|
|
+ results: [v.sa_shoppingcartid],
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return v
|
|
|
+ });
|
|
|
this.setData({
|
|
|
- list: res.data.map(v => {
|
|
|
- v.showPrice = CNY(v.oldprice)
|
|
|
- return v
|
|
|
- }),
|
|
|
+ list,
|
|
|
+ allBrandList,
|
|
|
isGet: true
|
|
|
});
|
|
|
-
|
|
|
if (wx.getStorageSync('shopping_tool')) {
|
|
|
this.setData({
|
|
|
...wx.getStorageSync('shopping_tool')
|
|
|
@@ -56,7 +70,6 @@ Component({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
clickBut(e) {
|
|
|
this.data.classList.length >= 2 ? wx.showToast({
|
|
|
title: '请选择订单领域(订单只允许同品牌/同领域的商品)',
|
|
|
@@ -104,6 +117,32 @@ Component({
|
|
|
this.getList();
|
|
|
})
|
|
|
},
|
|
|
+ /* 是否选择全部 */
|
|
|
+ setIsAll() {
|
|
|
+ let isAll = this.data.isAll;
|
|
|
+ //取消全选
|
|
|
+ if (isAll) {
|
|
|
+ this.setData({
|
|
|
+ sa_brandid: null,
|
|
|
+ results: []
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ //已选品牌产品情况下
|
|
|
+ if (this.data.sa_brandid) {
|
|
|
+ let obj = this.data.allBrandList.find(v => v.sa_brandid == this.data.sa_brandid)
|
|
|
+ this.setData({
|
|
|
+ results: obj.results
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (this.data.allBrandList.length == 0) return;
|
|
|
+ this.setData({
|
|
|
+ sa_brandid: this.data.allBrandList[0].sa_brandid,
|
|
|
+ results: this.data.allBrandList[0].results
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.computeSum();
|
|
|
+ },
|
|
|
/* 切换选中项 */
|
|
|
changeResults(e, my = false) {
|
|
|
const {
|
|
|
@@ -167,8 +206,14 @@ Component({
|
|
|
results,
|
|
|
sa_brandid
|
|
|
})
|
|
|
+ let isAll = false;
|
|
|
+ if (sa_brandid) {
|
|
|
+ let brand = this.data.allBrandList.find(v => v.sa_brandid == sa_brandid)
|
|
|
+ isAll = brand.results.length == results.length
|
|
|
+ }
|
|
|
this.setData({
|
|
|
sum: CNY(sum),
|
|
|
+ isAll,
|
|
|
results,
|
|
|
sa_brandid,
|
|
|
classList
|
|
|
@@ -197,8 +242,7 @@ Component({
|
|
|
deteleItem(e) {
|
|
|
const {
|
|
|
item
|
|
|
- } = e.currentTarget.dataset,
|
|
|
- that = this;
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
_Http.basic({
|
|
|
"id": 20220924095202,
|
|
|
"content": {
|
|
|
@@ -209,10 +253,12 @@ Component({
|
|
|
title: res.msg,
|
|
|
icon: "none"
|
|
|
});
|
|
|
+ let index = this.data.allBrandList.findIndex(v => v.sa_brandid == item.sa_brandid)
|
|
|
this.setData({
|
|
|
- list: that.data.list.filter(v => v.sa_shoppingcartid != item.sa_shoppingcartid)
|
|
|
+ list: this.data.list.filter(v => v.sa_shoppingcartid != item.sa_shoppingcartid),
|
|
|
+ [`allBrandList[${index}].results`]: this.data.allBrandList[index].results.filter(v => v != item.sa_shoppingcartid)
|
|
|
})
|
|
|
- if (that.data.results.some(v => v == item.sa_shoppingcartid)) that.changeResults({
|
|
|
+ if (this.data.results.some(v => v == item.sa_shoppingcartid)) this.changeResults({
|
|
|
item
|
|
|
}, true);
|
|
|
getApp().globalData.num = getApp().globalData.num - 1;
|