mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-07 01:46:44 +08:00
75 lines
1.7 KiB
Vue
75 lines
1.7 KiB
Vue
<template>
|
|
<view>
|
|
<u-loading-page :loadingText="text" :loading="true"></u-loading-page>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import apiLogin from '@/api/login.js'
|
|
import { getToken,setToken } from '@/utils/token'
|
|
export default{
|
|
data(){
|
|
return {
|
|
examId:'',
|
|
text:'"加载考试信息....',
|
|
toUrl:''
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
this.examId=options.id;
|
|
if(!this.examId){
|
|
this.text="未能正确加载,参数错误";
|
|
uni.showToast({
|
|
title:'参数错误'
|
|
})
|
|
}
|
|
this.toUrl='/pages/exam/exam?id='+this.examId;
|
|
},
|
|
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){
|
|
//加载用户信息
|
|
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);//记录新登录
|
|
uni.navigateTo({
|
|
url:toUrl
|
|
})
|
|
});
|
|
}else{
|
|
this.text="加载失败,请直接登录,然后再扫码进入";
|
|
uni.showToast({
|
|
title:'加载失败,请直接登录,然后再扫码进入'
|
|
})
|
|
}
|
|
}).catch(err=>{
|
|
//
|
|
uni.showToast({
|
|
title:'请求超时'
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
</style>
|