You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
867 B
JavaScript
33 lines
867 B
JavaScript
4 months ago
|
let isIPhoneX = null;
|
||
|
function getIsIPhoneX() {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
if (isIPhoneX !== null) {
|
||
|
resolve(isIPhoneX);
|
||
|
}
|
||
|
else {
|
||
|
wx.getSystemInfo({
|
||
|
success: ({ model, screenHeight }) => {
|
||
|
const iphoneX = /iphone x/i.test(model);
|
||
|
const iphoneNew = /iPhone11/i.test(model) && screenHeight === 812;
|
||
|
isIPhoneX = iphoneX || iphoneNew;
|
||
|
resolve(isIPhoneX);
|
||
|
},
|
||
|
fail: reject
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
export const iphonex = Behavior({
|
||
|
properties: {
|
||
|
safeAreaInsetBottom: {
|
||
|
type: Boolean,
|
||
|
value: true
|
||
|
}
|
||
|
},
|
||
|
created() {
|
||
|
getIsIPhoneX().then(isIPhoneX => {
|
||
|
this.set({ isIPhoneX });
|
||
|
});
|
||
|
}
|
||
|
});
|