PickerSelect.js
3.46 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
// packageCrowdFunding/components/PickerSelect/PickerSelect.js
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer: function(n) {
let { pickerObj, orderInfo } = this.data
orderInfo = wx.$util.deepClone(orderInfo)
if (n) {
pickerObj?.optionList?.map(i => {
i.active = false
if (i[pickerObj?.optionId] == orderInfo[pickerObj?.optionId]) {
i.active = true
}
return i
})
this.setData({
optionList: pickerObj?.optionList || []
})
}
}
},
title: String,
orderInfo: Object,
pickerObj: Object,
isAdditionRecordOrder: Boolean,
popupHeight: {
type: String,
value: '60%'
},
goodsNumber: {
type: Number,
value: 1
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
changeitem(e) {
let { target } = e.currentTarget.dataset
let { optionList, pickerObj } = this.data
optionList.map(i => {
i.active = false
if (i[pickerObj?.optionId] == target[pickerObj?.optionId]) {
i.active = true
}
return i
})
this.setData({optionList})
},
confirm() {
let { optionList, orderInfo, pickerObj, title, isAdditionRecordOrder, goodsNumber } = this.data
let arr = optionList?.filter(v => v.active) || []
if (!arr.length) {
return wx.showToast({
title: `请${title}`,
icon: 'none'
})
}
let thisPage = wx.$router.getPageInstance()
let copyOrderInfo = wx.$util.deepClone(orderInfo)
orderInfo[pickerObj.optionId] = arr[0][pickerObj.optionId] || ''
orderInfo[pickerObj.optionName] = arr[0][pickerObj.optionName] || ''
if (pickerObj.flag) { // 商品带出金额
// 定金金额
orderInfo['depositPrice'] = `¥${this.priceFilter(arr[0]?.activityPrice * goodsNumber / 100 || 0)}`
// 尾款金额 = 众筹价 - 定金金额
orderInfo['tailPayment'] = `¥${this.priceFilter((arr[0]?.crowdFundingPrice - arr[0]?.activityPrice) * goodsNumber / 100 || 0)}`
orderInfo['crowdFundingPrice'] = `¥${this.priceFilter(arr[0]?.crowdFundingPrice * goodsNumber / 100 || 0)}`
// 筛选交易流水号 补录用订单总价 关联尾款单(有定金支付时间 用尾款 没有支付时间 用订单总价)
if (isAdditionRecordOrder) {
// orderInfo['tailPayment'] = `¥${this.priceFilter(arr[0]?.crowdFundingPrice / 100 || 0)}`
orderInfo['totalFee'] = arr[0]?.crowdFundingPrice || 0
} else {
orderInfo['totalFee'] = (arr[0]?.crowdFundingPrice - arr[0]?.activityPrice) || 0
}
// 切换商品 清空选中的交易流水号
if (copyOrderInfo.goodsId !== arr[0][pickerObj.optionId]) orderInfo['outTradeNo'] = ''
// 特殊处理 一个id是众筹商品id 一个是嘀加智享车生活平台商品id
orderInfo.specialGoodsId = arr[0]?.goodsId
}
thisPage.setData({
orderInfo,
showPickerSelect: false
})
this.triggerEvent('confirm', orderInfo)
},
priceFilter(num) {
var pow = Math.pow(10, 2)
return (Math.round(num * pow) / pow).toFixed(2)
},
cancel() {
let thisPage = wx.$router.getPageInstance()
thisPage.setData({
showPickerSelect: false
})
}
}
})