index.js
8.48 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
var t = function(t) {
return t && t.__esModule ? t : {
default: t
};
}(require("../../../utils/filter.js")), e = require("./restapi.js"), a = require("../../../utils/util"), i = getApp();
Page(t.default.identityFilter({
data: {
menuActive: 1,
menuList: [ {
name: "车载导航",
id: 1
}, {
name: "爱车保镖",
id: 2
}, {
name: "电子辅助",
id: 3
}, {
name: "配件",
id: 4
} ],
showPopup: !1,
popupTitle: "",
secondTitle: "",
popupId: "",
showSelectCar: !1,
productList: [],
glsxProductCode: "",
queryCondition: {},
seriesList: [],
modelList: [],
showSeries: "",
seriesInfo: {},
modelInfo: {},
pageSize: 10,
currentPage: 0,
tabActive: "1",
shoppingNumber: 0,
userInfo: "",
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"
},
allcheck: !1,
displayConfig: ""
},
onLoad: function(t) {
var e = this;
wx.setNavigationBarTitle({
title: "在线采购"
});
var n = setInterval(function() {
i.globalData.userInfo && (clearInterval(n), (0, a.hideLoading)(), e.setData({
userInfo: i.globalData.userInfo
}), e.getList(), e.getBrand());
}, 100);
},
onReady: function() {},
onLogin: function() {},
onShow: function() {
this.getShoppingCarList();
},
onReachBottom: function() {
console.log("55555555555"), 3 == this.data.tabActive && this.selectComponent("#orderList").getList(),
this.getProduct();
},
menuEvent: function(t) {
var e = t.currentTarget.dataset.id;
this.setData({
menuActive: e,
currentPage: 0,
isLast: !1
}), this.getProduct();
},
openShoppingCar: function(t) {
var e = t.currentTarget.id, a = t.currentTarget.dataset.code, i = t.currentTarget.dataset.config, n = t.currentTarget.dataset.id, o = t.currentTarget.dataset.name, r = t.currentTarget.dataset.type;
this.setData({
showPopup: !0,
popupTitle: o,
secondTitle: n,
popupId: e,
glsxProductCode: a,
productConfigCode: i,
displayConfig: r
});
},
closeDialog: function() {
this.setData({
showPopup: !1,
isDelete: !1,
allcheck: !1
}), this.getShoppingCarList();
},
getList: function() {
var t = this, a = t.getParams();
a.type = 27, (0, e.GETTYPELIST)(a, function(e) {
if (0 == e.returnCode) {
var a = e.data || [];
t.setData({
menuList: a,
menuActive: a[0].id
}), t.getProduct();
}
});
},
getBrand: function() {
var t = this, i = t.getParams();
i.pageSize = 1e4, i.pageNo = 1, (0, e.GETBRANDLIST)(i, function(e) {
if (0 == e.returnCode) {
var i = e.data || {};
t.setData({
seriesList: i.listAudiMotorcycle
});
} else (0, a.showToast)(e.message);
});
},
getProduct: function() {
var t = this, i = {}, n = t.getParams(), o = t.data.currentPage + 1;
if (n.categoryId = t.data.menuActive, n.audiId = t.data.seriesInfo.id, n.motorcycle = t.data.modelInfo.name,
i.queryCondition = n, i.pageSize = t.data.pageSize, i.pageNo = o, t.data.isLast) return !1;
(0, a.showLoading)("加载中..."), (0, e.GETPRODUCTLIST)(i, function(e) {
if ((0, a.hideLoading)(), 0 == e.returnCode) {
var i = e.data || {}, n = i.listGhProductConfig || [], r = t.data.productList || [], s = [];
n.length < 10 && t.setData({
isLast: !0
}), t.setData({
currentPage: o
}), s = o > 1 ? n.concat(r) : n, t.setData({
productList: s,
queryCondition: i.queryCondition
});
}
});
},
goSearch: function() {
var t = this.data.seriesInfo || {}, e = this.data.modelInfo || {};
wx.navigateTo({
url: "/packageIndex/pages/search/index?code=" + this.data.glsxProductCode + "&audiId=" + t.id + "&motorcycle=" + e.name
});
},
getParams: function() {
var t = i.globalData.userInfo, e = {};
console.log(t)
return e.merchantCode = t.merchant.merchantId, e;
},
openDialog: function(t) {
var e = t.currentTarget.dataset.id;
this.setData({
showSelectCar: !0,
showSeries: e
});
},
closeCarDialog: function() {
this.setData({
showSelectCar: !1
});
},
configChange: function(t) {
var e = t.detail;
0 == e.close && this.closeDialog(), this.setData(e);
},
addEvent: function(t) {
var i = this, n = t.currentTarget.dataset.code, o = i.data.productList, r = i.getParams();
r.productConfigCode = n, r.total = 1, r.remark = "";
var s = [];
(o.find(function(t) {
return t.productConfigCode == n;
}).listConfigOther || []).map(function(t) {
"F" == t.option && s.push(t.attribInfoId);
}), r.listCartConfig = s, (0, e.ADDGHPRODUCTCONFIGCART)(r, function(t) {
0 == t.returnCode && ((0, a.showToast)("已加入购物车"), i.getShoppingCarList());
});
},
changeSeries: function(t) {
var e = t.currentTarget.dataset.id, a = t.currentTarget.dataset.name, i = this.data.seriesList, n = {};
n.id = e, n.name = a;
var o = i.find(function(t) {
return t.audiId == e;
});
this.setData({
seriesInfo: n,
modelList: o ? o.listMotocyleDto : [],
modelInfo: {},
currentPage: 0,
isLast: !1
}), this.closeCarDialog(), this.getProduct();
},
changeModel: function(t) {
var e = t.currentTarget.dataset.id, a = t.currentTarget.dataset.name, i = {};
i.id = e, i.name = a, this.setData({
modelInfo: i,
currentPage: 0,
isLast: !1
}), this.closeCarDialog(), this.getProduct();
},
closeTagEvent: function(t) {
var e = t.currentTarget.dataset.id, a = {};
"seriesInfo" == e && (a.modelInfo = {}), a[e] = {}, a.isLast = !1, a.currentPage = 0,
a.productList = [], this.setData(a), this.getProduct();
},
tabClickEvent: function(t) {
t.detail, this.setData({
tabActive: t.detail
});
var e = "在线采购", a = this.data.userInfo;
switch (t.detail) {
case "2":
e = a.merchant ? a.merchant.merchantName : "";
break;
case "3":
e = "采购订单";
break;
default:
e = "在线采购";
}
wx.setNavigationBarTitle({
title: e
});
},
getShoppingCarList: function() {
var t = this, i = t.getParams();
i.pageSize = 1e5, i.pageNo = 1, (0, e.LISTGHSHOPPINGCART)(i, function(e) {
if (0 == e.returnCode) {
var i = (e.data || {}).listGhShoppingCart || [];
t.setData({
shoppingNumber: i.length
});
} else (0, a.showToast)(e.message);
});
},
goLogin: function() {
wx.reLaunch({
url: "/pages/index/index"
});
},
batchAddEvent: function() {
var t = this.data.popupId;
"car" != t && this.selectComponent("#" + t).addEvent();
},
allcheckEvent: function(t) {
var e = this.data.popupId;
this.setData({
allcheck: t.detail
}), this.selectComponent("#" + e).allcheckEvent(t);
},
clearEvent: function() {
var t = this.data.popupId;
this.selectComponent("#" + t).clearEvent();
},
submitOrder: function() {
var t = this.data.popupId;
this.selectComponent("#" + t).submitOrder();
},
batchDelete: function() {
var t = this.data.popupId;
this.selectComponent("#" + t).batchDelete();
}
}));