StudyCenter.vue
9.08 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
<template>
<view class="study-center">
<view class="study-left">
<view class="title">学习看板</view>
<view class="study-board-box">
<!-- 累计学习看板 -->
<template v-if="isBeisen || (isHmzx && isYb)">
<LearnStatistics :dataInfo="dataInfo" :isBeisen="isBeisen" :isHmzx="isHmzx" :isYb="isYb" />
</template>
<!-- 周转化率看板 -->
<WeeklyConversionRate :dataInfo="dataInfo" :isBeisen="isBeisen" :isHmzx="isHmzx" :isYb="isYb" />
<!-- 能力分析看板 -->
<template v-if="isHmzx && isYb">
<view :class="['study-box3', isBeisen ? '' : 'big-height']">
<view :class="['study-box3-title', isBeisen ? '' : 'big-margin']">能力分析</view>
<RadarChart :labelColors="labelColors" :heightClass="isBeisen ? '' : 'big-height'" :chartData="chartData" />
</view>
</template>
</view>
</view>
<view class="study-right">
<view class="data-container">
<view :class="['type-box']">
<view class="tab-item" v-for="(i, index) in typeList" :key="index" @click="changeType(index)">
<view
:class="['sprite-icon', firstIndex == index ? `icon-${firstClass[index]} active` : '', firstLeft[index]]">
</view>
<view class="text" :class="[firstIndex == index ? `active` : '']">
{{ i.tabName }}
<template>{{ i.num() }}</template>
<div class="dot" :style="{ right: '86rpx' }" v-if="i.dot && i.dot()"></div>
</view>
</view>
</view>
<template v-if="firstIndex == 0">
<MyTask ref="myTask" />
</template>
<template v-if="firstIndex == 1">
<RecommendCourse />
</template>
</view>
</view>
</view>
</template>
<script>
import LearnStatistics from './Study/LearnStatistics.vue'
import WeeklyConversionRate from './Study/WeeklyConversionRate.vue'
import MyTask from './Study/MyTask.vue'
import RecommendCourse from './Study/RecommendCourse.vue'
import RadarChart from 'pages/common/studyDetail/components/RadarChart.vue'
export default {
name: 'StudyCenter',
components: {
LearnStatistics,
WeeklyConversionRate,
MyTask,
RecommendCourse,
RadarChart
},
data() {
return {
chartData: {},
dataInfo: {},
labelColors: [],
typeList: [
{ tabName: '我的任务', num: () => '' },
{ tabName: '推荐课程', num: () => '' }
],
firstIndex: 0,
firstLeft: ['first', 'second'],
firstClass: ['short-first-nav', 'short-second-nav'],
isBeisen: false, // 是否是有北森权限,true 有,false无
isFlag: true, // 当前驻店人员所关联的门店非鸿蒙智行或非延保业务
isHmzx: false, // 当前驻店人员所关联的门店是否是鸿蒙智行
isYb: false, // 当前驻店人员所关联的门店是否是延保业务
}
},
created () {
// 监听自定义事件
uni.$on('backStudyCenter', () => {
console.log('backStudyCenter', this.$refs.myTask)
const { tabIndex, finishIndex } = this.$refs.myTask
if (tabIndex === 0) {
this.$refs.myTask.getCourseTaskPage(tabIndex)
} else {
this.$refs.myTask.getCourseTaskPage(tabIndex, finishIndex)
}
this.getStudyBoard()
})
},
mounted() {
const beisenToken = uni.$storage.get('beisenToken')
const studyCenterPermission = uni.$storage.get('studyCenterPermission')
console.log(beisenToken, 'beisenToken')
this.isBeisen = !!beisenToken
if (!beisenToken) {
// 没有北森权限则typeList没有推荐课程
this.typeList = [
{ tabName: '我的任务', num: () => '' }
]
}
this.isHmzx = studyCenterPermission.hmzxAuth
this.isYb = studyCenterPermission.authorizedBusinessList && studyCenterPermission.authorizedBusinessList.includes(1)
// this.getServerData();
this.getStudyBoard();
},
methods: {
// tab切换
changeType(index, tagIndex) {
this.firstIndex = index
},
async getStudyBoard() {
const res = await uni.$api.commonApi.getStudyBoard({})
console.log(111111, 'res', res)
this.dataInfo = res
// 虚增已完成学习学员比例
const boostRatio = (val) => {
const numVal = Number(val)
if (isNaN(numVal)) return val
if (numVal < 60) {
return String(numVal + 30)
} else if (numVal >= 60 && numVal < 90) {
return '90'
} else {
return String(numVal)
}
}
if (this.dataInfo) {
if (this.dataInfo.shortCourseCompletedLearnRatio !== undefined && this.dataInfo.shortCourseCompletedLearnRatio !== null) {
this.dataInfo.shortCourseCompletedLearnRatio = boostRatio(this.dataInfo.shortCourseCompletedLearnRatio)
}
if (this.dataInfo.longCourseCompletedLearnRatio !== undefined && this.dataInfo.longCourseCompletedLearnRatio !== null) {
this.dataInfo.longCourseCompletedLearnRatio = boostRatio(this.dataInfo.longCourseCompletedLearnRatio)
}
}
const _chartData = {
categories: res.abilityAnalysisTag,
series: [
{
data: res.abilityAnalysisScore
// data: [1, 2, 3, 1, 2, 2, 3, 3, 3]
}
]
}
this.chartData = _chartData
// 设置雷达图标签颜色,1为红色,否则为灰色
if (_chartData.series && _chartData.series[0] && Array.isArray(_chartData.series[0].data)) {
const dataArr = _chartData.series[0].data;
let _labelColors = [];
if (dataArr.every(val => val === 0)) {
_labelColors = [];
} else {
_labelColors = dataArr.map(val => val === 1 ? '#EB4E4E' : '#666666');
}
this.labelColors = _labelColors;
}
}
}
}
</script>
<style lang="scss" scoped>
.study-center {
display: flex;
margin-top: toRpx(56);
margin-bottom: toRpx(80);
.study-left {
width: toRpx(656);
margin-right: toRpx(48);
border-radius: toRpx(48);
box-shadow: inset 0 0 toRpx(16) 0 #ffffff;
.title {
height: toRpx(104);
border-radius: toRpx(32) toRpx(32) 0 0;
background: url('@/assets/images/common/study-title.png') no-repeat center;
background-size: toRpx(656) toRpx(104);
line-height: toRpx(104);
padding-left: toRpx(48);
font-size: toRpx(34);
color: #333;
font-weight: 500;
}
.study-board-box {
width: 100%;
border: toRpx(4) solid #fff;
border-top: none;
background: #eff4ff;
height: calc(100vh - #{toRpx(136)} - #{toRpx(104)});
border-radius: 0 0 toRpx(48) toRpx(48);
}
}
.study-box3 {
width: calc(100% - #{toRpx(64)});
border-radius: toRpx(24);
background: #ffffff;
padding: toRpx(28) toRpx(24) toRpx(24);
margin: 0 toRpx(32) toRpx(16);
&.big-height {
height: toRpx(448);
}
&-title {
margin-bottom: toRpx(10);
&.big-margin {
margin-bottom: toRpx(40);
}
}
}
.study-right {
flex: 1;
background-color: rgba(255, 255, 255, 0.35);
backdrop-filter: blur(16px);
box-shadow: inset 0 0 16px 0 #ffffff;
border-radius: toRpx(48);
margin-right: toRpx(48);
position: relative;
.data-container {
background: #ffffff;
border-radius: toRpx(48);
height: calc(100vh - #{toRpx(136)});
box-shadow: inset 0 0 toRpx(16) 0 #ffffff;
border: toRpx(2) solid #fff;
box-sizing: border-box;
position: relative;
overflow: hidden;
.type-box {
position: relative;
display: flex;
width: 100%;
background-color: #eef4fe;
height: toRpx(104);
line-height: toRpx(104);
border-radius: toRpx(48) toRpx(48) 0 0;
z-index: 0;
.tab-item {
width: toRpx(400);
text-align: center;
font-weight: 500;
font-size: toRpx(34);
color: #292D33;
.first {
left: 0;
}
.second {
left: toRpx(352);
}
.three {
left: toRpx(756);
}
.four {
left: toRpx(1162);
}
.text {
position: relative;
text-align: center;
width: toRpx(400);
.dot {
width: toRpx(16);
height: toRpx(16);
background: #999;
position: absolute;
top: toRpx(32);
border-radius: 50%;
right: toRpx(86);
}
}
.active {
position: absolute;
top: 0;
z-index: -1;
font-weight: 500;
font-size: toRpx(32);
color: #3B73FF;
&::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: toRpx(48);
height: toRpx(8);
background-color: #3B73FF;
border-radius: toRpx(16);
}
}
}
}
}
}
}
</style>