Commit e960d981 by 胡悦

refactor(studyCenter): 重构学习中心相关事件处理逻辑

移除返回按钮中触发学习弹窗的事件发射,改为在studyWebview中统一处理
更新事件监听名称从showStudyPopup为levelStudyPopup和afterStudyPopup
调整页面样式和布局,优化考试次数显示格式
清理无用代码和注释,简化服务列表组件
1 parent 2740a3a8
...@@ -379,15 +379,11 @@ export default { ...@@ -379,15 +379,11 @@ export default {
} }
}, },
openPop() { openPop() {
// this.messageType = 'system'
// this.$refs.kfRef.open()
uni.navigateTo({ uni.navigateTo({
url: `/pages/common/messageList` url: `/pages/common/messageList`
}) })
}, },
getMessageInfo() { getMessageInfo() {
// this.getMessage()
// this.getMessageCount()
this.getMessagePop() this.getMessagePop()
}, },
jumpPersonCenter() { jumpPersonCenter() {
...@@ -441,13 +437,6 @@ export default { ...@@ -441,13 +437,6 @@ export default {
this.tabs[2].hidden = true this.tabs[2].hidden = true
this.tabs[3].hidden = true this.tabs[3].hidden = true
return return
} else {
// const { directSaleAuth, hmzxAuth, authorizedBusinessList } = res // 当驻店人员为非直营,且非鸿蒙智行延保业务驻店人员情况下。隐藏左侧【学习中心】图标
// const isYb = authorizedBusinessList && authorizedBusinessList.includes(1) // 1.延保 2.轻改 3.权益
// if (directSaleAuth || (hmzxAuth && isYb)) {
// this.tabs[2].hidden = false
// }
} }
} }
}, },
...@@ -456,6 +445,8 @@ export default { ...@@ -456,6 +445,8 @@ export default {
// this.trackInterval = null // this.trackInterval = null
}, },
beforeDestroy() { beforeDestroy() {
uni.$off('pageBack')
uni.$off('studyCenter')
uni.$off('ActivityCenter', this.handleActivityCenter); uni.$off('ActivityCenter', this.handleActivityCenter);
// clearInterval(this.trackInterval) // clearInterval(this.trackInterval)
// this.trackInterval = null // this.trackInterval = null
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
<!-- 考试次数 --> <!-- 考试次数 -->
<view class="exam-times"> <view class="exam-times">
<text class="times-value">剩余考试次数</text> <text class="times-value">剩余考试次数</text>
<template v-if="!item.examTimes">不限次数</template> <template v-if="!item.examTimes">不限制</template>
<template v-else> <template v-else>
<text>{{ filterValue(item.remainingTimes) }}/{{ filterValue(item.examTimes) }}次</text> <text>{{ filterValue(item.remainingTimes) }}/{{ filterValue(item.examTimes) }}</text>
</template> </template>
</view> </view>
...@@ -164,7 +164,7 @@ export default { ...@@ -164,7 +164,7 @@ export default {
// 跳转北森考试详情页 // 跳转北森考试详情页
async viewExam(item) { async viewExam(item) {
console.log('查看考试', item) console.log('查看考试', item)
if (item.remainingTimes <= 0) return if (item.examTimes && item.remainingTimes <= 0) return
// TODO: 跳转到考试详情页 // TODO: 跳转到考试详情页
this.showStudyPopup = false this.showStudyPopup = false
this.currentExam = item this.currentExam = item
...@@ -193,7 +193,7 @@ export default { ...@@ -193,7 +193,7 @@ export default {
const url = encodeURIComponent(`${baseUrl}?${queryString}#/viewDynamic?1=1`); const url = encodeURIComponent(`${baseUrl}?${queryString}#/viewDynamic?1=1`);
this.jumpUrl = `${tokenUrl}&return_url=${url}`; this.jumpUrl = `${tokenUrl}&return_url=${url}`;
uni.navigateTo({ uni.navigateTo({
url: `/pages/common/studyWebview?url=${encodeURIComponent(this.jumpUrl)}&pageTitle=学习测评` url: `/pages/common/studyWebview?url=${encodeURIComponent(this.jumpUrl)}&pageTitle=学习测评&type=1`
}) })
} else { } else {
throw new Error('获取 token 失败') throw new Error('获取 token 失败')
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<text class="times-value">剩余考试次数</text> <text class="times-value">剩余考试次数</text>
<template v-if="!item.examTimes">不限制</template> <template v-if="!item.examTimes">不限制</template>
<template v-else> <template v-else>
<text>{{ filterValue(item.remainingTimes) }}/{{ filterValue(item.examTimes) }}次</text> <text>{{ filterValue(item.remainingTimes) }}/{{ filterValue(item.examTimes) }}</text>
</template> </template>
</view> </view>
...@@ -166,7 +166,7 @@ export default { ...@@ -166,7 +166,7 @@ export default {
// 跳转北森考试详情页 // 跳转北森考试详情页
async viewExam(item) { async viewExam(item) {
console.log('查看考试', item) console.log('查看考试', item)
if (item.remainingTimes <= 0) return if (item.examTimes && item.remainingTimes <= 0) return
// TODO: 跳转到考试详情页 // TODO: 跳转到考试详情页
this.showStudyPopup = false this.showStudyPopup = false
this.currentExam = item this.currentExam = item
...@@ -195,7 +195,7 @@ export default { ...@@ -195,7 +195,7 @@ export default {
const url = encodeURIComponent(`${baseUrl}?${queryString}#/viewDynamic?1=1`); const url = encodeURIComponent(`${baseUrl}?${queryString}#/viewDynamic?1=1`);
this.jumpUrl = `${tokenUrl}&return_url=${url}`; this.jumpUrl = `${tokenUrl}&return_url=${url}`;
uni.navigateTo({ uni.navigateTo({
url: `/pages/common/studyWebview?url=${encodeURIComponent(this.jumpUrl)}&pageTitle=学习测评` url: `/pages/common/studyWebview?url=${encodeURIComponent(this.jumpUrl)}&pageTitle=学习测评&type=0`
}) })
} else { } else {
throw new Error('获取 token 失败') throw new Error('获取 token 失败')
......
...@@ -194,22 +194,16 @@ export default { ...@@ -194,22 +194,16 @@ export default {
// console.log('接收到考试提交弹窗事件') // console.log('接收到考试提交弹窗事件')
// this.showExamPopup = true // this.showExamPopup = true
// }) // })
uni.$on('showStudyPopup', obj => { uni.$off('levelStudyPopup');
uni.$on('levelStudyPopup', obj => {
console.log('接收到学习弹窗事件', obj) console.log('接收到学习弹窗事件', obj)
if (obj.type === 'examSubmit') { uni.$logger.local.info('接收到学习弹窗事件', obj)
this.showExamPopup = true this.showExamPopup = true
} else if (obj.type === 'getLevelExamInfo') {
// 查询是否有等级考试
this.getLevelExamInfo()
if (obj.name == 'myCourse') {
this.$refs.pointRef.getMyStudyTime()
}
}
}) })
}, },
beforeDestroy() { beforeDestroy() {
// 组件销毁前移除监听 // 组件销毁前移除监听
uni.$off('showStudyPopup') uni.$off('levelStudyPopup')
// uni.$off('showStudyPopup') // uni.$off('showStudyPopup')
}, },
mounted() { mounted() {
...@@ -267,7 +261,7 @@ export default { ...@@ -267,7 +261,7 @@ export default {
const url = encodeURIComponent(`${baseUrl}?${queryString}#/viewDynamic?1=1`) const url = encodeURIComponent(`${baseUrl}?${queryString}#/viewDynamic?1=1`)
this.jumpUrl = `${tokenUrl}&return_url=${url}` this.jumpUrl = `${tokenUrl}&return_url=${url}`
uni.navigateTo({ uni.navigateTo({
url: `/pages/common/studyWebview?url=${encodeURIComponent(this.jumpUrl)}&pageTitle=学习测评` url: `/pages/common/studyWebview?url=${encodeURIComponent(this.jumpUrl)}&pageTitle=学习测评&type=0`
}) })
} else { } else {
uni.showToast({ uni.showToast({
......
...@@ -79,43 +79,7 @@ export default { ...@@ -79,43 +79,7 @@ export default {
moduleIconEnum, moduleIconEnum,
moduleContentEnum, moduleContentEnum,
topList: [], topList: [],
msgList: [ msgList: []
{
moduleType: 3,
title: '请在06-dfasd',
createdTime: new Date().getTime(),
count: null,
strdate: '2025-06-11'
},
{
moduleType: 4,
title: '请在06-csaf ',
createdTime: new Date().getTime(),
count: 698,
strdate: '2025-06-11'
},
{
moduleType: 0,
title: '#这是通知标题##这是通知标题##这是通知标题##这是通知标题##这是通知标题#',
createdTime: new Date().getTime(),
count: 6,
strdate: '2025-06-11'
},
{
moduleType: 2,
title: 'dfs',
createdTime: new Date().getTime(),
count: 99,
strdate: '2025-06-12'
},
{
moduleType: 1,
title: 'df ',
createdTime: new Date().getTime(),
count: 99,
strdate: '2025-06-12'
}
]
} }
}, },
watch: { watch: {
...@@ -138,10 +102,6 @@ export default { ...@@ -138,10 +102,6 @@ export default {
// 过滤出topList中包含moduleType的对象 // 过滤出topList中包含moduleType的对象
const result = this.msgList.filter(item => this.topList.includes(item.moduleType)); const result = this.msgList.filter(item => this.topList.includes(item.moduleType));
return result return result
// // 按topList中的倒序排列
// return this.topList.slice().reverse().map(type =>
// this.msgList.find(item => item.moduleType === type)
// ).filter(Boolean);
}, },
getList() { getList() {
// 过滤掉topList中包含moduleType的对象 // 过滤掉topList中包含moduleType的对象
...@@ -183,9 +143,6 @@ export default { ...@@ -183,9 +143,6 @@ export default {
}, },
handleClick(item) { handleClick(item) {
this.$emit('handleClick', item) this.$emit('handleClick', item)
// uni.navigateTo({
// url: `/pages/common/serviceDetail/index?moduleType=${moduleType}`
// })
} }
} }
} }
......
...@@ -60,7 +60,7 @@ export default { ...@@ -60,7 +60,7 @@ export default {
nothing: false, nothing: false,
total: 0, total: 0,
pageNum: 1, pageNum: 1,
pageSize: 12, pageSize: 16,
scrollTop: 0, scrollTop: 0,
COURSE_TYPE COURSE_TYPE
} }
...@@ -137,11 +137,13 @@ export default { ...@@ -137,11 +137,13 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.completed-course { .completed-course {
height: calc(100% - #{toRpx(100)}); // height: calc(100% - #{toRpx(100)});
height: 100%;
.scroll-view { .scroll-view {
margin-top: toRpx(40); margin-top: toRpx(40);
height: calc(100% - #{toRpx(70)}); // height: calc(100% - #{toRpx(50)});
height: 100%;
.completed-course-list { .completed-course-list {
display: grid; display: grid;
......
...@@ -105,8 +105,6 @@ export default { ...@@ -105,8 +105,6 @@ export default {
if(currentWebview){ if(currentWebview){
currentWebview.close() currentWebview.close()
} }
// 点击返回按钮,触发学习弹窗事件
uni.$emit('showStudyPopup', {name: 'courseDetail', type: 'getLevelExamInfo'})
uni.navigateBack() uni.navigateBack()
}, },
async openCourse(index, item) { async openCourse(index, item) {
......
...@@ -95,8 +95,6 @@ export default { ...@@ -95,8 +95,6 @@ export default {
}, },
methods: { methods: {
back() { back() {
// 点击返回按钮,触发学习弹窗事件
uni.$emit('showStudyPopup', {name: 'leaderboard', type: 'getLevelExamInfo'})
uni.navigateBack() uni.navigateBack()
}, },
switchTab(index) { switchTab(index) {
......
...@@ -74,8 +74,6 @@ export default { ...@@ -74,8 +74,6 @@ export default {
}, },
methods: { methods: {
back() { back() {
// 点击返回按钮,触发学习弹窗事件
uni.$emit('showStudyPopup', {name: 'myCourse', type: 'getLevelExamInfo'})
uni.navigateBack() uni.navigateBack()
}, },
switchTab(index) { switchTab(index) {
...@@ -125,6 +123,7 @@ export default { ...@@ -125,6 +123,7 @@ export default {
position: relative; position: relative;
z-index: 10; z-index: 10;
background: transparent; background: transparent;
height: toRpx(140);
.nav-bar { .nav-bar {
display: flex; display: flex;
...@@ -157,7 +156,7 @@ export default { ...@@ -157,7 +156,7 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 toRpx(64); padding: 0 toRpx(64);
margin-top: toRpx(52); // margin-top: toRpx(52);
.tab-item { .tab-item {
width: toRpx(208); width: toRpx(208);
height: toRpx(72); height: toRpx(72);
......
...@@ -51,7 +51,7 @@ export default { ...@@ -51,7 +51,7 @@ export default {
}, },
created() { created() {
// 在组件创建时就开始监听,确保事件能被捕获 // 在组件创建时就开始监听,确保事件能被捕获
uni.$on('showStudyPopup', () => { uni.$on('afterStudyPopup', () => {
console.log('接收到考试提交弹窗事件') console.log('接收到考试提交弹窗事件')
if (this.currentTab === 1) { if (this.currentTab === 1) {
this.$refs.failedExam.showExamPopup = true this.$refs.failedExam.showExamPopup = true
...@@ -62,15 +62,13 @@ export default { ...@@ -62,15 +62,13 @@ export default {
}, },
beforeDestroy() { beforeDestroy() {
// 组件销毁前移除监听 // 组件销毁前移除监听
uni.$off('showStudyPopup') uni.$off('afterStudyPopup')
}, },
mounted() { mounted() {
this.getExamStatistics() this.getExamStatistics()
}, },
methods: { methods: {
back() { back() {
// 点击返回按钮,触发学习弹窗事件
uni.$emit('showStudyPopup', {name: 'myExam', type: 'getLevelExamInfo'})
uni.navigateBack() uni.navigateBack()
}, },
switchTab(index) { switchTab(index) {
...@@ -97,7 +95,7 @@ export default { ...@@ -97,7 +95,7 @@ export default {
background-image: url('@/assets/images/common/page-bg.webp'); background-image: url('@/assets/images/common/page-bg.webp');
background-size: 100%; background-size: 100%;
box-sizing: border-box; box-sizing: border-box;
padding-top: toRpx(112); padding-top: toRpx(156);
} }
.nav-bar { .nav-bar {
...@@ -132,7 +130,7 @@ export default { ...@@ -132,7 +130,7 @@ export default {
.tab-container { .tab-container {
display: flex; display: flex;
align-items: center; align-items: center;
margin-top: toRpx(44); // margin-top: toRpx(44);
margin-bottom: toRpx(28); margin-bottom: toRpx(28);
padding: 0 toRpx(64); padding: 0 toRpx(64);
.tab-item { .tab-item {
......
...@@ -123,8 +123,6 @@ ...@@ -123,8 +123,6 @@
}, },
methods: { methods: {
back() { back() {
// 点击返回按钮,触发学习弹窗事件
uni.$emit('showStudyPopup', {name: 'myTask', type: 'getLevelExamInfo'})
uni.navigateBack() uni.navigateBack()
}, },
goToMyTask() { goToMyTask() {
......
...@@ -37,6 +37,7 @@ export default { ...@@ -37,6 +37,7 @@ export default {
return { return {
webviewUrl: '', webviewUrl: '',
pageTitle: '学习测评', pageTitle: '学习测评',
type: null,
wv: null, wv: null,
hotArea: null, // 存储热区对象 hotArea: null, // 存储热区对象
showLoading: true // 控制 loading 显示 showLoading: true // 控制 loading 显示
...@@ -50,6 +51,9 @@ export default { ...@@ -50,6 +51,9 @@ export default {
// 和 detail.vue 一样,直接使用 URL,不需要 decode // 和 detail.vue 一样,直接使用 URL,不需要 decode
this.webviewUrl = options.url this.webviewUrl = options.url
} }
if (options.type) {
this.type = options.type
}
console.log('📱 学习中心 webview 接收到的 URL (直接使用):', this.webviewUrl) console.log('📱 学习中心 webview 接收到的 URL (直接使用):', this.webviewUrl)
// 提取并解码 return_url 部分以便查看 // 提取并解码 return_url 部分以便查看
...@@ -91,13 +95,6 @@ export default { ...@@ -91,13 +95,6 @@ export default {
this.hotArea = null this.hotArea = null
} }
}, },
onBackPress (options) {
if (options.from === 'backbutton') {
this.back()
return true
}
return false
},
onBackPress(options) { onBackPress(options) {
if (options.from === 'backbutton') { if (options.from === 'backbutton') {
// 阻止默认返回 // 阻止默认返回
...@@ -160,16 +157,24 @@ export default { ...@@ -160,16 +157,24 @@ export default {
}, },
back () { back () {
console.log('触发返回,发送事件') console.log('触发返回,发送事件')
const {type } = this
console.log(type, 'type')
// 先返回上一页 // 先返回上一页
uni.navigateBack({ uni.navigateBack({
success: () => { success: () => {
console.log('返回成功,触发弹窗事件') console.log('返回成功,触发弹窗事件')
uni.$logger.local.info('返回成功,触发弹窗事件', type)
// 延迟触发事件,确保页面已经返回 // 延迟触发事件,确保页面已经返回
setTimeout(() => { setTimeout(() => {
if (type == 0) {
uni.$emit('levelStudyPopup')
} else if (type == 1) {
uni.$emit('afterStudyPopup')
}
// uni.$emit('showExamSubmitPopup') // uni.$emit('showExamSubmitPopup')
uni.$emit('showStudyPopup', { // uni.$emit('showStudyPopup', {
type: 'examSubmit' // type: 'examSubmit'
}) // })
}, 100) }, 100)
} }
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!