search.js
5.13 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
function t(t, e, r) {
return e in t ? Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}) : t[e] = r, t;
}
var e, r = require("../../../utils/util"), a = require("../../restapi"), o = getApp();
Page({
data: (e = {
orderHistory: [],
orderList: [],
spaProductCode: "",
maxNumber: 9999,
showNodata: !1,
isLast: !1,
pageSize: 9999,
current: 0
}, t(e, "showNodata", !1), t(e, "showPopup", !1), t(e, "showOverlay", !1), t(e, "logistics", []),
t(e, "userInfo", {}), e),
onLoad: function(t) {
wx.setNavigationBarTitle({
title: "搜索"
});
},
onReady: function() {},
onShow: function() {
var t = wx.getStorageSync("orderHistory") || [];
this.setData({
orderHistory: t
});
},
clearHistory: function() {
this.setData({
orderHistory: []
}), wx.removeStorageSync("orderHistory");
},
onChange: function(t) {
this.setData({
spaProductCode: t.detail
});
},
onSearch: function() {
var t = this, e = wx.getStorageSync("orderHistory") || [], r = t.data.spaProductCode;
if (!r) return !1;
e.push(r), wx.setStorageSync("orderHistory", e), this.getList();
},
clickEvent: function(t) {
var e = t.currentTarget.dataset.name, r = this.data.queryCondition || {};
this.setData({
spaProductCode: e,
queryCondition: r
}), this.getList();
},
getList: function() {
var t = this, e = {}, r = t.data.isLast;
e.pageNum = 1, e.pageSize = t.data.pageSize, e.spaProductCode = t.data.spaProductCode,
e.spaProductName = t.data.spaProductCode, e.spaPurchaseCode = t.data.spaProductCode,
(0, a.GETWXLISTMERCHANTORDERS)(e, function(e) {
var a = (e.data || {}).list || [], o = t.data.orderList || [];
if (a.map(function(t) {
var e = (t.listMerchantOrderConfig || []).filter(function(t) {
return "F" != t.option;
});
return t.listMerchantOrderConfig = e, t;
}), 0 != e.returnCode) return t.setData({
isLast: !0
}), !1;
a.length < 10 && (r = !0);
var n = o.concat(a), s = !1;
n.length <= 0 && (s = !0);
var i = {};
console.log(n), i.orderList = a, i.isLast = r, i.current = 1, i.showNodata = s,
t.setData(i);
});
},
remind: function(t) {
var e = t.currentTarget.dataset, r = o.globalData.userInfo, n = {};
n.spaPurchaseCode = e.code, n.merchantName = r.merchant.merchantName, n.ghMerchantOrderCode = e.id,
(0, a.WXREMINDERORDER)(n, function(t) {
if (0 == t.returnCode) {
var e = "您的催单请求已发送客服进行跟进,请耐心等待";
t.data >= 5 && (e = "您的催单请求已达上限,客服会尽快与您联系"), wx.showModal({
content: e,
showCancel: !1
});
}
});
},
buyAgain: function(t) {
console.log(t);
var e = this, o = this.data.orderList || [], n = t.currentTarget.dataset.id, s = o.find(function(t) {
return t.id == n;
}), i = {};
i.ghMerchantOrderCode = s.ghMerchantOrderCode, i.merchantCode = s.merchantCode,
i.productConfigCode = s.productConfigCode, i.remark = s.remark, i.total = s.total,
i.listCartConfig = s.listMerchantOrderConfig, (0, a.ADDGHPRODUCTCONFIGCART)(i, function(t) {
0 == t.returnCode && ((0, r.showToast)("已加入购物车"), e.triggerEvent("change", !0));
});
},
getLogistics: function(t, e) {
var o = this, n = {};
n.ghMerchantOrderCode = t, (0, a.GETLOGISTICSBYSPAPURCHASECODE)(n, function(t) {
if (0 != t.returnCode) return (0, r.showToast)(t.message || t.msg), !1;
var a = t.data || [], n = a[0] ? a[0].bsAddress : {};
o.setData({
showPopup: !0,
menuShow: e,
logistics: a,
userInfo: n
});
});
},
cancelEvent: function(t) {
var e = this, o = {};
o.ghMerchantOrderCode = t.currentTarget.dataset.code, wx.showModal({
content: "请确认是否取消订单?",
showCancel: !0,
success: function(t) {
t.confirm && (0, a.WXCANCELORDER)(o, function(t) {
0 == t.returnCode && ((0, r.showToast)(t.message || "取消成功"), e.getList());
});
}
});
},
openDialog: function(t) {
var e = this.data.menuShow, r = t.currentTarget.dataset.index, a = t.currentTarget.dataset.code;
r >= 0 && (e[r] = !1), this.getLogistics(a, e);
},
closeDialog: function() {
this.setData({
showPopup: !1
});
},
clear: function() {
this.setData({
spaProductCode: "",
orderList: []
});
}
});