From d0ce92b873cb6e88365bc85dfc1c05704949cea5 Mon Sep 17 00:00:00 2001 From: yuhe <1641284022@qq.com> Date: Thu, 5 Dec 2024 19:56:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20=20getSystemInfo=20?= =?UTF-8?q?=E8=AD=A6=E5=91=8A=20=E6=9B=BF=E6=8D=A2=E4=B8=BA=E5=85=B7?= =?UTF-8?q?=E4=BD=93=E7=9A=84=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/get-system-info/get-system-info.uvue | 12 +++--------- pages/API/websocket/socketTask.uvue | 7 +------ pages/API/websocket/websocket.uvue | 7 +------ pages/tabBar/API.uvue | 11 ++--------- pages/template/drop-card/card/card.uvue | 10 ---------- pages/template/scroll-fold-nav/scroll-fold-nav.uvue | 7 ++----- .../swiper-vertical-video/swiper-vertical-video.uvue | 7 ------- .../uni-pay-x/components/uni-pay/uni-pay.uvue | 5 ----- 8 files changed, 9 insertions(+), 57 deletions(-) diff --git a/pages/API/get-system-info/get-system-info.uvue b/pages/API/get-system-info/get-system-info.uvue index 89647276..0cc6bd41 100644 --- a/pages/API/get-system-info/get-system-info.uvue +++ b/pages/API/get-system-info/get-system-info.uvue @@ -40,14 +40,8 @@ } let globalScreenHeight = 0 - try { - // #ifdef MP-WEIXIN - globalScreenHeight = uni.getWindowInfo().screenHeight - // #endif - // #ifndef MP-WEIXIN - globalScreenHeight = uni.getSystemInfoSync().screenHeight - // #endif - + try { + globalScreenHeight = uni.getWindowInfo().screenHeight } catch (e) { // 兼容本地测试 console.error(e) @@ -129,4 +123,4 @@ .uni-pd { padding-left: 15px; } - + diff --git a/pages/API/websocket/socketTask.uvue b/pages/API/websocket/socketTask.uvue index 969530a4..5797ccf8 100644 --- a/pages/API/websocket/socketTask.uvue +++ b/pages/API/websocket/socketTask.uvue @@ -44,12 +44,7 @@ }, }, onLoad() { - // #ifdef MP-WEIXIN - this.platform = uni.getDeviceInfo().platform - // #endif - // #ifndef MP-WEIXIN - this.platform = uni.getSystemInfoSync().platform - // #endif + this.platform = uni.getDeviceInfo().platform as string }, onUnload() { uni.hideLoading() diff --git a/pages/API/websocket/websocket.uvue b/pages/API/websocket/websocket.uvue index 5caf4ab3..41409ad3 100644 --- a/pages/API/websocket/websocket.uvue +++ b/pages/API/websocket/websocket.uvue @@ -45,12 +45,7 @@ }, }, onLoad() { - // #ifdef MP-WEIXIN - this.platform = uni.getDeviceInfo().platform - // #endif - // #ifndef MP-WEIXIN - this.platform = uni.getSystemInfoSync().platform - // #endif + this.platform = uni.getDeviceInfo().platform as string }, onUnload() { uni.closeSocket({ diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index 69132b6c..2d778b20 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -71,15 +71,8 @@ leftWinActive() : string { return state.leftWinActive.slice(1) }, - windowWidth() : number { - let windowWidth = 0 - // #ifdef MP-WEIXIN - windowWidth = uni.getWindowInfo().windowWidth - // #endif - // #ifndef MP-WEIXIN - windowWidth = uni.getSystemInfoSync().windowWidth - // #endif - return windowWidth + windowWidth() : number { + return uni.getWindowInfo().windowWidth } }, methods: { diff --git a/pages/template/drop-card/card/card.uvue b/pages/template/drop-card/card/card.uvue index 056d0f38..e37bfd98 100644 --- a/pages/template/drop-card/card/card.uvue +++ b/pages/template/drop-card/card/card.uvue @@ -53,18 +53,8 @@ } }, 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 158b2b28..383f2827 100644 --- a/pages/template/scroll-fold-nav/scroll-fold-nav.uvue +++ b/pages/template/scroll-fold-nav/scroll-fold-nav.uvue @@ -49,11 +49,8 @@ } }, onLoad() { - // #ifdef MP-WEIXIN - this.statusBarHeight = uni.getWindowInfo().statusBarHeight; - // #endif - // #ifndef MP-WEIXIN || WEB - this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight; + // #ifdef APP || MP + this.statusBarHeight = uni.getWindowInfo().statusBarHeight; // #endif this.nviBarHeight = NAVIBARHEIGHT + this.statusBarHeight; diff --git a/pages/template/swiper-vertical-video/swiper-vertical-video.uvue b/pages/template/swiper-vertical-video/swiper-vertical-video.uvue index d03132c8..856b8542 100644 --- a/pages/template/swiper-vertical-video/swiper-vertical-video.uvue +++ b/pages/template/swiper-vertical-video/swiper-vertical-video.uvue @@ -92,15 +92,8 @@ this.doPlay(0); //App端适配不同状态栏高度 let backElement = this.$refs['back'] as UniElement; - // #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 467e1ed6..2224b3dd 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 @@ -832,12 +832,7 @@ modeCom() : string { let mode = this.mode as string; if (mode != "") return mode; - // #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