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
668 B
36 lines
668 B
2 years ago
|
import { getUserWechatByUserId } from '@/api/user'
|
||
|
|
||
|
const state = {
|
||
|
userInfo: {}
|
||
|
}
|
||
|
const mutations = {
|
||
|
SET_USER_INFO(state, userInfo) {
|
||
|
state.userInfo = userInfo
|
||
|
}
|
||
|
}
|
||
|
const actions = {
|
||
|
// 设置是否注册
|
||
|
getUserInfo({ commit }) {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
if (Object.keys(state.userInfo).length) {
|
||
|
resolve()
|
||
|
}
|
||
|
getUserWechatByUserId({
|
||
|
token: localStorage.getItem('token')
|
||
|
})
|
||
|
.then(res => {
|
||
|
commit('SET_USER_INFO', res)
|
||
|
resolve()
|
||
|
})
|
||
|
.catch(error => {
|
||
|
reject(error)
|
||
|
})
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
export default {
|
||
|
state,
|
||
|
mutations,
|
||
|
actions
|
||
|
}
|