代码提交-3-13
This commit is contained in:
42
pages/cas/callback.vue
Normal file
42
pages/cas/callback.vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<view class="cas-callback">
|
||||
<text>正在处理统一认证登录...</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import appConfig from '@/config'
|
||||
import { casUnifiedLogin } from '@/api/login'
|
||||
|
||||
export default {
|
||||
onLoad(options) {
|
||||
// H5 环境下 options 可携带 ticket 参数
|
||||
const ticket = options?.ticket || (this.$route && this.$route.query && this.$route.query.ticket)
|
||||
if (!ticket) {
|
||||
this.$modal.msgError('CAS 未返回票据')
|
||||
this.$tab.reLaunch('/pages/login')
|
||||
return
|
||||
}
|
||||
|
||||
// 使用移动端CAS登录API,因为现在Nginx会根据User-Agent和请求参数自动路由
|
||||
this.$store.dispatch('CasAppLogin', ticket).then(() => {
|
||||
// 拉取用户信息并进入工作台
|
||||
this.$store.dispatch('GetInfo').then(() => {
|
||||
this.$tab.reLaunch('/pages/work/index')
|
||||
}).catch(() => {
|
||||
this.$tab.reLaunch('/pages/work/index')
|
||||
})
|
||||
}).catch(err => {
|
||||
this.$modal.msgError('移动端CAS登录失败:' + (err && err.toString ? err.toString() : '未知错误'))
|
||||
this.$tab.reLaunch('/pages/login')
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.cas-callback {
|
||||
padding: 40rpx;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user