Commit 08afab23 by Lin

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

- 在多个组件中添加课程点击事件追踪,记录课程ID和标题
- 更新推荐课程组件以显示评分星星,优化用户体验
- 调整样式以适应新评分显示
1 parent 27dd5b8f
...@@ -128,6 +128,12 @@ export default { ...@@ -128,6 +128,12 @@ export default {
} }
let { pageNum, total, nothing = 'nothing', pageSize } = this; let { pageNum, total, nothing = 'nothing', pageSize } = this;
// uni.$track.add({ eventCode: 'app_recommend_course', businessId: item.id, pagePath: '/pages/equity/index' }) // 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({ 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` 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 @@ ...@@ -27,13 +27,17 @@
{{ (item.totalDuration || item.totalDuration === 0) ? `${item.totalDuration}min` : '-' }} {{ (item.totalDuration || item.totalDuration === 0) ? `${item.totalDuration}min` : '-' }}
</view> </view>
</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 v-if="item.totalStar !== undefined" class="course-rating">
<view class="task-item-score">{{item.totalStar}}</view> <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>
<view class="task-item-text"> <view class="task-item-text">
<image class="task-item-student-icon" :src="require('@/assets/images/common/icon-group-person.png')" mode="aspectFit" /> <image class="task-item-student-icon" :src="require('@/assets/images/studyCenter/rs.png')" mode="aspectFit" />
<view class="task-item-student">{{item.learnTotal}}人已学习</view> <view class="task-item-student">{{ item.learnTotal == null ? '-' : item.learnTotal }}人已学习</view>
</view> </view>
</view> </view>
</view> </view>
...@@ -105,6 +109,22 @@ export default { ...@@ -105,6 +109,22 @@ export default {
uni.$off && uni.$off('backStudyCenter'); uni.$off && uni.$off('backStudyCenter');
}, },
methods: { 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) { formatTime(time, formatStr) {
if (!time) return '-'; if (!time) return '-';
...@@ -165,7 +185,12 @@ export default { ...@@ -165,7 +185,12 @@ export default {
return return
} }
let { pageNum, total, nothing = 'nothing', pageSize } = this; 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({ 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` 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 { ...@@ -409,6 +434,40 @@ export default {
align-items: center; 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 { .task-item-progress {
width: toRpx(288); width: toRpx(288);
height: toRpx(16); height: toRpx(16);
......
...@@ -128,6 +128,7 @@ export default { ...@@ -128,6 +128,7 @@ export default {
} else { } else {
this.taskList = this.taskList.concat(newList) this.taskList = this.taskList.concat(newList)
} }
console.log("taskList",this.taskList);
uni.hideLoading() uni.hideLoading()
this.total = res.total this.total = res.total
this.nothing = res.length ? true : false this.nothing = res.length ? true : false
...@@ -164,7 +165,12 @@ export default { ...@@ -164,7 +165,12 @@ export default {
return return
} }
let { pageNum, total, nothing = 'nothing', pageSize } = this; 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({ 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` 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 { ...@@ -179,6 +179,12 @@ export default {
} }
let { pageNum, total, nothing = 'nothing', pageSize } = this; let { pageNum, total, nothing = 'nothing', pageSize } = this;
// uni.$track.add({ eventCode: 'app_recommend_course', businessId: item.id, pagePath: '/pages/equity/index' }) // 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({ 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` 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!