mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-09 02:46:46 +08:00
117 lines
2.9 KiB
Vue
117 lines
2.9 KiB
Vue
<template>
|
|
<view>
|
|
<u-loading-page loadingText="加载中...." :loading="true"></u-loading-page>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import apiLogin from '@/api/login.js'
|
|
import { getToken,setToken } from '@/utils/token'
|
|
export default{
|
|
data(){
|
|
return {
|
|
toUrl:''
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
this.toUrl=options.returnUrl;
|
|
},
|
|
mounted() {
|
|
let token=getToken();
|
|
let $this=this;
|
|
console.log(token,'得到token');
|
|
if(!token){
|
|
console.log('未获得token,转向登录');
|
|
//this.$router.push({ path: process.env.VUE_APP_LOGIN_URL })
|
|
// #ifdef APP-PLUS
|
|
plus.runtime.openURL(this.$config.loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
|
// #endif
|
|
// #ifdef H5
|
|
window.open(this.$config.loginPath)
|
|
// #endif
|
|
}else{
|
|
uni.showModal({
|
|
title:'获取用户信息',
|
|
content:''
|
|
})
|
|
console.log('获取用户信息');
|
|
apiLogin.boeLogin(token).then(rs=>{
|
|
if(rs.status==200){
|
|
console.log('获取用户信息成功');
|
|
uni.showModal({
|
|
title:'获取用户成功',
|
|
content:rs.status
|
|
})
|
|
//setToken(rs.result.access_token);
|
|
//加载用户信息
|
|
this.$store.dispatch("InitData").then(res => {
|
|
//console.log(res)
|
|
//this.$watermark.set(res.result.name + res.result.loginName);
|
|
// uni.switchTab({
|
|
// url:'/pages/index/index'
|
|
// })
|
|
uni.setStorageSync("boe_new_login",1);//记录新登录
|
|
let openUrl=$this.toUrl;
|
|
if(openUrl){
|
|
console.log('跳转url='+openUrl);
|
|
if(openUrl.startsWith('http')){
|
|
uni.showModal({
|
|
title:'跳转url0',
|
|
content:openUrl
|
|
})
|
|
location.href=openUrl
|
|
}else{
|
|
if(openUrl=='/pages/index/index' || openUrl=='/pages/study/index' || openUrl=='/pages/plus/index' || openUrl=='/pages/my/index'){
|
|
uni.showModal({
|
|
title:'跳转url1',
|
|
content:openUrl
|
|
})
|
|
uni.switchTab({
|
|
url:openUrl
|
|
})
|
|
}else{
|
|
uni.showModal({
|
|
title:'跳转url2',
|
|
content:openUrl
|
|
})
|
|
uni.navigateTo({url:openUrl})
|
|
}
|
|
}
|
|
}else{
|
|
console.log('跳转到首页');
|
|
uni.switchTab({
|
|
url:'/pages/index/index'
|
|
})
|
|
}
|
|
|
|
}).catch(error => {
|
|
console.log('加载用户信息错误:',error);
|
|
uni.showModal({
|
|
title:'错误',
|
|
content:error
|
|
})
|
|
})
|
|
}else{
|
|
console.log(rs.message+','+rs.error);
|
|
//#ifdef APP-PLUS
|
|
plus.runtime.openURL(this.$config.loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
|
|
// #endif
|
|
// #ifdef H5
|
|
location.href=this.$config.loginPath;
|
|
//window.open(this.$config.loginPath)
|
|
// #endif
|
|
}
|
|
}).catch(err=>{
|
|
//
|
|
uni.showToast({
|
|
title:'请求超时'
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
</style>
|