app.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. console.info(options)
  49. let query = options.query || {}
  50. if (query.orderId) {
  51. wx.navigateTo({
  52. url: 'pages/ucenter/serviceDetail/serviceDetail?orderId='+query.orderId,
  53. })
  54. }
  55. },
  56. checkLoginReadyCallback: function () { //是否登录
  57. this.globalData.hasLogin = true;
  58. },
  59. globalData: {
  60. shopId:'',
  61. hasLogin: false, //是否授权登录
  62. isMember:false,//是否是会员
  63. userInfo: {},
  64. r_userid: 0, //推荐人id
  65. iscert: false, //是否注册过
  66. mapKey:'JA2BZ-XGOEU-UNZVD-46G64-S6MYJ-6BBF4',
  67. currentLocationName:"位置获取中",
  68. rId:'',//引荐人ID
  69. shareImage:'',
  70. recommend:{ //引荐人信息
  71. userName:'',
  72. avatarUrl:'',
  73. bCode:'',
  74. phone:'',
  75. unionId:'',
  76. openId:'',
  77. sessionKey:""
  78. },
  79. infoGoods:{
  80. picUrl:'',
  81. name:'',
  82. brief:"",
  83. type:'0'
  84. },//信息收集,
  85. infoAddress:{
  86. addressId:'',
  87. addressDetail:''
  88. },
  89. memberUserInfo:{
  90. nickName: '',
  91. avatarUrl: '/static/images/new/icon-user.png'
  92. }
  93. }
  94. })
  95. //购物车隐藏
  96. // {
  97. // "pagePath": "pages/tabBar/cart/cart",
  98. // "iconPath": "static/images/cart.png",
  99. // "selectedIconPath": "static/images/cart@selected.png",
  100. // "text": "购物车"
  101. // },