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

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

上级 cfa637dc
......@@ -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)
......
......@@ -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()
......
......@@ -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({
......
......@@ -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: {
......
......@@ -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(() => {
......
......@@ -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() {
......
......@@ -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
......
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册