CarQuotationDetail.js
6.83 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
// packageEquity/pages/carQuotation/CarQuotationDetail/CarQuotationDetail.js
import { getOrderDetail,getQuotationInfoById, updateCustomerInfo } from '../../../api'
import {
buildEquityCustomerDailyDetail
} from '../services/customerDailyFields.helpers.js'
let timer = null
Page({
/**
* 页面的初始数据
*/
data: {
textNameObj: {
confirmName: '下一步·去签名(4/4)(10s)',
// editName: '修改',
// cancelName: '稍后处理',
timer: null
},
showZyPopup: false,
zyFlag: false,
customerDailyInfo: {},
customerTagLabels: []
},
// 倒计时10s功能
countDownTimer(zyFlag) {
let sec = 10
let { id, orderId, timer } = this.data
let that = this
timer = setInterval(() => {
let objNameStr = 'textNameObj.confirmName'
// const str = '前往提单(10s)'
if (zyFlag) {
that.setData({
[objNameStr]: `下一步·上传协议(4/4)(${sec}s)`,
showBtnFlag: true
})
}
sec--
if (sec == -1) {
clearInterval(timer) // 清除定时器
// 跳转提单页面
// this.navigator()
if (zyFlag) { // 需要上传合同协议
return this.setData({ showZyPopup: true }) // 上传合同协议弹窗
}
// 跳转列表页面
wx.$router.reLaunch("packageEquity.equityPage?tabIndex=1");
}
}, 1000)
this.setData({timer})
},
btnTap(e) {
console.log(e)
let { name } = e.detail
let { id, orderId, timer, zyFlag } = this.data
if (name == 'confirm') {
clearInterval(timer)
if (zyFlag) return this.setData({showZyPopup: true})
wx.$router.redirectTo('signature', { id, orderId })
} else {
// this.triggerEvent('editSave')
this.navigator()
// wx.$router.reLaunch('packageEquity.equityPage')
// wx.$router.reLaunch('packageEquity.index')
}
},
// 合同协议上传确定
zyPayConfirm(e) {
wx.showLoading({title: '加载中', mask: true})
let { zyPayOrderInfo, zyConfirmFlag } = this.data
if (zyConfirmFlag) return false
this.setData({
zyConfirmFlag: true
});
// 更新客户信息
updateCustomerInfo({ ...zyPayOrderInfo, zyPayUrl: e.detail?.zyPayUrl?.join(',') }).then(result => {
wx.hideLoading()
let { code, message } = result
this.setData({
showZyPopup: false
})
if (code == 0) {
// 返回到报价单列表
wx.$router.reLaunch("packageEquity.equityPage?tabIndex=1");
} else {
wx.$util.showToast(message)
}
setTimeout(() => {
this.setData({
zyConfirmFlag: false,
})
})
})
},
getInsurance(res) {
let obj = wx.$util.deepClone(res), orderInfo = {};
let { default4SStoreInfo } = wx.$util.getUserInfo();
orderInfo.check = true
orderInfo.id = obj.id
orderInfo.orderId = obj.orderId
orderInfo.merchantId4s = default4SStoreInfo?.merchantId;
orderInfo.merchantName4s = default4SStoreInfo?.merchantName;
orderInfo.referrer = obj.referrer
orderInfo.referrerId = obj.referrerId
return orderInfo;
},
navigator() {
let { orderId } = this.data
wx.$router.go('serviceInfo', {
orderId: orderId,
apiName: 'handler'
})
},
getQuotationInfoById() {
let { id } = this.data
getQuotationInfoById({ id }).then(res => {
let { code, data } = res
console.log(res)
let { orderId, payId, merchantAddress, merchantName4s, quotationGoodsInfoList } = data
quotationGoodsInfoList
if (quotationGoodsInfoList&"ationGoodsInfoList.length) {
quotationGoodsInfoList.forEach(item=>{
if (item.position) {
const fieldMap = {
"4大件": "燃油车4大件服务",
"3电": "新能源3电服务",
"6大件": "新能源6大件服务",
// 在这里可以添加更多的替换规则
};
// 如果输入字段在字段映射中有匹配项,则进行替换,否则保持不变
fieldMap[item.position]&&( item.position = fieldMap[item.position])
}
if (item.quotationGoodsServiceItemsRelationDTOList&&item.quotationGoodsServiceItemsRelationDTOList.length) {
item.serviceItems = item.quotationGoodsServiceItemsRelationDTOList.reduce((prev,subItm,index)=>{
let unit = index == 0 ? '':'/'
prev += unit+subItm.serviceName
return prev
},'')
}
})
}
// 处理用于上传合同协议更新客户信息接口的参数
let zyPayOrderInfo = this.getInsurance(data)
const { customerDailyInfo, customerTagLabels } =
buildEquityCustomerDailyDetail(data)
this.setData({
orderCode: payId,
merchantAddress,
merchantName4s,
orderId,
['orderDetail.quotationGoodsInfoList']:quotationGoodsInfoList,
zyPayOrderInfo,
customerDailyInfo,
customerTagLabels
// quotationGoodsInfoList
// id
})
this.setData({
zyFlag: data?.zyPayStatus == 1 && data.orderStatus == 7
})
this.countDownTimer(data?.zyPayStatus == 1 && data.orderStatus == 7)
})
},
getOrderDetail() {
let { orderCode, orderDetail } = this.data
getOrderDetail({ orderCode }).then(res => {
let { code, data } = res
data.orderTime = data.orderTime ? wx.$util.tsFormatTime(data.orderTime, 'Y年M月D日 h:m:s') : ''
let paySuccessDate = data?.paySuccessDate || new Date()
data.paySuccessDate = wx.$util.tsFormatTime(paySuccessDate, 'Y年M月D日 h:m:s')
if (code == 0) {
this.setData({
orderDetail: {
...orderDetail,
...data.customer,
...data
}
})
}
})
},
onRoute(options) {
let { orderDetail, orderCode, orderId, id } = options
this.setData({
orderCode: orderCode,
orderDetail,
orderId,
id
})
this.getOrderDetail()
this.getQuotationInfoById()
// this.countDownTimer()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
// this.countDownTimer()
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
let { timer } = this.data
clearInterval(timer) // 清除定时器
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
let { timer } = this.data
clearInterval(timer) // 清除定时器
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {}
})