jmash-core-mp 0.1.53 → 0.1.54

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.
@@ -0,0 +1,22 @@
1
+ export interface ShopInfoModel {
2
+ shopId?: string;
3
+ shopName?: string;
4
+ address?: string;
5
+ picUrl?: string;
6
+ businessId?: string;
7
+ adPics?: string;
8
+ organTenant?: string;
9
+ organId?: string;
10
+ }
11
+ export interface BranchModel {
12
+ branchId?: string;
13
+ picUrl?: string;
14
+ facadeName?: string;
15
+ businessStartHour?: string;
16
+ businessEndHour?: string;
17
+ contacts?: string;
18
+ mobilePhone?: string;
19
+ address?: string;
20
+ longitude?: number;
21
+ latitude?: number;
22
+ }
@@ -0,0 +1 @@
1
+ export {};
package/lib/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export { grpc } from "./utils/grpc";
12
12
  export { db } from "./utils/db";
13
13
  export { useUserStore } from "./store/user";
14
14
  export { useOrganStore } from "./store/organ";
15
+ export { useShopStore } from "./store/shop";
15
16
  export { authApi } from "./api/auth";
16
17
  export { cmsApi } from "./api/cms";
17
18
  export { dictApi } from "./api/dict";
package/lib/index.js CHANGED
@@ -6,6 +6,7 @@ export { grpc } from "./utils/grpc";
6
6
  export { db } from "./utils/db";
7
7
  export { useUserStore } from "./store/user";
8
8
  export { useOrganStore } from "./store/organ";
9
+ export { useShopStore } from "./store/shop";
9
10
  export { authApi } from "./api/auth";
10
11
  export { cmsApi } from "./api/cms";
11
12
  export { dictApi } from "./api/dict";
@@ -0,0 +1,13 @@
1
+ import type { ShopInfoModel } from "../api/shop/types";
2
+ import type { BranchModel } from "../api/shop/types";
3
+ interface ShopState {
4
+ shopInfo: ShopInfoModel;
5
+ branchInfo: BranchModel;
6
+ isShop: boolean;
7
+ }
8
+ export declare const useShopStore: import("@mpxjs/pinia").StoreDefinition<"shop", ShopState, {}, {
9
+ switchShopBranch(shopInfo: ShopInfoModel, branchInfo: BranchModel): void;
10
+ switchShop(shopInfo: ShopInfoModel): void;
11
+ switchBranch(branchInfo: BranchModel): void;
12
+ }>;
13
+ export {};
@@ -0,0 +1,41 @@
1
+ import { defineStore } from "@mpxjs/pinia";
2
+ import { db } from "../utils/db";
3
+ export const useShopStore = defineStore("shop", {
4
+ state: () => ({
5
+ shopInfo: db.getShopInfo() || {},
6
+ branchInfo: db.getBranchInfo() || {},
7
+ isShop: db.getIsShop() || false,
8
+ }),
9
+ actions: {
10
+ // 切换商户门店
11
+ switchShopBranch(shopInfo, branchInfo) {
12
+ this.shopInfo = shopInfo;
13
+ this.branchInfo = branchInfo;
14
+ this.isShop = false;
15
+ // 切换商户门店
16
+ db.setShopInfo(shopInfo);
17
+ db.setBranchInfo(branchInfo);
18
+ db.setIsShop(false);
19
+ },
20
+ // 切换商户
21
+ switchShop(shopInfo) {
22
+ this.shopInfo = shopInfo;
23
+ this.branchInfo = {};
24
+ this.isShop = true;
25
+ // 切换商户
26
+ db.setShopInfo(shopInfo);
27
+ db.setBranchInfo({});
28
+ db.setIsShop(true);
29
+ },
30
+ // 切换门店
31
+ switchBranch(branchInfo) {
32
+ this.shopInfo = {};
33
+ this.branchInfo = branchInfo;
34
+ this.isShop = false;
35
+ // 切换门店
36
+ db.setShopInfo({});
37
+ db.setBranchInfo(branchInfo);
38
+ db.setIsShop(false);
39
+ },
40
+ },
41
+ });
package/lib/utils/db.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { TokenModel, UserInfo } from "../api/auth/types";
2
2
  import { StorageOrganInfoModel } from "../api/storage/types";
