diff --git a/pages_app/webview/webviewClass.vue b/pages_app/webview/webviewClass.vue index 6ec634b..4f90c89 100644 --- a/pages_app/webview/webviewClass.vue +++ b/pages_app/webview/webviewClass.vue @@ -118,38 +118,36 @@ const readnum = ref(0); const agreenum = ref(0); const isAgree = ref(0); const user_uuid = ref(""); -const bottomHeight = ref(65); const NAV_BAR_HEIGHT_PX = 44; -const WEBVIEW_BOTTOM_PX = 65; +const WEBVIEW_BOTTOM_PX = 55; const webviewTopPx = ref(88); -const webviewHeightPx = ref(600); +const webviewBottomPx = ref(WEBVIEW_BOTTOM_PX); const webviewStyles = ref({ width: "100%", top: `${webviewTopPx.value}px`, - height: `${webviewHeightPx.value}px`, - bottom: `65px`, + bottom: `${webviewBottomPx.value}px` }); const applyWebviewLayout = () => { - - -}; -const initWebviewLayout = () => { const resInfo = uni.getSystemInfoSync(); const statusBarHeight = Number(resInfo.statusBarHeight || 0); - const windowHeight = Number(resInfo.windowHeight || 0); - webviewTopPx.value = Math.round(statusBarHeight + NAV_BAR_HEIGHT_PX); - webviewHeightPx.value = Math.max( - 200, - Math.round(windowHeight - webviewTopPx.value - WEBVIEW_BOTTOM_PX) + const safeAreaBottom = Number( + (resInfo.safeAreaInsets && resInfo.safeAreaInsets.bottom) || 0 ); + webviewTopPx.value = Math.round(statusBarHeight + NAV_BAR_HEIGHT_PX); + webviewBottomPx.value = Math.round(WEBVIEW_BOTTOM_PX + safeAreaBottom); webviewStyles.value = { width: "100%", top: `${webviewTopPx.value}px`, - height: `${webviewHeightPx.value}px`, - bottom: `${WEBVIEW_BOTTOM_PX}px`, + bottom: `${webviewBottomPx.value}px` }; }; +const initWebviewLayout = () => { + applyWebviewLayout(); +}; +const onWindowResize = () => { + applyWebviewLayout(); +}; const getCollect = () => { api @@ -293,6 +291,7 @@ const goBack = () => { const webviewRef = ref(null); onShow(() => { + initWebviewLayout(); setTimeout(() => { uni.hideLoading(); }, 2000); @@ -300,6 +299,9 @@ onShow(() => { // plus.screen.lockOrientation('portrait-primary'); }); onUnload(() => { + if (typeof uni.offWindowResize === "function") { + uni.offWindowResize(onWindowResize); + } // console.log('onUnload'); // plus.screen.lockOrientation('portrait-primary'); }); @@ -312,7 +314,10 @@ onLoad((query) => { title: '加载中', mask: true, }); - //initWebviewLayout(); + initWebviewLayout(); + if (typeof uni.onWindowResize === "function") { + uni.onWindowResize(onWindowResize); + } const userInfo = uni.getStorageSync("userInfo"); if (query.type) { type.value = query.type; @@ -1105,15 +1110,15 @@ const shareToWeibo = () => { bottom: 0; left: 0; right: 0; - height: 60px; + height: 55px; display: flex; align-items: center; - z-index: 99; + z-index: 9999999999999999999999999999999999999999999999999999999999999999; background-color: #fff; } .bottom-cell { flex: 1; - height: 55px; + height: 100%; border-right: 2rpx solid #ccc; border-top: 2rpx solid #ccc; display: flex;