| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- import { getState, setState } from '@/store/modules/vuexStorange'
- import { getSelfInfo } from '@/utils/auth'
- /** 员工用户信息 */
- const state = {
- selfInfo: null,
- user: null,
- shopUser: null
- }
- const getters = {
- // 员工用户信息
- getSelfInfo: (state) => {
- getState(state, 'selfInfo', 'selfInfo')
- // if (state.selfInfo) return state.selfInfo
- // let data = {}
- // getSelfInfo().then(res => {
- // data = res
- // })
- // return data
- return state.selfInfo
- },
- // 用户信息
- getUser: (state) => {
- getState(state, 'user', 'userInfo')
- return state.user
- },
- // 商城用户信息
- getShopUser: (state) => {
- getState(state, 'shopUser', 'shopUser')
- return state.shopUser
- }
- }
- const actions = {
- // 员工用户信息
- setSelfInfo({
- commit,
- dispatch,
- getters,
- rootGetters,
- rootState,
- state
- }, userInfo) {
- commit('SET_BASIC_USER', userInfo)
- },
- delSelfInfo({
- commit,
- dispatch,
- getters,
- rootGetters,
- rootState,
- state
- }) {
- commit('DEL_BASIC_USER')
- },
- // 后台管理用户信息
- setUser({
- commit,
- dispatch,
- getters,
- rootGetters,
- rootState,
- state
- }, userInfo) {
- commit('SET_USER', userInfo)
- },
- delUser({
- commit,
- dispatch,
- getters,
- rootGetters,
- rootState,
- state
- }) {
- commit('DEL_USER')
- },
- // 商城用户信息
- setShopUser({
- commit,
- dispatch,
- getters,
- rootGetters,
- rootState,
- state
- }, userInfo) {
- commit('SET_SHOP_USER', userInfo)
- },
- delShopUser({
- commit,
- dispatch,
- getters,
- rootGetters,
- rootState,
- state
- }) {
- commit('DEL_SHOP_USER')
- }
- }
- const mutations = {
- // 员工用户信息
- SET_BASIC_USER(state, userInfo = {}) {
- setState(state, userInfo, 'selfInfo', 'selfInfo')
- },
- DEL_BASIC_USER(state) {
- state.selfInfo = ''
- },
- // 后台管理用户信息
- SET_USER(state, userInfo = {}) {
- setState(state, userInfo, 'user', 'userInfo')
- },
- DEL_USER(state) {
- state.user = ''
- },
- // 商城用户信息
- SET_SHOP_USER(state, userInfo = {}) {
- setState(state, userInfo, 'shopUser', 'shopUser')
- },
- DEL_USER(state) {
- state.shopUser = ''
- }
- }
- export default {
- state,
- getters,
- actions,
- mutations
- }
|