|
@@ -15,6 +15,7 @@ Page({
|
|
|
data: {
|
|
|
list: [],
|
|
|
results: [], //选中结果
|
|
|
+ resultsList: [],
|
|
|
sa_brandid: null, //当前选中品牌id
|
|
|
classList: [], //生成订单时所选
|
|
|
sum: 0, //价格合
|
|
@@ -27,26 +28,6 @@ Page({
|
|
|
this.setData({
|
|
|
hidePrice: wx.getStorageSync('hidePrice'),
|
|
|
})
|
|
|
- getApp().globalData.customizedProduct = (item, custom) => {
|
|
|
- return new Promise((resolve) => {
|
|
|
- _Http.basic({
|
|
|
- "id": 20220924104302,
|
|
|
- "content": {
|
|
|
- "sa_shoppingcartid": item.sa_shoppingcartid,
|
|
|
- "qty": item.qty,
|
|
|
- ...custom
|
|
|
- },
|
|
|
- }).then(res => {
|
|
|
- console.log("修改定制", res)
|
|
|
- wx.showToast({
|
|
|
- title: res.msg != '成功' ? res.msg : '修改成功',
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- this.getList()
|
|
|
- resolve(true)
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
},
|
|
|
/* 获取列表 */
|
|
|
getList() {
|
|
@@ -77,11 +58,13 @@ Page({
|
|
|
let obj = allBrandList.find(s => s.sa_brandid == v.sa_brandid);
|
|
|
if (obj) {
|
|
|
obj.results.push(v.sa_shoppingcartid)
|
|
|
+ obj.resultsList.push(v)
|
|
|
} else {
|
|
|
allBrandList.push({
|
|
|
brandname: v.brandname,
|
|
|
sa_brandid: v.sa_brandid,
|
|
|
results: [v.sa_shoppingcartid],
|
|
|
+ resultsList: [v]
|
|
|
})
|
|
|
}
|
|
|
if (v.iscustomsize) v.customText = getCustomText(v);
|
|
@@ -92,28 +75,40 @@ 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) {
|
|
|
- this.data.classList.length >= 2 ? wx.showToast({
|
|
|
+ this.handleSubmit();
|
|
|
+ /* this.data.classList.length >= 2 ? wx.showToast({
|
|
|
title: '请选择订单领域(订单只允许同品牌/同领域的商品)',
|
|
|
icon: "none",
|
|
|
duration: 3000
|
|
|
}) : this.handleSubmit(0);
|
|
|
+ */
|
|
|
},
|
|
|
/* 提交 */
|
|
|
submit(e) {
|
|
|
- this.handleSubmit(e.detail.value)
|
|
|
+ this.handleSubmit()
|
|
|
},
|
|
|
- handleSubmit(index) {
|
|
|
- let data = this.data.classList[index],
|
|
|
- that = this;
|
|
|
+ handleSubmit() {
|
|
|
+ let that = this;
|
|
|
+ let items = that.data.resultsList.map(v => {
|
|
|
+ return {
|
|
|
+ "sa_orderitemsid": 0,
|
|
|
+ "itemid": v.itemid,
|
|
|
+ "sa_brandid": v.sa_brandid,
|
|
|
+ "qty": v.qty,
|
|
|
+ width: v.width || 0,
|
|
|
+ length: v.length || 0,
|
|
|
+ sa_shoppingcartid: v.sa_shoppingcartid || 0,
|
|
|
+ sa_promotion_itemsid: v.sa_promotion_itemsid
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log("items", items)
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '是否确定生成促销订单',
|
|
@@ -129,20 +124,9 @@ Page({
|
|
|
"content": {
|
|
|
istool: 0,
|
|
|
type: "促销订单",
|
|
|
- "tradefield": data.type, //必选
|
|
|
+ //"tradefield": data.type, 必选
|
|
|
...ids,
|
|
|
- "items": data.list.map(v => {
|
|
|
- return {
|
|
|
- "sa_orderitemsid": 0,
|
|
|
- "itemid": v.itemid,
|
|
|
- "sa_brandid": v.sa_brandid,
|
|
|
- "qty": v.qty,
|
|
|
- width: v.width || 0,
|
|
|
- length: v.length || 0,
|
|
|
- sa_shoppingcartid: v.sa_shoppingcartid || 0,
|
|
|
- sa_promotion_itemsid: v.sa_promotion_itemsid
|
|
|
- }
|
|
|
- })
|
|
|
+ items
|
|
|
}
|
|
|
}).then(res => {
|
|
|
console.log("转化订单", res)
|
|
@@ -154,6 +138,7 @@ Page({
|
|
|
icon: "none"
|
|
|
});
|
|
|
getApp().globalData.getCollectCount()
|
|
|
+ that.getList();
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '生成成功!是否立即前往',
|
|
@@ -165,10 +150,7 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- that.getList();
|
|
|
})
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -181,20 +163,23 @@ Page({
|
|
|
if (isAll) {
|
|
|
this.setData({
|
|
|
sa_brandid: null,
|
|
|
- results: []
|
|
|
+ results: [],
|
|
|
+ resultsList: []
|
|
|
})
|
|
|
} 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
|
|
|
+ results: obj.results,
|
|
|
+ resultsList: obj.resultsList
|
|
|
})
|
|
|
} else {
|
|
|
if (this.data.allBrandList.length == 0) return;
|
|
|
this.setData({
|
|
|
sa_brandid: this.data.allBrandList[0].sa_brandid,
|
|
|
- results: this.data.allBrandList[0].results
|
|
|
+ results: this.data.allBrandList[0].results,
|
|
|
+ resultsList: this.data.allBrandList[0].resultsList,
|
|
|
})
|
|
|
}
|
|
|
};
|
|
@@ -206,17 +191,21 @@ Page({
|
|
|
item
|
|
|
} = my ? e : e.currentTarget.dataset;
|
|
|
let results = this.data.results,
|
|
|
+ resultsList = this.data.resultsList,
|
|
|
sa_brandid = this.data.sa_brandid;
|
|
|
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)
|
|
|
if (index == -1) {
|
|
|
results.push(item.sa_shoppingcartid);
|
|
|
+ resultsList.push(item)
|
|
|
} else {
|
|
|
results.splice(index, 1);
|
|
|
+ resultsList.splice(index, 1);
|
|
|
if (results.length == 0) sa_brandid = null;
|
|
|
}
|
|
|
};
|
|
@@ -230,18 +219,40 @@ Page({
|
|
|
const {
|
|
|
item
|
|
|
} = e.target.dataset;
|
|
|
+ getApp().globalData.customizedProduct = (item, custom) => {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20220924104302,
|
|
|
+ "content": {
|
|
|
+ "sa_shoppingcartid": item.sa_shoppingcartid,
|
|
|
+ "qty": item.qty,
|
|
|
+ ...custom
|
|
|
+ },
|
|
|
+ }).then(res => {
|
|
|
+ console.log("修改定制", res)
|
|
|
+ wx.showToast({
|
|
|
+ title: res.msg != '成功' ? res.msg : '修改成功',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ this.getList()
|
|
|
+ resolve(true)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
if (item) this.selectComponent("#Custom").onClick(item)
|
|
|
},
|
|
|
/* 计算总价/产品领域分类 */
|
|
|
computeSum() {
|
|
|
let results = this.data.results,
|
|
|
+ resultsList = [],
|
|
|
sum = 0,
|
|
|
classList = [];
|
|
|
if (results.length) results = results.filter(v => {
|
|
|
let item = this.data.list.find(va => va.sa_shoppingcartid == v);
|
|
|
+
|
|
|
if (item) {
|
|
|
- console.log(item.gradeprice)
|
|
|
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) {
|
|
@@ -267,12 +278,12 @@ Page({
|
|
|
let brand = this.data.allBrandList.find(v => v.sa_brandid == sa_brandid)
|
|
|
isAll = brand.results.length == results.length
|
|
|
}
|
|
|
- console.log(sum)
|
|
|
this.setData({
|
|
|
sum: CNY(sum),
|
|
|
isAll,
|
|
|
results,
|
|
|
sa_brandid,
|
|
|
+ resultsList,
|
|
|
classList
|
|
|
});
|
|
|
},
|