| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <template>
- <view class="container">
- <view class="bg-shape shadow"></view>
- <view class="bg-shape2 shadow"></view>
- <view class="loading-box">
- <uv-loading-icon color="#3b82f6" size="30"></uv-loading-icon>
- <text class="loading-text">正在自动登录,请稍候...</text>
- </view>
- <uv-toast ref="toastRef"></uv-toast>
- </view>
- </template>
- <script setup lang="ts">
- import { ref, onMounted } from 'vue';
- import { useUserStore } from '@/store/modules/user';
- const userStore = useUserStore();
- const toastRef = ref<any>(null);
- onMounted(async () => {
- // --- 逻辑拦截 ---
- // 如果缓存里已经有 Token,说明当前处于已登录状态
- if (userStore.token) {
- uni.switchTab({ url: '/pages/home/index' }).catch(() => {
- uni.reLaunch({ url: '/pages/home/index' });
- });
- return;
- }
- // --- 新增:企业微信免登拦截(URL 带 code) ---
- const urlCode = uni.getLaunchOptionsSync()?.query?.code as string | undefined;
- if (urlCode) {
- try {
- await userStore.oAuthLogin(urlCode);
- toastRef.value.show({ message: '登录成功', type: 'success' });
- // 成功跳转首页
- setTimeout(() => {
- uni.switchTab({ url: '/pages/home/index' }).catch(() => {
- uni.reLaunch({ url: '/pages/home/index' });
- });
- }, 800);
- return;
- } catch (error: any) {
- console.error('oAuthLogin Failure in Login Page:', error);
- toastRef.value.show({
- message: error?.message || '企业快捷登录失败',
- type: 'error',
- });
- uni.reLaunch({ url: '/pages/login/register' });
- return;
- }
- }
- // 无法进行免登时,回到手动登录页
- uni.reLaunch({ url: '/pages/login/index' });
- });
- </script>
- <style scoped>
- .container {
- min-height: 100vh;
- position: relative;
- background: #f8fafc;
- overflow: hidden;
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 0 40rpx;
- }
- .bg-shape {
- position: absolute;
- top: -100rpx;
- right: -100rpx;
- width: 500rpx;
- height: 500rpx;
- border-radius: 50%;
- background: linear-gradient(135deg, #3b82f6 0%, #2dd4bf 100%);
- opacity: 0.15;
- filter: blur(40rpx);
- }
- .bg-shape2 {
- position: absolute;
- bottom: -150rpx;
- left: -100rpx;
- width: 600rpx;
- height: 600rpx;
- border-radius: 50%;
- background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
- opacity: 0.15;
- filter: blur(50rpx);
- }
- .loading-box {
- display: flex;
- flex-direction: column;
- align-items: center;
- z-index: 10;
- /* 与左侧输入框 60(height) + 40(padding) + 4(border) 高度保持一致 */
- border-radius: 20rpx;
- background: #f1f5f9;
- flex-shrink: 0;
- cursor: pointer;
- }
- .options {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 50rpx;
- }
- .forgot {
- font-size: 26rpx;
- color: #3b82f6;
- font-weight: 500;
- padding: 10rpx 0;
- }
- .footer {
- margin-top: 40rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .footer-text {
- font-size: 26rpx;
- color: #64748b;
- }
- .footer-link {
- font-size: 26rpx;
- color: #3b82f6;
- font-weight: 600;
- margin-left: 10rpx;
- }
- </style>
|