mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-10 03:16:45 +08:00
2022年5月29日 从svn移到git
This commit is contained in:
85
pages/login/loading.vue
Normal file
85
pages/login/loading.vue
Normal file
@@ -0,0 +1,85 @@
|
||||
<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{
|
||||
apiLogin.boeLogin(token).then(rs=>{
|
||||
if(rs.status==200){
|
||||
//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'
|
||||
// })
|
||||
let openUrl=$this.toUrl;
|
||||
if(openUrl){
|
||||
if(openUrl.startsWith('http')){
|
||||
location.href=openUrl
|
||||
}else{
|
||||
if(openUrl=='/pages/index/index' || openUrl=='/pages/study/index' || openUrl=='/pages/plus/index' || openUrl=='/pages/my/index'){
|
||||
uni.switchTab({
|
||||
url:openUrl
|
||||
})
|
||||
}else{
|
||||
uni.navigateTo({url:openUrl})
|
||||
}
|
||||
}
|
||||
}else{
|
||||
uni.switchTab({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
}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>
|
||||
Reference in New Issue
Block a user