You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
725 B
27 lines
725 B
export default {
|
|
// 类似 vue 的 data
|
|
state: {
|
|
userInfo: {
|
|
token: ""
|
|
}, //保存用户登录信息,
|
|
toPath: "", //要跳转过去的页面,
|
|
},
|
|
// 类似 vue 里的 mothods(同步方法)
|
|
mutations: {
|
|
//改变用户信息,自动保存到本地的COOKIE
|
|
changeUserInfo(state, data) {
|
|
state.userInfo = data;
|
|
uni.setStorageSync('userInfo', JSON.stringify(data))
|
|
},
|
|
changeLoginPath(state) {
|
|
var pages = getCurrentPages() //获取加载的页面
|
|
var currentPage = pages[pages.length - 1] //获取当前页面的对象
|
|
state.toPath = currentPage.$page.fullPath
|
|
if(state.toPath == '/pages/login/login') return;
|
|
// 登录
|
|
uni.navigateTo({
|
|
url: '/pages/login/login'
|
|
})
|
|
},
|
|
}
|
|
}
|
|
|