sl-express/project-wl-siji-uniapp-vue3/store/modules/user.js
shuhongfan cf5ac25c14 init
2023-09-04 16:40:17 +08:00

48 lines
904 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {
getUserInfo
} from '@/pages/api/user.js';
// 用户信息模块(局部模块)
export default {
namespaced: true, // 开启命名空间
state() {
return {
userBase: {}, // 用户信息
loacation:{},
token: '', //token
}
},
mutations: {
// 定义mutations用于同步修改状态
// 设置token
setToken(state, provider) {
state.token = provider;
uni.setStorageSync("token", provider);
},
// 设置用户信息
setUserInfo(state, provider) {
state.userBase = provider;
},
// 设置经纬度
setlLacation(state, provider) {
state.loacation = provider;
},
},
actions: {
// 获取用户信息
async GetUsersInfo({state,commit},payload) {
if (state.token !== '') {
await getUserInfo().then((res)=>{
// 存储用户信息
commit('setUserInfo',res.data)
}).catch((err)=>{
})
}
}
},
getters: {
}
}