Commit d92e264c by jianan

fix(统一身份): 补交遗漏的票据落地页 pages/auth/ticket.vue

parent 69649f08
<template>
<view class="ticket-landing">
<image
src="@/static/images/logoLanuch.png"
style="width: 100rpx; height: 100rpx;"
mode="widthFix"
/>
<text class="tip">{{ tip }}</text>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { consumeTicket, setSsoToken, isMiniprogram, reloginViaMiniprogram } from '@/util/sso'
let tip = ref('登录中...')
onLoad((options) => {
const redirect = options.redirect
? decodeURIComponent(options.redirect)
: '/pages/index/index'
const ticket = options.ticket
// 无票据(误访问/收藏夹直开):不建 sso 态,回首页走老 H5 链路
if (!ticket) {
uni.reLaunch({ url: '/pages/index/index' })
return
}
consumeTicket(ticket).then(({ token, userId }) => {
// 令牌只进内存;业务 userId/isLogin 落 storage,随后请求由 interceptor 携带 X-Authorization
setSsoToken(token, userId)
uni.reLaunch({ url: redirect })
}).catch((err) => {
console.error('票据消费失败:', err)
if (isMiniprogram()) {
// 票据 30s 过期/已消费/重放:销毁本 web-view,原生强制重走 wx.login→票据
tip.value = '登录已过期,正在重新登录...'
reloginViaMiniprogram(redirect)
} else {
tip.value = '登录失败,即将返回首页'
setTimeout(() => uni.reLaunch({ url: '/pages/index/index' }), 1500)
}
})
})
</script>
<style lang="scss" scoped>
.ticket-landing {
min-height: 100vh;
background-color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 30rpx;
}
.tip {
font-size: 26rpx;
color: #999;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment