constructionOrderDetail.js
16.3 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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
// tabWorkOrder/pages/orderDetail/orderDetail.js
import api from '../../api.js'
import order_mixins, { data } from '../order_mixins.js'
import { getPositionList } from '~/store/index'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
IMG_URL,
...order_mixins.data,
qrFlag: true,
qrHeight: 107,
isYqdSuper: app.globalData.isYqdSuper,
isStaff: app.globalData.isStaff,
customerService: '',
defaultCustomerService: 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/kf.png',
// defaultCustomerService: 'https://img01.glsx.com.cn/group1/M00/21/01/wKgFHWKEkeSAZRltAAED5CfS91o118.png',
failCustomerService: '../images/kfrefresh.png',
showTip: false,
warrantyCardVisible: true,
showRatingPopup: false,
showRatingCard: true // 显示评价卡片
},
RatingPopupSetting() {
this.setData({
showRatingPopup: !this.data.showRatingPopup
})
},
jumpUserPortrait() {
wx.$router.go('tabDate.userPortrait', this.data.orderInfo)
},
// 跳转正确订单
redirectOrder() {
let { orderInfo } = this.data
let _this = this
wx.$util.showLoading('加载中...')
api
.getOrderDetail({
orderCode: orderInfo.associatedOrderCode
})
.then(result => {
// 根据不同状态和施工标志做对应跳转
let { code, data: item } = result
if (code == 0) {
item.oldOrderCode = orderInfo.associatedOrderCode
let name = item.status == 3 ? 'confirmOrder' : item.status == 1 ? 'createOrder' : 'orderDetail'
if (item.constructionFlag == 'Y' && item.status != 10) {
wx.$router.go('constructionOrderDetail', item)
} else {
// console.log(item)
// 解决错单能切换支付方式的问题
// wx.$router.go(name, { ...item, associateOrderType: true })
wx.$router.go(name, { ...item })
}
}
})
.catch(err => {
console.log(err)
})
// wx.$router.redirectTo('constructionOrderDetail', { orderCode: orderInfo.associatedOrderCode })
},
targetOperate() {
let { showTip } = this.data
this.setData({
showTip: !showTip
})
},
// 确定是否要显示
targetError() {
wx.$modal(this, {
show: true,
title: '工单标记',
tabTitleShow: false,
success: res => {
// 跳转新增订单页面 并带特定参数
let { orderInfo } = this.data
// orderInfo.orderSource = type
orderInfo.associateOrderCode = orderInfo.orderCode
delete orderInfo.orderCode
if (orderInfo.technicianList) {
delete orderInfo.technicianList
}
orderInfo.selectPayType = 2
// filmOrder 1精品升级
let urlName = orderInfo?.filmOrder == 1 ? 'premiumUpgrade' : 'createOrder'
wx.$router.redirectTo(urlName, orderInfo)
// wx.showToast({
// icon: 'success',
// title: '确定按钮点击'
// })
},
error: () => {
// wx.showToast({
// icon: 'error',
// title: '取消'
// })
}
})
},
// 选择技师确认
changeArtificer(e) {
let value = e?.detail || {}
let { orderInfo } = this.data
orderInfo?.subOrderList?.forEach(val => {
if (val.subOrderCode == value?.subOrderCode) {
val.technicianName = value.technicianName
val.technicianUuid = value.technicianUuid
val.technicianId = value.technicianId
}
})
let params = {
orderCode: orderInfo?.orderCode,
subOrderCode: value?.subOrderCode,
technicianName: value?.technicianName,
technicianUuid: value?.technicianUuid,
technicianId: value?.technicianId
}
api.updateTechnicianInfo(params).then(res => {
let { code, message } = res
if (code == 0) {
this.setData({
artificerSelectPopup: false,
artificerSelectObj: value,
orderInfo
})
} else {
wx.$util.showToast(message)
}
})
},
// 选择技师
selectArtificer(e) {
// 已施工完成不可操作
return
let { item } = e.currentTarget.dataset
this.setData({
artificerSelectPopup: true,
artificerSelectObj: item
})
},
jumpUpdate() {
let { orderInfo } = this.data
wx.$router.go('updateOrderInfo', orderInfo)
},
againOrder() {
// 新增订单
this.keepGoing(4)
},
showAgain() {
this.setData({
showPopup: true
})
},
setCopyData(e) {
let { content } = e.currentTarget.dataset
console.log(e, 'e');
wx.$util.setCopyData(`${content}`)
},
makePhoneCall(e) {
let { data } = e.currentTarget.dataset
wx.makePhoneCall({
phoneNumber: data
})
},
onRoute(options) {
console.log(options)
if (options.orderCode) {
this.setData({
orderCode: options.orderCode
})
this.getOrderDetail(options.orderCode)
// this.getGrass(options.orderCode)
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
// debugger
if (options.orderCode) {
this.getOrderDetail(options.orderCode)
}
let o = wx.$util.getStorageSync('dj_boutique_user_info')
this.checkPhoneShow(app.globalData.YQorderSetting?.yqPhoneConfig)
this.setData({
userInfo: o,
isYqdSuper: app.globalData.isYqdSuper,
isStaff: app.globalData.isStaff
})
},
checkPhoneShow(config) {
console.log('config', config)
// 有就屏蔽手机号的显示
if (config) {
let { customerObj } = this.data
delete customerObj[2]
this.setData({
customerObj
})
}
},
async getOrderDetail(orderCode) {
let _this = this
const positionTypeList = await getPositionList() || []
wx.$util.showLoading('加载中...')
api
.getOrderDetail({
orderCode
})
.then(res => {
let { code, message, data } = res
if (code == 0) {
wx.$util.hideLoading()
let couponName = data.customerCoupon ? data.customerCoupon.couponName : ''
let total_price = 0
let warrantyCardList = []
data.subOrderList = data.subOrderList.filter(item => item.merchantGoodsId)
for (var i = 0; i < data?.subOrderList?.length; i++) {
let e = data?.subOrderList[i]
total_price += e.totalPrice
e.price = Number(wx.$util.decimal(Number(e.totalPrice / e.number), 2)).toFixed(2)
e.positionStr = positionTypeList.filter(v => v.positionValue == e.upgradeGoodsPosition)[0]?.positionName || ''
if ((e.upgradeWarrantyPeriod || e.upgradeWarrantyPeriod > 0) && data.selectPayType != 0) {
warrantyCardList.push({
warrantyPeriod: e.upgradeWarrantyPeriod,
goodsName: e.upgradeGoodsAlias || e.upgradeGoodsName,
cardCode: e.cardCode
})
}
}
data = {
...data.customer,
...data.payOrder,
...data,
couponName,
total_price: data.selectPayType == 0 ? 0 : Number(wx.$util.decimal(total_price, 2)).toFixed(2)
}
if (data.customerCoupon) {
data.customerCoupon.customerCouponCode = data.customerCoupon.customerCouponCode.split('-')[0]
}
if (data.orderTime) data.time = new Date(data.orderTime).format('yyyy-MM-dd hh:mm:ss')
if (data.customer && data.customer.carSeriesName) {
data.carType = `${data.customer.carBrand || ''}-${data.customer.carChildsBrandName || ''}-${data.customer.carSeriesName || ''}`
}
// 处理订单是否显示 操作按钮 支付方式为pos和微信 并且订单状态是 4和6
// data.failureFlag != 'Y'
data.canOperate = [1, 3, 4].includes(data.selectPayType) && [4, 6].includes(data.status)
const orderInfo = data
console.log(orderInfo);
const clientSignatureDTOList = orderInfo.clientSignatureDTOList?.[0] || []
console.log(clientSignatureDTOList);
const showRatingCard = [6, 4, 2].includes(orderInfo.status) && orderInfo.selectPayType != 0 && !clientSignatureDTOList.electronicSignature
this.setData({
orderInfo: { ...clientSignatureDTOList, ...data },
flag: true,
warrantyCardList,
showRatingCard
})
this.setQrBoxHeight()
// 超时关闭的不显示客服码和
data.status != 10 && this.getWorkWechatLiveQRCode()
// 已评价的就不再显示评价码 战败也不显示
data.status != 6 && data.selectPayType != 0 && this.getQrCode(data)
// 条形码
warrantyCardList.length && this.getBarCode()
this.getServiceBaseInfo(data.merchantId)
// if (data.status == 6) return
// 校验是否显示二级流量方
if (data.subShopMerchantName) {
let { customerObj } = this.data
if (customerObj.findIndex(val => val?.key && val.key == 'subShopMerchantName') < 0) {
customerObj[customerObj.length - 2] = {
label: '二级流量方',
key: 'subShopMerchantName'
}
}
this.setData({
customerObj
})
}
// 门店是否配置技师
// if (data?.technicianConfigDTOList?.length > 0) {
// this.isArtificer(data)
// }
// 获取园区店技师配置数据 wx.$util.getStorageSync('dj_boutique_user_info')?.merchantId
api.getQYTechnicianList({ yqMerchantId: wx.$util.getStorageSync('dj_boutique_user_info')?.merchantId }).then(respone => {
if (respone?.code == 0) {
if (respone?.data.length > 0) this.isArtificer(respone.data)
}
})
} else {
wx.showModal({
title: '温馨提示',
content: message,
showCancel: false,
confirmText: '刷新',
confirmColor: '#347BFF',
success(res) {
if (res.confirm) {
_this.getOrderDetail(orderCode)
}
}
})
}
})
},
isArtificer(data) {
let { customerObj, orderInfo } = this.data
orderInfo.isOpenArtificer = true
orderInfo.technicianList = data || [] // 技师数据
// if (customerObj.findIndex(val => val?.key && val.key == 'technicianName') < 0) {
// customerObj[customerObj.length] = {
// label: '选择技师:',
// key: 'technicianName'
// }
// }
this.setData({
artificerList: data,
customerObj,
orderInfo
})
},
getBarCode() {
// warrantyCardList
let that = this
let { warrantyCardList } = this.data
warrantyCardList.forEach((element, index) => {
setTimeout(() => {
// console.log(data.now())
api
.createBarCode({ content: element.cardCode })
.then(result => {
// console.log(index)
// console.log(element.cardCode)
// console.log(result)
let { code, data } = result
// 待优化 应该都有之后再一次性更新
// warrantyCardList[index].barCodeUrl = 'http://qcimg01.glsx.com.cn:7060/group1/M00/02/96/wKgD3mNXkD-ALMu3AAABmn9Id4c794.png'
if (code == 0) {
warrantyCardList[index].barCodeUrl = data
}
that.setData({
warrantyCardList
})
})
.catch(err => { })
}, 500 * index)
})
},
getServiceBaseInfo(merchantId) {
api.getServiceBaseInfo({ merchantId }).then(result => {
console.log(result, 'result')
let { data, code } = result
console.log(data)
if (data.cardCodeFlag && data.cardCodeFlag == 1) {
this.setData({
warrantyCardVisible: false
})
}
})
},
setQrBoxHeight() {
const { orderInfo } = this.data
let statusList = [2, 4, 6]
if (statusList.includes(orderInfo.status) && orderInfo.selectPayType != 0) {
wx.$util.getViewInfo('#qr-view', () => {
this.setData({
// qrHeight: height,
qrFlag: true
})
})
}
},
showQrBox() {
this.setData({
qrFlag: !this.data.qrFlag
})
},
getQrCode() {
// console.log('getQrcode')
let data = this.data.orderInfo
let appId = 'wx06d1198e751435d1'
let path = 'packagePersonal/pages/boutiquePages/boutiqueInstall/boutiqueInstall'
let scene = `orderCode=${data.orderCode}&merchantId=${data.merchantId}`
// B端小程序调用接口生成领券码时,传参userId用uuid,类型由int变string
api
.createWeappQrcode({
qrcodeType: 'QR_WXA_UNLIMIT',
appId,
channelType: 1,
path,
scene
})
.then(qr => {
if (qr.data) {
this.setData({
qr: qr.data
})
}
this.setData({
qrFlag: true
})
})
},
keepGoing(type) {
let { orderInfo } = this.data
orderInfo.orderSource = type
// delete orderInfo.orderCode
// 去除掉错误订单对应的关联码
// delete orderInfo.associateOrderCode
// 1031车膜下单版本 再次下单去掉商品信息 需重新选择
let deleteList = ['orderCode', 'associateOrderCode', 'merchantDistributionList', 'expenseCategoryList', 'profitAllocatinList', 'clientSignatureDTOList', 'customerPhotos', 'rating', 'sellerName', 'sellerUserId', 'sellerMerchantName', 'sellerMerchantId', 'subOrderList', 'technicianList', 'merchantExpenseDistributionList']
for (var i = 0; i < deleteList.length; i++) {
// console.log(arr[i])
orderInfo[deleteList[i]] && delete orderInfo[deleteList[i]]
}
orderInfo.againOrder = true
// console.log(orderInfo);
// return
wx.$router.redirectTo('createOrder', orderInfo)
// merchantDistributionList,expenseCategoryList,profitAllocatinList
},
// previewImage(e) {
// let { url } = e.currentTarget.dataset
// console.log(url)
// if (url.includes('http')) {
// wx.previewImage({
// urls: [url],
// current: url
// })
// } else {
// this.getWorkWechatLiveQRCode()
// }
// },
// imageLoad(params) {
// console.log('load', this.data.imgSrc)
// // this.setdata({})
// },
// imageError(params) {
// console.log('error', this.data.imgSrc)
// },
getWorkWechatLiveQRCode() {
this.setData({
customerService: ''
})
// setTimeout(() => {
let { failCustomerService, defaultCustomerService } = this.data
let { orderCode, customerPhone: phoneNumber, selectPayType } = this.data.orderInfo
// console.log(orderCode, phoneNumber, selectPayType)
// 订单状态 1-升级订单 2-战败订单
let orderType = selectPayType == 0 ? 2 : 1
api
.getWorkWechatLiveQRCode({ orderCode, phoneNumber, orderType })
.then(result => {
let { code, data: url, message } = result
console.log(url)
if (code == 0) {
this.setData({
customerService: url
})
} else {
// console.log(defaultCustomerService)
this.setData({
customerService: defaultCustomerService
})
}
// else {
// wx.$util.showToast(message)
// }
})
.catch(err => {
// console.log(err)
this.setData({
customerService: failCustomerService
})
})
// }, 3000)
},
previewImage(e) {
let { url, index } = e.currentTarget.dataset
let urlList = url.map(v => { return v.payVoucher })
wx.previewImage({
urls: urlList,
current: urlList[index]
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () { },
/**
* 生命周期函数--监听页面显示
*/
onShow: function (options) {
console.log(this.data)
let code = this.data.orderCode || ''
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () { },
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () { },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () { },
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () { }
})