UserTab.vue
6.73 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
<template>
<div class="user-tab">
<!-- <StatisticsBox class="user" :list="userData"></StatisticsBox> -->
<div class="statistics user">
<div
:class="['statistics-item', { 'item-active': selectIndex == index && selectIndex < 3 }]"
v-for="(item, index) in userData"
:key="index"
:style="{ width: 100 / userData.length + '%' }"
@click="clickSaasTab(index)"
>
<div class="statistics-top">
<div class="statistics-name">{{ item.name }}</div>
<div class="statistics-price">
<span class="statistics-unit" v-if="item.unitType == 'left'">{{ item.unit }}</span>
<span class="statistics-price-number">{{ numAddSymbol(item.value) }}</span>
<span v-if="item.unitType == 'right'">{{ item.unit }}</span>
</div>
<div v-if="item.rate" class="statistics-top-rate">
占比
<span>{{ item.rate }}%</span>
</div>
</div>
<div class="statistics-bottom" v-if="item.bottomLabel || item.bottomType">
<template v-if="item.bottomType == 'money'">
<span>{{ item.bottomLabel }}</span>
<span>¥{{ numAddSymbol(item.bottomValue) }}</span>
</template>
<template v-else-if="item.bottomType == 'slot'">
<slot :name="item.valueName" :[item.valueName]="item"></slot>
</template>
<template v-else-if="item.bottomType == 'ratio'">
<div class="ratio">
<div class="ratio-left">
{{ item.ratioLeftLabel }}
<span :class="item.ratioLeftValue > 0 ? 'positive' : 'negative'">{{ item.ratioLeftValue }}%</span>
</div>
<div class="ratio-right">
{{ item.ratioRightLabel }}
<span :class="item.ratioRightValue > 0 ? 'positive' : 'negative'">{{ item.ratioRightValue }}%</span>
</div>
</div>
</template>
<template v-else>
<span>{{ item.bottomLabel }}</span>
<span class="bottom-num">{{ numAddSymbol(item.bottomValue) }}</span>
</template>
</div>
</div>
</div>
</div>
</template>
<script>
const TEXT_VIEW = [
{
name: '用户数',
valueName: 'totalnum',
value: '15,351,2',
bottomLabel: '当年新增',
bottemName: 'increnum',
bottomValue: '7,329,2'
},
{
name: '企微客户数',
valueName: 'totalwechatnum',
value: '15,351,2',
bottomLabel: '当年新增',
bottemName: 'increwechatnum',
bottomValue: '7,329,2'
},
{
name: '企微群数',
valueName: 'totalwechatgroupnum',
value: '15,351,2',
bottomLabel: '当年新增',
bottemName: 'increwechatgroupnum',
bottomValue: '7,329,2'
},
{
name: '小程序',
valueName: 'totalappletnum',
value: '15,351,2',
bottomLabel: '当年新增',
bottemName: 'increappletnum',
bottomValue: '7,329,2'
},
{
name: '硬件线索客户数',
valueName: 'totalsinglewechantnum',
value: '15,351,2',
bottomLabel: '当年新增',
bottemName: 'incresinglewechantnum',
bottomValue: '7,329,2'
}
]
export default {
name: 'UserTab',
data() {
return {
dataList: TEXT_VIEW,
userData: TEXT_VIEW,
selectIndex: 0
}
},
async created() {
await this.getoverview()
},
mounted() {
this.getTrend('total', '用户数')
},
methods: {
getoverview() {
this.api.operational.getoverview().then(res => {
if (res.code === '0') {
const _data = res.data.dataList[0]
this.dataList.forEach(item => {
item.value = _data[item.valueName]
item.bottomValue = _data[item.bottemName]
})
}
})
},
getTrend(queryItem, name) {
const selectIndex = TEXT_VIEW.findIndex(item => item.name === name)
if (selectIndex > 2) return
this.selectIndex = selectIndex
const params = { req: { queryItem } }
this.api.operational.getTrend(params).then(res => {
if (res.code === '0') {
const dataList = res.data.dataList
const obj = {
dataList,
name
}
this.$bus.$emit('drawPrivateChart', obj)
}
})
},
clickSaasTab(val) {
if (val > 2) return
if (val === this.selectIndex) return
switch (val) {
case 0:
this.getTrend('total', '用户数')
break
case 1:
this.getTrend('wechat', '企微客户数')
break
case 2:
this.getTrend('wechatgroup', '企微群数')
break
}
this.selectIndex = val
}
}
}
</script>
<style scoped lang="scss">
.user-tab {
width: 100%;
height: 9.02vh;
margin: 2.22vh 0 0.98vh 0;
.statistics {
display: flex;
color: #fff;
height: 9.01vh;
&-item {
padding: 0.49vh 0.53vw;
margin-right: 0.56vw;
background: rgba(11, 44, 142, 0.28);
// box-shadow: inset 0 0 20px 0 #3d57ff69;
&:last-child {
margin-right: 0;
}
}
&-top {
position: relative;
padding-left: 0.3vw;
&-rate {
position: absolute;
right: 0;
top: 0;
font-size: 12px;
color: #95acd9;
span {
color: #eb6001;
}
}
}
&-name {
font-weight: 500;
font-size: 12px;
margin-bottom: 0.4vh;
height: 1.82vh;
}
&-unit {
padding-right: 0.56vw;
}
&-price {
display: flex;
align-items: center;
color: #25d6ff;
font-weight: 600;
font-size: 14px;
height: 2.81vh;
&-number {
padding-right: 0.56vw;
font-size: 24px;
color: #5894ff;
background-image: -webkit-linear-gradient(left, #24d8ff, #7787ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
&-bottom {
display: flex;
justify-content: space-between;
font-size: 12px;
color: #95acd9;
border-top: 1px solid #2a3d72;
padding: 0.3vh 0.3vw 0;
margin-top: 0.4vh;
.ratio {
display: flex;
width: 100%;
justify-content: space-between;
.positive,
.negative {
display: inline-block;
margin-left: 0.28vw;
}
.positive {
color: #eb6001;
}
.negative {
color: #16e193;
}
}
.bottom-num {
color: #fff;
}
}
.item-active {
border: 1px solid #24d8ff;
}
}
}
</style>