const app = getApp() Page({ data: { menu: { show: true, top: 0, left: 0 } }, onLoad(options) { }, onShow() { if (typeof this.getTabBar === 'function') { this.getTabBar().setData({ selected: 3 }) } }, onLongPress(e) { console.log(e); let { currentTarget, detail, touches, target } = e let remainingW = app.globalData.windowWidth - touches[0].clientX let remainingH = app.globalData.windowHeight - touches[0].clientY let wFlag = remainingW - 145 > 0 let hFlag = remainingH - 200 > 0 this.setData({ menu: { show: true, top: hFlag ? e.detail.y : e.detail.y - 100, left: wFlag ? e.detail.x : e.detail.x - 135 } }) } })