| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import { getMobileUserInfo } from '@/api/index';
- import { selectAllocationPermission } from '@/api/week';
- const user = {
- state: {
- userInfo: null,
- activaTypeStore: null,
- isAssignFlag: false, //是否有客资分配权限
- },
- mutations: {
- SET_USER_INFO: (state, userInfo) => {
- state.userInfo = userInfo;
- },
- SET_ACTIVA_TYPE_STORE: (state, value) => {
- state.activaTypeStore = value;
- },
- SET_ASSIGN_FLAG: (state, value) => {
- state.isAssignFlag = value;
- },
- },
- actions: {
- // 获取用户信息
- getUserInfo({ dispatch, commit, state }) {
- dispatch('getAssignPermission');
- return new Promise((resolve, reject) => {
- getMobileUserInfo()
- .then((res) => {
- commit('SET_USER_INFO', res.data);
- localStorage.setItem('nickName', res.data.nickName);
- localStorage.setItem('postName', res.data.postName);
- localStorage.setItem('zipPhoto', res.data.zipPhoto);
- localStorage.setItem('deptLevel', res.data.depts[0].deptLevel);
- localStorage.setItem('userId', res.data.userId);
- dispatch('getAssignPermission');
- resolve();
- })
- .catch((error) => {
- reject(error);
- });
- });
- },
- // 查询当前用户是否存在家装客资分配权限
- getAssignPermission({ commit }) {
- selectAllocationPermission()
- .then((res) => {
- console.log(res);
- commit('SET_ASSIGN_FLAG', res.data.isAllocationPermission);
- })
- .catch((error) => {
- console.log(error);
- });
- },
- // 储存提示类-未拜访-从那个店铺类型进入未拜访列表
- setActivaTypeStore({ commit }, value) {
- commit('SET_ACTIVA_TYPE_STORE', value);
- },
- },
- };
- export default user;
|