-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
386 lines (358 loc) · 9 KB
/
main.js
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
import App from './App'
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
//注册uView组件
import uView from 'uview-ui';
Vue.use(uView);
app.$mount()
// #endif
// #ifdef VUE3
import {
createSSRApp
} from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif
// let baseUrl = "http://你自己电脑的IP地址(绝对不能写localhost和127.0.0.1)/hxds-driver"
let baseUrl = "http://csitak.natappfree.cc/hxds-driver" //"http://127.0.0.1:8201/hxds-driver"
Vue.prototype.url = {
registerNewDriver: `${baseUrl}/driver/registerNewDriver`,
updateDriverAuth: `${baseUrl}/driver/updateDriverAuth`,
uploadCosPrivateFile: `${baseUrl}/cos/uploadCosPrivateFile`,
deleteCosPrivateFile: `${baseUrl}/cos/deleteCosPrivateFile`,
createDriverFaceModel: `${baseUrl}/driver/createDriverFaceModel`,
verificateDriverFace: `${baseUrl}/driver/recognition/verificateDriverFace`,
login: `${baseUrl}/driver/login`,
logout: `${baseUrl}/driver/loginout`,
searchDriverBaseInfo: `${baseUrl}/driver/searchDriverBaseInfo`,
searchWorkbenchData: `${baseUrl}/driver/searchWorkbenchData`,
searchDriverAuth: `${baseUrl}/driver/searchDriverAuth`,
startWork: `${baseUrl}/driver/startWork`,
stopWork: `${baseUrl}/driver/stopWork`,
receiveNewOrderMessage: `${baseUrl}/message/order/new/receiveNewOrderMessage`,
acceptNewOrder: `${baseUrl}/order/acceptNewOrder`,
searchDriverExecuteOrder: `${baseUrl}/order/searchDriverExecuteOrder`,
searchDriverCurrentOrder: `${baseUrl}/order/searchDriverCurrentOrder`,
searchOrderForMoveById: `${baseUrl}/order/searchOrderForMoveById`,
arriveStartPlace: `${baseUrl}/order/arriveStartPlace`,
startDriving: `${baseUrl}/order/startDriving`,
uploadRecordFile: `${baseUrl}/monitoring/uploadRecordFile`,
updateOrderStatus: `${baseUrl}/order/updateOrderStatus`,
updateBillFee: `${baseUrl}/order/updateBillFee`,
searchReviewDriverOrderBill: `${baseUrl}/order/searchReviewDriverOrderBill`,
searchOrderStatus: `${baseUrl}/order/searchOrderStatus`,
updateOrderAboutPayment: `${baseUrl}/order/updateOrderAboutPayment`,
searchDriverOrderByPage: `${baseUrl}/order/searchDriverOrderByPage`,
searchOrderById: `${baseUrl}/order/searchOrderById`,
startCommentWorkflow: `${baseUrl}/order/startCommentWorkflow`,
}
Vue.prototype.tencent = {
map: {
referer: "华夏代驾",
key: "FGRBZ-GS266-44VSO-ER7OG-IW5S7-ANB47"
}
}
Vue.prototype.ajax = function(url, method, data, fun, load) {
let timer = null
if (load == true || load == undefined) {
uni.showLoading({
title: "执行中"
})
timer = setTimeout(function() {
uni.hideLoading()
}, 60 * 1000)
}
uni.request({
"url": url,
"method": method,
"header": {
token: uni.getStorageSync("token")
},
"data": data,
success: function(resp) {
if (load == true || load == undefined) {
clearTimeout(timer)
uni.hideLoading()
}
if (resp.statusCode == 401) {
uni.redirectTo({
url: "/pages/login/login.vue"
})
} else if (resp.statusCode == 200 && resp.data.code == 200) {
let data = resp.data
if (data.hasOwnProperty("token")) {
let token = data.token
uni.setStorageSync("token", token)
}
fun(resp)
} else if (resp.data.error=="该微信已完成注册") {
uni.showToast({
icon:"none",
title:"该微信已完成注册"
})
} else {
uni.showToast({
icon: "none",
title: "执行异常"
})
console.error(resp.data)
}
},
fail: function(error) {
if (load == true || load == undefined) {
clearTimeout(timer)
uni.hideLoading()
}
}
})
}
Vue.prototype.refreshMessage = function(that) {
uni.request({
"url": that.url.refreshMessage,
"method": "POST",
"header": {
token: uni.getStorageSync("token")
},
"data": {
identity: 'driver'
},
success: function(resp) {
if (resp.statusCode == 401) {
uni.redirectTo({
url: "/pages/login/login.vue"
})
} else if (resp.statusCode == 200 && resp.data.code == 200) {
uni.$emit("updateMessageService", true)
let result = resp.data.result
let lastRows = result.lastRows
let unreadRows = result.unreadRows
if (lastRows > 0) {
uni.$emit("showMessageTip", lastRows)
}
} else {
console.error(resp.data)
//在工作台页面触发更新消息服务状态,显示服务可用或者不可用
uni.$emit("updateMessageService", false)
}
console.log("刷新消息")
},
fail: function(error) {
//在工作台页面触发更新消息服务状态,显示服务可用或者不可用
uni.$emit("updateMessageService", false)
}
})
}
Vue.prototype.uploadCos = function(url, path, module, fun) {
uni.uploadFile({
url: url,
filePath: path,
name: "file",
header: {
token: uni.getStorageSync("token")
},
formData: {
"module": module
},
success: function(resp) {
let data = JSON.parse(resp.data)
if (resp.statusCode == 401) {
uni.redirectTo({
url: "/pages/login/login.vue"
})
} else if (resp.statusCode == 200 && data.code == 200) {
fun(resp)
} else {
uni.showToast({
icon: "none",
title: data.error
})
}
}
})
}
Vue.prototype.upload = function(url, path, data, fun) {
uni.uploadFile({
url: url,
filePath: path,
name: "file",
header: {
token: uni.getStorageSync("token")
},
formData: data,
success: function(resp) {
let data = JSON.parse(resp.data)
if (resp.statusCode == 401) {
uni.redirectTo({
url: "/pages/login/login.vue"
})
} else if (resp.statusCode == 200 && data.code == 200) {
fun(resp)
} else {
uni.showToast({
icon: "none",
title: data.error
})
}
}
})
}
Vue.prototype.toPage = function(url) {
uni.navigateTo({
url: url
})
}
Vue.prototype.checkNull = function(data, name) {
if (data == null) {
this.$refs.uToast.show({
title: name + "不能为空",
type: 'error'
})
return true
}
return false
}
Vue.prototype.checkBlank = function(data, name) {
if (data == null || data == "") {
this.$refs.uToast.show({
title: name + "不能为空",
type: 'error'
})
return true
}
return false
}
Vue.prototype.checkValidName = function(data, name) {
if (data == null || data == "") {
this.$refs.uToast.show({
title: name + "不能为空",
type: 'error'
})
return false
} else if (!/^[\u4e00-\u9fa5]{2,15}$/.test(data)) {
this.$refs.uToast.show({
title: name + "不正确",
type: 'error'
})
return false
}
return true
}
Vue.prototype.checkValidTel = function(data, name) {
if (data == null || data == "") {
this.$refs.uToast.show({
title: name + "不能为空",
type: 'error'
})
return false
} else if (!/^1[0-9]{10}$/.test(data)) {
this.$refs.uToast.show({
title: name + "不正确",
type: 'error'
})
return false
}
return true
}
Vue.prototype.checkValidEmail = function(data, name) {
if (data == null || data == "") {
this.$refs.uToast.show({
title: name + "不能为空",
type: 'error'
})
return false
} else if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(data)) {
this.$refs.uToast.show({
title: name + "不正确",
type: 'error'
})
return false
}
return true
}
Vue.prototype.checkValidAddress = function(data, name) {
if (data == null || data == "") {
this.$refs.uToast.show({
title: name + "不能为空",
type: 'error'
})
return false
} else if (!/^[0-9a-zA-Z\u4e00-\u9fa5\-]{6,50}$/.test(data)) {
this.$refs.uToast.show({
title: name + "不正确",
type: 'error'
})
return false
}
return true
}
Vue.prototype.checkValidFee = function(data, name) {
if (data == null || data == "") {
this.$refs.uToast.show({
title: name + "不能为空",
type: 'error'
})
return false
} else if (!/^[1-9]\d*\.\d{1,2}$|^0\.\d{1,2}$|^[1-9]\d*$/.test(data)) {
this.$refs.uToast.show({
title: name + "不正确",
type: 'error'
})
return false
}
return true
}
Vue.prototype.changeNumber = function(value) {
let newValue = ['', ''];
let fr = 1000;
const ad = 1;
let num = 3;
const fm = 1;
while (value / fr >= 1) {
fr *= 10;
num += 1;
}
if (num <= 4) {
// 千
newValue[1] = '千';
newValue[0] = parseInt(value / 1000) + '';
} else if (num <= 8) {
// 万
const text1 = parseInt(num - 4) / 3 > 1 ? '千万' : '万';
const fm = '万' === text1 ? 10000 : 10000000;
newValue[1] = text1;
newValue[0] = value / fm + '';
} else if (num <= 16) {
// 亿
let text1 = (num - 8) / 3 > 1 ? '千亿' : '亿';
text1 = (num - 8) / 4 > 1 ? '万亿' : text1;
text1 = (num - 8) / 7 > 1 ? '千万亿' : text1;
// tslint:disable-next-line:no-shadowed-variable
let fm = 1;
if ('亿' === text1) {
fm = 100000000;
} else if ('千亿' === text1) {
fm = 100000000000;
} else if ('万亿' === text1) {
fm = 1000000000000;
} else if ('千万亿' === text1) {
fm = 1000000000000000;
}
newValue[1] = text1;
newValue[0] = parseInt(value / fm) + '';
}
if (value < 1000) {
newValue[1] = '';
newValue[0] = value + '';
}
let temp = Math.floor((newValue[0]) * 100) / 100
return temp + newValue[1];
}