car.js
7.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
var t = require("../restapi"), e = require("../../utils/util"), a = getApp();
Component({
properties: {},
data: {
icon: {
active: "https://img01.glsx.com.cn/weapp/resource/eims/radio_active.png",
normal: "https://img01.glsx.com.cn/weapp/resource/eims/radio_normal.png"
},
checkList: [],
maxNumber: 9999,
list: [],
oList: [],
showCheckall: !1,
isDelete: !1,
noPass: !1,
total: 0,
allcheck: !1
},
methods: {
onChange: function(t) {
var e = t.detail, a = this.data.list, o = this.data.showCheckall;
console.log(t), o = e.length == a.length, this.setData({
checkList: t.detail,
showCheckall: o
}), this.sum();
},
submitOrder: function() {
var t = this.data.checkList, a = this.data.oList, o = [];
if (console.log(t), !t || t.length <= 0) return (0, e.showToast)("请勾选下单的物品"), !1;
var r = !0, i = !1, n = void 0;
try {
for (var s, c = t[Symbol.iterator](); !(r = (s = c.next()).done); r = !0) !function() {
var t = s.value, e = a.find(function(e) {
return e.cartCode == t;
});
e && o.push(e);
}();
} catch (t) {
t = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(t);
i = !0, n = t;
} finally {
try {
!r && c.return && c.return();
} finally {
if (i) throw n;
}
}
console.log(o), wx.setStorageSync("order", o), this.triggerEvent("change", {
close: !1
}), wx.navigateTo({
url: "/packageIndex/pages/order/index"
});
},
updateNumber: function(a) {
console.log(a);
var o = this, r = o.data.maxNumber, i = Number(a.detail), n = a.currentTarget.dataset.code;
if (!a.detail) return !1;
if (i > r) return (0, e.showToast)("购买数量超过最大数量"), o.setData({
noPass: !1
}), !1;
o.setData({
noPass: !0
});
var s = o.getParams();
s.cartCode = n, s.total = i, (0, t.UPDATEGHPRODUCTCONFIGCART)(s, function(t) {
console.log(t), 0 == t.returnCode && o.getList();
});
},
sum: function() {
var t = this.data.oList, e = this.data.checkList, a = 0, o = !0, r = !1, i = void 0;
try {
for (var n, s = e[Symbol.iterator](); !(o = (n = s.next()).done); o = !0) !function() {
var e = n.value, o = t.find(function(t) {
return t.cartCode == e;
});
console.log(o), o && (a += Number(o.total));
}();
} catch (t) {
t = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(t);
r = !0, i = t;
} finally {
try {
!o && s.return && s.return();
} finally {
if (r) throw i;
}
}
this.setData({
total: a
});
},
allcheckEvent: function(t) {
console.log(t);
var e = this.data.oList, a = [];
if (t.detail) {
var o = !0, r = !1, i = void 0;
try {
for (var n, s = e[Symbol.iterator](); !(o = (n = s.next()).done); o = !0) {
var c = n.value;
a.push(c.cartCode.toString());
}
} catch (t) {
t = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(t);
r = !0, i = t;
} finally {
try {
!o && s.return && s.return();
} finally {
if (r) throw i;
}
}
}
this.setData({
allcheck: t.detail,
checkList: a
}), this.sum();
},
manageMethod: function(t) {
console.log(t);
var e = !1;
1 == t.currentTarget.id && (e = !0), this.setData({
isDelete: e
});
var a = {};
a.isDelete = e, this.triggerEvent("change", a);
},
clearEvent: function() {
var t = [];
(this.data.oList || []).map(function(e) {
t.push(e.cartCode);
}), this.setData({
checkList: [],
allcheck: !1
}), this.deleteProduct(t);
},
getParams: function() {
var t = a.globalData.userInfo, e = {};
return e.merchantCode = t.merchant.merchantId, e;
},
getList: function() {
var e = this, a = e.getParams();
a.pageSize = 1e5, a.pageNo = 1, (0, t.LISTGHSHOPPINGCART)(a, function(t) {
if (console.log(t), 0 == t.returnCode) {
var a = (t.data || {}).listGhShoppingCart || [], o = [], r = [];
a.map(function(t) {
var e = o.findIndex(function(e) {
return t.categoryId == e;
}), a = [];
if ((t.listCartConfig || []).map(function(t) {
"F" != t.option && a.push(t);
}), t.configList = a, e >= 0) r[e].list.push(t); else {
var i = {};
i.name = t.categoryName, i.id = t.categoryId, i.list = [ t ], r.push(i), o.push(t.categoryId);
}
}), console.log(r), e.setData({
list: r,
oList: a
}), e.sum();
}
});
},
deleteProduct: function(a) {
var o = this, r = o.getParams();
r.cartCodes = a, (0, t.DELGHPRODUCTCONFIGCART)(r, function(t) {
console.log(t), 0 == t.returnCode && ((0, e.showToast)("删除成功"), o.getList());
});
},
singleDelete: function(t) {
var e = this.data.checkList || [], a = t.currentTarget.id, o = [], r = e.findIndex(function(t) {
return t == a;
});
r >= 0 && e.splice(r, 1), console.log(r), o.push(a), this.setData({
checkList: e
}), console.log(e), this.deleteProduct(o);
},
batchDelete: function() {
var t = this.data.checkList, a = this.data.oList, o = [];
if (!t || t.length <= 0) return (0, e.showToast)("请勾选要删除的产品"), !1;
t.map(function(t) {
var e = a.find(function(e) {
return e.cartCode == t;
});
e && o.push(e.cartCode);
}), this.setData({
checkList: []
}), this.deleteProduct(o);
}
},
ready: function() {
this.getList();
}
});