app.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // app.js
  2. App({
  3. "permission": {
  4. "scope.userLocation": {
  5. "desc": "你的位置信息将用于地图展示"
  6. }
  7. },
  8. "requiredPrivateInfos": ["getLocation"],
  9. onLaunch() {
  10. // 初始化路由跟踪
  11. if (typeof this.globalData === 'undefined') {
  12. this.globalData = {}
  13. }
  14. this.globalData.route = 'pages/index/index'
  15. },
  16. onLaunch: function () {
  17. var userInfo=wx.getStorageSync('userInfo');
  18. if(userInfo){
  19. this.globalData.userInfo=userInfo
  20. }
  21. },
  22. globalData:{
  23. userInfo:null,
  24. apiBaseUrl: wx.getSystemInfoSync().platform === 'devtools' ?
  25. 'http://localhost:8000' :
  26. 'https://api.yourdomain.com',
  27. debugMode: true,
  28. },
  29. initUserInfo:function(res,localInfo){
  30. var info={
  31. token:res.token,
  32. phone:res.phone,
  33. id:res.id,
  34. nickName:localInfo.nickName,
  35. avatarUrl:localInfo.avatarUrl,
  36. };
  37. this.globalData.userInfo=info;
  38. wx.setStorageSync('userInfo', info)
  39. },
  40. delUserInfo:function(){
  41. this.globalData.userInfo=null;
  42. wx.removeStorageSync('userInfo');
  43. }
  44. })