Commit 8f50eb08 by cen

fix: 销毁左边菜单活动中心监听

1 parent bb8b93c6
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class="card" @click="handleAvtivityItemClick()"> <view class="card" @click="handleAvtivityItemClick()">
<view v-if="tabIndex === 1" class="time-limit-countdown"> <view v-if="tabIndex === 1" class="time-limit-countdown">
<template v-if="countdownObj._timeout"> <template v-if="countdownObj._timeout">
<view class="countdown-label timeout-label">已超时</view> <view class="countdown-label timeout-label">活动开始</view>
</template> </template>
<template v-else-if="countdownObj._remainSeconds < 3600"> <template v-else-if="countdownObj._remainSeconds < 3600">
<!-- 小于1小时,显示分钟/秒 --> <!-- 小于1小时,显示分钟/秒 -->
......
...@@ -174,17 +174,19 @@ export default { ...@@ -174,17 +174,19 @@ export default {
} }
}, },
created () { created () {
// 监听自定义事件 // 监听自定义事件
uni.$on('pageBack', () => { uni.$on('pageBack', () => {
console.log('pageBack') console.log('pageBack')
this.getMessageInfo(); this.getMessageInfo();
}); });
uni.$on('ActivityCenter', () => { uni.$on('ActivityCenter', this.handleActivityCenter);
console.log('ActivityCenter') // uni.$on('ActivityCenter', () => {
let { tabs } = this, // console.log('ActivityCenter')
index = tabs.findIndex(e => e.name == 'ActivityCenter') // let { tabs } = this,
this.changeIndex(index, this.tabs[index]) // index = tabs.findIndex(e => e.name == 'ActivityCenter')
}) // this.changeIndex(index, this.tabs[index])
// })
// uni.$on('studyCenter', () => { // uni.$on('studyCenter', () => {
// let { tabs } = this, // let { tabs } = this,
// index = tabs.findIndex(e => e.name == 'StudyCenter') // index = tabs.findIndex(e => e.name == 'StudyCenter')
...@@ -252,6 +254,14 @@ export default { ...@@ -252,6 +254,14 @@ export default {
}) })
}) })
}, },
handleActivityCenter() {
console.log('ActivityCenter triggered'); // 添加日志查看触发次数
let { tabs } = this;
let index = tabs.findIndex(e => e.name == 'ActivityCenter');
if (index !== -1) {
this.changeIndex(index, this.tabs[index]);
}
},
async changeIndex (index, item) { async changeIndex (index, item) {
if (item.eventCode) uni.$track.add({ if (item.eventCode) uni.$track.add({
eventCode: item.eventCode eventCode: item.eventCode
...@@ -435,6 +445,7 @@ export default { ...@@ -435,6 +445,7 @@ export default {
// this.trackInterval = null // this.trackInterval = null
}, },
beforeDestroy () { beforeDestroy () {
uni.$off('ActivityCenter', this.handleActivityCenter);
// clearInterval(this.trackInterval) // clearInterval(this.trackInterval)
// this.trackInterval = null // this.trackInterval = null
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!