From 33c5b17c78d2db8da787d39a562f87b60c15ee5f Mon Sep 17 00:00:00 2001 From: yuhe <1641284022@qq.com> Date: Mon, 2 Dec 2024 17:48:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=B8=8A=E7=9A=84=20getSystemInfo?= =?UTF-8?q?=20=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/get-system-info/get-system-info.uvue | 10 ++++++++-- pages/API/websocket/socketTask.uvue | 9 +++++++-- pages/API/websocket/websocket.uvue | 7 ++++++- pages/tabBar/API.uvue | 11 +++++++++-- pages/template/drop-card/card/card.uvue | 6 ++++++ pages/template/scroll-fold-nav/scroll-fold-nav.uvue | 8 ++++++-- .../swiper-vertical-video/swiper-vertical-video.uvue | 9 ++++++++- uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue | 9 +++++++-- 8 files changed, 57 insertions(+), 12 deletions(-) diff --git a/pages/API/get-system-info/get-system-info.uvue b/pages/API/get-system-info/get-system-info.uvue index ad032ba3..89647276 100644 --- a/pages/API/get-system-info/get-system-info.uvue +++ b/pages/API/get-system-info/get-system-info.uvue @@ -40,8 +40,14 @@ } let globalScreenHeight = 0 - try { - globalScreenHeight = uni.getSystemInfoSync().screenHeight + try { + // #ifdef MP-WEIXIN + globalScreenHeight = uni.getWindowInfo().screenHeight + // #endif + // #ifndef MP-WEIXIN + globalScreenHeight = uni.getSystemInfoSync().screenHeight + // #endif + } catch (e) { // 兼容本地测试 console.error(e) diff --git a/pages/API/websocket/socketTask.uvue b/pages/API/websocket/socketTask.uvue index 4f9ae687..969530a4 100644 --- a/pages/API/websocket/socketTask.uvue +++ b/pages/API/websocket/socketTask.uvue @@ -43,8 +43,13 @@ } }, }, - onLoad() { - this.platform = uni.getSystemInfoSync().platform + onLoad() { + // #ifdef MP-WEIXIN + this.platform = uni.getDeviceInfo().platform + // #endif + // #ifndef MP-WEIXIN + this.platform = uni.getSystemInfoSync().platform + // #endif }, onUnload() { uni.hideLoading() diff --git a/pages/API/websocket/websocket.uvue b/pages/API/websocket/websocket.uvue index 4db59145..5caf4ab3 100644 --- a/pages/API/websocket/websocket.uvue +++ b/pages/API/websocket/websocket.uvue @@ -45,7 +45,12 @@ }, }, onLoad() { - this.platform = uni.getSystemInfoSync().platform + // #ifdef MP-WEIXIN + this.platform = uni.getDeviceInfo().platform + // #endif + // #ifndef MP-WEIXIN + this.platform = uni.getSystemInfoSync().platform + // #endif }, onUnload() { uni.closeSocket({ diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index 6ede6282..69132b6c 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -71,8 +71,15 @@ leftWinActive() : string { return state.leftWinActive.slice(1) }, - windowWidth() : number { - return uni.getSystemInfoSync().windowWidth + windowWidth() : number { + let windowWidth = 0 + // #ifdef MP-WEIXIN + windowWidth = uni.getWindowInfo().windowWidth + // #endif + // #ifndef MP-WEIXIN + windowWidth = uni.getSystemInfoSync().windowWidth + // #endif + return windowWidth } }, methods: { diff --git a/pages/template/drop-card/card/card.uvue b/pages/template/drop-card/card/card.uvue index 6b4c75a8..056d0f38 100644 --- a/pages/template/drop-card/card/card.uvue +++ b/pages/template/drop-card/card/card.uvue @@ -53,12 +53,18 @@ } }, mounted() { + // #ifdef MP-WEIXIN + screenWidth = uni.getWindowInfo().screenWidth + screenHeight = uni.getWindowInfo().screenHeight; + // #endif + // #ifndef MP-WEIXIN uni.getSystemInfo({ success: (e) => { screenWidth = e.screenWidth; screenHeight = e.screenHeight; } }) + // #endif // TODO 需要延迟设置才能生效 setTimeout(() => { diff --git a/pages/template/scroll-fold-nav/scroll-fold-nav.uvue b/pages/template/scroll-fold-nav/scroll-fold-nav.uvue index c848c062..158b2b28 100644 --- a/pages/template/scroll-fold-nav/scroll-fold-nav.uvue +++ b/pages/template/scroll-fold-nav/scroll-fold-nav.uvue @@ -49,9 +49,13 @@ } }, onLoad() { - // #ifdef APP || MP - this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight; + // #ifdef MP-WEIXIN + this.statusBarHeight = uni.getWindowInfo().statusBarHeight; // #endif + // #ifndef MP-WEIXIN || WEB + this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight; + // #endif + this.nviBarHeight = NAVIBARHEIGHT + this.statusBarHeight; }, onReady() { diff --git a/pages/template/swiper-vertical-video/swiper-vertical-video.uvue b/pages/template/swiper-vertical-video/swiper-vertical-video.uvue index 30eb98bb..d03132c8 100644 --- a/pages/template/swiper-vertical-video/swiper-vertical-video.uvue +++ b/pages/template/swiper-vertical-video/swiper-vertical-video.uvue @@ -92,8 +92,15 @@ this.doPlay(0); //App端适配不同状态栏高度 let backElement = this.$refs['back'] as UniElement; - backElement.style.setProperty('top', uni.getSystemInfoSync().statusBarHeight+'px'); // #endif + + // #ifdef MP-WEIXIN + backElement.style.setProperty('top', uni.getWindowInfo().statusBarHeight+'px'); + // #endif + // #ifndef MP-WEIXIN || WEB + backElement.style.setProperty('top', uni.getSystemInfoSync().statusBarHeight+'px'); + // #endif + }, onShow() { currentPageIsShow = true diff --git a/uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue b/uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue index abbac79f..467e1ed6 100644 --- a/uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue +++ b/uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue @@ -233,7 +233,7 @@ }) } // #endif - + // #ifdef MP-WEIXIN // 如果是微信小程序,则设置只支持微信支付 this.originalRroviders = ["wxpay"]; @@ -832,7 +832,12 @@ modeCom() : string { let mode = this.mode as string; if (mode != "") return mode; - let systemInfo = uni.getSystemInfoSync(); + // #ifdef MP-WEIXIN + let systemInfo = uni.getDeviceInfo(); + // #endif + // #ifndef MP-WEIXIN + let systemInfo = uni.getSystemInfoSync(); + // #endif return systemInfo.deviceType == "pc" ? "pc" : "mobile"; }, totalFeeCom() : number { -- GitLab