<script>
import {
getToken
} from '@/utils/auth';
export default {
data() {
isLogin:false,
},
//判断是否登录
created() {
if(getToken()){
this.isLogin = true;
}else{
this.isLogin = false;
}
},
methods: {
toLogin(){
showConfirm('请注册、登录后完成相关操作').then(res => {
if (res.confirm) {
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
let redirect = routes[routes.length - 1].$route.fullPath // 获取当前页面路由,也就是最后一个打开的页面路由
uni.reLaunch({
url:'/pages/login/login?redirect=' + redirect
})
}
})
},
// 点击某个需要权限的按钮,登陆后重新返回到当前页面
click() {
if(!this.isLogin){
this.toLogin();
return;
}
},
}
}
</script>