App.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <script>
  2. import { isLoggedIn, startStatusCheck, stopStatusCheck } from './utils/auth.js'
  3. export default {
  4. globalData: {
  5. userInfo: null,
  6. envVersion:''
  7. },
  8. onLaunch: function() {
  9. console.log('App Launch')
  10. // #ifdef H5
  11. // 检查URL中是否有微信授权回调的code参数
  12. const urlParams = new URLSearchParams(window.location.search)
  13. const code = urlParams.get('code')
  14. if (code) {
  15. console.log('[App] 检测到微信授权回调code:', code)
  16. // H5环境下使用原生跳转
  17. const loginUrl = `${window.location.origin}${window.location.pathname}#/pages/login/login?code=${code}`
  18. console.log('[App] 跳转到登录页:', loginUrl)
  19. window.location.replace(loginUrl)
  20. return
  21. }
  22. // #endif
  23. // 如果已登录,启动用户状态定时检查
  24. if (isLoggedIn()) {
  25. console.log('[App] 用户已登录,启动状态检查')
  26. startStatusCheck()
  27. }
  28. // #ifdef H5
  29. // H5键盘适配
  30. let baseLayoutHeight = window.innerHeight || document.documentElement.clientHeight || 0
  31. const setKeyboardOffset = () => {
  32. const vv = window.visualViewport
  33. if (!vv) {
  34. document.documentElement.style.setProperty('--keyboard-offset', '0px')
  35. return
  36. }
  37. const currentLayoutHeight = window.innerHeight || document.documentElement.clientHeight || 0
  38. baseLayoutHeight = Math.max(baseLayoutHeight, currentLayoutHeight)
  39. const vvHeight = vv.height
  40. const offsetTop = vv.offsetTop || 0
  41. const keyboardHeight = Math.max(0, baseLayoutHeight - vvHeight - offsetTop)
  42. document.documentElement.style.setProperty('--keyboard-offset', `${keyboardHeight}px`)
  43. }
  44. this.__keyboardOffsetHandler = setKeyboardOffset
  45. if (window.visualViewport) {
  46. window.visualViewport.addEventListener('resize', setKeyboardOffset)
  47. window.visualViewport.addEventListener('scroll', setKeyboardOffset)
  48. }
  49. window.addEventListener('resize', () => {
  50. const h = window.innerHeight || document.documentElement.clientHeight || 0
  51. baseLayoutHeight = Math.max(baseLayoutHeight, h)
  52. setKeyboardOffset()
  53. })
  54. window.addEventListener('focusin', setKeyboardOffset)
  55. window.addEventListener('focusout', () => {
  56. document.documentElement.style.setProperty('--keyboard-offset', '0px')
  57. })
  58. setKeyboardOffset()
  59. // #endif
  60. },
  61. onShow: function() {
  62. const accountInfo = wx.getAccountInfoSync();
  63. //fakecheck
  64. // this.globalData.envVersion = accountInfo.miniProgram.envVersion
  65. console.log('App Show')
  66. // 确保导航栏标题正确显示
  67. uni.setNavigationBarTitle({
  68. title: '量化交易大师'
  69. })
  70. // 应用回到前台时,如果已登录则启动状态检查
  71. if (isLoggedIn()) {
  72. startStatusCheck()
  73. }
  74. },
  75. onHide: function() {
  76. console.log('App Hide')
  77. // 应用进入后台时停止状态检查,节省资源
  78. stopStatusCheck()
  79. }
  80. }
  81. </script>
  82. <style>
  83. /*每个页面公共css */
  84. page {
  85. background-color: #f5f6fb;
  86. }
  87. /* #ifdef H5 */
  88. uni-page-head,
  89. uni-page-head .uni-page-head {
  90. height: 44px !important;
  91. min-height: 44px !important;
  92. padding-top: 0 !important;
  93. }
  94. uni-page-head .uni-page-head__title {
  95. line-height: 44px !important;
  96. }
  97. /* #endif */
  98. .container {
  99. height: 100%;
  100. display: flex;
  101. flex-direction: column;
  102. align-items: center;
  103. justify-content: space-between;
  104. padding: 200rpx 0;
  105. box-sizing: border-box;
  106. }
  107. .ph-bos{
  108. width: 750rpx;
  109. height: 100vh;
  110. position: relative;
  111. }
  112. .ph-bos .ph-image{
  113. width: 750rpx;
  114. height: 100vh;
  115. }
  116. .ph-bos .ph-next{
  117. width: 140rpx;
  118. position: absolute;
  119. top: 92%;
  120. left: 305rpx;
  121. text-align: center;
  122. padding: 4rpx 0rpx;
  123. background-color: #ffffff;
  124. border-radius: 20rpx;
  125. }
  126. </style>