app.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // app.js
  2. var projectMode = 1;//0代表开发模式(本地环境),1代表测试模式(线上测试环境),2代表线上模式(正式运行环境)
  3. var info = wx.getSystemInfoSync();
  4. if (info.platform != "devtools" && projectMode == 0) { projectMode = 1 }
  5. var envVersion = `${__wxConfig.envVersion}`;//develop 开发版,trial 体验版,release 正式版
  6. if (envVersion == 'release') { projectMode = 2 }
  7. import api from './utils/api'
  8. App({
  9. onLaunch() {
  10. //云开发
  11. // wx.cloud.init({
  12. // traceUser: true,
  13. // })
  14. wx.setStorageSync('islocation', false)
  15. var that = this;
  16. //this.getLocation();
  17. },
  18. globalData: {
  19. userInfo: null,
  20. btnInfo: null,
  21. status: ['可下单', '服务中', '已满柜', '暂停服务'],
  22. baseAppUrl: projectMode == 2 ? 'https://hx.xishuashua.art/' : (projectMode == 1 ? 'https://hx.xishuashua.art/' : 'https://wash.nanodreamtech.com/'),
  23. location: "",
  24. islocation: true
  25. },
  26. api: api,
  27. getLocation(e) {
  28. var that = this;
  29. return new Promise((resolve, reject) => {
  30. wx.getLocation({
  31. success(res) {
  32. console.log('开启后台定位', res)
  33. console.log('location change', res)
  34. that.globalData.location = res;
  35. wx.setStorageSync('latitude', res.latitude)
  36. wx.setStorageSync('longitude', res.longitude)
  37. }, fail(res) {
  38. console.log('开启后台定位失败', res)
  39. that.globalData.islocation = false;
  40. wx.setStorageSync('islocation', true)
  41. wx.showLoading({
  42. title: '请授权获取地址。',
  43. })
  44. setTimeout(function () {
  45. wx.hideLoading();
  46. }, 2000)
  47. }
  48. })
  49. })
  50. },
  51. })