Card.js
2.82 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
// pages/addTransform/components/card/Card.js
Component({
/**
* 组件的属性列表
*/
properties: {
cardForm: {
type: Object,
observer(n) {
this.setData({
cardForm: n
})
}
},
actualForm: {
type: Object,
observer(n) {
this.setData({
actualForm: n
})
this.calcProfit()
}
},
tagIndex: {
type: Number,
observer(n) {
this.calcProfit()
}
}
},
/**
* 组件的初始数据
*/
data: {
IMGURL: wx.$imgUrl,
typeObj: {
service: {
name: '服务类',
bgColor: 'rgba(255,231,205,0.80)',
color: '#EF971E'
},
membrane: {
name: '膜类',
bgColor: '#E3ECFF',
color: '#4E87FB'
},
beauty: {
name: '美容类',
bgColor: '#EAE9FF',
color: '#5851FF'
},
light: {
name: '轻改类',
bgColor: '#D7F5E5',
color: '#21AB60'
}
},
},
ready() {
},
/**
* 组件的方法列表
*/
methods: {
handleClick() {
this.triggerEvent('click', this.data.cardForm)
},
calcProfit() {
var targetItem = this.data.cardForm
let sales = +this.data.actualForm.sales || 0
let userNum = +this.data.actualForm.userNum || 0
let defaultPrice = +targetItem.priceList[0].value
if(targetItem.detailAttrName) {
switch(targetItem.detailAttrName) {
case 'digitRight':
targetItem.profit = (sales * 0.5 * defaultPrice * 12).toFixed(0) + ''
break
case 'sunMembrane':
targetItem.profit = (sales * 0.8 * 0.7 * defaultPrice * 12).toFixed(0) + ''
break
case 'paintMembrane':
targetItem.profit = (userNum * 0.15 * defaultPrice * 12).toFixed(0) + ''
break
case 'colorMembrane':
targetItem.profit = (userNum * 0.05 * defaultPrice * 12).toFixed(0) + ''
break
case 'digitBeauty':
targetItem.profit = (sales * 0.2 * defaultPrice * 12).toFixed(0) + ''
break
case 'chair':
targetItem.profit = (userNum * defaultPrice * 0.9 * 0.01).toFixed(0) + ''
break
case 'ar':
targetItem.profit = (userNum * defaultPrice * 0.9 * 0.15).toFixed(0) + ''
break
case 'lamp':
targetItem.profit = (userNum * defaultPrice * 0.9 * 0.15).toFixed(0) + ''
break
case 'navigation':
targetItem.profit = (userNum * defaultPrice * 0.9 * 0.15).toFixed(0) + ''
break
default:
break
}
}
this.setData({
cardForm: targetItem
})
},
}
})