mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-09 19:06:43 +08:00
54 lines
1.2 KiB
Vue
54 lines
1.2 KiB
Vue
<template>
|
||
<div>
|
||
<p v-if="loading">正在跳转,请稍候...</p>
|
||
<p v-if="error" class="error">{{ errorMessage }}</p>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import axios from 'axios'
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
loading: true,
|
||
error: false,
|
||
errorMessage: ''
|
||
}
|
||
},
|
||
created() {
|
||
this.fetchCode()
|
||
},
|
||
methods: {
|
||
async fetchCode() {
|
||
try {
|
||
// 替换为你的实际API地址
|
||
const response = await axios.post('/userbasic/sso/getCode', {})
|
||
const code = response.data.result
|
||
if (code) {
|
||
// 替换为你的目标外部链接,并确保参数名称正确
|
||
const redirectUrl = `https://lexiangla.com?company_from=d1f3b156e9ed11ef9dc9720f77c5afa9&login_way=sso&sso_auth_code=${encodeURIComponent(code)}`
|
||
window.location.href = redirectUrl
|
||
} else {
|
||
this.handleError('未获取到有效code')
|
||
}
|
||
} catch (error) {
|
||
this.handleError(`请求失败: ${error.message}`)
|
||
}
|
||
},
|
||
handleError(message) {
|
||
this.loading = false
|
||
this.error = true
|
||
this.errorMessage = message
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
.error {
|
||
color: red;
|
||
font-weight: bold;
|
||
}
|
||
</style>
|