Merge branch 'dev/1.0' of https://git.aigc-quickapp.com/Uniapp/lucky_shop into dev/1.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view :style="themeColor" class="vr-page">
|
||||
<web-view :src="src" class="vr-webview" @titleUpdate="updateNavbarTitle"></web-view>
|
||||
<web-view :src="src" class="vr-webview" @titleUpdate="forceCustomTitle"></web-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -9,17 +9,24 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
src: '',
|
||||
title: ''
|
||||
title: '',
|
||||
customTitle: '',
|
||||
titleTimer: null
|
||||
};
|
||||
},
|
||||
onLoad(option) {
|
||||
this.title = option?.title ?? '';
|
||||
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.title = res.data.title;
|
||||
this.startTitleGuard();
|
||||
}
|
||||
},
|
||||
fail: res => {
|
||||
@@ -27,19 +34,35 @@ export default {
|
||||
});
|
||||
},
|
||||
onShow() {
|
||||
this.updateNavbarTitle();
|
||||
},
|
||||
watch: {
|
||||
title(newVal) {
|
||||
this.updateNavbarTitle(newVal);
|
||||
if (this.customTitle) {
|
||||
uni.setNavigationBarTitle({ title: this.customTitle });
|
||||
}
|
||||
},
|
||||
onUnload() {
|
||||
this.clearTitleGuard();
|
||||
},
|
||||
methods: {
|
||||
updateNavbarTitle(newTitle) {
|
||||
const title = newTitle ?? this.title;
|
||||
uni.setNavigationBarTitle({title});
|
||||
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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user