feat:更新176
This commit is contained in:
@@ -92,12 +92,91 @@ export default {
|
||||
guideShow: false,
|
||||
guideStep: 0,
|
||||
scrollTop: 0,
|
||||
hideTimer: null,
|
||||
showTimer: null,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
guideShow(val) {
|
||||
if (val) {
|
||||
this.hideTabBarSafe();
|
||||
} else {
|
||||
this.showTabBarSafe();
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
// #ifdef MP
|
||||
// 尽早检测,如果是首次进入直接先隐藏tabBar,避免界面抖动或首屏遮挡
|
||||
const hasSeen = uni.getStorageSync("has_seen_home_guide");
|
||||
if (!hasSeen) {
|
||||
this.hideTabBarSafe();
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
mounted() {
|
||||
this.checkGuideShow();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.cleanupAndShowTabBar();
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.cleanupAndShowTabBar();
|
||||
},
|
||||
unmounted() {
|
||||
this.cleanupAndShowTabBar();
|
||||
},
|
||||
methods: {
|
||||
hideTabBarSafe() {
|
||||
// #ifdef MP
|
||||
clearTimeout(this.hideTimer);
|
||||
const tryHide = (retryCount = 0) => {
|
||||
uni.hideTabBar({
|
||||
animation: false,
|
||||
fail: (err) => {
|
||||
if (retryCount < 5 && this.guideShow) {
|
||||
this.hideTimer = setTimeout(() => {
|
||||
tryHide(retryCount + 1);
|
||||
}, 120 * (retryCount + 1));
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
this.$nextTick(() => {
|
||||
tryHide(0);
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
showTabBarSafe() {
|
||||
// #ifdef MP
|
||||
clearTimeout(this.hideTimer);
|
||||
clearTimeout(this.showTimer);
|
||||
const tryShow = (retryCount = 0) => {
|
||||
uni.showTabBar({
|
||||
animation: false,
|
||||
fail: (err) => {
|
||||
if (retryCount < 3) {
|
||||
this.showTimer = setTimeout(() => {
|
||||
tryShow(retryCount + 1);
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
this.$nextTick(() => {
|
||||
tryShow(0);
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
cleanupAndShowTabBar() {
|
||||
// #ifdef MP
|
||||
clearTimeout(this.hideTimer);
|
||||
clearTimeout(this.showTimer);
|
||||
if (this.guideShow) {
|
||||
this.showTabBarSafe();
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
onScroll(e) {
|
||||
this.scrollTop = e.detail.scrollTop;
|
||||
},
|
||||
@@ -118,6 +197,7 @@ export default {
|
||||
closeGuide() {
|
||||
this.guideShow = false;
|
||||
uni.setStorageSync("has_seen_home_guide", true);
|
||||
this.showTabBarSafe();
|
||||
this.$emit("close");
|
||||
},
|
||||
nextGuideStep() {
|
||||
|
||||
Reference in New Issue
Block a user