index.js
3.2 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
var t = require("../restapi"), a = require("../../utils/util"), e = getApp();
Component({
properties: {
config: {
type: [ String, Number ],
value: ""
},
displayConfig: {
type: String,
value: ""
}
},
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"
},
maxNumber: 9999,
configList: [],
form: {},
list: []
},
methods: {
onChange: function(t) {
var a = t.currentTarget.id, e = this.data.form;
e[a] = t.detail, console.log(e), this.setData({
form: e
});
},
inputEvent: function(t) {
var a = {};
a[t.currentTarget.id] = t.detail.value, this.setData(a);
},
getParams: function() {
var t = e.globalData.userInfo, a = {};
return a.merchantCode = t.merchant.merchantId, a;
},
getList: function() {
var a = this, e = a.getParams();
e.productConfigCode = a.data.config, (0, t.GETGHPRODUCTCONFIGOTHER)(e, function(t) {
if (console.log(t), 0 == t.returnCode) {
var e = (t.data || {}).listConfigOther || [], o = [], i = [];
e.map(function(t) {
var a = o.findIndex(function(a) {
return t.attribTypeId == a;
});
if (a >= 0) i[a].list.push(t); else {
var e = {};
e.name = t.attribTypeName, e.id = t.attribTypeId, e.list = [ t ], i.push(e), o.push(t.attribTypeId);
}
}), console.log(i), a.setData({
configList: i,
list: e
});
}
});
},
addEvent: function() {
var e = this, o = e.getParams(), i = e.data.form, n = [], r = e.data.list;
for (var s in i) !function(t) {
console.log(t);
var a = i[t], e = r.find(function(t) {
return t.attribInfoId == a;
});
e && n.push(e);
}(s);
return "N" != e.data.displayConfig && (!n || n.length <= 0) ? ((0, a.showToast)("请选择配置"),
!1) : e.data.total ? (o.productConfigCode = e.data.config, o.total = e.data.total,
o.remark = e.data.remark, o.listCartConfig = n, console.log(o), void (0, t.ADDGHPRODUCTCONFIGCART)(o, function(t) {
console.log(t), 0 == t.returnCode && ((0, a.showToast)("加入购物车成功"), e.triggerEvent("change", {
close: !1
}));
})) : ((0, a.showToast)("请设置发货数量"), !1);
},
updateNumber: function(t) {
var a = t.currentTarget.id;
console.log(t);
var e = {};
e[a] = t.detail, this.setData(e);
}
},
ready: function() {
console.log(this.data.config), this.getList();
}
});