提交 33c5b17c 编写于 作者: Dcloud_UNI_yuhe's avatar Dcloud_UNI_yuhe

fix: 修复微信小程序上的 getSystemInfo 警告

上级 cfa637dc
...@@ -40,8 +40,14 @@ ...@@ -40,8 +40,14 @@
} }
let globalScreenHeight = 0 let globalScreenHeight = 0
try { try {
globalScreenHeight = uni.getSystemInfoSync().screenHeight // #ifdef MP-WEIXIN
globalScreenHeight = uni.getWindowInfo().screenHeight
// #endif
// #ifndef MP-WEIXIN
globalScreenHeight = uni.getSystemInfoSync().screenHeight
// #endif
} catch (e) { } catch (e) {
// 兼容本地测试 // 兼容本地测试
console.error(e) console.error(e)
......
...@@ -43,8 +43,13 @@ ...@@ -43,8 +43,13 @@
} }
}, },
}, },
onLoad() { 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() { onUnload() {
uni.hideLoading() uni.hideLoading()
......
...@@ -45,7 +45,12 @@ ...@@ -45,7 +45,12 @@
}, },
}, },
onLoad() { 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() { onUnload() {
uni.closeSocket({ uni.closeSocket({
......
...@@ -71,8 +71,15 @@ ...@@ -71,8 +71,15 @@
leftWinActive() : string { leftWinActive() : string {
return state.leftWinActive.slice(1) return state.leftWinActive.slice(1)
}, },
windowWidth() : number { windowWidth() : number {
return uni.getSystemInfoSync().windowWidth let windowWidth = 0
// #ifdef MP-WEIXIN
windowWidth = uni.getWindowInfo().windowWidth
// #endif
// #ifndef MP-WEIXIN
windowWidth = uni.getSystemInfoSync().windowWidth
// #endif
return windowWidth
} }
}, },
methods: { methods: {
......
...@@ -53,12 +53,18 @@ ...@@ -53,12 +53,18 @@
} }
}, },
mounted() { mounted() {
// #ifdef MP-WEIXIN
screenWidth = uni.getWindowInfo().screenWidth
screenHeight = uni.getWindowInfo().screenHeight;
// #endif
// #ifndef MP-WEIXIN
uni.getSystemInfo({ uni.getSystemInfo({
success: (e) => { success: (e) => {
screenWidth = e.screenWidth; screenWidth = e.screenWidth;
screenHeight = e.screenHeight; screenHeight = e.screenHeight;
} }
}) })
// #endif
// TODO 需要延迟设置才能生效 // TODO 需要延迟设置才能生效
setTimeout(() => { setTimeout(() => {
......
...@@ -49,9 +49,13 @@ ...@@ -49,9 +49,13 @@
} }
}, },
onLoad() { onLoad() {
// #ifdef APP || MP // #ifdef MP-WEIXIN
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight; this.statusBarHeight = uni.getWindowInfo().statusBarHeight;
// #endif // #endif
// #ifndef MP-WEIXIN || WEB
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
// #endif
this.nviBarHeight = NAVIBARHEIGHT + this.statusBarHeight; this.nviBarHeight = NAVIBARHEIGHT + this.statusBarHeight;
}, },
onReady() { onReady() {
......
...@@ -92,8 +92,15 @@ ...@@ -92,8 +92,15 @@
this.doPlay(0); this.doPlay(0);
//App端适配不同状态栏高度 //App端适配不同状态栏高度
let backElement = this.$refs['back'] as UniElement; let backElement = this.$refs['back'] as UniElement;
backElement.style.setProperty('top', uni.getSystemInfoSync().statusBarHeight+'px');
// #endif // #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() { onShow() {
currentPageIsShow = true currentPageIsShow = true
......
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
}) })
} }
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
// 如果是微信小程序,则设置只支持微信支付 // 如果是微信小程序,则设置只支持微信支付
this.originalRroviders = ["wxpay"]; this.originalRroviders = ["wxpay"];
...@@ -832,7 +832,12 @@ ...@@ -832,7 +832,12 @@
modeCom() : string { modeCom() : string {
let mode = this.mode as string; let mode = this.mode as string;
if (mode != "") return mode; 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"; return systemInfo.deviceType == "pc" ? "pc" : "mobile";
}, },
totalFeeCom() : number { totalFeeCom() : number {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册