index.js
7.27 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
var t = require("../restapi"), e = require("../../utils/util"), a = getApp();
Component({
properties: {
code: {
type: [ String, Number ],
value: ""
},
queryCondition: {
type: Object,
value: {}
},
spa: {
type: [ String, Number ],
value: ""
}
},
data: {
menuList: [],
menuActive: "",
show: !1,
maxNumber: 9999,
yearList: [],
yearActive: "",
checkList: [],
modelList: [],
remark: "",
totalList: {},
form: {},
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"
},
cList: {}
},
methods: {
menuEvent: function(t) {
var e = t.currentTarget.id;
this.setData({
menuActive: e
}), this.getYear();
},
showMore: function(t) {
var e = this.data.show;
this.setData({
show: !e
});
},
getParams: function() {
var t = a.globalData.userInfo, e = {};
return e.merchantCode = t.merchant.merchantId, e;
},
getYear: function() {
var o = this, i = {}, n = (o.getParams(), o.data.queryCondition), r = a.globalData.userInfo;
console.log(r), n.spaProductCode = o.data.spa || null, n.merchantCode = r.merchant.merchantId,
n.audiId = o.data.menuActive, o.data.code && (i.glsxProductCode = o.data.code || ""),
i.queryCondition = n, (0, t.LISTYEARMODE)(i, function(t) {
console.log(t), 0 == t.returnCode ? (o.setData({
yearList: t.data || []
}), o.getModel()) : (0, e.showToast)(t.message);
});
},
getCarseries: function() {
var o = this, i = {}, n = o.data.queryCondition, r = a.globalData.userInfo;
n.spaProductCode = o.data.spa || null, n.merchantCode = r.merchant.merchantId, o.data.code && (i.glsxProductCode = o.data.code || ""),
i.queryCondition = n, (0, t.LISTAUDIINFO)(i, function(t) {
if (console.log(t), 0 == t.returnCode) {
var a = t.data || [];
o.setData({
menuList: a,
menuActive: a[0] ? a[0].id : ""
}), a[0] && a[0].id ? o.getYear() : o.triggerEvent("change", {
close: !1
});
} else (0, e.showToast)(t.message);
});
},
getModel: function() {
var o = this, i = {}, n = o.data.queryCondition, r = a.globalData.userInfo;
o.data.code && (i.glsxProductCode = o.data.code || ""), n.merchantCode = r.merchant.merchantId,
i.queryCondition = n, i.modelYearId = o.data.yearActive, i.audiId = o.data.menuActive,
i.pageSize = 1e5, i.pageNo = 1, (0, t.PAGEMOTORCYCLE)(i, function(t) {
if (0 == t.returnCode) {
var a = (t.data || {}).listGhProductConfig || [];
a.map(function(t) {
var e = o.treatData(t.listConfigOther || []);
return t.configList = e, t.total = 0, t;
}), console.log(a), o.setData({
modelList: a
});
} else (0, e.showToast)(t.message);
});
},
yearEvent: function(t) {
var e = t.currentTarget.dataset.id;
this.setData({
yearActive: e
}), this.getModel();
},
inputEvent: function(t) {
var e = {};
e[t.currentTarget.id] = t.detail.value, this.setData(e);
},
addEvent: function() {
var a = this, o = a.getParams(), i = (a.data.form, []), n = a.data.checkList;
if (!n || n.length <= 0) return (0, e.showToast)("请选择车型"), !1;
n.map(function(t) {
var e = {};
e.productConfigCode = t.productConfigCode, e.total = t.total, e.remark = a.data.remark;
var o = t.listConfigOther || [], n = t.listCartConfig || [];
o.map(function(t) {
"F" == t.option && n.push({
id: t.attribInfoId
});
}), e.listCartConfig = n, i.push(e);
}), delete o.spaProductCode, o.listShopCarts = i, console.log(o), (0, t.BATCHADDGHPRODUCTCONFIGCART)(o, function(t) {
console.log(t), 0 == t.returnCode ? ((0, e.showToast)("加入购物车成功"), a.triggerEvent("change", {
close: !1
})) : (0, e.showToast)(t.message);
});
},
updateNumber: function(t) {
console.log(t);
var a = t.currentTarget.id, o = this.data.modelList, i = this.data.checkList || [], n = this.data.totalList || {}, r = Number(t.detail), s = this.data.maxNumber, d = this.data.cList || [], c = i.findIndex(function(t) {
return t.productConfigCode == a;
}), u = o.find(function(t) {
return t.productConfigCode == a;
}), l = o.findIndex(function(t) {
return t.productConfigCode == a;
});
if (r > s) return (0, e.showToast)("购买数量超过最大数量"), this.setData({
noPass: !1
}), !1;
console.log(u), u.total = r, u.listCartConfig = d[a], o[l] = u, t.detail > 0 ? (n[a] = t.detail,
c >= 0 ? i[c] = u : i.push(u)) : (delete n[a], c >= 0 && i.splice(c, 1)), this.setData({
checkList: i,
modelList: o,
totalList: n
});
},
treatData: function(t) {
var e = [], a = [];
return t.map(function(t) {
var o = e.findIndex(function(e) {
return t.attribTypeId == e;
});
if (o >= 0) "O" == t.option && a[o].list.push(t); else if ("O" == t.option) {
var i = {};
i.name = t.attribTypeName, i.id = t.id, i.list = [ t ], a.push(i), e.push(t.attribTypeId);
}
}), a;
},
radioChangeEvent: function(t) {
var e = t.currentTarget.id, a = t.currentTarget.dataset.mid, o = this.data.form, i = this.data.checkList || [], n = this.data.cList || [], r = i.findIndex(function(t) {
return console.log(t.productConfigCode + "---" + a), t.productConfigCode == a;
});
if (r >= 0) {
var s = i[r].listCartConfig || [];
s.push({
id: t.detail
}), i[r].listCartConfig = s;
} else {
var d = n[a] || [];
d.push({
id: t.detail
}), n[a] = d;
}
console.log(n), o[e] = t.detail, this.setData({
form: o,
checkList: i,
cList: n
}), console.log(i);
}
},
ready: function() {
console.log(this.data.queryCondition), this.getCarseries();
}
});