Page({
data: {
isLandscape: false
},
onLoad() {
this.checkOrientation();
my.onScreenOrientationChange(this.handleOrientationChange);
},
checkOrientation() {
my.getScreenOrientation({
success: (res) => {
const isLandscape = res.orientation.includes('landscape');
this.setData({ isLandscape });
}
});
},
handleOrientationChange(res) {
const isLandscape = res.orientation.includes('landscape');
this.setData({ isLandscape });
},
onUnload() {
my.offScreenOrientationChange(this.handleOrientationChange);
}
});