EquityList.js
8.95 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
// packageEquity/pages/carEquity/components/EquityList/EquityList.js
import { checkDailyReport } from "~/store/ModalToQueueControl";
import carLifeApi from '../../../../carEquityApi'
import constantData from '../constant/data'
const TABLIST = ['全部', '待补单', '提单失败', '已完成']
Component({
/**
* 组件的属性列表
*/
properties: {
navBarHeight: {
type: Number,
value: 0
},
outTabIndex: {
type: Number,
observer(val) {
console.log(val)
if (val == 1) {
let {
list
} = this.data
setTimeout(() => {
// 解决商品内容提早请求,导致不计算问题
this.setData({
list: {
...list
}
})
}, 10)
}
}
}
},
/**
* 组件的初始数据
*/
data: {
storeInfo: {},
orderObj: [{
label: '车架号',
key: 'vin'
},
{
label: '业务来源',
key: 'ywly'
},
{
label: '商品名称',
key: 'goodName'
},
{
label: '服务期限',
key: 'serviceExpire',
suffix: '年'
},
{
label: '商品内容',
key: 'goodServiceName'
}
],
statisticsObj: {},
btnTxt: {
0: '去录单',
2: '查看合同',
3: '重新录单'
},
searchObj: {},
customerName: '',
list: [],
tabIndex: 0,
// 0待补单;2提单成功;3提单失败
tabList: ['全部', '待补单', '提单失败', '已完成'],
pageSize: 4,
pageNum: 1,
total: 0,
nothing: false,
flag: true,
tipsProps: {
tipsText: '为保障客户权益,请尽快处理!',
showTips: true,
type: 1,
noIcon: true,
iconUrl: '../images/order-close.png'
},
triggered: false,
scrollTop: 0,
isShowTips: true,
userInfo: {}
},
lifetimes: {
attached() {
this.setData({
storeInfo: wx.$util.getUserInfo()?.default4SStoreInfo || {},
userInfo: wx.$util.getUserInfo() || {}
})
this.onLoad(true)
}
},
/**
* 组件的方法列表
*/
methods: {
onLoad(noGetList) {
let userInfo = wx.$util.getUserInfo() || {};
this.setData({
nothing: false,
pageNum: 1,
storeInfo: wx.$util.getUserInfo()?.default4SStoreInfo || {},
isOrder: !(userInfo?.isSuper || userInfo?.loginRole == 3 || userInfo.loginRole == 5)
})
this.getTotal()
if (!noGetList) this.getList(true)
},
onBottomRefresh() {
this.getList()
},
closeTips() {
this.setData({
isShowTips: false
})
},
getTotal() {
let {
storeInfo
} = this.data
carLifeApi
.equityStatistics({
merchantId: storeInfo?.merchantId
})
.then(res => {
// console.log(res, '统计---')
if (res.code == '0') {
let {
data
} = res
this.setData({
statisticsObj: data || {}
})
this.setData({
['tabList[0]']: { text: TABLIST[0], count: data.totalOder || 0 },
['tabList[1]']: { text: TABLIST[1], count: data.ladingOder || 0 },
['tabList[2]']: { text: TABLIST[2], count: data.failed || 0 },
['tabList[3]']: { text: TABLIST[3], count: data.success || 0 }
})
} else {
wx.$util.showToast(res.message || '接口异常')
}
})
},
getList(isReset = false) {
let {
pageSize,
pageNum,
tabList,
tabIndex,
customerName,
storeInfo
} = this.data
if (this.data.nothing) {
return
}
let params = {
pageSize,
pageNum,
customerName,
// item.confName ==
orderStatus: constantData.equityStatusList.find(item => tabList[tabIndex].text == item.confName)?.confId || '',
merchantId: storeInfo?.merchantId
}
carLifeApi.equityPage(params).then(res => {
if (res.code == '0') {
let {
data,
count
} = res.data
let tempList = isReset ? data || [] : this.data.list.concat(data || [])
this.setData({
list: tempList,
pageNum: pageNum + 1,
total: count,
nothing: count == tempList.length,
triggered: false
})
if (isReset) {
this.setData({
scrollTop: 0
})
}
console.log(this.data.list)
} else {
this.setData({
list: [],
nothing: false,
total: 0
})
wx.$util.showToast(res.message || '接口异常')
}
})
},
search() {
this.setData({
pageNum: 1,
nothing: false,
total: 0
})
this.getList(true)
},
handleReset() {
this.setData({
customerName: ''
})
this.search()
},
input(e) {
let {
value
} = e.detail
this.setData({
customerName: value
})
},
// 首次进入会触发该方法,因此不需要在attached调getList
tabClick(e) {
let {
searchObj
} = this.data
delete searchObj.statusList
this.setData({
tabIndex: e.detail,
searchObj
})
this.search()
},
// 录单/重新录单
async handleRecordOrder(e) {
// 校验是否填写昨日日报
let staffCheck = await checkDailyReport(true);
if (staffCheck) return false;;
let {
target
} = e.currentTarget.dataset
console.log(target)
wx.$router.go('serviceInfo', {
contractNo: target.contractNo,
apiName: 'detail'
})
},
// 查看/下载合同
async handlePreviewContract(e) {
let {
target,
type
} = e.currentTarget.dataset
wx.$util.showLoading('加载中...')
let params = {
contractNo: target.contractNo
// contractNo: 'car679883190869172224' //开发测试用
}
let result = await carLifeApi.equityOrderList({
orderId: target.orderId
})
let {
code,
data
} = result
if (code == 0) {
if (data.length == 1) {
carLifeApi.printContract(params).then(res => {
wx.$util.hideLoading()
if (res.code == '0') {
this.setData({
url: res.data
})
if (type == 'download') {
// 复制合同链接
this.copyContractUrl(res.data)
} else this.handleDownload()
console.log(this.data.url)
} else {
wx.$util.showToast(res.message || '接口异常')
}
})
} else {
wx.$util.hideLoading()
wx.$router.go('previewList', {
list: data
})
}
}
console.log(result, 'result')
return
},
// 签名
async handleSignature(e) {
// 校验是否填写昨日日报
let staffCheck = await checkDailyReport(true);
if (staffCheck) return false;
let { target } = e.currentTarget.dataset
wx.$router.go("signature", {
orderId: target.orderId,
tabIndex: 2
});
},
// 复制链接
copyContractUrl(e) {
if (!e) {
wx.$util.showToast('没有合同')
return
}
wx.showModal({
title: '温馨提示',
content: '如需下载PDF报告单,请复制下载地址后到手机浏览器中打开。下载地址5分钟内有效',
confirmText: '复制地址',
confirmColor: '#347BFF',
success(res) {
if (res.confirm) {
wx.setClipboardData({
data: e
})
}
}
})
},
handleDownload() {
let {
url
} = this.data
let _this = this
if (!url) {
wx.$util.showToast('没有合同')
return
}
console.log('handleDownload')
wx.downloadFile({
// 示例 url,并非真实存在
url: url,
success: function (res) {
const manage = wx.getFileSystemManager()
let file = url.split('/')
let fileName = file[file.length - 1]
manage.saveFile({
tempFilePath: res.tempFilePath,
filePath: wx.env.USER_DATA_PATH + '/' + fileName,
success: function (res) {
console.log('保存成功')
wx.openDocument({
filePath: wx.env.USER_DATA_PATH + '/' + fileName,
fileType: 'pdf',
showMenu: true,
success: function (res) {
console.log('打开文档成功')
}
})
}
})
// console.log(wx.env.USER_DATA_PATH + "/" + fileName,'wx.env.USER_DATA_PATH + "/" + fileName');
}
})
}
}
})