App.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <script>
  2. import configpath from 'config/setting.config.js';
  3. import api from 'api/index.js'
  4. import Vue from 'vue'
  5. const inforeq = (cb) => {
  6. fetch('/static/.config.json')
  7. .then((res) => res.json())
  8. .then(async (res) => {
  9. let obj = {
  10. ...res,
  11. img_local_host: (process.env.NODE_ENV === 'production' ?
  12. res.prodIp || configpath.prodIp :
  13. process.env.NODE_ENV === 'test' ?
  14. res.testIp || configpath.testIp :
  15. res.devIp || configpath.devIp) + '/file/',
  16. // 请求 地址
  17. baseURL: (process.env.NODE_ENV === 'production' ?
  18. res.prodIp || configpath.prodIp :
  19. process.env.NODE_ENV === 'test' ?
  20. res.testIp || configpath.testIp :
  21. res.devIp || configpath.devIp) + '/api/h5',
  22. }
  23. cb && cb(obj)
  24. })
  25. }
  26. export default {
  27. globalData: {
  28. SET_STATUS_BAR: 0,
  29. SET_CUSTOM_BAR: 0,
  30. SET_SYSTEM_INFO: {},
  31. configData: {},
  32. token: ''
  33. },
  34. onLaunch: function(option) {
  35. let token = window.location.search.split('token=')[1]
  36. console.log('App Launch')
  37. // console.log(token)
  38. let t = this;
  39. inforeq((res) => {
  40. t.globalData.configData = res
  41. if (token && token.length > 0) {
  42. uni.setStorage({
  43. key: 'token',
  44. data: token,
  45. success: function() {
  46. console.log('success');
  47. }
  48. });
  49. t.globalData.token = token
  50. }
  51. })
  52. },
  53. onShow: function() {
  54. console.log('App Show')
  55. },
  56. onHide: function() {
  57. console.log('App Hide')
  58. },
  59. }
  60. </script>
  61. <style>
  62. /*每个页面公共css */
  63. @import url("@/static/style/style.css");
  64. @import url("@/static/style/icon.css");
  65. @import url("@/static/style/color.css");
  66. page {
  67. background: #f5f5f5;
  68. }
  69. .my-button {
  70. border-radius: 0px;
  71. transform: initial;
  72. background-color: transparent;
  73. }
  74. .my-button:after {
  75. border-width: 0px !important;
  76. border-radius: 0px !important;
  77. transform: initial;
  78. background-color: transparent;
  79. width: 100%;
  80. height: 100%;
  81. }
  82. .bule_line {
  83. width: 10rpx;
  84. height: 30rpx;
  85. background-color: #1e8ff9;
  86. border-radius: 6rpx;
  87. box-shadow: 0px 2px 4px 0px rgba(121, 190, 254, 0.59);
  88. }
  89. </style>
  90. uni.getSystemInfo({
  91. success: (e) => {
  92. let statusBar = 0
  93. let customBar = 0
  94. // #ifdef MP
  95. statusBar = e.statusBarHeight
  96. customBar = e.statusBarHeight + 45
  97. if (e.platform === 'android') {
  98. customBar = e.statusBarHeight + 50
  99. }
  100. // #endif
  101. // #ifdef MP-WEIXIN
  102. statusBar = e.statusBarHeight
  103. const custom = wx.getMenuButtonBoundingClientRect()
  104. customBar = custom.bottom + custom.top - e.statusBarHeight
  105. // #endif
  106. // #ifdef MP-ALIPAY
  107. statusBar = e.statusBarHeight
  108. customBar = e.statusBarHeight + e.titleBarHeight
  109. // #endif
  110. // #ifdef APP-PLUS
  111. console.log('app-plus', e)
  112. statusBar = e.statusBarHeight
  113. customBar = e.statusBarHeight + 45
  114. // #endif
  115. // #ifdef H5
  116. statusBar = 0
  117. customBar = e.statusBarHeight + 45
  118. // #endif
  119. this.globalData.SET_SYSTEM_INFO = e
  120. this.globalData.SET_CUSTOM_BAR = customBar
  121. this.globalData.SET_STATUS_BAR = statusBar
  122. }
  123. })