user.js 905 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const state = () => ({
  2. authUserId: '',
  3. userInfo: {},
  4. accessToken: '',
  5. appId: '',
  6. accountType: '',
  7. clubUserId: '',
  8. authId: '',
  9. })
  10. const mutations = {
  11. // 设置用户信息
  12. SET_USER_INFO(state, data) {
  13. state.userInfo = data
  14. state.clubUserId = data.clubUserId
  15. state.authId = data.authId
  16. state.accessToken = data.accessToken
  17. },
  18. // 设置appId
  19. SET_APPID(state, appId) {
  20. state.appId = appId
  21. },
  22. // 设置供应商id
  23. SET_AUTH_USER_ID(state, authUserId) {
  24. state.authUserId = authUserId
  25. },
  26. // 微信公众号状态
  27. SET_ACCOUNT_TYPE(state, accountType) {
  28. state.accountType = accountType
  29. },
  30. }
  31. const actions = {
  32. // 退出登录
  33. logout({ commit }) {
  34. commit('SET_USER_INFO', {})
  35. },
  36. // 用户登录
  37. login({ commit }, data) {
  38. commit('SET_USER_INFO', data)
  39. },
  40. }
  41. export default {
  42. namespaced: true,
  43. state,
  44. mutations,
  45. actions,
  46. }