app.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. var util = require('./utils/util.js');
  2. var api = require('./config/api.js');
  3. var user = require('./utils/user.js');
  4. App({
  5. onLaunch: function () {
  6. const updateManager = wx.getUpdateManager();
  7. wx.getUpdateManager().onUpdateReady(function () {
  8. wx.showModal({
  9. title: '更新提示',
  10. content: '新版本已经准备好,是否重启应用?',
  11. success: function (res) {
  12. if (res.confirm) {
  13. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  14. updateManager.applyUpdate()
  15. }
  16. }
  17. })
  18. })
  19. /*网络状态
  20. wx.onNetworkStatusChange(function (res) {
  21. if (res.networkType === 'none') {
  22. wx.showToast({
  23. title: '网络已断开',
  24. icon: 'none'
  25. })
  26. } else if (res.networkType === "2g" || res.networkType === "3g")
  27. wx.showToast({
  28. title: '您的网络状态不佳,' + res.networkType + ',建议使用wifi',
  29. icon: 'none'
  30. });
  31. })*/
  32. //初始化小程序云开发
  33. //wx.cloud.init();
  34. },
  35. onShow: function (options) {
  36. /*是否授权登录*/
  37. user.checkLogin().then(res => {
  38. this.globalData.hasLogin = true;
  39. if (this.checkLoginReadyCallback) {
  40. this.checkLoginReadyCallback();
  41. }
  42. }).catch(() => {
  43. this.globalData.hasLogin = false;
  44. });
  45. //购物车数据显示
  46. //user.cartcount();
  47. },
  48. checkLoginReadyCallback: function () { //是否登录
  49. this.globalData.hasLogin = true;
  50. },
  51. globalData: {
  52. hasLogin: false, //是否授权登录
  53. userInfo: {},
  54. r_userid: 0, //推荐人id
  55. iscert: false, //是否注册过
  56. mapKey:'JA2BZ-XGOEU-UNZVD-46G64-S6MYJ-6BBF4',
  57. currentLocationName:"位置获取中",
  58. rId:'',//引荐人ID
  59. shareImage:'',
  60. recommend:{ //引荐人信息
  61. userName:'',
  62. avatarUrl:'',
  63. bCode:'',
  64. phone:'',
  65. unionId:'',
  66. openId:'',
  67. sessionKey:""
  68. },
  69. infoGoods:{
  70. picUrl:'',
  71. name:'',
  72. brief:"",
  73. type:'0'
  74. },//信息收集,
  75. infoAddress:{
  76. addressId:'',
  77. addressDetail:''
  78. },
  79. }
  80. })
  81. //购物车隐藏
  82. // {
  83. // "pagePath": "pages/tabBar/cart/cart",
  84. // "iconPath": "static/images/cart.png",
  85. // "selectedIconPath": "static/images/cart@selected.png",
  86. // "text": "购物车"
  87. // },