var http = require("/utils/config.js"); import touch from '/utils/touch.js' //新加 App({ globalData: { statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'], windowHeight: wx.getSystemInfoSync()['windowHeight'], localUrl: http.url, screenHeight: '', login: false, swichChecked: false, userInfo: null, // top_menuButtonInfo: wx.getMenuButtonBoundingClientRect() navBarHeight: 0, // 导航栏高度 menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致) menuTop: 0, // 胶囊距底部间距(保持底部间距一致) menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致) }, onLaunch: function () { var that = this; // 获取系统信息 const systemInfo = wx.getSystemInfoSync(); // 胶囊按钮位置信息 const menuButtonInfo = wx.getMenuButtonBoundingClientRect(); // 导航栏高度 = 状态栏高度 + 44 that.globalData.navBarHeight = systemInfo.statusBarHeight + 44; that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right; that.globalData.menuTop = menuButtonInfo.top; that.globalData.menuHeight = menuButtonInfo.height; // 登录 // console.log(http) wx.getSystemInfo({ success: res => { // console.log(res.safeArea.bottom) console.log('手机信息res' + res.model) if (res.model == 'iPhone X' || res.model == 'iPhone XR' || res.model == 'iPhone XS Max') { that.globalData.screenHeight = 'xSeries' } else if (res.safeArea.bottom >= 750) { that.globalData.screenHeight = 'xSeries' } } }) if (wx.canIUse('getUpdateManager')) { const updateManager = wx.getUpdateManager() updateManager.onCheckForUpdate(function (res) { if (res.hasUpdate) { updateManager.onUpdateReady(function () { wx.showModal({ title: '更新提示', content: '新版本已经准备好,是否重启应用?', success: function (res) { if (res.confirm) { updateManager.applyUpdate() } } }) }) updateManager.onUpdateFailed(function () { wx.showModal({ title: '已经有新版本了哟~', content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~' }) }) } }) } else { wx.showModal({ title: '提示', content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' }) } if (wx.getStorageSync('token')) { } }, touch: new touch(), //实例化这个touch对象 request(api, params, method) { var that = this; if (true) { return new Promise((resolve, reject) => { wx.request({ url: this.globalData.localUrl + api, data: params, header: { 'content-type': 'application/x-www-form-urlencoded', 'Authorization': 'bearer' + ' ' + wx.getStorageSync('token'), }, method: method, success: (res) => { resolve(res) // console.log(res) if (res.statusCode == 450) { return; } if (res.data.statusCode != 200) { if (res.data.message == '订单不存在或订单已结算') { wx.redirectTo({ url: '/pages/index/index', }) return false; } else if (res.data.message == '运动中不能关锁') { return false; } if (res.message != undefined) { wx.showToast({ title: res.message, icon: 'none', duration: 3000, mask: true }) } else if (res.data.message != undefined) { wx.showToast({ title: res.data.message, icon: 'none', duration: 3000, mask: true }) } } else if (res.statusCode != 200) { if (res.data.message == '订单不存在或订单已结算') { wx.redirectTo({ url: '/pages/index/index', }) return false; } else if (res.data.message == '运动中不能关锁') { return false; } if (res.message != undefined) { wx.showToast({ title: res.message, icon: 'none', duration: 3000, mask: true }) } else if (res.data.message != undefined) { wx.showToast({ title: res.data.message, icon: 'none', duration: 3000, mask: true }) } } if (res.statusCode == 401) { wx.removeStorageSync('token') wx.showToast({ title: '登陆过期请重新登陆~', icon: 'none', mask: true, success: function () { wx.redirectTo({ url: '../login/login', }) } }) } }, fail: (err) => { wx.showToast({ title: err, icon: 'none', mask: true }); reject("请求失败") } }) }) } }, })