Files
lucky_shop/pages_tool/vr/index.vue
2026-07-25 17:53:39 +08:00

81 lines
1.5 KiB
Vue

<template>
<view :style="themeColor" class="vr-page">
<web-view :src="src" class="vr-webview" @titleUpdate="forceCustomTitle"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
src: '',
title: '',
customTitle: '',
titleTimer: null
};
},
onLoad(option) {
this.customTitle = option?.title || '工厂展示';
this.title = this.customTitle;
uni.setNavigationBarTitle({ title: this.customTitle });
this.$api.sendRequest({
url: '/api/config/defaultvr',
success: res => {
if (res.code == 0) {
this.customTitle = res.data.title;
this.title = this.customTitle;
uni.setNavigationBarTitle({ title: this.customTitle });
this.src = res.data.url;
this.startTitleGuard();
}
},
fail: res => {
}
});
},
onShow() {
if (this.customTitle) {
uni.setNavigationBarTitle({ title: this.customTitle });
}
},
onUnload() {
this.clearTitleGuard();
},
methods: {
forceCustomTitle() {
uni.setNavigationBarTitle({ title: this.customTitle });
},
startTitleGuard() {
this.clearTitleGuard();
let count = 0;
this.titleTimer = setInterval(() => {
uni.setNavigationBarTitle({ title: this.customTitle });
count++;
if (count >= 10) {
this.clearTitleGuard();
}
}, 100);
},
clearTitleGuard() {
if (this.titleTimer) {
clearInterval(this.titleTimer);
this.titleTimer = null;
}
}
}
};
</script>
<style lang="scss">
.vr-page {
height: 100vh;
width: 100%;
background: #fff;
}
.vr-webview {
width: 100%;
height: 100%;
}
</style>