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

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

上级 cfa637dc
...@@ -41,7 +41,13 @@ ...@@ -41,7 +41,13 @@
let globalScreenHeight = 0 let globalScreenHeight = 0
try { try {
// #ifdef MP-WEIXIN
globalScreenHeight = uni.getWindowInfo().screenHeight
// #endif
// #ifndef MP-WEIXIN
globalScreenHeight = uni.getSystemInfoSync().screenHeight globalScreenHeight = uni.getSystemInfoSync().screenHeight
// #endif
} catch (e) { } catch (e) {
// 兼容本地测试 // 兼容本地测试
console.error(e) console.error(e)
......
...@@ -44,7 +44,12 @@ ...@@ -44,7 +44,12 @@
}, },
}, },
onLoad() { onLoad() {
// #ifdef MP-WEIXIN
this.platform = uni.getDeviceInfo().platform
// #endif
// #ifndef MP-WEIXIN
this.platform = uni.getSystemInfoSync().platform this.platform = uni.getSystemInfoSync().platform
// #endif
}, },
onUnload() { onUnload() {
uni.hideLoading() uni.hideLoading()
......
...@@ -45,7 +45,12 @@ ...@@ -45,7 +45,12 @@
}, },
}, },
onLoad() { onLoad() {
// #ifdef MP-WEIXIN
this.platform = uni.getDeviceInfo().platform
// #endif
// #ifndef MP-WEIXIN
this.platform = uni.getSystemInfoSync().platform this.platform = uni.getSystemInfoSync().platform
// #endif
}, },
onUnload() { onUnload() {
uni.closeSocket({ uni.closeSocket({
......
...@@ -72,7 +72,14 @@ ...@@ -72,7 +72,14 @@
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.getWindowInfo().statusBarHeight;
// #endif
// #ifndef MP-WEIXIN || WEB
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight; this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
// #endif // #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;
// #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'); backElement.style.setProperty('top', uni.getSystemInfoSync().statusBarHeight+'px');
// #endif // #endif
}, },
onShow() { onShow() {
currentPageIsShow = true currentPageIsShow = true
......
...@@ -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;
// #ifdef MP-WEIXIN
let systemInfo = uni.getDeviceInfo();
// #endif
// #ifndef MP-WEIXIN
let systemInfo = uni.getSystemInfoSync(); 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.
先完成此消息的编辑!
想要评论请 注册