| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <script>
- import { isLoggedIn, startStatusCheck, stopStatusCheck } from './utils/auth.js'
- export default {
- globalData: {
- userInfo: null,
- envVersion:''
- },
- onLaunch: function() {
- console.log('App Launch')
- // #ifdef H5
- // 检查URL中是否有微信授权回调的code参数
- const urlParams = new URLSearchParams(window.location.search)
- const code = urlParams.get('code')
- if (code) {
- console.log('[App] 检测到微信授权回调code:', code)
- // H5环境下使用原生跳转
- const loginUrl = `${window.location.origin}${window.location.pathname}#/pages/login/login?code=${code}`
- console.log('[App] 跳转到登录页:', loginUrl)
- window.location.replace(loginUrl)
- return
- }
- // #endif
- // 如果已登录,启动用户状态定时检查
- if (isLoggedIn()) {
- console.log('[App] 用户已登录,启动状态检查')
- startStatusCheck()
- }
- // #ifdef H5
- // H5键盘适配
- let baseLayoutHeight = window.innerHeight || document.documentElement.clientHeight || 0
- const setKeyboardOffset = () => {
- const vv = window.visualViewport
- if (!vv) {
- document.documentElement.style.setProperty('--keyboard-offset', '0px')
- return
- }
- const currentLayoutHeight = window.innerHeight || document.documentElement.clientHeight || 0
- baseLayoutHeight = Math.max(baseLayoutHeight, currentLayoutHeight)
- const vvHeight = vv.height
- const offsetTop = vv.offsetTop || 0
- const keyboardHeight = Math.max(0, baseLayoutHeight - vvHeight - offsetTop)
- document.documentElement.style.setProperty('--keyboard-offset', `${keyboardHeight}px`)
- }
- this.__keyboardOffsetHandler = setKeyboardOffset
- if (window.visualViewport) {
- window.visualViewport.addEventListener('resize', setKeyboardOffset)
- window.visualViewport.addEventListener('scroll', setKeyboardOffset)
- }
- window.addEventListener('resize', () => {
- const h = window.innerHeight || document.documentElement.clientHeight || 0
- baseLayoutHeight = Math.max(baseLayoutHeight, h)
- setKeyboardOffset()
- })
- window.addEventListener('focusin', setKeyboardOffset)
- window.addEventListener('focusout', () => {
- document.documentElement.style.setProperty('--keyboard-offset', '0px')
- })
- setKeyboardOffset()
- // #endif
- },
- onShow: function() {
- const accountInfo = wx.getAccountInfoSync();
- //fakecheck
- // this.globalData.envVersion = accountInfo.miniProgram.envVersion
- console.log('App Show')
- // 确保导航栏标题正确显示
- uni.setNavigationBarTitle({
- title: '量化交易大师'
- })
- // 应用回到前台时,如果已登录则启动状态检查
- if (isLoggedIn()) {
- startStatusCheck()
- }
- },
- onHide: function() {
- console.log('App Hide')
- // 应用进入后台时停止状态检查,节省资源
- stopStatusCheck()
- }
- }
- </script>
- <style>
- /*每个页面公共css */
- page {
- background-color: #f5f6fb;
- }
- /* #ifdef H5 */
- uni-page-head,
- uni-page-head .uni-page-head {
- height: 44px !important;
- min-height: 44px !important;
- padding-top: 0 !important;
- }
- uni-page-head .uni-page-head__title {
- line-height: 44px !important;
- }
- /* #endif */
- .container {
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: space-between;
- padding: 200rpx 0;
- box-sizing: border-box;
- }
- .ph-bos{
- width: 750rpx;
- height: 100vh;
- position: relative;
- }
- .ph-bos .ph-image{
- width: 750rpx;
- height: 100vh;
- }
- .ph-bos .ph-next{
- width: 140rpx;
- position: absolute;
- top: 92%;
- left: 305rpx;
- text-align: center;
- padding: 4rpx 0rpx;
- background-color: #ffffff;
- border-radius: 20rpx;
- }
- </style>
|