修改启动白屏
This commit is contained in:
parent
f3be53fe2f
commit
1601a3e4ae
2
main.js
2
main.js
|
|
@ -29,7 +29,7 @@ export function createApp() {
|
|||
app.config.globalProperties.$system = plus.os.name;
|
||||
// #endif
|
||||
app.config.globalProperties.$systemInfo = systemInfo
|
||||
uni.setStorageSync('version', '1.0.4.sp17')
|
||||
uni.setStorageSync('version', '1.0.4.sp21')
|
||||
app.config.globalProperties.$version = uni.getStorageSync('version')
|
||||
app.use(globalMethods);
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<template>
|
||||
<view class="container" :style="{ height: data.windowHeight + 'px' }">
|
||||
<image class="index-bg-img" :style="{ width: windowWidth + 'px' }" src="/static/image/index/index-bg.png"
|
||||
mode="widthFix">
|
||||
<image v-if="isReady" class="index-bg-img" :style="{ width: windowWidth + 'px' }"
|
||||
src="/static/image/index/index-bg.png" mode="widthFix">
|
||||
</image>
|
||||
<view class="nav-bar-box" :style="{ backgroundColor: data.navBarBgColor }">
|
||||
<view v-if="isReady" class="nav-bar-box" :style="{ backgroundColor: data.navBarBgColor }">
|
||||
<view class="status-box" :style="{ height: statusBarHeight + 'px' }"></view>
|
||||
<view class="nav-box">
|
||||
<view class="left-box" @click="exit" @tap="exit" @touchstart.stop="exit">
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
</view>
|
||||
|
||||
</view>
|
||||
<view class="content-box" :style="{ height: windowHeight + 'px' }">
|
||||
<view v-if="isReady" class="content-box" :style="{ height: windowHeight + 'px' }">
|
||||
<scroll-view scroll-y="true" class="scroll-view"
|
||||
:style="{ height: (windowHeight - statusBarHeight - 44) + 'px', marginTop: (statusBarHeight + 44) + 'px' }"
|
||||
@scroll="handleScroll">
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
:src="`/static/image/index/${userInfo.vip > 1 ? (userInfo.vip == 3 ? 'lifetime-vip-bg' : 'vip-bg') : 'no-vip-bg'}.png`"
|
||||
mode=""></image>
|
||||
<view class="user-info-box" :style="{ width: (windowWidth - 32) + 'px' }">
|
||||
<image class="user-avatar" :src="userInfo.avater"></image>
|
||||
<image v-if="userInfo.avater" class="user-avatar" :src="userInfo.avater"></image>
|
||||
<view class="user-info">
|
||||
<view class="name-box">
|
||||
<text class="phone-text">ID:{{ userInfo.user_id }}</text>
|
||||
|
|
@ -161,12 +161,11 @@ import {
|
|||
} from '@dcloudio/uni-app';
|
||||
|
||||
onReady(() => {
|
||||
// NVUE 挂载极快,但给它 100~200ms 的喘息让原生视图确认渲染
|
||||
setTimeout(() => {
|
||||
// #ifdef APP-PLUS
|
||||
plus.navigator.closeSplashscreen();
|
||||
// #endif
|
||||
}, 150);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
// 内部埋点方法
|
||||
|
|
@ -292,10 +291,11 @@ const otherList = [{
|
|||
]
|
||||
|
||||
const data = reactive({
|
||||
isReady: false,
|
||||
navBarBgColor: 'transparent',
|
||||
statusBarHeight: 0,
|
||||
windowWidth: 0,
|
||||
windowHeight: 0,
|
||||
windowWidth: 390, // 防0导致初次Weex负数高度白屏崩溃
|
||||
windowHeight: 844, // 防0导致初次Weex负数高度白屏崩溃
|
||||
userInfo: {},
|
||||
videoHelpList: [],
|
||||
noticeInfo: {},
|
||||
|
|
@ -305,6 +305,7 @@ const data = reactive({
|
|||
})
|
||||
|
||||
const {
|
||||
isReady,
|
||||
statusBarHeight,
|
||||
windowWidth,
|
||||
windowHeight,
|
||||
|
|
@ -336,21 +337,41 @@ onLoad(async () => {
|
|||
data.vision = uni.getStorageSync('version')
|
||||
})
|
||||
|
||||
const updateSystemSize = () => {
|
||||
try {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
// 防止安卓宿主中首次热更新进入,短暂状态下获取宽高均为0导致的白屏bug
|
||||
if (systemInfo.windowHeight > 0 && systemInfo.windowWidth > 0) {
|
||||
data.statusBarHeight = systemInfo.statusBarHeight;
|
||||
data.windowWidth = systemInfo.windowWidth;
|
||||
data.windowHeight = systemInfo.windowHeight;
|
||||
|
||||
// 针对部分小米/底层ROM的顽疾:
|
||||
// 强制延迟挂载超重DOM,让其宿主完全完成测绘后再放入节点,避免Weex渲染主线程卡死白屏
|
||||
setTimeout(() => {
|
||||
data.isReady = true;
|
||||
}, 300);
|
||||
} else {
|
||||
// 未获取到正常宽高,延迟再次进行重试
|
||||
setTimeout(updateSystemSize, 100);
|
||||
}
|
||||
} catch (error) {
|
||||
setTimeout(updateSystemSize, 100);
|
||||
}
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
// 启动时获取数据
|
||||
fetchUserData()
|
||||
// 每次显示时刷新数据
|
||||
setUserData()
|
||||
// 获取系统信息
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
data.statusBarHeight = systemInfo.statusBarHeight;
|
||||
data.windowWidth = systemInfo.windowWidth;
|
||||
data.windowHeight = systemInfo.windowHeight;
|
||||
// 循环检测更新真实屏幕宽高
|
||||
updateSystemSize();
|
||||
// #ifdef APP-PLUS
|
||||
util.setAndroidSystemBarColor('#F0F4F9')
|
||||
setTimeout(() => {
|
||||
plus.navigator.setStatusBarStyle("dark");
|
||||
}, 500)
|
||||
// util.setAndroidSystemBarColor('#F0F4F9');
|
||||
// plus.navigator.setStatusBarStyle("dark");
|
||||
}, 800);
|
||||
// #endif
|
||||
})
|
||||
|
||||
|
|
@ -434,7 +455,7 @@ const setUserData = () => {
|
|||
const userInfoData = storage.get("userInfo")
|
||||
data.userInfo = userInfoData || {
|
||||
user_id: '加载中...',
|
||||
avater: '/static/default-avatar.png',
|
||||
avater: '',
|
||||
vip: 0,
|
||||
vip_expire: ''
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue