app.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // app.js
  2. const api = require('./api/index')
  3. App({
  4. onLaunch() {
  5. wx.setStorageSync('showDialog', true)
  6. // 展示本地存储能力
  7. const logs = wx.getStorageSync('logs') || []
  8. logs.unshift(Date.now())
  9. wx.setStorageSync('logs', logs)
  10. //获取顶部navBar的信息
  11. const that = this;
  12. // 获取系统信息
  13. const systemInfo = wx.getSystemInfoSync();
  14. // 胶囊按钮位置信息
  15. const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
  16. that.globalData.windowWidth = systemInfo.windowWidth
  17. that.globalData.windowHeight = systemInfo.windowHeight
  18. // 导航栏高度 = 状态栏高度 + 44
  19. that.globalData.navBarHeight = systemInfo.statusBarHeight + 44;
  20. that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
  21. that.globalData.menuTop = menuButtonInfo.top;
  22. that.globalData.menuHeight = menuButtonInfo.height;
  23. that.globalData.menuWidth = menuButtonInfo.width;
  24. wx.setStorageSync('height', that.globalData.navBarHeight)
  25. this.getPersonRights()
  26. //静态图片地址
  27. var Path = {
  28. develop: {
  29. localImagePath:'',
  30. imghttp:'http://192.168.1.16:8801/fileManager/downloadFile?fileId='
  31. }, // 开发环境地址
  32. trial: {
  33. localImagePath:'.',
  34. imghttp:'https://www.xsip.cn/fileManager/downloadFile?fileId='
  35. }, // 测试环境地址
  36. release:{
  37. localImagePath:'.',
  38. imghttp:'https://www.xsip.cn/fileManager/downloadFile?fileId='
  39. }, // 生产环境地址
  40. }
  41. const accountInfo = wx.getAccountInfoSync();
  42. const envVersion = accountInfo.miniProgram.envVersion;
  43. that.globalData.localImagePath = Path[envVersion].localImagePath;
  44. that.globalData.imghttp = Path[envVersion].imghttp;
  45. },
  46. globalData: {
  47. userInfo: null,
  48. navBarHeight: 0, // 导航栏高度
  49. menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致)
  50. menuTop: 0, // 胶囊距顶部间距
  51. menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致)
  52. menuWidth:0,
  53. windowHeight:0,
  54. windowWidth:0,
  55. phone:'0755-82839168',
  56. localImagePath:'',//发布是'.',本地开发是''
  57. imghttp:'https://www.xsip.cn/fileManager/downloadFile?fileId='
  58. },
  59. getPersonRights(){
  60. api.getPersonRights({},false).then(res=>{
  61. if(res.code == 200){
  62. var data = JSON.stringify(res.data.data)
  63. wx.setStorageSync('vip', data)
  64. }
  65. })
  66. },
  67. })