<template>
  <view class="box">
    <image class="img" src="https://minio.menduner.com/dev/fe9890be9b1176f84f2aa282b0f6adce300b133f65eb3d7b45ae057aa5698324.png"></image>
    <view class="color-primary font-size-20 font-weight-bold">门墩儿 专注顶尖招聘</view>
    <view class="icons">
      <uni-icons type="spinner-cycle" size="24" />
    </view>
  </view>
</template>

<script setup>
import { onShow } from '@dcloudio/uni-app'
import { getAccessToken } from '@/utils/request'
import { showAuthModal } from '@/hooks/useModal'


const tabBarControl = (show = false) => { // 显示/隐藏 TabBar
  console.log('TabBar:', show ? '展示' : '隐藏')
  const currentPage = getCurrentPages()
  if (!currentPage) return
  const currentTabBar = currentPage[0]?.getTabBar?.()
  currentTabBar?.setData({ show })
}

onShow(() => {
  tabBarControl(false)
	if (!getAccessToken()) {
    showAuthModal()
    uni.reLaunch({ url: '/pages/index/search' }) // redirectTo: 关闭当前页面，跳转（不可返回）; reLaunch: 关闭所有页面，重新打开（完全重置导航栈）
  } else {
    // 检查是否是个人令牌
    if (uni.getStorageSync('token') && uni.getStorageSync('isPersonalToken')) {
      try {
        const url = uni.getStorageSync('entRegisterData') ? '/pages/register/review?hasData=true' : '/pages/register/index'
        uni.redirectTo({ url }) // redirectTo: 关闭当前页面，跳转（不可返回）; reLaunch: 关闭所有页面，重新打开（完全重置导航栈）
      } catch (e) {
        console.error('Navigation error:', e)
      }
    }
  }
})
</script>
<style lang="scss" scoped>
.box {
  text-align: center;
  .img {
    width: 105px;
    height: 45px;
    margin-top: 30vh;
    margin-bottom: 16px;
  }
  .icons {
    position: fixed;
    bottom: 20vh;
    width: 100%;
    margin: 0 auto;
  }
}
</style>
