jmash-core-mp 0.1.68 → 0.1.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/myorgan/index.d.ts +8 -0
- package/lib/api/myorgan/index.js +24 -0
- package/lib/api/shop/index.d.ts +2 -1
- package/lib/api/shop/index.js +11 -0
- package/lib/api/shop/types.d.ts +25 -7
- package/lib/store/organ.d.ts +9 -0
- package/lib/store/organ.js +50 -0
- package/lib/store/shop.d.ts +6 -2
- package/lib/store/shop.js +41 -0
- package/lib/store/user.d.ts +0 -2
- package/lib/store/user.js +1 -8
- package/lib/utils/db.d.ts +10 -3
- package/lib/utils/db.js +56 -10
- package/package.json +1 -1
- package/src/api/myorgan/index.ts +29 -0
- package/src/api/shop/index.ts +16 -0
- package/src/api/shop/types.ts +50 -14
- package/src/components/shop/shop-selected-item.mpx +5 -3
- package/src/store/organ.ts +59 -0
- package/src/store/shop.ts +54 -2
- package/src/store/user.ts +1 -10
- package/src/utils/db.ts +62 -12
- package/lib/app.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-activity-item.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-activity-list.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-article-item.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-article-list.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-article-view.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-article.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-like.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-location-list.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-location.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-product-item.mpx.d.ts +0 -1
- package/lib/components/cms/jmash-cms-product-list.mpx.d.ts +0 -1
- package/lib/components/common/jmash-none-data.mpx.d.ts +0 -1
- package/lib/components/common/jmash-stepper.mpx.d.ts +0 -1
- package/lib/components/common/jmash-top-navigation.mpx.d.ts +0 -1
- package/lib/components/organ/organ-search.mpx.d.ts +0 -1
- package/lib/components/shop/branch-search.mpx.d.ts +0 -1
- package/lib/components/shop/shop-search.mpx.d.ts +0 -1
- package/lib/packages/pages/cms/cms-activity-list.mpx.d.ts +0 -1
- package/lib/packages/pages/cms/cms-article-list.mpx.d.ts +0 -1
- package/lib/packages/pages/cms/cms-location-list.mpx.d.ts +0 -1
- package/lib/packages/pages/cms/cms-product-list.mpx.d.ts +0 -1
- package/lib/pages/branch-search.mpx.d.ts +0 -1
- package/lib/pages/organ-search.mpx.d.ts +0 -1
- package/lib/pages/shop-search.mpx.d.ts +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResponseData } from "../../api/types";
|
|
2
|
+
import type { RolesPerms, UserInfo } from "../auth/types";
|
|
3
|
+
declare class OrganUserApi {
|
|
4
|
+
userInfo(organTenant: string): Promise<ResponseData<UserInfo>>;
|
|
5
|
+
userRolesPerms(organTenant: string): Promise<ResponseData<RolesPerms>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const organUserApi: OrganUserApi;
|
|
8
|
+
export {};
|
package/lib/api/myorgan/index.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import mpx from "@mpxjs/core";
|
|
2
|
+
class OrganUserApi {
|
|
3
|
+
// 获取当前会话用户
|
|
4
|
+
userInfo(organTenant) {
|
|
5
|
+
const config = getApp().globalData.config;
|
|
6
|
+
organTenant = organTenant || config.tenant;
|
|
7
|
+
return mpx.xfetch.fetch({
|
|
8
|
+
url: "/v1/rbac/auth/user?tenant=" + organTenant,
|
|
9
|
+
method: "GET",
|
|
10
|
+
header: { "Grpc-Metadata-Tenant": organTenant },
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
// 当前用户角色权限
|
|
14
|
+
userRolesPerms(organTenant) {
|
|
15
|
+
const config = getApp().globalData.config;
|
|
16
|
+
organTenant = organTenant || config.tenant;
|
|
17
|
+
return mpx.xfetch.fetch({
|
|
18
|
+
url: "/v1/rbac/auth/roles_perms?tenant=" + organTenant,
|
|
19
|
+
method: "GET",
|
|
20
|
+
header: { "Grpc-Metadata-Tenant": organTenant },
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export const organUserApi = new OrganUserApi();
|
package/lib/api/shop/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ResponseData } from "../../api/types";
|
|
2
|
-
import { BranchPage, BranchPageReq, ShopInfoModel, BranchModel, ShopPage, ShopPageReq } from "./types";
|
|
2
|
+
import { BranchPage, BranchPageReq, ShopInfoModel, BranchModel, ShopPage, ShopPageReq, ShopBranchsUsersModel } from "./types";
|
|
3
3
|
declare class ShopApiImpl {
|
|
4
4
|
findShopBranchPage(data: BranchPageReq): Promise<ResponseData<BranchPage>>;
|
|
5
5
|
findShopPage(data: ShopPageReq): Promise<ResponseData<ShopPage>>;
|
|
6
6
|
findShopInfoById(shopId: string): Promise<ResponseData<ShopInfoModel>>;
|
|
7
7
|
findShopBranchById(organTenant: string, branchId: string): Promise<ResponseData<BranchModel>>;
|
|
8
|
+
findMyShopBranchUser(organTenant: string, branchId: string): Promise<ResponseData<ShopBranchsUsersModel>>;
|
|
8
9
|
}
|
|
9
10
|
declare const shopApi: ShopApiImpl;
|
|
10
11
|
export { shopApi };
|
package/lib/api/shop/index.js
CHANGED
|
@@ -35,6 +35,17 @@ class ShopApiImpl {
|
|
|
35
35
|
return mpx.xfetch.fetch({
|
|
36
36
|
url: "/v1/front/shop/branch/id/" + organTenant + "/" + branchId,
|
|
37
37
|
method: "GET",
|
|
38
|
+
header: { "Grpc-Metadata-Tenant": organTenant },
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
// 查询门店用户
|
|
42
|
+
findMyShopBranchUser(organTenant, branchId) {
|
|
43
|
+
const config = getApp().globalData.config;
|
|
44
|
+
organTenant = organTenant || config.tenant;
|
|
45
|
+
return mpx.xfetch.fetch({
|
|
46
|
+
url: "/v1/front/shop/branchs_users/my/" + organTenant + "/" + branchId,
|
|
47
|
+
method: "GET",
|
|
48
|
+
header: { "Grpc-Metadata-Tenant": organTenant },
|
|
38
49
|
});
|
|
39
50
|
}
|
|
40
51
|
}
|
package/lib/api/shop/types.d.ts
CHANGED
|
@@ -14,17 +14,10 @@ export interface ShopInfoModel {
|
|
|
14
14
|
latitude?: string;
|
|
15
15
|
note?: string;
|
|
16
16
|
businessPicUrl?: string;
|
|
17
|
-
idCard?: string;
|
|
18
|
-
idCardIns?: string;
|
|
19
|
-
mchName?: string;
|
|
20
|
-
bankName?: string;
|
|
21
|
-
bankCode?: string;
|
|
22
|
-
bankCodeIns?: string;
|
|
23
17
|
status?: boolean;
|
|
24
18
|
businessId?: string;
|
|
25
19
|
regionCode?: string;
|
|
26
20
|
adPics?: string;
|
|
27
|
-
accountName?: string;
|
|
28
21
|
organId?: string;
|
|
29
22
|
organTenant?: string;
|
|
30
23
|
createBy?: string;
|
|
@@ -77,6 +70,10 @@ export interface BranchModel {
|
|
|
77
70
|
distanceMeter?: string;
|
|
78
71
|
organTenant?: string;
|
|
79
72
|
}
|
|
73
|
+
export interface BranchKey {
|
|
74
|
+
tenant?: string;
|
|
75
|
+
branchId?: string;
|
|
76
|
+
}
|
|
80
77
|
export interface BranchPageReq {
|
|
81
78
|
tenant?: string;
|
|
82
79
|
curPage?: number;
|
|
@@ -103,3 +100,24 @@ export interface BranchPage {
|
|
|
103
100
|
totalSize: number;
|
|
104
101
|
pageCount: number;
|
|
105
102
|
}
|
|
103
|
+
export interface ShopBranchsUsersModel {
|
|
104
|
+
tenantId?: string;
|
|
105
|
+
userId?: string;
|
|
106
|
+
shopBranchId?: string;
|
|
107
|
+
realName?: string;
|
|
108
|
+
nickName?: string;
|
|
109
|
+
headImage?: string;
|
|
110
|
+
mobilePhone?: string;
|
|
111
|
+
mobilePhoneIns?: string;
|
|
112
|
+
parentId?: string;
|
|
113
|
+
parentBranchId?: string;
|
|
114
|
+
invitationCode?: string;
|
|
115
|
+
invitationNum?: number;
|
|
116
|
+
status?: boolean;
|
|
117
|
+
createBy?: string;
|
|
118
|
+
createTime?: string;
|
|
119
|
+
updateBy?: string;
|
|
120
|
+
updateTime?: string;
|
|
121
|
+
isLeader?: boolean;
|
|
122
|
+
regionCode?: string;
|
|
123
|
+
}
|
package/lib/store/organ.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { StorageOrganInfoModel } from "../api/storage/types";
|
|
2
|
+
import { UserInfo, RolesPerms } from "../api/auth/types";
|
|
2
3
|
interface OrganState {
|
|
3
4
|
organTenant: string;
|
|
4
5
|
organInfo: StorageOrganInfoModel;
|
|
6
|
+
organUserInfo: UserInfo;
|
|
7
|
+
organRoleCodes: string[];
|
|
8
|
+
organPermCodes: string[];
|
|
9
|
+
isSales: boolean;
|
|
5
10
|
}
|
|
6
11
|
export declare const useOrganStore: import("@mpxjs/pinia").StoreDefinition<"organ", OrganState, {}, {
|
|
12
|
+
clearOrganUser(): void;
|
|
7
13
|
setOrganInfo(data: StorageOrganInfoModel): void;
|
|
8
14
|
setOrganTenant(organTenant: string): Promise<boolean>;
|
|
15
|
+
getOrganUserInfo(): Promise<UserInfo>;
|
|
16
|
+
getOrganUserRolesPerms(): Promise<RolesPerms>;
|
|
17
|
+
setSales(isSales: boolean): void;
|
|
9
18
|
}>;
|
|
10
19
|
export {};
|
package/lib/store/organ.js
CHANGED
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { defineStore } from "@mpxjs/pinia";
|
|
2
2
|
import { storageApi } from "../api/storage";
|
|
3
3
|
import { db } from "../utils/db";
|
|
4
|
+
import { organUserApi } from "../api/myorgan";
|
|
4
5
|
export const useOrganStore = defineStore("organ", {
|
|
5
6
|
state: () => ({
|
|
6
7
|
organTenant: db.getOrganTenant() || "",
|
|
7
8
|
organInfo: db.getOrganInfo() || {},
|
|
9
|
+
//用户信息
|
|
10
|
+
organUserInfo: db.getOrganUserInfo() || {},
|
|
11
|
+
// 角色编码
|
|
12
|
+
organRoleCodes: db.getOrganRoleCodes() || [],
|
|
13
|
+
// 权限编码
|
|
14
|
+
organPermCodes: db.getOrganPermCodes() || [],
|
|
15
|
+
// 是否销售员
|
|
16
|
+
isSales: db.getOrganSales() || false,
|
|
8
17
|
}),
|
|
9
18
|
actions: {
|
|
19
|
+
clearOrganUser() {
|
|
20
|
+
this.organUserInfo = {};
|
|
21
|
+
this.organRoleCodes = [];
|
|
22
|
+
this.organPermCodes = [];
|
|
23
|
+
this.isSales = false;
|
|
24
|
+
db.setOrganUserInfo({});
|
|
25
|
+
db.setOrganRoleCodes([]);
|
|
26
|
+
db.setOrganPermCodes([]);
|
|
27
|
+
db.setOrganSales(false);
|
|
28
|
+
},
|
|
10
29
|
//设置组织信息.
|
|
11
30
|
setOrganInfo(data) {
|
|
12
31
|
this.organInfo = data;
|
|
13
32
|
this.organTenant = data.organTenant || "";
|
|
33
|
+
this.clearOrganUser();
|
|
14
34
|
db.setOrganInfo(data);
|
|
15
35
|
db.setOrganTenant(data.organTenant || "");
|
|
16
36
|
},
|
|
@@ -18,6 +38,7 @@ export const useOrganStore = defineStore("organ", {
|
|
|
18
38
|
setOrganTenant(organTenant) {
|
|
19
39
|
this.organTenant = organTenant;
|
|
20
40
|
db.setOrganTenant(organTenant);
|
|
41
|
+
this.clearOrganUser();
|
|
21
42
|
return storageApi.findOrganTenant().then((res) => {
|
|
22
43
|
if (res.statusCode === 200) {
|
|
23
44
|
this.organInfo = res.data;
|
|
@@ -29,5 +50,34 @@ export const useOrganStore = defineStore("organ", {
|
|
|
29
50
|
}
|
|
30
51
|
});
|
|
31
52
|
},
|
|
53
|
+
// 获取组织用户信息
|
|
54
|
+
getOrganUserInfo() {
|
|
55
|
+
// 无缓存请求接口
|
|
56
|
+
return organUserApi
|
|
57
|
+
.userInfo(this.organTenant)
|
|
58
|
+
.then((resp) => {
|
|
59
|
+
this.organUserInfo = resp.data;
|
|
60
|
+
db.setOrganUserInfo(resp.data);
|
|
61
|
+
return resp.data;
|
|
62
|
+
})
|
|
63
|
+
.catch(() => Promise.reject("获取组织用户信息错误!"));
|
|
64
|
+
},
|
|
65
|
+
// 获取组织用户角色权限
|
|
66
|
+
getOrganUserRolesPerms() {
|
|
67
|
+
// 无缓存请求接口
|
|
68
|
+
return organUserApi
|
|
69
|
+
.userRolesPerms(this.organTenant)
|
|
70
|
+
.then((resp) => {
|
|
71
|
+
this.organRoleCodes = resp.data.roleCodes || [];
|
|
72
|
+
this.organPermCodes = resp.data.permCodes || [];
|
|
73
|
+
return resp.data;
|
|
74
|
+
})
|
|
75
|
+
.catch(() => Promise.reject("获取组织用户角色权限错误!"));
|
|
76
|
+
},
|
|
77
|
+
// 设置销售员
|
|
78
|
+
setSales(isSales) {
|
|
79
|
+
this.isSales = isSales;
|
|
80
|
+
db.setOrganSales(isSales);
|
|
81
|
+
},
|
|
32
82
|
},
|
|
33
83
|
});
|
package/lib/store/shop.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import type { ShopInfoModel } from "../api/shop/types";
|
|
2
|
-
import type { BranchModel } from "../api/shop/types";
|
|
1
|
+
import type { ShopInfoModel, BranchModel, ShopBranchsUsersModel } from "../api/shop/types";
|
|
3
2
|
interface ShopState {
|
|
4
3
|
shopInfo: ShopInfoModel;
|
|
5
4
|
branchInfo: BranchModel;
|
|
6
5
|
isShop: boolean;
|
|
6
|
+
branchUser: ShopBranchsUsersModel;
|
|
7
|
+
isBranchManage: boolean;
|
|
8
|
+
isBranchEmployee: boolean;
|
|
7
9
|
}
|
|
8
10
|
export declare const useShopStore: import("@mpxjs/pinia").StoreDefinition<"shop", ShopState, {}, {
|
|
11
|
+
getMyBranchUserInfo(): Promise<ShopBranchsUsersModel>;
|
|
9
12
|
clearShop(): void;
|
|
13
|
+
clearBranchUser(): void;
|
|
10
14
|
switchShopBranch(shopInfo: ShopInfoModel, branchInfo: BranchModel): Promise<boolean>;
|
|
11
15
|
switchShop(shopInfo: ShopInfoModel): Promise<boolean>;
|
|
12
16
|
switchBranch(branchInfo: BranchModel): Promise<boolean>;
|
package/lib/store/shop.js
CHANGED
|
@@ -7,8 +7,34 @@ export const useShopStore = defineStore("shop", {
|
|
|
7
7
|
shopInfo: db.getShopInfo() || {},
|
|
8
8
|
branchInfo: db.getBranchInfo() || {},
|
|
9
9
|
isShop: db.getIsShop() || false,
|
|
10
|
+
//门店员工信息
|
|
11
|
+
branchUser: {},
|
|
12
|
+
//是否是门店店长
|
|
13
|
+
isBranchManage: false,
|
|
14
|
+
//是否是门店员工
|
|
15
|
+
isBranchEmployee: false,
|
|
10
16
|
}),
|
|
11
17
|
actions: {
|
|
18
|
+
// 获取我的门店用户信息
|
|
19
|
+
getMyBranchUserInfo() {
|
|
20
|
+
return shopApi
|
|
21
|
+
.findMyShopBranchUser(this.branchInfo.organTenant || "", this.branchInfo.branchId || "")
|
|
22
|
+
.then((resp) => {
|
|
23
|
+
if (resp.data.shopBranchId !== "") {
|
|
24
|
+
console.log("shopuser", resp.data);
|
|
25
|
+
this.branchUser = resp.data || {};
|
|
26
|
+
this.isBranchManage = resp.data.isLeader || false;
|
|
27
|
+
this.isBranchEmployee = true;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
console.log("empty", resp.data);
|
|
31
|
+
this.clearBranchUser();
|
|
32
|
+
}
|
|
33
|
+
return resp.data;
|
|
34
|
+
})
|
|
35
|
+
.catch(() => Promise.reject("获取我的门店用户信息错误!"));
|
|
36
|
+
},
|
|
37
|
+
// 清除商户门店
|
|
12
38
|
clearShop() {
|
|
13
39
|
this.shopInfo = {};
|
|
14
40
|
this.branchInfo = {};
|
|
@@ -16,11 +42,22 @@ export const useShopStore = defineStore("shop", {
|
|
|
16
42
|
db.removeBranchInfo();
|
|
17
43
|
db.removeShopInfo();
|
|
18
44
|
db.removeIsShop();
|
|
45
|
+
//清理门店用户
|
|
46
|
+
this.clearBranchUser();
|
|
47
|
+
},
|
|
48
|
+
// 清理门店用户
|
|
49
|
+
clearBranchUser() {
|
|
50
|
+
this.branchUser = {};
|
|
51
|
+
this.isBranchManage = false;
|
|
52
|
+
this.isBranchEmployee = false;
|
|
19
53
|
},
|
|
54
|
+
// 切换商户门店
|
|
20
55
|
switchShopBranch(shopInfo, branchInfo) {
|
|
21
56
|
this.shopInfo = shopInfo;
|
|
22
57
|
this.branchInfo = branchInfo;
|
|
23
58
|
this.isShop = false;
|
|
59
|
+
//清理门店用户
|
|
60
|
+
this.clearBranchUser();
|
|
24
61
|
// 切换商户门店
|
|
25
62
|
db.setShopInfo(shopInfo);
|
|
26
63
|
db.setBranchInfo(branchInfo);
|
|
@@ -33,6 +70,8 @@ export const useShopStore = defineStore("shop", {
|
|
|
33
70
|
this.shopInfo = shopInfo;
|
|
34
71
|
this.branchInfo = {};
|
|
35
72
|
this.isShop = true;
|
|
73
|
+
//清理门店用户
|
|
74
|
+
this.clearBranchUser();
|
|
36
75
|
// 切换商户
|
|
37
76
|
db.setShopInfo(shopInfo);
|
|
38
77
|
db.setBranchInfo({});
|
|
@@ -44,6 +83,8 @@ export const useShopStore = defineStore("shop", {
|
|
|
44
83
|
switchBranch(branchInfo) {
|
|
45
84
|
this.branchInfo = branchInfo;
|
|
46
85
|
this.isShop = false;
|
|
86
|
+
//清理门店用户
|
|
87
|
+
this.clearBranchUser();
|
|
47
88
|
// 切换门店
|
|
48
89
|
db.setBranchInfo(branchInfo);
|
|
49
90
|
db.setIsShop(false);
|
package/lib/store/user.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ interface UserState {
|
|
|
6
6
|
permCodes: string[];
|
|
7
7
|
accessToken: string;
|
|
8
8
|
expiresDate: number;
|
|
9
|
-
isSales: boolean;
|
|
10
9
|
referee: string;
|
|
11
10
|
}
|
|
12
11
|
export declare const useUserStore: import("@mpxjs/pinia").StoreDefinition<"user", UserState, {}, {
|
|
@@ -29,7 +28,6 @@ export declare const useUserStore: import("@mpxjs/pinia").StoreDefinition<"user"
|
|
|
29
28
|
setUserInfo(userInfo: UserInfo): void;
|
|
30
29
|
getRolePerm(cache?: boolean): Promise<RolesPerms>;
|
|
31
30
|
refreshToken(): Promise<boolean>;
|
|
32
|
-
setSales(isSales: boolean): void;
|
|
33
31
|
setReferee(referee: string): void;
|
|
34
32
|
}>;
|
|
35
33
|
export {};
|
package/lib/store/user.js
CHANGED
|
@@ -10,8 +10,6 @@ export const useUserStore = defineStore("user", {
|
|
|
10
10
|
permCodes: db.getPermCodes() || [],
|
|
11
11
|
accessToken: db.getToken() || "",
|
|
12
12
|
expiresDate: db.getTokenExpiresDate() || 0,
|
|
13
|
-
// 是否销售员
|
|
14
|
-
isSales: db.getSales() || false,
|
|
15
13
|
// 推荐人
|
|
16
14
|
referee: db.getReferee() || "",
|
|
17
15
|
}),
|
|
@@ -141,7 +139,7 @@ export const useUserStore = defineStore("user", {
|
|
|
141
139
|
},
|
|
142
140
|
// 退出登录,清空状态
|
|
143
141
|
logout() {
|
|
144
|
-
db.
|
|
142
|
+
db.removeLogin();
|
|
145
143
|
this.userInfo = {};
|
|
146
144
|
this.roleCodes = [];
|
|
147
145
|
this.permCodes = [];
|
|
@@ -226,11 +224,6 @@ export const useUserStore = defineStore("user", {
|
|
|
226
224
|
return true;
|
|
227
225
|
});
|
|
228
226
|
},
|
|
229
|
-
// 设置销售员
|
|
230
|
-
setSales(isSales) {
|
|
231
|
-
this.isSales = isSales;
|
|
232
|
-
db.setSales(isSales);
|
|
233
|
-
},
|
|
234
227
|
// 设置推荐人
|
|
235
228
|
setReferee(referee) {
|
|
236
229
|
this.referee = referee;
|
package/lib/utils/db.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ declare class LocalStorage {
|
|
|
9
9
|
removeRefreshToken(): void;
|
|
10
10
|
getTokenExpiresDate(): number;
|
|
11
11
|
setToken(data: TokenModel): void;
|
|
12
|
-
clearStorage(): void;
|
|
13
12
|
getBearerToken(): string;
|
|
14
13
|
getUserInfo(): any;
|
|
15
14
|
setUserInfo(data: UserInfo): void;
|
|
@@ -17,8 +16,8 @@ declare class LocalStorage {
|
|
|
17
16
|
setRoleCodes(codes: string[]): void;
|
|
18
17
|
getPermCodes(): any;
|
|
19
18
|
setPermCodes(codes: string[]): void;
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
removeLogin(): void;
|
|
20
|
+
clearStorage(): void;
|
|
22
21
|
/**
|
|
23
22
|
* 获取推荐人
|
|
24
23
|
*/
|
|
@@ -31,6 +30,14 @@ declare class LocalStorage {
|
|
|
31
30
|
setOrganTenant(organTenant: string): void;
|
|
32
31
|
getOrganInfo(): StorageOrganInfoModel;
|
|
33
32
|
setOrganInfo(data: StorageOrganInfoModel): void;
|
|
33
|
+
getOrganUserInfo(): any;
|
|
34
|
+
setOrganUserInfo(data: UserInfo): void;
|
|
35
|
+
getOrganRoleCodes(): any;
|
|
36
|
+
setOrganRoleCodes(codes: string[]): void;
|
|
37
|
+
getOrganPermCodes(): any;
|
|
38
|
+
setOrganPermCodes(codes: string[]): void;
|
|
39
|
+
getOrganSales(): boolean;
|
|
40
|
+
setOrganSales(isSales: boolean): void;
|
|
34
41
|
getShopInfo(): ShopInfoModel;
|
|
35
42
|
setShopInfo(data: ShopInfoModel): void;
|
|
36
43
|
getBranchInfo(): BranchModel;
|
package/lib/utils/db.js
CHANGED
|
@@ -39,10 +39,6 @@ class LocalStorage {
|
|
|
39
39
|
const expiresDate = new Date().getTime() + data.expiresIn * 1000;
|
|
40
40
|
mpx.setStorageSync("expiresDate", expiresDate);
|
|
41
41
|
}
|
|
42
|
-
// 清理本地缓存
|
|
43
|
-
clearStorage() {
|
|
44
|
-
mpx.clearStorage();
|
|
45
|
-
}
|
|
46
42
|
// 获取Bearer 格式请求Token
|
|
47
43
|
getBearerToken() {
|
|
48
44
|
const token = this.getToken();
|
|
@@ -75,13 +71,23 @@ class LocalStorage {
|
|
|
75
71
|
setPermCodes(codes) {
|
|
76
72
|
mpx.setStorageSync("permCodes", codes);
|
|
77
73
|
}
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
// 移除登录缓存信息
|
|
75
|
+
removeLogin() {
|
|
76
|
+
// 登录Token
|
|
77
|
+
mpx.removeStorageSync("token");
|
|
78
|
+
mpx.removeStorageSync("expiresIn");
|
|
79
|
+
mpx.removeStorageSync("refreshToken");
|
|
80
|
+
mpx.removeStorageSync("expiresDate");
|
|
81
|
+
// 用户信息
|
|
82
|
+
mpx.removeStorageSync("userInfo");
|
|
83
|
+
mpx.removeStorageSync("roleCodes");
|
|
84
|
+
mpx.removeStorageSync("permCodes");
|
|
85
|
+
mpx.removeStorageSync("isSales");
|
|
86
|
+
// 组织用户信息
|
|
81
87
|
}
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
mpx.
|
|
88
|
+
// 清理本地缓存
|
|
89
|
+
clearStorage() {
|
|
90
|
+
mpx.clearStorage();
|
|
85
91
|
}
|
|
86
92
|
/**
|
|
87
93
|
* 获取推荐人
|
|
@@ -115,6 +121,46 @@ class LocalStorage {
|
|
|
115
121
|
const config = getApp().globalData.config;
|
|
116
122
|
mpx.setStorageSync("OrganInfo:" + config.tenant, data);
|
|
117
123
|
}
|
|
124
|
+
// 获取用户信息
|
|
125
|
+
getOrganUserInfo() {
|
|
126
|
+
const config = getApp().globalData.config;
|
|
127
|
+
return mpx.getStorageSync("OrganUserInfo:" + config.tenant) || {};
|
|
128
|
+
}
|
|
129
|
+
// 设置用户信息
|
|
130
|
+
setOrganUserInfo(data) {
|
|
131
|
+
const config = getApp().globalData.config;
|
|
132
|
+
mpx.setStorageSync("OrganUserInfo:" + config.tenant, data);
|
|
133
|
+
}
|
|
134
|
+
// 获取角色列表
|
|
135
|
+
getOrganRoleCodes() {
|
|
136
|
+
const config = getApp().globalData.config;
|
|
137
|
+
return mpx.getStorageSync("OrganRoleCodes:" + config.tenant) || [];
|
|
138
|
+
}
|
|
139
|
+
// 设置角色列表
|
|
140
|
+
setOrganRoleCodes(codes) {
|
|
141
|
+
const config = getApp().globalData.config;
|
|
142
|
+
mpx.setStorageSync("OrganRoleCodes:" + config.tenant, codes);
|
|
143
|
+
}
|
|
144
|
+
// 获取权限列表
|
|
145
|
+
getOrganPermCodes() {
|
|
146
|
+
const config = getApp().globalData.config;
|
|
147
|
+
return mpx.getStorageSync("OrganPermCodes:" + config.tenant) || [];
|
|
148
|
+
}
|
|
149
|
+
// 设置权限列表
|
|
150
|
+
setOrganPermCodes(codes) {
|
|
151
|
+
const config = getApp().globalData.config;
|
|
152
|
+
mpx.setStorageSync("OrganPermCodes:" + config.tenant, codes);
|
|
153
|
+
}
|
|
154
|
+
// 用户是否销售员
|
|
155
|
+
getOrganSales() {
|
|
156
|
+
const config = getApp().globalData.config;
|
|
157
|
+
return mpx.getStorageSync("OrganSales:" + config.tenant) || false;
|
|
158
|
+
}
|
|
159
|
+
// 设置销售员
|
|
160
|
+
setOrganSales(isSales) {
|
|
161
|
+
const config = getApp().globalData.config;
|
|
162
|
+
mpx.setStorageSync("OrganSales:" + config.tenant, isSales);
|
|
163
|
+
}
|
|
118
164
|
// 获取商铺信息
|
|
119
165
|
getShopInfo() {
|
|
120
166
|
return mpx.getStorageSync("shopInfo");
|
package/package.json
CHANGED
package/src/api/myorgan/index.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ResponseData } from "../../api/types";
|
|
2
|
+
import type { RolesPerms, UserInfo } from "../auth/types";
|
|
3
|
+
import mpx from "@mpxjs/core";
|
|
4
|
+
|
|
5
|
+
class OrganUserApi {
|
|
6
|
+
// 获取当前会话用户
|
|
7
|
+
userInfo(organTenant: string): Promise<ResponseData<UserInfo>> {
|
|
8
|
+
const config = getApp().globalData.config;
|
|
9
|
+
organTenant = organTenant || config.tenant;
|
|
10
|
+
return mpx.xfetch.fetch({
|
|
11
|
+
url: "/v1/rbac/auth/user?tenant=" + organTenant,
|
|
12
|
+
method: "GET",
|
|
13
|
+
header: { "Grpc-Metadata-Tenant": organTenant },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 当前用户角色权限
|
|
18
|
+
userRolesPerms(organTenant: string): Promise<ResponseData<RolesPerms>> {
|
|
19
|
+
const config = getApp().globalData.config;
|
|
20
|
+
organTenant = organTenant || config.tenant;
|
|
21
|
+
return mpx.xfetch.fetch({
|
|
22
|
+
url: "/v1/rbac/auth/roles_perms?tenant=" + organTenant,
|
|
23
|
+
method: "GET",
|
|
24
|
+
header: { "Grpc-Metadata-Tenant": organTenant },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const organUserApi = new OrganUserApi();
|
package/src/api/shop/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
BranchModel,
|
|
8
8
|
ShopPage,
|
|
9
9
|
ShopPageReq,
|
|
10
|
+
ShopBranchsUsersModel,
|
|
10
11
|
} from "./types";
|
|
11
12
|
|
|
12
13
|
class ShopApiImpl {
|
|
@@ -50,6 +51,21 @@ class ShopApiImpl {
|
|
|
50
51
|
return mpx.xfetch.fetch({
|
|
51
52
|
url: "/v1/front/shop/branch/id/" + organTenant + "/" + branchId,
|
|
52
53
|
method: "GET",
|
|
54
|
+
header: { "Grpc-Metadata-Tenant": organTenant },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 查询门店用户
|
|
59
|
+
findMyShopBranchUser(
|
|
60
|
+
organTenant: string,
|
|
61
|
+
branchId: string
|
|
62
|
+
): Promise<ResponseData<ShopBranchsUsersModel>> {
|
|
63
|
+
const config = getApp().globalData.config;
|
|
64
|
+
organTenant = organTenant || config.tenant;
|
|
65
|
+
return mpx.xfetch.fetch({
|
|
66
|
+
url: "/v1/front/shop/branchs_users/my/" + organTenant + "/" + branchId,
|
|
67
|
+
method: "GET",
|
|
68
|
+
header: { "Grpc-Metadata-Tenant": organTenant },
|
|
53
69
|
});
|
|
54
70
|
}
|
|
55
71
|
}
|
package/src/api/shop/types.ts
CHANGED
|
@@ -30,18 +30,6 @@ export interface ShopInfoModel {
|
|
|
30
30
|
note?: string;
|
|
31
31
|
// 营业执照
|
|
32
32
|
businessPicUrl?: string;
|
|
33
|
-
// 法人身份证
|
|
34
|
-
idCard?: string;
|
|
35
|
-
// 法人身份证脱敏
|
|
36
|
-
idCardIns?: string;
|
|
37
|
-
// 商户名称
|
|
38
|
-
mchName?: string;
|
|
39
|
-
// 开户行
|
|
40
|
-
bankName?: string;
|
|
41
|
-
// 银行账号
|
|
42
|
-
bankCode?: string;
|
|
43
|
-
// 银行账号脱敏
|
|
44
|
-
bankCodeIns?: string;
|
|
45
33
|
// 状态
|
|
46
34
|
status?: boolean;
|
|
47
35
|
// 商户ID
|
|
@@ -50,8 +38,6 @@ export interface ShopInfoModel {
|
|
|
50
38
|
regionCode?: string;
|
|
51
39
|
// 店铺广告位图片
|
|
52
40
|
adPics?: string;
|
|
53
|
-
// 账号名称
|
|
54
|
-
accountName?: string;
|
|
55
41
|
// 组织ID
|
|
56
42
|
organId?: string;
|
|
57
43
|
// 组织租户
|
|
@@ -155,6 +141,14 @@ export interface BranchModel {
|
|
|
155
141
|
organTenant?: string;
|
|
156
142
|
}
|
|
157
143
|
|
|
144
|
+
// 门店用户查询实体
|
|
145
|
+
export interface BranchKey {
|
|
146
|
+
// 租户
|
|
147
|
+
tenant?: string;
|
|
148
|
+
// 门店ID
|
|
149
|
+
branchId?: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
158
152
|
// 门店管理查询
|
|
159
153
|
export interface BranchPageReq {
|
|
160
154
|
// 租户
|
|
@@ -206,3 +200,45 @@ export interface BranchPage {
|
|
|
206
200
|
// 总页数
|
|
207
201
|
pageCount: number;
|
|
208
202
|
}
|
|
203
|
+
|
|
204
|
+
// 门店用户关系实体
|
|
205
|
+
export interface ShopBranchsUsersModel {
|
|
206
|
+
// 租户ID
|
|
207
|
+
tenantId?: string;
|
|
208
|
+
// 用户ID
|
|
209
|
+
userId?: string;
|
|
210
|
+
// 门店ID
|
|
211
|
+
shopBranchId?: string;
|
|
212
|
+
// 姓名
|
|
213
|
+
realName?: string;
|
|
214
|
+
// 昵称
|
|
215
|
+
nickName?: string;
|
|
216
|
+
// 头像
|
|
217
|
+
headImage?: string;
|
|
218
|
+
// 联系电话
|
|
219
|
+
mobilePhone?: string;
|
|
220
|
+
// 联系电话脱敏
|
|
221
|
+
mobilePhoneIns?: string;
|
|
222
|
+
// 上级(总部店长)
|
|
223
|
+
parentId?: string;
|
|
224
|
+
// 上级门店(总部)
|
|
225
|
+
parentBranchId?: string;
|
|
226
|
+
// 邀请码
|
|
227
|
+
invitationCode?: string;
|
|
228
|
+
// 邀请人数
|
|
229
|
+
invitationNum?: number;
|
|
230
|
+
// 状态(可用、禁用)
|
|
231
|
+
status?: boolean;
|
|
232
|
+
// 创建人
|
|
233
|
+
createBy?: string;
|
|
234
|
+
// 创建时间
|
|
235
|
+
createTime?: string;
|
|
236
|
+
// 更新人
|
|
237
|
+
updateBy?: string;
|
|
238
|
+
// 更新时间
|
|
239
|
+
updateTime?: string;
|
|
240
|
+
// 是否门店店长
|
|
241
|
+
isLeader?: boolean;
|
|
242
|
+
// 地区编码
|
|
243
|
+
regionCode?: string;
|
|
244
|
+
}
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
<text>{{ branchInfo.createTime || shopInfo.createTime }}</text>
|
|
15
15
|
</view>
|
|
16
16
|
<view>{{ branchInfo.note || shopInfo.note }}</view>
|
|
17
|
+
<view wx:if="{{ shopStore.isBranchManage || shopStore.isBranchEmployee }}">{{ shopStore.isBranchManage ?
|
|
18
|
+
'门店店长' : '门店员工' }}</view>
|
|
17
19
|
</view>
|
|
18
20
|
</view>
|
|
19
21
|
</template>
|
|
@@ -32,10 +34,10 @@ createComponent({
|
|
|
32
34
|
const shopStore = useShopStore();
|
|
33
35
|
let branchInfo = shopStore.branchInfo;
|
|
34
36
|
let shopInfo = shopStore.shopInfo;
|
|
35
|
-
|
|
37
|
+
//获取门店用户信息
|
|
38
|
+
shopStore.getMyBranchUserInfo();
|
|
39
|
+
return { resourceUrl, baseUrl, branchInfo, shopInfo, shopStore }
|
|
36
40
|
},
|
|
37
|
-
methods: {
|
|
38
|
-
}
|
|
39
41
|
})
|
|
40
42
|
</script>
|
|
41
43
|
|
package/src/store/organ.ts
CHANGED
|
@@ -2,24 +2,53 @@ import { defineStore } from "@mpxjs/pinia";
|
|
|
2
2
|
import { storageApi } from "../api/storage";
|
|
3
3
|
import { StorageOrganInfoModel } from "../api/storage/types";
|
|
4
4
|
import { db } from "../utils/db";
|
|
5
|
+
import { UserInfo, RolesPerms } from "../api/auth/types";
|
|
6
|
+
import { organUserApi } from "../api/myorgan";
|
|
5
7
|
|
|
6
8
|
interface OrganState {
|
|
7
9
|
//组织租户
|
|
8
10
|
organTenant: string;
|
|
9
11
|
//组织信息
|
|
10
12
|
organInfo: StorageOrganInfoModel;
|
|
13
|
+
//用户信息
|
|
14
|
+
organUserInfo: UserInfo;
|
|
15
|
+
// 角色编码
|
|
16
|
+
organRoleCodes: string[];
|
|
17
|
+
// 权限编码
|
|
18
|
+
organPermCodes: string[];
|
|
19
|
+
// 是否销售员
|
|
20
|
+
isSales: boolean;
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
export const useOrganStore = defineStore("organ", {
|
|
14
24
|
state: (): OrganState => ({
|
|
15
25
|
organTenant: db.getOrganTenant() || "",
|
|
16
26
|
organInfo: db.getOrganInfo() || {},
|
|
27
|
+
//用户信息
|
|
28
|
+
organUserInfo: db.getOrganUserInfo() || {},
|
|
29
|
+
// 角色编码
|
|
30
|
+
organRoleCodes: db.getOrganRoleCodes() || [],
|
|
31
|
+
// 权限编码
|
|
32
|
+
organPermCodes: db.getOrganPermCodes() || [],
|
|
33
|
+
// 是否销售员
|
|
34
|
+
isSales: db.getOrganSales() || false,
|
|
17
35
|
}),
|
|
18
36
|
actions: {
|
|
37
|
+
clearOrganUser() {
|
|
38
|
+
this.organUserInfo = {} as UserInfo;
|
|
39
|
+
this.organRoleCodes = [];
|
|
40
|
+
this.organPermCodes = [];
|
|
41
|
+
this.isSales = false;
|
|
42
|
+
db.setOrganUserInfo({} as UserInfo);
|
|
43
|
+
db.setOrganRoleCodes([]);
|
|
44
|
+
db.setOrganPermCodes([]);
|
|
45
|
+
db.setOrganSales(false);
|
|
46
|
+
},
|
|
19
47
|
//设置组织信息.
|
|
20
48
|
setOrganInfo(data: StorageOrganInfoModel) {
|
|
21
49
|
this.organInfo = data;
|
|
22
50
|
this.organTenant = data.organTenant || "";
|
|
51
|
+
this.clearOrganUser();
|
|
23
52
|
db.setOrganInfo(data);
|
|
24
53
|
db.setOrganTenant(data.organTenant || "");
|
|
25
54
|
},
|
|
@@ -27,6 +56,7 @@ export const useOrganStore = defineStore("organ", {
|
|
|
27
56
|
setOrganTenant(organTenant: string): Promise<boolean> {
|
|
28
57
|
this.organTenant = organTenant;
|
|
29
58
|
db.setOrganTenant(organTenant);
|
|
59
|
+
this.clearOrganUser();
|
|
30
60
|
return storageApi.findOrganTenant().then((res) => {
|
|
31
61
|
if (res.statusCode === 200) {
|
|
32
62
|
this.organInfo = res.data;
|
|
@@ -37,5 +67,34 @@ export const useOrganStore = defineStore("organ", {
|
|
|
37
67
|
}
|
|
38
68
|
});
|
|
39
69
|
},
|
|
70
|
+
// 获取组织用户信息
|
|
71
|
+
getOrganUserInfo(): Promise<UserInfo> {
|
|
72
|
+
// 无缓存请求接口
|
|
73
|
+
return organUserApi
|
|
74
|
+
.userInfo(this.organTenant)
|
|
75
|
+
.then((resp) => {
|
|
76
|
+
this.organUserInfo = resp.data;
|
|
77
|
+
db.setOrganUserInfo(resp.data);
|
|
78
|
+
return resp.data;
|
|
79
|
+
})
|
|
80
|
+
.catch(() => Promise.reject("获取组织用户信息错误!"));
|
|
81
|
+
},
|
|
82
|
+
// 获取组织用户角色权限
|
|
83
|
+
getOrganUserRolesPerms(): Promise<RolesPerms> {
|
|
84
|
+
// 无缓存请求接口
|
|
85
|
+
return organUserApi
|
|
86
|
+
.userRolesPerms(this.organTenant)
|
|
87
|
+
.then((resp) => {
|
|
88
|
+
this.organRoleCodes = resp.data.roleCodes || [];
|
|
89
|
+
this.organPermCodes = resp.data.permCodes || [];
|
|
90
|
+
return resp.data;
|
|
91
|
+
})
|
|
92
|
+
.catch(() => Promise.reject("获取组织用户角色权限错误!"));
|
|
93
|
+
},
|
|
94
|
+
// 设置销售员
|
|
95
|
+
setSales(isSales: boolean): void {
|
|
96
|
+
this.isSales = isSales;
|
|
97
|
+
db.setOrganSales(isSales);
|
|
98
|
+
},
|
|
40
99
|
},
|
|
41
100
|
});
|
package/src/store/shop.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { defineStore } from "@mpxjs/pinia";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
ShopInfoModel,
|
|
4
|
+
BranchModel,
|
|
5
|
+
ShopBranchsUsersModel,
|
|
6
|
+
} from "../api/shop/types";
|
|
4
7
|
import { db } from "../utils/db";
|
|
5
8
|
import { useOrganStore } from "./organ";
|
|
6
9
|
import { shopApi } from "../api/shop/index";
|
|
@@ -13,6 +16,12 @@ interface ShopState {
|
|
|
13
16
|
branchInfo: BranchModel;
|
|
14
17
|
//是否是商户
|
|
15
18
|
isShop: boolean;
|
|
19
|
+
//门店员工信息
|
|
20
|
+
branchUser: ShopBranchsUsersModel;
|
|
21
|
+
//是否是门店店长
|
|
22
|
+
isBranchManage: boolean;
|
|
23
|
+
//是否是门店员工
|
|
24
|
+
isBranchEmployee: boolean;
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
export const useShopStore = defineStore("shop", {
|
|
@@ -20,8 +29,36 @@ export const useShopStore = defineStore("shop", {
|
|
|
20
29
|
shopInfo: db.getShopInfo() || {},
|
|
21
30
|
branchInfo: db.getBranchInfo() || {},
|
|
22
31
|
isShop: db.getIsShop() || false,
|
|
32
|
+
//门店员工信息
|
|
33
|
+
branchUser: {} as ShopBranchsUsersModel,
|
|
34
|
+
//是否是门店店长
|
|
35
|
+
isBranchManage: false,
|
|
36
|
+
//是否是门店员工
|
|
37
|
+
isBranchEmployee: false,
|
|
23
38
|
}),
|
|
24
39
|
actions: {
|
|
40
|
+
// 获取我的门店用户信息
|
|
41
|
+
getMyBranchUserInfo(): Promise<ShopBranchsUsersModel> {
|
|
42
|
+
return shopApi
|
|
43
|
+
.findMyShopBranchUser(
|
|
44
|
+
this.branchInfo.organTenant || "",
|
|
45
|
+
this.branchInfo.branchId || ""
|
|
46
|
+
)
|
|
47
|
+
.then((resp) => {
|
|
48
|
+
if (resp.data.shopBranchId !== "") {
|
|
49
|
+
console.log("shopuser", resp.data);
|
|
50
|
+
this.branchUser = resp.data || {};
|
|
51
|
+
this.isBranchManage = resp.data.isLeader || false;
|
|
52
|
+
this.isBranchEmployee = true;
|
|
53
|
+
} else {
|
|
54
|
+
console.log("empty", resp.data);
|
|
55
|
+
this.clearBranchUser();
|
|
56
|
+
}
|
|
57
|
+
return resp.data;
|
|
58
|
+
})
|
|
59
|
+
.catch(() => Promise.reject("获取我的门店用户信息错误!"));
|
|
60
|
+
},
|
|
61
|
+
// 清除商户门店
|
|
25
62
|
clearShop() {
|
|
26
63
|
this.shopInfo = {};
|
|
27
64
|
this.branchInfo = {};
|
|
@@ -29,7 +66,16 @@ export const useShopStore = defineStore("shop", {
|
|
|
29
66
|
db.removeBranchInfo();
|
|
30
67
|
db.removeShopInfo();
|
|
31
68
|
db.removeIsShop();
|
|
69
|
+
//清理门店用户
|
|
70
|
+
this.clearBranchUser();
|
|
71
|
+
},
|
|
72
|
+
// 清理门店用户
|
|
73
|
+
clearBranchUser() {
|
|
74
|
+
this.branchUser = {};
|
|
75
|
+
this.isBranchManage = false;
|
|
76
|
+
this.isBranchEmployee = false;
|
|
32
77
|
},
|
|
78
|
+
// 切换商户门店
|
|
33
79
|
switchShopBranch(
|
|
34
80
|
shopInfo: ShopInfoModel,
|
|
35
81
|
branchInfo: BranchModel
|
|
@@ -37,6 +83,8 @@ export const useShopStore = defineStore("shop", {
|
|
|
37
83
|
this.shopInfo = shopInfo;
|
|
38
84
|
this.branchInfo = branchInfo;
|
|
39
85
|
this.isShop = false;
|
|
86
|
+
//清理门店用户
|
|
87
|
+
this.clearBranchUser();
|
|
40
88
|
// 切换商户门店
|
|
41
89
|
db.setShopInfo(shopInfo);
|
|
42
90
|
db.setBranchInfo(branchInfo);
|
|
@@ -49,6 +97,8 @@ export const useShopStore = defineStore("shop", {
|
|
|
49
97
|
this.shopInfo = shopInfo;
|
|
50
98
|
this.branchInfo = {};
|
|
51
99
|
this.isShop = true;
|
|
100
|
+
//清理门店用户
|
|
101
|
+
this.clearBranchUser();
|
|
52
102
|
// 切换商户
|
|
53
103
|
db.setShopInfo(shopInfo);
|
|
54
104
|
db.setBranchInfo({});
|
|
@@ -60,6 +110,8 @@ export const useShopStore = defineStore("shop", {
|
|
|
60
110
|
switchBranch(branchInfo: BranchModel): Promise<boolean> {
|
|
61
111
|
this.branchInfo = branchInfo;
|
|
62
112
|
this.isShop = false;
|
|
113
|
+
//清理门店用户
|
|
114
|
+
this.clearBranchUser();
|
|
63
115
|
// 切换门店
|
|
64
116
|
db.setBranchInfo(branchInfo);
|
|
65
117
|
db.setIsShop(false);
|
package/src/store/user.ts
CHANGED
|
@@ -25,8 +25,6 @@ interface UserState {
|
|
|
25
25
|
accessToken: string;
|
|
26
26
|
//Token过期时间
|
|
27
27
|
expiresDate: number;
|
|
28
|
-
// 是否销售员
|
|
29
|
-
isSales: boolean;
|
|
30
28
|
// 推荐人
|
|
31
29
|
referee: string;
|
|
32
30
|
}
|
|
@@ -38,8 +36,6 @@ export const useUserStore = defineStore("user", {
|
|
|
38
36
|
permCodes: (db.getPermCodes() as string[]) || [],
|
|
39
37
|
accessToken: (db.getToken() as string) || "",
|
|
40
38
|
expiresDate: (db.getTokenExpiresDate() as number) || 0,
|
|
41
|
-
// 是否销售员
|
|
42
|
-
isSales: db.getSales() || false,
|
|
43
39
|
// 推荐人
|
|
44
40
|
referee: db.getReferee() || "",
|
|
45
41
|
}),
|
|
@@ -182,7 +178,7 @@ export const useUserStore = defineStore("user", {
|
|
|
182
178
|
},
|
|
183
179
|
// 退出登录,清空状态
|
|
184
180
|
logout() {
|
|
185
|
-
db.
|
|
181
|
+
db.removeLogin();
|
|
186
182
|
this.userInfo = {} as UserInfo;
|
|
187
183
|
this.roleCodes = [];
|
|
188
184
|
this.permCodes = [];
|
|
@@ -273,11 +269,6 @@ export const useUserStore = defineStore("user", {
|
|
|
273
269
|
return true;
|
|
274
270
|
});
|
|
275
271
|
},
|
|
276
|
-
// 设置销售员
|
|
277
|
-
setSales(isSales: boolean): void {
|
|
278
|
-
this.isSales = isSales;
|
|
279
|
-
db.setSales(isSales);
|
|
280
|
-
},
|
|
281
272
|
// 设置推荐人
|
|
282
273
|
setReferee(referee: string): void {
|
|
283
274
|
this.referee = referee;
|
package/src/utils/db.ts
CHANGED
|
@@ -49,11 +49,6 @@ class LocalStorage {
|
|
|
49
49
|
mpx.setStorageSync("expiresDate", expiresDate);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// 清理本地缓存
|
|
53
|
-
clearStorage(): void {
|
|
54
|
-
mpx.clearStorage();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
52
|
// 获取Bearer 格式请求Token
|
|
58
53
|
getBearerToken(): string {
|
|
59
54
|
const token = this.getToken();
|
|
@@ -93,15 +88,25 @@ class LocalStorage {
|
|
|
93
88
|
mpx.setStorageSync("permCodes", codes);
|
|
94
89
|
}
|
|
95
90
|
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
mpx.
|
|
91
|
+
// 移除登录缓存信息
|
|
92
|
+
removeLogin() {
|
|
93
|
+
// 登录Token
|
|
94
|
+
mpx.removeStorageSync("token");
|
|
95
|
+
mpx.removeStorageSync("expiresIn");
|
|
96
|
+
mpx.removeStorageSync("refreshToken");
|
|
97
|
+
mpx.removeStorageSync("expiresDate");
|
|
98
|
+
// 用户信息
|
|
99
|
+
mpx.removeStorageSync("userInfo");
|
|
100
|
+
mpx.removeStorageSync("roleCodes");
|
|
101
|
+
mpx.removeStorageSync("permCodes");
|
|
102
|
+
mpx.removeStorageSync("isSales");
|
|
103
|
+
// 组织用户信息
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
// 清理本地缓存
|
|
107
|
+
clearStorage(): void {
|
|
108
|
+
mpx.clearStorage();
|
|
109
|
+
}
|
|
105
110
|
/**
|
|
106
111
|
* 获取推荐人
|
|
107
112
|
*/
|
|
@@ -135,6 +140,51 @@ class LocalStorage {
|
|
|
135
140
|
const config = getApp().globalData.config;
|
|
136
141
|
mpx.setStorageSync("OrganInfo:" + config.tenant, data);
|
|
137
142
|
}
|
|
143
|
+
// 获取用户信息
|
|
144
|
+
getOrganUserInfo() {
|
|
145
|
+
const config = getApp().globalData.config;
|
|
146
|
+
return mpx.getStorageSync("OrganUserInfo:" + config.tenant) || {};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 设置用户信息
|
|
150
|
+
setOrganUserInfo(data: UserInfo) {
|
|
151
|
+
const config = getApp().globalData.config;
|
|
152
|
+
mpx.setStorageSync("OrganUserInfo:" + config.tenant, data);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// 获取角色列表
|
|
156
|
+
getOrganRoleCodes() {
|
|
157
|
+
const config = getApp().globalData.config;
|
|
158
|
+
return mpx.getStorageSync("OrganRoleCodes:" + config.tenant) || [];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 设置角色列表
|
|
162
|
+
setOrganRoleCodes(codes: string[]) {
|
|
163
|
+
const config = getApp().globalData.config;
|
|
164
|
+
mpx.setStorageSync("OrganRoleCodes:" + config.tenant, codes);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// 获取权限列表
|
|
168
|
+
getOrganPermCodes() {
|
|
169
|
+
const config = getApp().globalData.config;
|
|
170
|
+
return mpx.getStorageSync("OrganPermCodes:" + config.tenant) || [];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 设置权限列表
|
|
174
|
+
setOrganPermCodes(codes: string[]) {
|
|
175
|
+
const config = getApp().globalData.config;
|
|
176
|
+
mpx.setStorageSync("OrganPermCodes:" + config.tenant, codes);
|
|
177
|
+
}
|
|
178
|
+
// 用户是否销售员
|
|
179
|
+
getOrganSales(): boolean {
|
|
180
|
+
const config = getApp().globalData.config;
|
|
181
|
+
return mpx.getStorageSync("OrganSales:" + config.tenant) || false;
|
|
182
|
+
}
|
|
183
|
+
// 设置销售员
|
|
184
|
+
setOrganSales(isSales: boolean): void {
|
|
185
|
+
const config = getApp().globalData.config;
|
|
186
|
+
mpx.setStorageSync("OrganSales:" + config.tenant, isSales);
|
|
187
|
+
}
|
|
138
188
|
|
|
139
189
|
// 获取商铺信息
|
|
140
190
|
getShopInfo(): ShopInfoModel {
|
package/lib/app.mpx.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|