express.js
6.78 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
var e = getApp(), s = e.request,oo=e.globalData,os=oo.setting;
var ut = require("../../../../utils/util.js");
Page({
data: {
url: e.globalData.setting.url,
resourceUrl: e.globalData.setting.imghost,
delivery: null,
express: null,
re_arr:null,//反转后的数组
error: "快递信息异常",
active:0,
has_connaect:1,
is_get:0
},
onLoad: function(e) {
var th=this;
//----获取系统参数-----
getApp().getConfig2(function (ee) {
var is_connaect=1;
if(ee.switch_list){
var json_d = JSON.parse(ee.switch_list);
if(json_d.weapp_customertype==0){
is_connaect=0;
}
th.setData({
store_config: ee,
sys_switch: json_d,
has_connaect:is_connaect
})
}else{
th.setData({
has_connaect:0
})
}
th.requestDelivery(e.order_id);
})
},
requestDelivery: function(e) {
var r = this;
s.get("/api/order/deliverydoc/page", {
data: { order_id: e,store_id:os.stoid,pageSize:100},
success: function(e) {
if(ut.ajax_ok(e)){
var list=e.data.data.pageData;
for (let i = 0; i < list.length; i++) {
list[i].all_gd_num=0;
var json=list[i].erp_ck_warelist;
if(json){
json=JSON.parse(json);
for (let j = 0; j < json.length; j++) {
list[i].all_gd_num+=json[j].qty;
}
}
list[i].erp_sender_city=r.sheng_lue(list[i].erp_sender_city,4);
list[i].erp_receiver_city=r.sheng_lue(list[i].erp_receiver_city,4);
}
r.setData({
delivery: list[0],
delivery_arr:list
}), r.requestExpress();
}
}
});
},
requestExpress: function() {
var s = this;
var url="/api/weshop/order/wuliu/" + this.data.delivery.shipping_code + "/" + this.data.delivery.invoice_no + "/" + this.data.delivery.mobile;
getApp().request.promiseGet(url, {}).then(e => {
wx.hideLoading();
s.setData({is_get:1})
if(e.data.code==0 && e.data.data){
var re_arr = e.data.data.Traces.reverse();
s.setData({
express: e.data.data, re_arr: re_arr,
});
}
}).catch(function(err) {
wx.hideLoading();
e.showWarning("请求失败");
})
},
click_bao_btn(e){
var index= parseInt(e.currentTarget.dataset.idx);
var item=this.data.delivery_arr[index];
this.setData({
delivery: item,
active:index,
express:null,
re_arr:[],
is_get:0
});
wx.showLoading();
this.requestExpress();
},
//打开客服操作菜单
openCS() {
let self=this;
// 判断会员状态
let user_info = getApp().globalData.userInfo;
if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) {
wx.navigateTo({
url: '/packageE/pages/togoin/togoin',
})
return false;
};
// csType/在线客服设置:
// 0关闭(如果有设置热线电话,则显示拨打热线电话)、
// 1小程序客服、
// 2企业微信客服
if (this.data.sys_switch) {
let csType = this.data.sys_switch.weapp_customertype;
if (csType == 0) {
// 拨打电话号码
this.contactService();
} else {
this.getTel()
.then(() => {
self.setData({
hiddenCS: false,
});
});
};
};
},
//关闭客服操作菜单
closeCS() {
this.setData({
hiddenCS: true,
});
},
// 获取客服电话
getTel() {
var self=this;
return new Promise((resolve, reject) => {
getApp().getConfig(function (t) {
if (t.store_tel == undefined) {
getApp().request.get("/api/weshop/store/get/" + os.stoid, {
isShowLoading: 1,
data: {},
success: function (rs) {
getApp().globalData.config = rs.data.data;
if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) {
getApp().my_warnning("商家未设置电话", 0, th);
return false;
}
self.setData({
store_tel: rs.data.data.store_tel,
});
// s.confirmBox("请联系客服:" + rs.data.data.store_tel);
}
})
} else {
self.setData({
store_tel: t.store_tel,
});
// s.confirmBox("请联系客服:" + t.store_tel);
};
resolve();
});
});
},
customer_chat: function () {
getApp().customer_chat("");
},
//---------联系客服------------
contactService: function () {
getApp().com_call(this);
},
//---------联系微信客服------------
con_weixin: function () {
var url = this.data.sys_switch.weapp_customertype_url;
var id = this.data.sys_switch.weapp_customertype_appid;
wx.openCustomerServiceChat({
extInfo: { url: url },
corpId: id,
success(res) { }
})
},
// 内容复制到剪贴板
copy() {
// console.log('点击了复制按钮');
wx.setClipboardData({
data: this.data.delivery.invoice_no,
success(res) {
wx.getClipboardData({
success(res) {
console.log(res.data);
}
})
}
})
},
sheng_lue(txt,maxLength){
if(!txt) return '';
if (txt.length > maxLength) {
txt = txt.substr(0, maxLength) + '...';
}
return txt
}
});