盐都小程序
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.

36 lines
893 B

1 year ago
export default {
// 类似 vue 的 data
state: {
location: {
lat: '',
lon: ''
},
userInfo: {
token: ""
}, //保存用户登录信息,
toPath: "", //要跳转过去的页面,
},
// 类似 vue 里的 mothods(同步方法)
mutations: {
//改变用户信息,自动保存到本地的COOKIE
changeUserInfo(state, data) {
state.userInfo = data;
uni.setStorageSync('userInfo', JSON.stringify(data))
},
changeLoationInfo(state, data) {
uni.setStorageSync('locationInfo', JSON.stringify(data))
state.location = 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'
})
},
}
}