SecondStep.js
10.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
// packageEquity/pages/carEquity/components/SecondStep/SecondStep.js
import data from '../constant/stepData'
import fn from '../constant/ruleFn'
import { priceCounter } from '~/packageEquity/api'
const defaultLabelWidth = 'var(--fontSize140)'
Component({
options: {
styleIsolation: 'apply-shared'
},
// behaviors: ['wx://component-export'],
attached() {
console.log('component attached')
this.makeYear()
},
/**
* 组件的属性列表
*/
pageLifetimes: {
show: function () {},
attached: function () {
// 在组件实例进入页面节点树时执行
},
hide: function () {}
},
properties: {
serviceInfo: {
type: Object,
value: () => {}
},
orderInfo: {
type: Object,
observer: function (n) {
if (n.quotedPriceUpdate) {
this.setData({
testQuotedPriceUpdate: n.quotedPriceUpdate
})
}
if (n?.modifyEquityQuotation) {
this.setData({
activeNames: ['3'],
disable: true
})
} else {
this.setData({
activeNames: ['1', '2', '3', '4'],
disable: false
})
}
}
},
quotationGoodsList: {
type: Array,
value: () => {}
}
},
observers: {
'orderInfo.outTradeNo': function (value) {
console.log(value, 'outTradeNo')
this.setData({
textNameObj: {
confirmName: '下一步(2/4)'
}
})
}
},
/**
* 组件的初始数据
*/
data: {
defaultLabelWidth,
showYear: false,
// 选择时间的年份
columns: [],
disable: false,
currentDate: new Date().getTime(),
// 默认当前年份
currentIndex: new Date().getFullYear() - (new Date().getFullYear() - 25),
currentName: new Date().getFullYear() + '年',
popupShow: false,
popupInputShow: false,
// customInput: true,
// secondObj: data.secondObj,
formRule: data.formRule,
textNameObj: {
confirmName: '下一步·生成告知书(2/4)',
// editName: '修改',
cancelName: '存草稿'
},
// '1', '2', '3',
activeNames: ['1', '2', '3', '4'],
showPicker: false,
// optionsSelect: Object.freeze(optionsSelect),
popObj: {
popValue: ''
},
popinputobj: {
type: 'add'
},
showError: false,
insuranceCheck: false,
testQuotedPriceUpdate: 0
},
/**
* 组件的方法列表
*/
methods: {
// test() {
// let { activeNames } = this.data
// console.log('activeNames', activeNames)
// },
onChangeInsurance(e) {
console.log(e)
// vdQuotationGoodsList
let { detail } = e
let { id } = e.currentTarget.dataset
console.log(detail, 'detail')
if (!detail) {
return this.setData({
insuranceCheck: false
})
}
let thisPage = wx.$router.getPageInstance()
let { quotationGoodsList } = this.data
let goodsItem = quotationGoodsList.find(item => item.id == id)
let { id: appreciation, goodsInfo, upgradeGoodsName: goodsName, upgradeGoodsServiceItemsList } = goodsItem
thisPage.setData({})
let params = thisPage.getInsurance()
let owner = thisPage.getOwnerInfo()
owner.salesType = owner.salesType=='售后'?1:0
// const owner = wx.$util.deepClone(thisPage.data.owner)
params.owner = owner
params.goodsId = goodsItem.id
params.goodsName = goodsItem.goodsName
params.insureList = params.insureList.map(item => {
if (item.type == 3) {
item = {
appreciation,
goodsName,
type: 3
}
}
return item
})
// params.owner = owner
// params.owner.price = this.multipliedByHundred(orderInfo.owner?.price) || ''
// console.log(thisPage)
if (params.owner?.buyCarTime) {
delete params.owner.buyCarTime
}
// quotedPriceUpdate
delete params?.quotedPriceUpdate
// if (params?.quotedPriceUpdate) {
// }
// params.insureList = []
console.log(params, 'params')
wx.$util.showLoading()
priceCounter(params)
.then(result => {
wx.hideLoading()
console.log('result', result)
let { data, code, message } = result
if (code == 0) {
let thisPage = wx.$router.getPageInstance()
thisPage.setData({
['orderInfo.quotedPriceUpdate']: data.quotedPriceUpdate,
['orderInfo.goodsId']: goodsItem.id,
['orderInfo.goodsName']: goodsItem.goodsName,
['orderInfo.valueAddedVehicleLoss']: {
appreciation,
goodsName,
type: 3
},
['orderInfo.quotationGoodsInfo']: {
titlePictureUrl: goodsInfo.thumbUrl,
goodsName,
quotationGoodsServiceItemsRelationDTOList: upgradeGoodsServiceItemsList
}
})
this.setData({
insuranceCheck: true,
testQuotedPriceUpdate: data.quotedPriceUpdate / 100
})
} else {
wx.$util.showToast({
title: message || '获取报价失败',
icon: 'error'
})
}
})
.catch(err => {})
},
//--------自定义方法----------
// 选择年份的区域,弹出弹窗框
chooseYear() {
console.log('选择年份')
this.setData({
showYear: true
})
},
// 弹出框确认事件
onConfirm(e) {
// console.log(e, 1111)
let { value } = e.detail
let thisPage = wx.$router.getPageInstance()
console.log(value, 'value')
thisPage.setData({
// ['orderInfo' + '.' + attrtype + '.' + attrname]: value
['orderInfo.vehiclesAndVessels.compensation']: value + '年'
})
this.setData({
showYear: false
})
this.cancelInsuranceCheck()
},
cancelInsuranceCheck() {
// this.setData({
// // insuranceCheck: false
// })
let thisPage = wx.$router.getPageInstance()
thisPage.setData({
['orderInfo.quotedPriceUpdate']: '',
['orderInfo.goodsId']: '',
['orderInfo.goodsName']: '',
['orderInfo.valueAddedVehicleLoss']: {
appreciation: '',
goodsName: '',
type: 3
}
})
},
// 取消选择年份的弹框
onCancel() {
let that = this
that.setData({
showYear: false
})
},
// 对选择时间进行单独的处理
makeYear() {
// console.log('makeYear')
let year = []
let currentDate = new Date()
console.log(currentDate.getFullYear())
for (let j = currentDate.getFullYear() - 25; j < currentDate.getFullYear(); j++) {
year.push(j)
}
for (let i = currentDate.getFullYear(); i <= currentDate.getFullYear() + 25; i++) {
year.push(i)
}
// console.log(year, 'year')
this.setData({
columns: year
})
},
handlePopupShow(e) {
// console.log(e)
let { disable } = this.data
if (disable) return false //修改权益价时,不可修改
// let { attrtype, attrname, typename } = e.target.dataset
let { attrtype, attrname, typename } = e.currentTarget.dataset
console.log(attrtype, attrname, typename, 'attrType, attrName')
let thisPage = wx.$router.getPageInstance()
let popValue = thisPage.data.orderInfo?.[attrtype]?.[attrname] || ''
this.setData({
popupShow: true,
// popValue
popObj: {
attrtype,
attrname,
popValue,
typename
}
})
},
handlePopInputShow(e) {
// console.log(e)
let { disable } = this.data
if (disable) return false //修改权益价时,不可修改
let { handletype, index } = e.currentTarget.dataset
// console.log(handletype, index, 'type, index')
let thisPage = wx.$router.getPageInstance()
let popValue = ''
if (handletype == 'edit') {
popValue = thisPage.data.orderInfo?.['otherInsuranceList']?.[index] || ''
}
// console.log(popValue, 'popValue')
this.setData({
popupInputShow: true,
popinputobj: {
handletype,
index,
...popValue
}
})
},
btnTap(e) {
// console.log(e)
let { name } = e.detail
// let { attrtype, attrname, typename } = this.data.tableObj
let { showError, insuranceCheck, orderInfo } = this.data
if (showError) return wx.$util.showToast('权益价不能小于最低权益价')
if (name == 'confirm') {
// 不是修改报价时,需要勾选保险
// if (!insuranceCheck && !orderInfo.modifyEquityQuotation) return wx.$util.showToast('请先勾选保险')
if (!orderInfo.quotedPriceUpdate && !orderInfo.modifyEquityQuotation) return wx.$util.showToast('请先勾选增值车损险')
this.triggerEvent('confirm')
} else {
this.triggerEvent('editSave')
}
},
onChange(event) {
console.log(event, 'event')
this.setData({
activeNames: event.detail
})
},
handleInput(e) {
let value = e.detail
console.log(e)
let { attrname, attrtype, type } = e.currentTarget.dataset
value = type == 'number' ? wx.$util.numberFixedDigit(value) : value
if (type == 'number') {
value = parseFloat(value) > 2000000 ? 2000000 : value
}
let thisPage = wx.$router.getPageInstance()
console.log(attrtype)
if (attrtype == 'modifyEquityQuotation') {
let { orderInfo } = this.data
let showError = orderInfo.modifyEquityQuotation.minEquityPrice <= value ? false : true
this.setData({
showError
})
}
// ['orderInfo' + '.' + attrType]
// console.log(['orderInfo' + '.' + attrType], '2')
thisPage.setData({
['orderInfo' + '.' + attrtype + '.' + attrname]: value
})
this.cancelInsuranceCheck()
// console.log(thisPage.data)
}
// numberFixedDigit (e) { // 固定两位小数
// e.target.value = (e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || ''
// this.$nextTick(() => {
// this.number= e.target.value
// })
// },
}
})