This commit is contained in:
杨鹏
2025-10-15 17:11:33 +08:00
parent c05f6e540d
commit c3fd0c2e00
4 changed files with 77 additions and 18 deletions
+38 -2
View File
@@ -10,10 +10,11 @@
<script setup>
import { computed, ref } from 'vue';
import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
import { onLoad, onUnload, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import $share from '@/sheep/platform/share';
import CoverViewTabbar from '@/pages/index/components/cover-view-tabbar.vue';
import { getAccessToken } from '@/sheep/request';
// 隐藏原生tabBar
uni.hideTabBar({
@@ -26,6 +27,13 @@
const template = computed(() => sheep.$store('app').template?.home);
const tokenCheckTimer = ref(null);
const token = ref('');
const url = ref(
`https://fitting-room.huimeimeta.com/pages/report/index?token=${getAccessToken()}&t=${Date.now()}`,
);
onLoad((options) => {
// #ifdef MP
// 小程序识别二维码
@@ -50,9 +58,37 @@
if (options.page) {
sheep.$router.go(decodeURIComponent(options.page));
}
token.value = getAccessToken();
startTokenListener();
});
const url = ref('https://fitting-room.huimeimeta.com/pages/report/index');
onUnload(() => {
stopTokenListener();
});
function checkTokenUpdate() {
const currentToken = getAccessToken() || '';
if (currentToken !== token.value) {
console.log('检测到token变化,更新H5页面');
token.value = currentToken;
url.value = `https://fitting-room.huimeimeta.com/pages/report/index?token=${currentToken}&t=${Date.now()}`;
}
}
function stopTokenListener() {
if (tokenCheckTimer.value) {
clearInterval(tokenCheckTimer.value);
tokenCheckTimer.value = null;
}
}
function startTokenListener() {
tokenCheckTimer.value = setInterval(() => {
checkTokenUpdate();
}, 1000);
}
</script>
<style lang="scss" scoped></style>