StoreMessage.js
6.32 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
// packageCustomer/components/StoreMessage/StoreMessage.js
import { IMG_URL } from '~/utils/constantData'
Component({
options: {
addGlobalClass: true
},
properties: {
// 盈亏与展业等摘要信息
summary: {
type: Object,
value: {
profit: { ok: true, text: '盈利情况' },
business: { ok: true, text: '展业情况', warningCount: 0 },
bottomMetric: {
title: '渗透率临近业务兜底指标',
periodIndex: 0.1094, // 10.94%
bottomRequire: 0.5 // 50%
}
}
},
// 兜底指标预警列表
warnings: {
type: Array,
value: [
{ title: '轮胎转化率临近业务兜底指标预警', periodIndex: 0.1094, bottomRequire: 0.5 },
{ title: '安心包转化率临近业务兜底指标预警', periodIndex: 0.1094, bottomRequire: 0.5 },
{ title: '转化率临近业务兜底指标预警', periodIndex: 0.1094, bottomRequire: 0.5 }
]
},
// 驻店人员列表
residents: {
type: Array,
value: [
// { role: '店总', name: '李四', phone: '13510769158' },
// { role: '王五', name: '王五', phone: '13510769158' }
]
},
// 默认展开的折叠项(自定义折叠仍可参考该配置)
defaultActive: {
type: Array,
value: ['bottom', 'residents']
}
},
data: {
IMG_URL,
activeNames: [],
// 自定义折叠展开状态
showBusiness: false,
showBottom: false,
// 动画对象
businessAnimation: {},
bottomAnimation: {},
infoData: {
displaySituationWarningCount: 5,
safetyIndexWarningCount: 2,
profitAndLoss: 2,
// 展业情况测试数据
displaySituationWarningList: [],
// 兜底指标预警测试数据
safetyIndexWarningList: [{
rule: '轮胎转化率临近业务兜底指标预警',
cycleIndicator: 50,
fallbackIndicator: 20
}, {
rule: '安心包转化率临近业务兜底指标预警',
cycleIndicator: 35,
fallbackIndicator: 25
}, {
rule: '保险产品转化率临近业务兜底指标预警',
cycleIndicator: 28,
fallbackIndicator: 30
}, {
rule: '增值服务转化率临近业务兜底指标预警',
cycleIndicator: 45,
fallbackIndicator: 40
}, {
rule: '客户满意度临近业务兜底指标预警',
cycleIndicator: 38,
fallbackIndicator: 35
}],
storePersonnel: [{
personnelName: '王五王五王五王五王五王五王五王五王五王五王五',
personnelMobile: 13510769158
}, {
personnelName: '王五',
personnelMobile: 13510769158
}]
}
},
lifetimes: {
attached() {
// 初始化展开状态:仅在有数据时允许展开
const hasBusiness = (this.data.infoData?.displaySituationWarningList || []).length > 0
const hasBottom = (this.data.infoData?.safetyIndexWarningList || []).length > 0
this.setData({
showBusiness: hasBusiness ? false : false,
showBottom: hasBottom ? false : false
})
}
},
methods: {
// 兼容之前 collapse 的回调(不再使用)
onCollapseChange(e) {
this.setData({ activeNames: e.detail })
},
// 切换展业情况展开
toggleBusiness(e) {
const has = Number(e?.currentTarget?.dataset?.has || 0)
if (!has) return
const isExpanding = !this.data.showBusiness
this.setData({ showBusiness: isExpanding })
if (isExpanding) {
this.expandPanel('business')
} else {
this.collapsePanel('business')
}
},
// 切换兜底预警展开
toggleBottom(e) {
const has = Number(e?.currentTarget?.dataset?.has || 0)
if (!has) return
const isExpanding = !this.data.showBottom
this.setData({ showBottom: isExpanding })
if (isExpanding) {
this.expandPanel('bottom')
} else {
this.collapsePanel('bottom')
}
},
getDetailData() {
let { infoData } = this.data
infoData.safetyIndexWarningList?.forEach(val => {
val.cycleIndicator = this.formatPercent(val.cycleIndicator)
val.fallbackIndicator = this.formatPercent(val.fallbackIndicator)
})
this.setData({
infoData
})
},
formatPercent(n) {
const rate = Number(n || 0)
return `${rate.toFixed(2)}%`
},
// 展开面板动画
expandPanel(type) {
const contentSelector = type === 'business' ? '.business-content' : '.bottom-content'
const animationKey = type === 'business' ? 'businessAnimation' : 'bottomAnimation'
// 先临时设置为auto高度以获取实际高度
const tempAnimation = wx.createAnimation({
duration: 0,
timingFunction: 'ease'
})
tempAnimation.height('auto').opacity(1).step()
this.setData({
[animationKey]: tempAnimation.export()
})
// 下一帧获取内容实际高度并应用动画
setTimeout(() => {
wx.createSelectorQuery().in(this).select(contentSelector).boundingClientRect((rect) => {
if (rect && rect.height > 0) {
// 先设置为0,然后动画到实际高度
const startAnimation = wx.createAnimation({
duration: 0,
timingFunction: 'ease'
})
startAnimation.height('0px').opacity(0).step()
const endAnimation = wx.createAnimation({
duration: 300,
timingFunction: 'ease'
})
endAnimation.height(rect.height + 'px').opacity(1).step()
this.setData({
[animationKey]: startAnimation.export()
})
setTimeout(() => {
this.setData({
[animationKey]: endAnimation.export()
})
}, 50)
}
}).exec()
}, 50)
},
// 收起面板动画
collapsePanel(type) {
const animationKey = type === 'business' ? 'businessAnimation' : 'bottomAnimation'
const animation = wx.createAnimation({
duration: 300,
timingFunction: 'ease'
})
animation.height('0px').opacity(0).step()
this.setData({
[animationKey]: animation.export()
})
}
}
})