jmash-core-mp 0.1.60 → 0.1.61
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/shop/index.d.ts +3 -2
- package/lib/api/shop/index.js +13 -3
- package/lib/api/shop/types.d.ts +20 -0
- package/lib/components/organ/organ-item.mpx.d.ts +1 -0
- package/lib/components/shop/branch-item.mpx.d.ts +1 -0
- package/lib/components/shop/branch-search.mpx.d.ts +1 -0
- package/lib/components/shop/shop-item.mpx.d.ts +1 -0
- package/lib/components/shop/shop-search.mpx.d.ts +1 -0
- package/lib/components/shop/shop-selected-item.mpx.d.ts +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/store/shop.d.ts +1 -0
- package/lib/store/shop.js +20 -5
- package/lib/utils/db.d.ts +3 -0
- package/lib/utils/db.js +12 -0
- package/package.json +1 -1
- package/src/api/shop/index.ts +20 -4
- package/src/api/shop/types.ts +39 -0
- package/src/components/organ/organ-item.mpx +3 -0
- package/src/components/shop/shop-item.mpx +14 -19
- package/src/components/shop/shop-search.mpx +15 -21
- package/src/index.ts +2 -0
- package/src/pages/tabbar/home.mpx +1 -1
- package/src/store/shop.ts +19 -5
- package/src/utils/db.ts +13 -0
package/lib/api/shop/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ResponseData } from "../../api/types";
|
|
2
|
-
import { BranchPage, BranchPageReq, ShopInfoModel } from "./types";
|
|
2
|
+
import { BranchPage, BranchPageReq, ShopInfoModel, ShopPage, ShopPageReq } from "./types";
|
|
3
3
|
declare class ShopApiImpl {
|
|
4
4
|
findShopBranchPage(data: BranchPageReq): Promise<ResponseData<BranchPage>>;
|
|
5
|
-
|
|
5
|
+
findShopPage(data: ShopPageReq): Promise<ResponseData<ShopPage>>;
|
|
6
|
+
findShopInfoById(shopId: string): Promise<ResponseData<ShopInfoModel>>;
|
|
6
7
|
}
|
|
7
8
|
declare const shopApi: ShopApiImpl;
|
|
8
9
|
export { shopApi };
|
package/lib/api/shop/index.js
CHANGED
|
@@ -11,10 +11,20 @@ class ShopApiImpl {
|
|
|
11
11
|
header: { Authorization: false },
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
//
|
|
15
|
-
|
|
14
|
+
// 查询分页信息电商管理
|
|
15
|
+
findShopPage(data) {
|
|
16
|
+
const config = getApp().globalData.config;
|
|
17
|
+
return mpx.xfetch.fetch({
|
|
18
|
+
url: "/v1/shop/info/page/" + config.tenant,
|
|
19
|
+
method: "GET",
|
|
20
|
+
data: data,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// 查询电商管理
|
|
24
|
+
findShopInfoById(shopId) {
|
|
25
|
+
const config = getApp().globalData.config;
|
|
16
26
|
return mpx.xfetch.fetch({
|
|
17
|
-
url: "/v1/front/shop/info/
|
|
27
|
+
url: "/v1/front/shop/info/id/" + config.tenant + "/" + shopId,
|
|
18
28
|
method: "GET",
|
|
19
29
|
});
|
|
20
30
|
}
|
package/lib/api/shop/types.d.ts
CHANGED
|
@@ -30,6 +30,26 @@ export interface ShopInfoModel {
|
|
|
30
30
|
createBy?: string;
|
|
31
31
|
createTime?: string;
|
|
32
32
|
}
|
|
33
|
+
export interface ShopPageReq {
|
|
34
|
+
curPage?: number;
|
|
35
|
+
pageSize?: number;
|
|
36
|
+
orderName?: string;
|
|
37
|
+
orderAsc?: boolean;
|
|
38
|
+
likeShopName?: string;
|
|
39
|
+
hasStatus?: boolean;
|
|
40
|
+
status?: boolean;
|
|
41
|
+
shopName?: string;
|
|
42
|
+
organId?: string;
|
|
43
|
+
sceneId?: string;
|
|
44
|
+
excludeSceneId?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ShopPage {
|
|
47
|
+
results: Array<ShopInfoModel>;
|
|
48
|
+
curPage: number;
|
|
49
|
+
pageSize: number;
|
|
50
|
+
totalSize: number;
|
|
51
|
+
pageCount: number;
|
|
52
|
+
}
|
|
33
53
|
export interface BranchModel {
|
|
34
54
|
tenantId?: string;
|
|
35
55
|
branchId?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { EntryDict, EnumDict, EntryLayDict, CustomBizDict } from "./api/dicts";
|
|
|
6
6
|
export type { FileInfo, FileBase64Req, FileDownInfo, FileWebReq, } from "./api/files/types";
|
|
7
7
|
export type { DictRegionList, DictRegionReq, DictRegionModel, } from "./api/region/types";
|
|
8
8
|
export type { StorageOrganInfoReq, StorageOrganInfoList, StorageOrganInfoModel, ShopBrowserUserList, ShopBrowserUserModel, StorageOrganBrowserUpdateReq, StorageOrganBrowserModel, } from "./api/storage/types";
|
|
9
|
-
export type { ShopInfoModel, BranchModel, BranchPageReq, BranchPage, } from "./api/shop/types";
|
|
9
|
+
export type { ShopInfoModel, BranchModel, BranchPageReq, BranchPage, ShopPageReq, ShopPage, } from "./api/shop/types";
|
|
10
10
|
export { mpxFetch } from "./utils/request";
|
|
11
11
|
export { config, initConfig, setConfig } from "./utils/config";
|
|
12
12
|
export { grpc } from "./utils/grpc";
|
package/lib/store/shop.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ interface ShopState {
|
|
|
6
6
|
isShop: boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare const useShopStore: import("@mpxjs/pinia").StoreDefinition<"shop", ShopState, {}, {
|
|
9
|
+
clearShop(): void;
|
|
9
10
|
switchShopBranch(shopInfo: ShopInfoModel, branchInfo: BranchModel): Promise<boolean>;
|
|
10
11
|
switchShop(shopInfo: ShopInfoModel): Promise<boolean>;
|
|
11
12
|
switchBranch(branchInfo: BranchModel): Promise<boolean>;
|
package/lib/store/shop.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineStore } from "@mpxjs/pinia";
|
|
2
2
|
import { db } from "../utils/db";
|
|
3
3
|
import { useOrganStore } from "./organ";
|
|
4
|
+
import { shopApi } from "../api/shop/index";
|
|
4
5
|
export const useShopStore = defineStore("shop", {
|
|
5
6
|
state: () => ({
|
|
6
7
|
shopInfo: db.getShopInfo() || {},
|
|
@@ -8,7 +9,14 @@ export const useShopStore = defineStore("shop", {
|
|
|
8
9
|
isShop: db.getIsShop() || false,
|
|
9
10
|
}),
|
|
10
11
|
actions: {
|
|
11
|
-
|
|
12
|
+
clearShop() {
|
|
13
|
+
this.shopInfo = {};
|
|
14
|
+
this.branchInfo = {};
|
|
15
|
+
this.isShop = false;
|
|
16
|
+
db.removeBranchInfo();
|
|
17
|
+
db.removeShopInfo();
|
|
18
|
+
db.removeIsShop();
|
|
19
|
+
},
|
|
12
20
|
switchShopBranch(shopInfo, branchInfo) {
|
|
13
21
|
this.shopInfo = shopInfo;
|
|
14
22
|
this.branchInfo = branchInfo;
|
|
@@ -34,15 +42,22 @@ export const useShopStore = defineStore("shop", {
|
|
|
34
42
|
},
|
|
35
43
|
// 切换门店
|
|
36
44
|
switchBranch(branchInfo) {
|
|
37
|
-
this.shopInfo = {};
|
|
38
45
|
this.branchInfo = branchInfo;
|
|
39
46
|
this.isShop = false;
|
|
40
47
|
// 切换门店
|
|
41
|
-
db.setShopInfo({});
|
|
42
48
|
db.setBranchInfo(branchInfo);
|
|
43
49
|
db.setIsShop(false);
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
return shopApi.findShopInfoById(branchInfo.shopId || "").then((res) => {
|
|
51
|
+
if (res.statusCode === 200) {
|
|
52
|
+
this.shopInfo = res.data || {};
|
|
53
|
+
db.setShopInfo(this.shopInfo);
|
|
54
|
+
const organStore = useOrganStore();
|
|
55
|
+
return organStore.setOrganTenant(branchInfo.organTenant || "");
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return Promise.resolve(false);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
46
61
|
},
|
|
47
62
|
},
|
|
48
63
|
});
|
package/lib/utils/db.d.ts
CHANGED
|
@@ -37,6 +37,9 @@ declare class LocalStorage {
|
|
|
37
37
|
setBranchInfo(data: BranchModel): void;
|
|
38
38
|
getIsShop(): boolean;
|
|
39
39
|
setIsShop(isShop: boolean): void;
|
|
40
|
+
removeShopInfo(): void;
|
|
41
|
+
removeBranchInfo(): void;
|
|
42
|
+
removeIsShop(): void;
|
|
40
43
|
}
|
|
41
44
|
declare const db: LocalStorage;
|
|
42
45
|
export { db };
|
package/lib/utils/db.js
CHANGED
|
@@ -139,6 +139,18 @@ class LocalStorage {
|
|
|
139
139
|
setIsShop(isShop) {
|
|
140
140
|
mpx.setStorageSync("isShop", isShop);
|
|
141
141
|
}
|
|
142
|
+
// 删除商铺信息
|
|
143
|
+
removeShopInfo() {
|
|
144
|
+
mpx.removeStorageSync("shopInfo");
|
|
145
|
+
}
|
|
146
|
+
// 删除门店信息
|
|
147
|
+
removeBranchInfo() {
|
|
148
|
+
mpx.removeStorageSync("branchInfo");
|
|
149
|
+
}
|
|
150
|
+
// 删除是否是商户
|
|
151
|
+
removeIsShop() {
|
|
152
|
+
mpx.removeStorageSync("isShop");
|
|
153
|
+
}
|
|
142
154
|
}
|
|
143
155
|
const db = new LocalStorage();
|
|
144
156
|
export { db };
|
package/package.json
CHANGED
package/src/api/shop/index.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import mpx from "@mpxjs/core";
|
|
2
2
|
import { ResponseData } from "../../api/types";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
BranchPage,
|
|
5
|
+
BranchPageReq,
|
|
6
|
+
ShopInfoModel,
|
|
7
|
+
ShopPage,
|
|
8
|
+
ShopPageReq,
|
|
9
|
+
} from "./types";
|
|
4
10
|
|
|
5
11
|
class ShopApiImpl {
|
|
6
12
|
// 查询分页信息门店管理
|
|
@@ -14,11 +20,21 @@ class ShopApiImpl {
|
|
|
14
20
|
header: { Authorization: false },
|
|
15
21
|
});
|
|
16
22
|
}
|
|
23
|
+
// 查询分页信息电商管理
|
|
24
|
+
findShopPage(data: ShopPageReq): Promise<ResponseData<ShopPage>> {
|
|
25
|
+
const config = getApp().globalData.config;
|
|
26
|
+
return mpx.xfetch.fetch({
|
|
27
|
+
url: "/v1/shop/info/page/" + config.tenant,
|
|
28
|
+
method: "GET",
|
|
29
|
+
data: data,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
17
32
|
|
|
18
|
-
//
|
|
19
|
-
findShopInfoById(
|
|
33
|
+
// 查询电商管理
|
|
34
|
+
findShopInfoById(shopId: string): Promise<ResponseData<ShopInfoModel>> {
|
|
35
|
+
const config = getApp().globalData.config;
|
|
20
36
|
return mpx.xfetch.fetch({
|
|
21
|
-
url: "/v1/front/shop/info/
|
|
37
|
+
url: "/v1/front/shop/info/id/" + config.tenant + "/" + shopId,
|
|
22
38
|
method: "GET",
|
|
23
39
|
});
|
|
24
40
|
}
|
package/src/api/shop/types.ts
CHANGED
|
@@ -62,6 +62,45 @@ export interface ShopInfoModel {
|
|
|
62
62
|
createTime?: string;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
export interface ShopPageReq {
|
|
66
|
+
// 当前页码
|
|
67
|
+
curPage?: number;
|
|
68
|
+
// 页尺寸
|
|
69
|
+
pageSize?: number;
|
|
70
|
+
// 排序名称
|
|
71
|
+
orderName?: string;
|
|
72
|
+
// 是否升序排序
|
|
73
|
+
orderAsc?: boolean;
|
|
74
|
+
//店铺名称模糊.
|
|
75
|
+
likeShopName?: string;
|
|
76
|
+
//是否包含状态
|
|
77
|
+
hasStatus?: boolean;
|
|
78
|
+
//状态
|
|
79
|
+
status?: boolean;
|
|
80
|
+
//店铺名称.
|
|
81
|
+
shopName?: string;
|
|
82
|
+
//组织ID.
|
|
83
|
+
organId?: string;
|
|
84
|
+
//场景ID.
|
|
85
|
+
sceneId?: string;
|
|
86
|
+
//不包含的场景ID.
|
|
87
|
+
excludeSceneId?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 电商管理分页
|
|
91
|
+
export interface ShopPage {
|
|
92
|
+
// 当前页内容
|
|
93
|
+
results: Array<ShopInfoModel>;
|
|
94
|
+
// 当前页码
|
|
95
|
+
curPage: number;
|
|
96
|
+
// 页尺寸
|
|
97
|
+
pageSize: number;
|
|
98
|
+
// 总记录数
|
|
99
|
+
totalSize: number;
|
|
100
|
+
// 总页数
|
|
101
|
+
pageCount: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
65
104
|
// 门店管理实体
|
|
66
105
|
export interface BranchModel {
|
|
67
106
|
// 租户ID
|
|
@@ -27,6 +27,7 @@ import type { EventBase } from "../../api/types";
|
|
|
27
27
|
import type { StorageOrganInfoModel } from "../../api/storage/types";
|
|
28
28
|
import { storageApi } from "../../api/storage/index";
|
|
29
29
|
import { useOrganStore } from "../../store/organ";
|
|
30
|
+
import { useShopStore } from "../../store/shop";
|
|
30
31
|
|
|
31
32
|
createComponent({
|
|
32
33
|
properties: {
|
|
@@ -57,9 +58,11 @@ createComponent({
|
|
|
57
58
|
requestId: Math.random() * 10 + "1",
|
|
58
59
|
};
|
|
59
60
|
const organStore = useOrganStore();
|
|
61
|
+
const shopStore = useShopStore();
|
|
60
62
|
storageApi.updateStorageOrganBrowser(tempData).then((res) => {
|
|
61
63
|
if (this.defaultClick) {
|
|
62
64
|
organStore.setOrganInfo(this.organInfo as StorageOrganInfoModel);
|
|
65
|
+
shopStore.clearShop();
|
|
63
66
|
mpx.reLaunch({
|
|
64
67
|
url: "/pages/tabbar/home"
|
|
65
68
|
});
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
* @events click 组织详情事件,参数为组织信息
|
|
6
6
|
*/
|
|
7
7
|
<template>
|
|
8
|
-
<view class="organ-item" data-id="{{
|
|
8
|
+
<view class="organ-item" data-id="{{ shopInfo.shopId }}" data-tenant="{{ shopInfo.organTenant }}"
|
|
9
9
|
bind:tap="handleInfo">
|
|
10
|
-
<image wx:if="{{ baseUrl &&
|
|
10
|
+
<image wx:if="{{ baseUrl && shopInfo.picUrl }}" class="organ-logo" src="{{ baseUrl + shopInfo.picUrl }}"
|
|
11
11
|
mode="aspectFit" />
|
|
12
|
-
<image wx:if="{{ resourceUrl && !
|
|
12
|
+
<image wx:if="{{ resourceUrl && !shopInfo.picUrl }}" class="organ-logo"
|
|
13
13
|
src="{{ resourceUrl + 'gray_logo_upload.png' }}" mode="aspectFit" />
|
|
14
14
|
<view class="organ-item-right">
|
|
15
15
|
<view class="organ-item-title">
|
|
16
|
-
<text class="organ-title-c">{{
|
|
17
|
-
<text>{{
|
|
16
|
+
<text class="organ-title-c">{{ shopInfo.shopName }}</text>
|
|
17
|
+
<text>{{ shopInfo.createTime }}</text>
|
|
18
18
|
</view>
|
|
19
|
-
<view>{{
|
|
19
|
+
<view>{{ shopInfo.remark }}</view>
|
|
20
20
|
</view>
|
|
21
21
|
</view>
|
|
22
22
|
</template>
|
|
@@ -25,12 +25,11 @@
|
|
|
25
25
|
import mpx, { createComponent } from "@mpxjs/core";
|
|
26
26
|
import type { EventBase } from "../../api/types";
|
|
27
27
|
import { useShopStore } from "../../store/shop";
|
|
28
|
-
import { shopApi } from "../../api/shop/index";
|
|
29
28
|
|
|
30
29
|
createComponent({
|
|
31
30
|
properties: {
|
|
32
|
-
//
|
|
33
|
-
|
|
31
|
+
// 电商信息
|
|
32
|
+
shopInfo: {
|
|
34
33
|
type: Object,
|
|
35
34
|
value: {}
|
|
36
35
|
},
|
|
@@ -50,19 +49,15 @@ createComponent({
|
|
|
50
49
|
methods: {
|
|
51
50
|
// 店铺详情
|
|
52
51
|
handleInfo(e: EventBase) {
|
|
53
|
-
console.log("
|
|
52
|
+
console.log("选择电商", this.shopInfo);
|
|
54
53
|
const shopStore = useShopStore();
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
mpx.reLaunch({
|
|
60
|
-
url: "/pages/tabbar/home"
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
this.triggerEvent("click", res.data);
|
|
54
|
+
shopStore.switchShop(this.shopInfo).then(() => {
|
|
55
|
+
if (this.defaultClick) {
|
|
56
|
+
mpx.reLaunch({
|
|
57
|
+
url: "/pages/tabbar/home"
|
|
64
58
|
});
|
|
65
59
|
}
|
|
60
|
+
this.triggerEvent("click", this.shopInfo);
|
|
66
61
|
});
|
|
67
62
|
}
|
|
68
63
|
}
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
<!-- 搜索框 -->
|
|
10
10
|
<view class="search-box">
|
|
11
11
|
<jmash-search placeholder="{{ placeholder }}" isSearchBtn="{{ true }}"
|
|
12
|
-
likeName="{{ queryParams.
|
|
13
|
-
<button class="search-right" bind:tap="
|
|
12
|
+
likeName="{{ queryParams.likeShopName }}" bind:handleSearch="searchEvent">
|
|
13
|
+
<button class="search-right" bind:tap="querySearchShopList">搜索</button>
|
|
14
14
|
</jmash-search>
|
|
15
15
|
</view>
|
|
16
16
|
<!-- 搜索店铺列表 -->
|
|
17
17
|
<scroll-view class="organ-content-h" scroll-y>
|
|
18
18
|
<view class="organ-content">
|
|
19
19
|
<view wx:if="{{ mySearchList.length > 0 }}">
|
|
20
|
-
<shop-item wx:for="{{ mySearchList }}" wx:key="index"
|
|
20
|
+
<shop-item wx:for="{{ mySearchList }}" wx:key="index" shopInfo="{{ item }}"
|
|
21
21
|
defaultClick="{{ defaultClick }}" bind:click="handleItemClick" />
|
|
22
22
|
</view>
|
|
23
23
|
<jmash-none-data wx:else imgUrl="/mall/no-data.png" content="暂无搜索内容" contentColor="#5A94F1" />
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
<script lang="ts">
|
|
30
30
|
import { createComponent, ref } from "@mpxjs/core";
|
|
31
31
|
import { formatDateTime } from "../../utils/common";
|
|
32
|
-
import type {
|
|
33
|
-
import {
|
|
32
|
+
import type { ShopInfoModel } from "../../api/shop/types";
|
|
33
|
+
import { shopApi } from "../../api/shop/index";
|
|
34
34
|
import type { EventBase } from "../../api/types";
|
|
35
35
|
|
|
36
36
|
createComponent({
|
|
@@ -43,12 +43,7 @@ createComponent({
|
|
|
43
43
|
// 搜索框占位符
|
|
44
44
|
placeholder: {
|
|
45
45
|
type: String,
|
|
46
|
-
value: "
|
|
47
|
-
},
|
|
48
|
-
// 服务类型
|
|
49
|
-
serviceType: {
|
|
50
|
-
type: String,
|
|
51
|
-
value: "mall"
|
|
46
|
+
value: "搜索电商"
|
|
52
47
|
},
|
|
53
48
|
// 是否默认点击跳转
|
|
54
49
|
defaultClick: {
|
|
@@ -59,15 +54,14 @@ createComponent({
|
|
|
59
54
|
setup(props) {
|
|
60
55
|
// 搜索参数
|
|
61
56
|
let queryParams = ref({
|
|
62
|
-
|
|
63
|
-
likeOrganName: "",
|
|
57
|
+
likeShopName: "",
|
|
64
58
|
});
|
|
65
59
|
// 搜索店铺列表
|
|
66
|
-
let mySearchList = ref([] as
|
|
60
|
+
let mySearchList = ref([] as ShopInfoModel[]);
|
|
67
61
|
|
|
68
62
|
// 搜索店铺列表
|
|
69
|
-
function
|
|
70
|
-
|
|
63
|
+
function querySearchShopList() {
|
|
64
|
+
shopApi.findShopPage(queryParams.value).then(({ data }) => {
|
|
71
65
|
data.results.forEach((item) => {
|
|
72
66
|
item.createTime = formatDateTime(item.createTime as string, "YYYY-MM-DD")
|
|
73
67
|
});
|
|
@@ -76,28 +70,28 @@ createComponent({
|
|
|
76
70
|
};
|
|
77
71
|
// 输入搜索关键字
|
|
78
72
|
function searchEvent(e: EventBase) {
|
|
79
|
-
queryParams.value.
|
|
73
|
+
queryParams.value.likeShopName = e.detail;
|
|
80
74
|
};
|
|
81
75
|
|
|
82
76
|
// 主动刷新列表(供外部调用)
|
|
83
77
|
function refresh() {
|
|
84
|
-
|
|
78
|
+
querySearchShopList();
|
|
85
79
|
};
|
|
86
80
|
|
|
87
81
|
// 初始化加载
|
|
88
|
-
|
|
82
|
+
querySearchShopList();
|
|
89
83
|
|
|
90
84
|
return {
|
|
91
85
|
queryParams,
|
|
92
86
|
mySearchList,
|
|
93
|
-
|
|
87
|
+
querySearchShopList,
|
|
94
88
|
searchEvent,
|
|
95
89
|
refresh,
|
|
96
90
|
}
|
|
97
91
|
},
|
|
98
92
|
methods: {
|
|
99
93
|
// 店铺点击事件,向上抛出 tenant
|
|
100
|
-
handleItemClick(item:
|
|
94
|
+
handleItemClick(item: ShopInfoModel) {
|
|
101
95
|
this.triggerEvent("click", item);
|
|
102
96
|
}
|
|
103
97
|
}
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ createPage({
|
|
|
17
17
|
id: 1,
|
|
18
18
|
items: [
|
|
19
19
|
{ key: 'organ', title: '选择组织', icon: '🏠', iconBg: '#409eff', path: '/pages/organ' },
|
|
20
|
-
{ key: 'shop', title: '
|
|
20
|
+
{ key: 'shop', title: '选择电商', icon: '🏠', iconBg: '#409eff', path: '/pages/shop-search' },
|
|
21
21
|
{ key: 'branch', title: '选择门店', icon: '🏠', iconBg: '#409eff', path: '/pages/branch-search' },
|
|
22
22
|
{ key: 'home', title: '主页(全屏登录检查)', icon: '🏠', iconBg: '#409eff', path: '/pages/home' },
|
|
23
23
|
{ key: 'home2', title: '主页(全屏登录)', icon: '🏠', iconBg: '#67c23a', path: '/pages/home2' },
|
package/src/store/shop.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ShopInfoModel } from "../api/shop/types";
|
|
|
3
3
|
import type { BranchModel } from "../api/shop/types";
|
|
4
4
|
import { db } from "../utils/db";
|
|
5
5
|
import { useOrganStore } from "./organ";
|
|
6
|
+
import { shopApi } from "../api/shop/index";
|
|
6
7
|
|
|
7
8
|
// 商户状态
|
|
8
9
|
interface ShopState {
|
|
@@ -21,7 +22,14 @@ export const useShopStore = defineStore("shop", {
|
|
|
21
22
|
isShop: db.getIsShop() || false,
|
|
22
23
|
}),
|
|
23
24
|
actions: {
|
|
24
|
-
|
|
25
|
+
clearShop() {
|
|
26
|
+
this.shopInfo = {};
|
|
27
|
+
this.branchInfo = {};
|
|
28
|
+
this.isShop = false;
|
|
29
|
+
db.removeBranchInfo();
|
|
30
|
+
db.removeShopInfo();
|
|
31
|
+
db.removeIsShop();
|
|
32
|
+
},
|
|
25
33
|
switchShopBranch(
|
|
26
34
|
shopInfo: ShopInfoModel,
|
|
27
35
|
branchInfo: BranchModel
|
|
@@ -50,15 +58,21 @@ export const useShopStore = defineStore("shop", {
|
|
|
50
58
|
},
|
|
51
59
|
// 切换门店
|
|
52
60
|
switchBranch(branchInfo: BranchModel): Promise<boolean> {
|
|
53
|
-
this.shopInfo = {};
|
|
54
61
|
this.branchInfo = branchInfo;
|
|
55
62
|
this.isShop = false;
|
|
56
63
|
// 切换门店
|
|
57
|
-
db.setShopInfo({});
|
|
58
64
|
db.setBranchInfo(branchInfo);
|
|
59
65
|
db.setIsShop(false);
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
return shopApi.findShopInfoById(branchInfo.shopId || "").then((res) => {
|
|
67
|
+
if (res.statusCode === 200) {
|
|
68
|
+
this.shopInfo = res.data || {};
|
|
69
|
+
db.setShopInfo(this.shopInfo);
|
|
70
|
+
const organStore = useOrganStore();
|
|
71
|
+
return organStore.setOrganTenant(branchInfo.organTenant || "");
|
|
72
|
+
} else {
|
|
73
|
+
return Promise.resolve(false);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
62
76
|
},
|
|
63
77
|
},
|
|
64
78
|
});
|
package/src/utils/db.ts
CHANGED
|
@@ -140,6 +140,7 @@ class LocalStorage {
|
|
|
140
140
|
getShopInfo(): ShopInfoModel {
|
|
141
141
|
return mpx.getStorageSync("shopInfo");
|
|
142
142
|
}
|
|
143
|
+
|
|
143
144
|
// 设置商铺信息
|
|
144
145
|
setShopInfo(data: ShopInfoModel) {
|
|
145
146
|
mpx.setStorageSync("shopInfo", data);
|
|
@@ -160,6 +161,18 @@ class LocalStorage {
|
|
|
160
161
|
setIsShop(isShop: boolean): void {
|
|
161
162
|
mpx.setStorageSync("isShop", isShop);
|
|
162
163
|
}
|
|
164
|
+
// 删除商铺信息
|
|
165
|
+
removeShopInfo() {
|
|
166
|
+
mpx.removeStorageSync("shopInfo");
|
|
167
|
+
}
|
|
168
|
+
// 删除门店信息
|
|
169
|
+
removeBranchInfo() {
|
|
170
|
+
mpx.removeStorageSync("branchInfo");
|
|
171
|
+
}
|
|
172
|
+
// 删除是否是商户
|
|
173
|
+
removeIsShop() {
|
|
174
|
+
mpx.removeStorageSync("isShop");
|
|
175
|
+
}
|
|
163
176
|
}
|
|
164
177
|
|
|
165
178
|
const db = new LocalStorage();
|