app.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. var util = require('we7/resource/js/util.js');
  2. var timeQueue = require('lionfish_comshop/utils/timeQueue');
  3. require('lionfish_comshop/utils//mixins.js');
  4. require('/lib/SPage.js')
  5. App({
  6. onLaunch: async function (options) {
  7. let scene = options.scene || '';
  8. this.globalData.scene = scene;
  9. console.log('scene:' + scene);
  10. var userInfo = wx.getStorageSync("userInfo");
  11. this.globalData.userInfo = userInfo;
  12. wx.setStorageSync("isparse_formdata", 0);
  13. var currentCommunity = wx.getStorageSync("community");
  14. this.globalData.hasDefaultCommunity = !!currentCommunity;
  15. this.globalData.community = currentCommunity;
  16. this.globalData.systemInfo = wx.getSystemInfoSync();
  17. var model = this.globalData.systemInfo.model;
  18. this.globalData.isIpx = model.indexOf("iPhone X") > -1 || model.indexOf("unknown<iPhone") > -1;
  19. this.globalData.timer = new timeQueue.default();
  20. },
  21. $mixinP:{
  22. onLoad(options){
  23. console.log("options", options)
  24. }
  25. },
  26. onShow: function () {
  27. if(this.globalData.scene!=1154) this.getUpdate();
  28. },
  29. onHide: function () {
  30. },
  31. //加载微擎工具类
  32. util: util,
  33. //用户信息,sessionid是用户是否登录的凭证
  34. userInfo: {
  35. sessionid: null,
  36. },
  37. globalData: {
  38. systemInfo: {},
  39. isIpx: false,
  40. userInfo: {},
  41. canGetGPS: true,
  42. city: {},
  43. community: {},
  44. location: {},
  45. hasDefaultCommunity: true,
  46. historyCommunity: [],
  47. changedCommunity: false,
  48. disUserInfo: {},
  49. changeCity: "",
  50. timer: 0,
  51. formIds: [],
  52. community_id: '',
  53. placeholdeImg: '',
  54. cartNum: 0,
  55. cartNumStamp: 0,
  56. common_header_backgroundimage: '',
  57. appLoadStatus: 1, // 1 正常 0 未登录 2 未选择社区
  58. goodsListCarCount: [],
  59. typeCateId: 0,
  60. navBackUrl: '',
  61. isblack: 0,
  62. skin: {
  63. color: '#ff5344',
  64. subColor: '#ed7b3a',
  65. lighter: '#fff9f4'
  66. },
  67. goods_sale_unit: '件',
  68. scene: '',
  69. indexCateId: ''
  70. },
  71. getUpdate: function(){
  72. if (wx.canIUse("getUpdateManager")) {
  73. const updateManager = wx.getUpdateManager();
  74. updateManager.onCheckForUpdate(function (res) {
  75. res.hasUpdate && (updateManager.onUpdateReady(function () {
  76. wx.showModal({
  77. title: "更新提示",
  78. content: "新版本已经准备好,是否马上重启小程序?",
  79. success: function (t) {
  80. t.confirm && updateManager.applyUpdate();
  81. }
  82. });
  83. }), updateManager.onUpdateFailed(function () {
  84. wx.showModal({
  85. title: "已经有新版本了哟~",
  86. content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~"
  87. });
  88. }));
  89. });
  90. } else wx.showModal({
  91. title: "提示",
  92. content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
  93. });
  94. },
  95. getConfig: function() {
  96. var token = wx.getStorageSync('token');
  97. return new Promise((resolve, reject)=>{
  98. util.request({
  99. url: 'entry/wxapp/user',
  100. data: {
  101. controller: 'index.get_firstload_msg',
  102. token,
  103. m: 'lionfish_comshop'
  104. },
  105. method: 'post',
  106. dataType: 'json',
  107. success: function(res) {
  108. if(res.data.code==0) {
  109. let { new_head_id, default_head_info, isparse_formdata } = res.data;
  110. if(!token) isparse_formdata = 0;
  111. wx.setStorageSync('isparse_formdata', isparse_formdata);
  112. if(new_head_id>0&&Object.keys(default_head_info).length) {
  113. wx.setStorageSync('community', default_head_info);
  114. }
  115. resolve(res)
  116. } else {
  117. reject()
  118. }
  119. }
  120. })
  121. })
  122. },
  123. setShareConfig: function(){
  124. wx.showShareMenu({
  125. menus: ['shareAppMessage', 'shareTimeline']
  126. })
  127. },
  128. siteInfo: require('siteinfo.js')
  129. });