index.vue 1.01 KB
<!--
 * @Date: 2022-09-19 14:11:06
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2026-01-13 00:18:41
 * @FilePath: /xyxBooking-weapp/src/pages/auth/index.vue
 * @Description: 授权页
-->
<template>
  <view class="auth-page">
    <view class="loading">
        <view>正在授权登录...</view>
    </view>
  </view>
</template>

<script setup>
import Taro, { useDidShow } from '@tarojs/taro'
import { silentAuth, returnToOriginalPage } from '@/utils/authRedirect'

useDidShow(() => {
    /**
     * 尝试静默授权
     * - 授权成功后回跳到来源页
     * - 授权失败则跳转至授权页面
     */
    silentAuth()
      .then(() => returnToOriginalPage())
      .catch((error) => {
        Taro.showToast({ title: error?.message || '授权失败', icon: 'none' })
      })
})
</script>

<style lang="less">
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    .loading {
        text-align: center;
        color: #999;
    }
}
</style>