C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.2 KiB

  1. let config = require("./config/config.js");
  2. const Http = require("./utils/HttpBasics");
  3. App({
  4. data: {},
  5. onLaunch: function(options) {
  6. console.log("onUnload ")
  7. var that = this;
  8. that.globalData.sceneAddress = options.scene;
  9. if (wx.canIUse('getUpdateManager')) {
  10. const updateManager = wx.getUpdateManager()
  11. updateManager.onCheckForUpdate(function (res) {
  12. console.log('onCheckForUpdate====', res)
  13. // 请求完新版本信息的回调
  14. if (res.hasUpdate) {
  15. console.log('res.hasUpdate====')
  16. updateManager.onUpdateReady(function () {
  17. wx.showModal({
  18. title: '更新提示',
  19. content: '新版本已经准备好,是否重启应用?',
  20. success: function (res) {
  21. console.log('success====', res)
  22. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  23. if (res.confirm) {
  24. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  25. updateManager.applyUpdate()
  26. }
  27. }
  28. })
  29. })
  30. updateManager.onUpdateFailed(function () {
  31. // 新的版本下载失败
  32. wx.showModal({
  33. title: '已经有新版本了哟~',
  34. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  35. })
  36. })
  37. }
  38. })
  39. }
  40. },
  41. /**
  42. * 获取地址位置信息
  43. */
  44. getLocation: function() {
  45. var that = this
  46. wx.getLocation({
  47. type: "wgs84",
  48. success: function(res) {
  49. that.globalData.locationInfo = res;
  50. },
  51. fail: error => {
  52. console.log(error);
  53. }
  54. });
  55. },
  56. globalData: {
  57. // token
  58. token: null,
  59. // 渠道
  60. sceneAddress: null,
  61. // location info
  62. locationInfo: null,
  63. // 二维码参数
  64. scene: null,
  65. // 支持智慧停车, 用户名下有车
  66. phone: null,
  67. supportCar: false,
  68. parkVendor: 1, // 1: ETCP, 2: TJD
  69. // ETCP token
  70. etcpToken: null,
  71. carLogin: false,
  72. // 当前商场信息
  73. market: {
  74. name: "陕西大悦城"
  75. }
  76. }
  77. });