LearnStatistics.js
1.93 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
// packageStudyCenter/pages/myTask/components/LearnStatistics/LearnStatistics.js
Component({
properties: {
isBeisen: {
type: Boolean,
value: false
},
dataInfo: {
type: Object,
value: {}
},
isHmzx: {
type: Boolean,
value: false
},
isYb: {
type: Boolean,
value: false
}
},
data: {
progressList: [
{
type: 3,
title: '短课程进度',
unit: '%',
key: 'shortCourseProgress',
ratio: 'shortCourseCompletedLearnRatio',
hidden: false
},
{
type: 4,
title: '长课程进度',
unit: '%',
key: 'longCourseProgress',
ratio: 'longCourseCompletedLearnRatio',
hidden: false
}
],
progressListFiltered: []
},
observers: {
'isHmzx, isYb, isBeisen': function(isHmzx, isYb, isBeisen) {
this.updateProgressList();
},
'dataInfo': function(dataInfo) {
this.updateProgressList();
}
},
lifetimes: {
attached() {
this.updateProgressList();
}
},
methods: {
updateProgressList() {
const { isHmzx, isYb, isBeisen, progressList } = this.data;
const updatedList = progressList.map(item => {
let hidden = item.hidden;
if (item.type === 3) {
// 短课程:非慧营销或非延保时隐藏
hidden = !isHmzx || !isYb;
} else if (item.type === 4) {
// 长课程:非北森时隐藏
hidden = !isBeisen;
}
return { ...item, hidden };
});
// 过滤出需要显示的项
const filteredList = updatedList.filter(item => !item.hidden);
this.setData({
progressList: updatedList,
progressListFiltered: filteredList
});
},
getDisplayValue(value) {
if (value === 0 || value === '0') {
return '0';
}
return value || '-';
}
}
});