app.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. isMember:false,//是否是会员
  54. userInfo: {},
  55. r_userid: 0, //推荐人id
  56. iscert: false, //是否注册过
  57. mapKey:'JA2BZ-XGOEU-UNZVD-46G64-S6MYJ-6BBF4',
  58. currentLocationName:"位置获取中",
  59. rId:'',//引荐人ID
  60. shareImage:'',
  61. recommend:{ //引荐人信息
  62. userName:'',
  63. avatarUrl:'',
  64. bCode:'',
  65. phone:'',
  66. unionId:'',
  67. openId:'',
  68. sessionKey:""
  69. },
  70. infoGoods:{
  71. picUrl:'',
  72. name:'',
  73. brief:"",
  74. type:'0'
  75. },//信息收集,
  76. infoAddress:{
  77. addressId:'',
  78. addressDetail:''
  79. },
  80. }
  81. })
  82. //购物车隐藏
  83. // {
  84. // "pagePath": "pages/tabBar/cart/cart",
  85. // "iconPath": "static/images/cart.png",
  86. // "selectedIconPath": "static/images/cart@selected.png",
  87. // "text": "购物车"
  88. // },