user.js 803 B

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