app.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. var util = require('we7/resource/js/util.js');
  2. var timeQueue = require('lionfish_comshop/utils/timeQueue');
  3. App({
  4. onLaunch: function (res) {
  5. wx.hideTabBar();
  6. var that = this;
  7. var userInfo = wx.getStorageSync("userInfo");
  8. this.globalData.userInfo = userInfo;
  9. var historyCommunity = wx.getStorageSync("historyCommunity") || [];
  10. var currentCommunity = wx.getStorageSync("community");
  11. this.globalData.hasDefaultCommunity = !!currentCommunity;
  12. this.globalData.community = currentCommunity;
  13. this.globalData.systemInfo = wx.getSystemInfoSync();
  14. var model = this.globalData.systemInfo.model;
  15. this.globalData.isIpx = model.indexOf("iPhone X") > -1 || model.indexOf("unknown<iPhone") > -1;
  16. this.globalData.timer = new timeQueue.default();
  17. },
  18. onShow: function (res) {
  19. this.getUpdate();
  20. },
  21. onHide: function () {
  22. },
  23. //加载微擎工具类
  24. util: util,
  25. //导航菜单,微擎将会自己实现一个导航菜单,结构与小程序导航菜单相同
  26. //用户信息,sessionid是用户是否登录的凭证
  27. userInfo: {
  28. sessionid: null,
  29. },
  30. globalData: {
  31. systemInfo: {},
  32. isIpx: false,
  33. userInfo: {},
  34. canGetGPS: true,
  35. city: {},
  36. community: {},
  37. location: {},
  38. hasDefaultCommunity: true,
  39. historyCommunity: [],
  40. changedCommunity: false,
  41. disUserInfo: {},
  42. changeCity: "",
  43. timer: 0,
  44. formIds: [],
  45. community_id: '',
  46. placeholdeImg: '',
  47. cartNum: 0,
  48. cartNumStamp: 0,
  49. common_header_backgroundimage: '',
  50. appLoadStatus: 1, // 1 正常 0 未登录 2 未选择社区
  51. goodsListCarCount: [],
  52. typeCateId: 0
  53. },
  54. getUpdate: function(){
  55. if (wx.canIUse("getUpdateManager")) {
  56. const updateManager = wx.getUpdateManager();
  57. updateManager.onCheckForUpdate(function (res) {
  58. res.hasUpdate && (updateManager.onUpdateReady(function () {
  59. wx.showModal({
  60. title: "更新提示",
  61. content: "新版本已经准备好,是否马上重启小程序?",
  62. success: function (t) {
  63. t.confirm && updateManager.applyUpdate();
  64. }
  65. });
  66. }), updateManager.onUpdateFailed(function () {
  67. wx.showModal({
  68. title: "已经有新版本了哟~",
  69. content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~"
  70. });
  71. }));
  72. });
  73. } else wx.showModal({
  74. title: "提示",
  75. content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
  76. });
  77. },
  78. siteInfo: require('siteinfo.js')
  79. });