index.js
6.86 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
var t = require("./restapi.js"), e = require("../../utils/util"), a = getApp();
Component({
properties: {},
options: {
styleIsolation: "shared"
},
data: {
active: 0,
searchText: "",
orderList: [],
menuShow: {},
showPopup: !1,
showOverlay: !1,
menuList: [],
TYPELIST: {
0: "U",
1: "F",
2: "O",
3: "C"
},
isLast: !1,
pageSize: 10,
current: 0,
showNodata: !1,
typeId: "",
logistics: [],
userInfo: {}
},
methods: {
showMenu: function(t) {
var e = this.data.menuShow, a = t.currentTarget.dataset.index;
e[a] = !e[a], this.setData({
menuShow: e
});
},
hideMenu: function(t) {
var e = this.data.menuShow;
e[t.currentTarget.dataset.index] = !1, this.setData({
menuShow: e
});
},
onChange: function(t) {
this.setData({
active: t.detail.index,
isLast: !1,
current: 0,
orderList: []
}), this.getList();
},
openDialog: function(t) {
var e = this.data.menuShow, a = t.currentTarget.dataset.index, r = t.currentTarget.dataset.code;
a >= 0 && (e[a] = !1), this.getLogistics(r, e);
},
closeDialog: function() {
this.setData({
showPopup: !1
});
},
remind: function(e) {
var r = e.currentTarget.dataset, n = a.globalData.userInfo, s = {};
s.spaPurchaseCode = r.code, s.merchantName = n.merchant.merchantName, s.ghMerchantOrderCode = r.id,
(0, t.WXREMINDERORDER)(s, function(t) {
if (0 == t.returnCode) {
var e = "您的催单请求已发送客服进行跟进,请耐心等待";
t.data >= 5 && (e = "您的催单请求已达上限,客服会尽快与您联系"), wx.showModal({
content: e,
showCancel: !1
});
}
});
},
buyAgain: function(a) {
console.log(a);
var r = this, n = this.data.orderList || [], s = a.currentTarget.dataset.id, o = n.find(function(t) {
return t.id == s;
}), i = {};
i.ghMerchantOrderCode = o.ghMerchantOrderCode, i.merchantCode = o.merchantCode,
i.productConfigCode = o.productConfigCode, i.remark = o.remark, i.total = o.total,
i.listCartConfig = o.listMerchantOrderConfig, (0, t.ADDGHPRODUCTCONFIGCART)(i, function(t) {
0 == t.returnCode && ((0, e.showToast)("已加入购物车"), r.triggerEvent("change", !0));
});
},
getMenu: function() {
var e = this, a = e.getParams();
a.type = 27, (0, t.GETTYPELIST)(a, function(t) {
if (0 == t.returnCode) {
var a = t.data || [];
e.setData({
menuList: a
});
}
});
},
getParams: function() {
var t = a.globalData.userInfo, e = {};
return e.merchantCode = t.merchant.merchantId, e;
},
openFilter: function() {
this.setData({
showOverlay: !0
});
},
closeFilter: function() {
this.setData({
showOverlay: !1
});
},
getList: function() {
var a = this, r = a.data.TYPELIST, n = a.getParams(), s = a.data.current + 1, o = a.data.isLast;
if (n.dtoStatus = r[a.data.active], n.categoryId = a.data.typeId, n.pageNum = s,
n.pageSize = a.data.pageSize, o) return !1;
(0, e.showLoading)("加载中..."), (0, t.GETWXLISTMERCHANTORDERS)(n, function(t) {
(0, e.hideLoading)();
var r = (t.data || {}).list || [], n = a.data.orderList || [];
if (r.map(function(t) {
var e = (t.listMerchantOrderConfig || []).filter(function(t) {
return "F" != t.option;
});
return t.listMerchantOrderConfig = e, t;
}), 0 != t.returnCode) return a.setData({
isLast: !0
}), !1;
r.length < 10 && (o = !0);
var i = n.concat(r), c = !1;
i.length <= 0 && (c = !0);
var u = {};
console.log(i), u.orderList = i, u.isLast = o, u.current = s, u.showNodata = c,
a.setData(u);
});
},
treatData: function(t) {
var e = [];
return t.map(function(t) {
var a = e.findIndex(function(e) {
return e.spaPurchaseCode == t.spaPurchaseCode;
});
if (a < 0) {
var r = JSON.parse(JSON.stringify(t));
r.list = [ t ], e.push(r);
} else e[a].list.push(t);
}), e;
},
getLogistics: function(a, r) {
var n = this, s = {};
s.ghMerchantOrderCode = a, (0, t.GETLOGISTICSBYSPAPURCHASECODE)(s, function(t) {
if (0 != t.returnCode) return (0, e.showToast)(t.message || t.msg), !1;
var a = t.data || [], s = a[0] ? a[0].bsAddress : {};
n.setData({
showPopup: !0,
menuShow: r,
logistics: a,
userInfo: s
});
});
},
cancelEvent: function(a) {
var r = this, n = {};
n.ghMerchantOrderCode = a.currentTarget.dataset.code, wx.showModal({
content: "请确认是否取消订单?",
showCancel: !0,
success: function(a) {
a.confirm && (0, t.WXCANCELORDER)(n, function(t) {
0 == t.returnCode && ((0, e.showToast)(t.message || "取消成功"), r.setData({
isLast: !1,
orderList: [],
current: 0
}), r.getList());
});
}
});
},
menuEvent: function(t) {
var e = t.currentTarget.dataset.id;
this.setData({
typeId: e,
showOverlay: !1,
isLast: !1,
current: 0,
orderList: []
}), this.getList();
},
goSearch: function() {
wx.navigateTo({
url: "/packageIndex/pages/search/search"
});
}
},
ready: function() {
this.getMenu(), this.getList();
}
});