// app.js var projectMode = 1;//0代表开发模式(本地环境),1代表测试模式(线上测试环境),2代表线上模式(正式运行环境) var info = wx.getSystemInfoSync(); if (info.platform != "devtools" && projectMode == 0) { projectMode = 1 } var envVersion = `${__wxConfig.envVersion}`;//develop 开发版,trial 体验版,release 正式版 if (envVersion == 'release') { projectMode = 2 } import api from './utils/api' App({ onLaunch() { //云开发 // wx.cloud.init({ // traceUser: true, // }) this.updateApp() wx.setStorageSync('islocation', false) var that = this; //this.getLocation(); }, globalData: { userInfo: null, btnInfo: null, status: ['可下单', '服务中', '已满柜', '暂停服务'], baseAppUrl: projectMode == 2 ? 'https://hx.xishuashua.art/' : (projectMode == 1 ? 'https://wash.nanodreamtech.com/' : 'https://wash.nanodreamtech.com/'), location: "", islocation: true }, api: api, getLocation(e) { var that = this; return new Promise((resolve, reject) => { wx.getLocation({ success(res) { console.log('开启后台定位', res) console.log('location change', res) that.globalData.location = res; wx.setStorageSync('latitude', res.latitude) wx.setStorageSync('longitude', res.longitude) }, fail(res) { console.log('开启后台定位失败', res) that.globalData.islocation = false; wx.setStorageSync('islocation', true) wx.showLoading({ title: '请授权获取地址。', }) setTimeout(function () { wx.hideLoading(); }, 2000) } }) }) }, updateApp:function(){ const updateManager = wx.getUpdateManager() updateManager.onCheckForUpdate(function (res) { // 请求完新版本信息的回调 if (res.hasUpdate) { wx.showLoading({ title:'更新下载中...', }) } }) updateManager.onUpdateReady(function () { wx.hideLoading(); wx.showModal({ title:'更新提示', content:'新版本已经准备好,是否重启应用?', success:function (res) { if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate() } } }) }) updateManager.onUpdateFailed(function () { // 新的版本下载失败 wx.hideLoading(); wx.showToast({ title:'下载失败...', icon:"none" }); }) }, })