12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- const install = (Vue, vm) => {
- /**
- *是否登录
- */
- const isLogin=()=>{
- //没有token,就进行跳转登录
- const token = vm.vuex_token
- // console.log(vm.vuex_token.exp)
- const timeStamp = Math.round(new Date().getTime()/1000).toString();
- // console.log(timeStamp)
- if(timeStamp>vm.vuex_token.exp){
- // if(!token){
- //来自那个页面
- const currentPage = getCurrentPages().pop()
- //缓存当前页
- uni.setStorageSync('back_url',currentPage.route)
- //console.log(getCurrentPages())
-
- vm.$u.toast('Token失效,请重新登录')
- setTimeout(() => {
- vm.$u.route({
- type:'redirect',
- url: 'pages/auth/login',
- })
- }, 2500)
- return false
- }
- return true
- }
-
- //添加方法
- vm.$u.utils={
- isLogin,
-
-
- }
-
- }
-
- export default {
- install
- }
|