App.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. let serialNumber = window.location.search.split('serialNumber=')[1]
  37. console.log('App Launch', token, serialNumber)
  38. // console.log(token)
  39. let t = this;
  40. inforeq((res) => {
  41. t.globalData.configData = res
  42. if (token && token.length > 0) {
  43. uni.setStorage({
  44. key: 'token',
  45. data: token,
  46. success: function() {
  47. console.log('success');
  48. }
  49. });
  50. t.globalData.token = token
  51. }
  52. if (serialNumber && serialNumber.length > 0) {
  53. uni.setStorage({
  54. key: 'serialNumber',
  55. data: serialNumber,
  56. success: function() {
  57. console.log('success');
  58. }
  59. });
  60. t.globalData.serialNumber = serialNumber
  61. }
  62. })
  63. },
  64. onShow: function() {
  65. console.log('App Show')
  66. },
  67. onHide: function() {
  68. console.log('App Hide')
  69. },
  70. }
  71. </script>
  72. <style>
  73. /*每个页面公共css */
  74. @import url("@/static/style/style.css");
  75. @import url("@/static/style/icon.css");
  76. @import url("@/static/style/color.css");
  77. page {
  78. background: #f5f5f5;
  79. }
  80. .my-button {
  81. border-radius: 0px;
  82. transform: initial;
  83. background-color: transparent;
  84. }
  85. .my-button:after {
  86. border-width: 0px !important;
  87. border-radius: 0px !important;
  88. transform: initial;
  89. background-color: transparent;
  90. width: 100%;
  91. height: 100%;
  92. }
  93. .bule_line {
  94. width: 10rpx;
  95. height: 30rpx;
  96. background-color: #1e8ff9;
  97. border-radius: 6rpx;
  98. box-shadow: 0px 2px 4px 0px rgba(121, 190, 254, 0.59);
  99. }
  100. </style>
  101. uni.getSystemInfo({
  102. success: (e) => {
  103. let statusBar = 0
  104. let customBar = 0
  105. // #ifdef MP
  106. statusBar = e.statusBarHeight
  107. customBar = e.statusBarHeight + 45
  108. if (e.platform === 'android') {
  109. customBar = e.statusBarHeight + 50
  110. }
  111. // #endif
  112. // #ifdef MP-WEIXIN
  113. statusBar = e.statusBarHeight
  114. const custom = wx.getMenuButtonBoundingClientRect()
  115. customBar = custom.bottom + custom.top - e.statusBarHeight
  116. // #endif
  117. // #ifdef MP-ALIPAY
  118. statusBar = e.statusBarHeight
  119. customBar = e.statusBarHeight + e.titleBarHeight
  120. // #endif
  121. // #ifdef APP-PLUS
  122. console.log('app-plus', e)
  123. statusBar = e.statusBarHeight
  124. customBar = e.statusBarHeight + 45
  125. // #endif
  126. // #ifdef H5
  127. statusBar = 0
  128. customBar = e.statusBarHeight + 45
  129. // #endif
  130. this.globalData.SET_SYSTEM_INFO = e
  131. this.globalData.SET_CUSTOM_BAR = customBar
  132. this.globalData.SET_STATUS_BAR = statusBar
  133. }
  134. })