app.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // app.js
  2. const login = require("./utils/login.js");
  3. const request = require("./utils/request.js");
  4. App({
  5. onLaunch() {
  6. // 自动登录
  7. login.autoLogin()
  8. this.getDistrictData()
  9. this.getNavBarInfo()
  10. },
  11. getDistrictData() {
  12. let that = this;
  13. request.getData(
  14. 'app/district/list',{},
  15. res => {
  16. wx.setStorageSync('districtData', res.data.data)
  17. }
  18. )
  19. },
  20. getNavBarInfo() {
  21. const that = this;
  22. // 获取系统信息
  23. const systemInfo = wx.getSystemInfoSync();
  24. // 胶囊按钮位置信息
  25. const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
  26. // 导航栏高度 = 状态栏到胶囊的间距(胶囊距上距离-状态栏高度) * 2 + 胶囊高度 + 状态栏高度
  27. that.globalData.navBarHeight = (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 + menuButtonInfo.height + systemInfo.statusBarHeight;
  28. that.globalData.menuTop = menuButtonInfo.top;
  29. that.globalData.menuHeight = menuButtonInfo.height;
  30. },
  31. globalData: {
  32. navBarHeight: 0, // 导航栏高度
  33. menuTop: 0, // 胶囊距顶部间距(保持顶部间距一致)
  34. menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致)
  35. userInfo: null,
  36. content: '',
  37. imgList: [],
  38. selectedTagList: [],
  39. env: {
  40. uploadImageUrl: 'https://toktok-beer.oss-cn-shenzhen.aliyuncs.com/',
  41. AccessKeySecret: '',
  42. OSSAccessKeyId: '',
  43. securityToken: '',
  44. timeout: 87600
  45. },
  46. adress_select: {}
  47. }
  48. })