3
+ import { ShopInfoModel, BranchModel } from "../api/shop/types";
3
4
  declare class LocalStorage {
4
5
  getToken(): string;
5
6
  getUserTenant(): string;
@@ -30,6 +31,12 @@ declare class LocalStorage {
30
31
  setOrganTenant(organTenant: string): void;
31
32
  getOrganInfo(): StorageOrganInfoModel;
32
33
  setOrganInfo(data: StorageOrganInfoModel): void;
34
+ getShopInfo(): ShopInfoModel;
35
+ setShopInfo(data: ShopInfoModel): void;
36
+ getBranchInfo(): BranchModel;
37
+ setBranchInfo(data: BranchModel): void;
38
+ getIsShop(): boolean;
39
+ setIsShop(isShop: boolean): void;
33
40
  }
34
41
  declare const db: LocalStorage;
35
42
  export { db };
package/lib/utils/db.js CHANGED
@@ -113,6 +113,30 @@ class LocalStorage {
113
113
  setOrganInfo(data) {
114
114
  mpx.setStorageSync("organInfo", data);
115
115
  }
116
+ // 获取商铺信息
117
+ getShopInfo() {
118
+ return mpx.getStorageSync("shopInfo");
119
+ }
120
+ // 设置商铺信息
121
+ setShopInfo(data) {
122
+ mpx.setStorageSync("shopInfo", data);
123
+ }
124
+ // 获取门店信息
125
+ getBranchInfo() {
126
+ return mpx.getStorageSync("branchInfo");
127
+ }
128
+ // 设置门店信息
129
+ setBranchInfo(data) {
130
+ mpx.setStorageSync("branchInfo", data);
131
+ }
132
+ // 获取是否是商户
133
+ getIsShop() {
134
+ return mpx.getStorageSync("isShop");
135
+ }
136
+ // 设置是否是商户
137
+ setIsShop(isShop) {
138
+ mpx.setStorageSync("isShop", isShop);
139
+ }
116
140
  }
117
141
  const db = new LocalStorage();
118
142
  export { db };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.53",
3
+ "version": "0.1.54",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -0,0 +1,43 @@
1
+ // 店铺管理实体
2
+ export interface ShopInfoModel {
3
+ // 店铺ID
4
+ shopId?: string;
5
+ // 店铺名称
6
+ shopName?: string;
7
+ // 详细地址
8
+ address?: string;
9
+ // 店铺图片
10
+ picUrl?: string;
11
+ // 商户ID
12
+ businessId?: string;
13
+ // 宣传图
14
+ adPics?: string;
15
+ // 组织租户
16
+ organTenant?: string;
17
+ // 组织ID
18
+ organId?: string;
19
+ }
20
+
21
+ // 门店管理实体
22
+ export interface BranchModel {
23
+ // 门店ID
24
+ branchId?: string;
25
+ // 门店图片
26
+ picUrl?: string;
27
+ // 门店名称
28
+ facadeName?: string;
29
+ // 营业开始时间
30
+ businessStartHour?: string;
31
+ // 营业结束时间
32
+ businessEndHour?: string;
33
+ // 门店联系人
34
+ contacts?: string;
35
+ // 联系电话
36
+ mobilePhone?: string;
37
+ // 详细地址
38
+ address?: string;
39
+ // 经度
40
+ longitude?: number;
41
+ // 纬度
42
+ latitude?: number;
43
+ }
package/src/index.ts CHANGED
@@ -62,6 +62,7 @@ export { grpc } from "./utils/grpc";
62
62
  export { db } from "./utils/db";
63
63
  export { useUserStore } from "./store/user";
64
64
  export { useOrganStore } from "./store/organ";
65
+ export { useShopStore } from "./store/shop";
65
66
  export { authApi } from "./api/auth";
66
67
  export { cmsApi } from "./api/cms";
67
68
  export { dictApi } from "./api/dict";
@@ -0,0 +1,54 @@
1
+ import { defineStore } from "@mpxjs/pinia";
2
+ import type { ShopInfoModel } from "../api/shop/types";
3
+ import type { BranchModel } from "../api/shop/types";
4
+ import { db } from "../utils/db";
5
+
6
+ // 商户状态
7
+ interface ShopState {
8
+ //商户信息
9
+ shopInfo: ShopInfoModel;
10
+ //门店信息
11
+ branchInfo: BranchModel;
12
+ //是否是商户
13
+ isShop: boolean;
14
+ }
15
+
16
+ export const useShopStore = defineStore("shop", {
17
+ state: (): ShopState => ({
18
+ shopInfo: db.getShopInfo() || {},
19
+ branchInfo: db.getBranchInfo() || {},
20
+ isShop: db.getIsShop() || false,
21
+ }),
22
+ actions: {
23
+ // 切换商户门店
24
+ switchShopBranch(shopInfo: ShopInfoModel, branchInfo: BranchModel) {
25
+ this.shopInfo = shopInfo;
26
+ this.branchInfo = branchInfo;
27
+ this.isShop = false;
28
+ // 切换商户门店
29
+ db.setShopInfo(shopInfo);
30
+ db.setBranchInfo(branchInfo);
31
+ db.setIsShop(false);
32
+ },
33
+ // 切换商户
34
+ switchShop(shopInfo: ShopInfoModel) {
35
+ this.shopInfo = shopInfo;
36
+ this.branchInfo = {};
37
+ this.isShop = true;
38
+ // 切换商户
39
+ db.setShopInfo(shopInfo);
40
+ db.setBranchInfo({});
41
+ db.setIsShop(true);
42
+ },
43
+ // 切换门店
44
+ switchBranch(branchInfo: BranchModel) {
45
+ this.shopInfo = {};
46
+ this.branchInfo = branchInfo;
47
+ this.isShop = false;
48
+ // 切换门店
49
+ db.setShopInfo({});
50
+ db.setBranchInfo(branchInfo);
51
+ db.setIsShop(false);
52
+ },
53
+ },
54
+ });
package/src/utils/db.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import mpx from "@mpxjs/core";
2
2
  import type { TokenModel, UserInfo } from "../api/auth/types";
3
3
  import { StorageOrganInfoModel } from "../api/storage/types";
4
+ import { ShopInfoModel, BranchModel } from "../api/shop/types";
4
5
 
5
6
  // 本地存储
6
7
  class LocalStorage {
@@ -132,6 +133,31 @@ class LocalStorage {
132
133
  setOrganInfo(data: StorageOrganInfoModel) {
133
134
  mpx.setStorageSync("organInfo", data);
134
135
  }
136
+
137
+ // 获取商铺信息
138
+ getShopInfo(): ShopInfoModel {
139
+ return mpx.getStorageSync("shopInfo");
140
+ }
141
+ // 设置商铺信息
142
+ setShopInfo(data: ShopInfoModel) {
143
+ mpx.setStorageSync("shopInfo", data);
144
+ }
145
+ // 获取门店信息
146
+ getBranchInfo(): BranchModel {
147
+ return mpx.getStorageSync("branchInfo");
148
+ }
149
+ // 设置门店信息
150
+ setBranchInfo(data: BranchModel) {
151
+ mpx.setStorageSync("branchInfo", data);
152
+ }
153
+ // 获取是否是商户
154
+ getIsShop(): boolean {
155
+ return mpx.getStorageSync("isShop");
156
+ }
157
+ // 设置是否是商户
158
+ setIsShop(isShop: boolean): void {
159
+ mpx.setStorageSync("isShop", isShop);
160
+ }
135
161
  }
136
162
 
137
163
  const db = new LocalStorage();