app.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. title:'晟果实业'
  71. },
  72. getUpdate: function(){
  73. if (wx.canIUse("getUpdateManager")) {
  74. const updateManager = wx.getUpdateManager();
  75. updateManager.onCheckForUpdate(function (res) {
  76. res.hasUpdate && (updateManager.onUpdateReady(function () {
  77. wx.showModal({
  78. title: "更新提示",
  79. content: "新版本已经准备好,是否马上重启小程序?",
  80. success: function (t) {
  81. t.confirm && updateManager.applyUpdate();
  82. }
  83. });
  84. }), updateManager.onUpdateFailed(function () {
  85. wx.showModal({
  86. title: "已经有新版本了哟~",
  87. content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~"
  88. });
  89. }));
  90. });
  91. } else wx.showModal({
  92. title: "提示",
  93. content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
  94. });
  95. },
  96. getConfig: function() {
  97. var token = wx.getStorageSync('token');
  98. return new Promise((resolve, reject)=>{
  99. util.request({
  100. url: 'entry/wxapp/user',
  101. data: {
  102. controller: 'index.get_firstload_msg',
  103. token,
  104. m: 'lionfish_comshop'
  105. },
  106. method: 'post',
  107. dataType: 'json',
  108. success: function(res) {
  109. if(res.data.code==0) {
  110. let { new_head_id, default_head_info, isparse_formdata } = res.data;
  111. if(!token) isparse_formdata = 0;
  112. wx.setStorageSync('isparse_formdata', isparse_formdata);
  113. if(new_head_id>0&&Object.keys(default_head_info).length) {
  114. wx.setStorageSync('community', default_head_info);
  115. }
  116. resolve(res)
  117. } else {
  118. reject()
  119. }
  120. }
  121. })
  122. })
  123. },
  124. setShareConfig: function(){
  125. wx.showShareMenu({
  126. menus: ['shareAppMessage', 'shareTimeline']
  127. })
  128. },
  129. siteInfo: require('siteinfo.js')
  130. });