// 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, // }) 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://hx.xishuashua.art/' : '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) } }) }) }, })