|
@@ -8,33 +8,26 @@ Page({
|
|
|
sa_brandid: null, //当前选中品牌id
|
|
|
sum: 0, //价格合
|
|
|
yfsum: 0, //运费合
|
|
|
+ classList: [], //生成订单时所选
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
this.getList()
|
|
|
},
|
|
|
+ clickBut(e) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请选择订单领域(订单只允许同品牌/同领域的商品)',
|
|
|
+ icon: "none",
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ },
|
|
|
/* 提交 */
|
|
|
- submit() {
|
|
|
- console.log("提交订单", this.data.results)
|
|
|
- let obj = {};
|
|
|
- let list = this.data.results.map(v => {
|
|
|
- let data = this.data.list.find(value => value.sa_shoppingcartid == v);
|
|
|
- //根据领域分类
|
|
|
- if (obj[data.brandname]) {
|
|
|
- obj[data.brandname].list.push(data)
|
|
|
- } else {
|
|
|
- obj[data.brandname] = {
|
|
|
- type: data.brandname,
|
|
|
- list: [data]
|
|
|
- }
|
|
|
- };
|
|
|
- return data;
|
|
|
- });
|
|
|
-
|
|
|
+ submit(e) {
|
|
|
+ let data = this.data.classList[e.detail.value];
|
|
|
_Http.basic({
|
|
|
"id": 20221128183202,
|
|
|
"content": {
|
|
|
- "tradefield": "消防", //必选
|
|
|
- "items": list.map(v => {
|
|
|
+ "tradefield": data.type, //必选
|
|
|
+ "items": data.list.map(v => {
|
|
|
return {
|
|
|
"sa_orderitemsid": 0,
|
|
|
"itemid": v.itemid,
|
|
@@ -119,16 +112,29 @@ Page({
|
|
|
})
|
|
|
this.computeSum();
|
|
|
},
|
|
|
- /* 计算总价 */
|
|
|
+ /* 计算总价/产品领域分类 */
|
|
|
computeSum() {
|
|
|
let results = this.data.results,
|
|
|
sum = 0,
|
|
|
yfsum = 0,
|
|
|
- deteleList = [];
|
|
|
+ deteleList = [],
|
|
|
+ classList = [];
|
|
|
if (results.length) results.forEach((v, i) => {
|
|
|
let item = this.data.list.find(va => va.sa_shoppingcartid == v);
|
|
|
if (item) {
|
|
|
sum += (item.qty * item.gradeprice).toFixed(2) - 0;
|
|
|
+ /* 领域分类 */
|
|
|
+ let index = classList.findIndex(value => value.type == item.tradefield_shoppingcart);
|
|
|
+ if (index == -1) {
|
|
|
+ classList.push({
|
|
|
+ type: item.tradefield_shoppingcart,
|
|
|
+ list: [item],
|
|
|
+ name: item.tradefield_shoppingcart + "(1件商品)"
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ classList[index].list.push(item)
|
|
|
+ classList[index].name = classList[index].type + `(${classList[index].list.length}件商品)`
|
|
|
+ }
|
|
|
} else {
|
|
|
deteleList.push(i)
|
|
|
}
|
|
@@ -148,7 +154,8 @@ Page({
|
|
|
sum,
|
|
|
yfsum,
|
|
|
results,
|
|
|
- sa_brandid
|
|
|
+ sa_brandid,
|
|
|
+ classList
|
|
|
})
|
|
|
},
|
|
|
/* 删除产品 */
|