Commit 08afab23 by Lin

feat: 添加课程点击追踪和评分星星显示

- 在多个组件中添加课程点击事件追踪,记录课程ID和标题
- 更新推荐课程组件以显示评分星星,优化用户体验
- 调整样式以适应新评分显示
1 parent 27dd5b8f
......@@ -128,6 +128,12 @@ export default {
}
let { pageNum, total, nothing = 'nothing', pageSize } = this;
// uni.$track.add({ eventCode: 'app_recommend_course', businessId: item.id, pagePath: '/pages/equity/index' })
let businessParam = {
courseId:item.courseId,
title:item.title
}
console.log("businessParamC",businessParam);
uni.$track.add({ eventCode: 'app_studyCourse_click', businessParam: businessParam })
uni.navigateTo({
url: `/pages/common/studyCenter/courseDetail?apiType=getMyCourseList&index=${index}&courseList=${encodeURIComponent(JSON.stringify(this.completedCourseList))}&pageNum=${pageNum}&pageSize=${pageSize}&total=${total}&learnStatus=2`
})
......
......@@ -27,13 +27,17 @@
{{ (item.totalDuration || item.totalDuration === 0) ? `${item.totalDuration}min` : '-' }}
</view>
</view>
<view class="task-item-text task-item-text-rate">
<u-rate :count="5" v-model="item.totalStar" active-color="#FFB642" inactive-color="#E0E0E0"></u-rate>
<view class="task-item-score">{{item.totalStar}}</view>
<!-- 评分星星 -->
<view v-if="item.totalStar !== undefined" class="course-rating">
<view class="star-list">
<image v-for="star in 5" :key="star" class="star-icon" :src="getStarIcon(item.totalStar, star)"
mode="aspectFit" />
</view>
<text class="rating-text">{{ item.totalStar }}</text>
</view>
<view class="task-item-text">
<image class="task-item-student-icon" :src="require('@/assets/images/common/icon-group-person.png')" mode="aspectFit" />
<view class="task-item-student">{{item.learnTotal}}人已学习</view>
<image class="task-item-student-icon" :src="require('@/assets/images/studyCenter/rs.png')" mode="aspectFit" />
<view class="task-item-student">{{ item.learnTotal == null ? '-' : item.learnTotal }}人已学习</view>
</view>
</view>
</view>
......@@ -105,6 +109,22 @@ export default {
uni.$off && uni.$off('backStudyCenter');
},
methods: {
// 获取星星图标
getStarIcon(rating, position) {
const roundedRating = Math.round(rating) / 2 // 四舍五入到0.5
const diff = roundedRating - (position - 1)
if (diff >= 1) {
// 亮星
return require('@/assets/images/studyCenter/liang.png')
} else if (diff === 0.5) {
// 半星
return require('@/assets/images/studyCenter/zuo.png')
} else {
// 灰星
return require('@/assets/images/studyCenter/hui.png')
}
},
// 格式化时间
formatTime(time, formatStr) {
if (!time) return '-';
......@@ -165,7 +185,12 @@ export default {
return
}
let { pageNum, total, nothing = 'nothing', pageSize } = this;
// uni.$track.add({ eventCode: 'app_recommend_course', businessId: item.id, pagePath: '/pages/equity/index' })
let businessParam = {
courseId:item.courseId,
title:item.title
}
console.log("businessParam",businessParam);
uni.$track.add({ eventCode: 'app_studyCourse_click', businessParam: businessParam })
uni.navigateTo({
url: `/pages/common/studyCenter/courseDetail?apiType=getMyCourseList&index=${index}&courseList=${encodeURIComponent(JSON.stringify(this.taskList))}&pageNum=${pageNum}&pageSize=${pageSize}&total=${total}&learnStatus=1`
})
......@@ -409,6 +434,40 @@ export default {
align-items: center;
}
// 评分星星
.course-rating {
display: flex;
align-items: center;
margin-top: toRpx(12);
margin-bottom: toRpx(12);
.star-list {
display: flex;
align-items: center;
.star-icon {
width: toRpx(40);
height: toRpx(40);
margin-right: toRpx(6);
&:last-child {
margin-right: 0;
}
}
}
.rating-text {
width: toRpx(40);
height: toRpx(36);
color: #666666;
font-size: toRpx(28);
font-weight: 400;
font-family: "HarmonyOSSansSC";
text-align: left;
line-height: toRpx(36);
margin-left: toRpx(6);
}
}
.task-item-progress {
width: toRpx(288);
height: toRpx(16);
......
......@@ -128,6 +128,7 @@ export default {
} else {
this.taskList = this.taskList.concat(newList)
}
console.log("taskList",this.taskList);
uni.hideLoading()
this.total = res.total
this.nothing = res.length ? true : false
......@@ -164,7 +165,12 @@ export default {
return
}
let { pageNum, total, nothing = 'nothing', pageSize } = this;
// uni.$track.add({ eventCode: 'app_recommend_course', businessId: item.id, pagePath: '/pages/equity/index' })
let businessParam = {
courseId:item.courseId,
title:item.title
}
console.log("businessParam",businessParam);
uni.$track.add({ eventCode: 'app_studyCourse_click', businessParam: businessParam })
uni.navigateTo({
url: `/pages/common/studyCenter/courseDetail?apiType=getMyCourseList&index=${index}&courseList=${encodeURIComponent(JSON.stringify(this.taskList))}&pageNum=${pageNum}&pageSize=${pageSize}&total=${total}&learnStatus=1`
})
......
......@@ -179,6 +179,12 @@ export default {
}
let { pageNum, total, nothing = 'nothing', pageSize } = this;
// uni.$track.add({ eventCode: 'app_recommend_course', businessId: item.id, pagePath: '/pages/equity/index' })
let businessParam = {
courseId:item.courseId,
title:item.title
}
console.log("businessParam",businessParam);
uni.$track.add({ eventCode: 'app_studyCourse_click', businessParam: businessParam })
uni.navigateTo({
url: `/pages/common/studyCenter/courseDetail?apiType=getMyCourseList&index=${index}&courseList=${encodeURIComponent(JSON.stringify(this.recommendCourseList))}&pageNum=${pageNum}&pageSize=${pageSize}&total=${total}&learnStatus=0`
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!