yuxun-store
v2.0.5
Published
> TODO: description
Downloads
1
Readme
yuxun-store
誉讯网 存储
引用
对应版本:
[email protected]
重大更新--修改
userStore
引用方式
import Vue from "vue";
import Vuex from "vuex";
import $router from "@/config/router";
import {
getters,
appStore,
userStore,
publicStore,
EStoreActions,
EDictType,
} from "yuxun-store";
import gettersPrivate from "./modules/getters";
import { websiteUrl } from "yuxun-config";
import {
AddressGetProvinceAndCity,
ChangeCurrentEp,
DictDataGet,
GetMemberInfo,
MemberGetMyEpList,
} from "@/common/service/usercenter.service";
const modulesFiles = require.context("./modules/service", false, /\.(ts|js)$/);
const modules = modulesFiles
.keys()
.reduce((modules: any, modulePath: string) => {
const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, "$1");
const value = modulesFiles(modulePath);
modules[moduleName] = value.default;
return modules;
}, {});
Vue.use(Vuex);
const store = new Vuex.Store({
modules,
getters: Object.assign(getters, gettersPrivate) as any,
});
// 动态加载基础store
store.registerModule("app", appStore(store as any, $router) as any);
store.registerModule(
"user",
userStore({
$store: store as any,
$router: $router as any,
logoutCallback: () => {
window.location.href = `${websiteUrl.sk}/login?callback=${window.location.href}`;
},
}) as any
);
store.registerModule("public", publicStore(store as any, $router) as any);
/** 获取字典数据 */
export function dispatchDictData(type: EDictType) {
return store.dispatch(EStoreActions.GET_DICT_DATA, {
remote: DictDataGet,
type,
});
}
/** 获取地区数据 */
export function dispatchAddress() {
return store.dispatch(EStoreActions.GET_CITY, AddressGetProvinceAndCity);
}
/** 切换企业 */
export function dispatchChangeCurrentEp(epId: string) {
return store.dispatch(EStoreActions.CHANGE_CURRENT_EP, {
remote: ChangeCurrentEp,
epId,
});
}
/** 获取用户信息 */
export function dispatchSetMemberInfo() {
return store.dispatch(EStoreActions.SET_MEMBER_INFO, {
remoteMemberGetMyEpList: MemberGetMyEpList,
remoteGetMemberInfo: GetMemberInfo,
});
}
export default store;
获取当前用户已加入企业
usercenter.service.ts;
import {
IResponseMemberGetMyEpList,
IResponseGetMemberInfo,
} from "yuxun-store";
/**
* 基础资源 B端页面顶部使用 包含自己创建并通过审核、成功加入、并且关系为启用的企业 (Auth)
* @property { string } epId 企业Id
* @property { string } epName 企业名称
* @property { string } epCode 企业code
* @property { string } epCodePath 企业code路径
* @property { string } epNamePath 企业name路径
* @property { string } adminFlag 管理员标识 1管理员
* @property { string } defaultFlag 默认企业 1默认企业
* @property { string } audit 审核状态 101待审核,103审核不通过 ,104通过
* @property { string } firstId 企业Id
* @property { string } parentId 企业Id
*/
export function MemberGetMyEpList() {
return $http<Array<IResponseMemberGetMyEpList>>({
url: `${process.env.VUE_APP_API_USER_CENTER}/Member/GetMyEpList`,
method: "GET",
auth: true,
});
}
/**
* 用户登录后获取菜单权限企业
* @property { Array<IResponseGetMenuList> } menuList 菜单信息
* @property { Array<IResponseGetMenuList> } privilegeList 接口信息
* @property { Array<IResponseGetMenuList> } epList 企业信息
*/
export function GetMemberInfo(): Promise<IResponse<IResponseGetMemberInfo>> {
return $http<IResponseGetMemberInfo>({
url: `${process.env.VUE_APP_API_USER_CENTER}/member/GetMemberInfo`,
auth: true,
method: "GET",
});
}
切换当前企业
usercenter.service.ts;
/**
* 切换企业
* @param { string } epId 切换的企业id
*/
export function ChangeCurrentEp(epId: string) {
return $http<string>({
url: `${process.env.VUE_APP_API_USER_CENTER}/Member/ChangeCurrentEp`,
method: "POST",
auth: true,
params: {
epId,
},
});
}
获取省市
usercenter.service.ts;
/**
* 获取省市给企业管理员地区授权
* @property { string } code 地区code
* @property { string } name 地区名称
* @property { string } children? 地区子集
*/
export function AddressGetProvinceAndCity() {
return $http<Array<IResponseAddressGetProvinceAndCity>>({
url: `${process.env.VUE_APP_API_USER_CENTER}/Address/GetProvinceAndCity`,
method: "GET",
});
}
获取字典
/**
* 字典(枚举)列表
* @property { string } id 字典id
* @property { string } key 字典标签 如:男
* @property { string } value 字典值 如:1
* @property { string } parentId 父级id
* @property { 0 | 1 } defaultFlag 是否默认 0否 1是
*/
export function DictDataGet(dictType: EDictType) {
return $http<Array<IResponseDictDataGet>>({
url: `${process.env.VUE_APP_API_USER_CENTER}/DictData/Get`,
method: "GET",
auth: true,
params: {
dictType,
},
});
}