jmash-core-mp 0.1.59 → 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 -1
- package/lib/api/shop/index.js +17 -0
- 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 +25 -1
- package/src/api/shop/types.ts +39 -0
- package/src/app.mpx +1 -0
- package/src/components/organ/organ-item.mpx +3 -0
- package/src/components/shop/branch-search.mpx +1 -1
- package/src/components/shop/shop-item.mpx +113 -0
- package/src/components/shop/shop-search.mpx +142 -0
- package/src/index.ts +2 -0
- package/src/pages/shop-search.mpx +60 -0
- package/src/pages/tabbar/home.mpx +2 -12
- package/src/store/shop.ts +19 -5
- package/src/utils/db.ts +13 -0
package/lib/api/shop/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ResponseData } from "../../api/types";
|
|
2
|
-
import { BranchPage, BranchPageReq } 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
|
+
findShopPage(data: ShopPageReq): Promise<ResponseData<ShopPage>>;
|
|
6
|
+
findShopInfoById(shopId: string): Promise<ResponseData<ShopInfoModel>>;
|
|
5
7
|
}
|
|
6
8
|
declare const shopApi: ShopApiImpl;
|
|
7
9
|
export { shopApi };
|
package/lib/api/shop/index.js
CHANGED
|
@@ -11,6 +11,23 @@ class ShopApiImpl {
|
|
|
11
11
|
header: { Authorization: false },
|
|
12
12
|
});
|
|
13
13
|
}
|
|
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;
|
|
26
|
+
return mpx.xfetch.fetch({
|
|
27
|
+
url: "/v1/front/shop/info/id/" + config.tenant + "/" + shopId,
|
|
28
|
+
method: "GET",
|
|
29
|
+
});
|
|
30
|
+
}
|
|
14
31
|
}
|
|
15
32
|
const shopApi = new ShopApiImpl();
|
|
16
33
|
export { shopApi };
|
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,6 +20,24 @@ 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
|
+
}
|
|
32
|
+
|
|
33
|
+
// 查询电商管理
|
|
34
|
+
findShopInfoById(shopId: string): Promise<ResponseData<ShopInfoModel>> {
|
|
35
|
+
const config = getApp().globalData.config;
|
|
36
|
+
return mpx.xfetch.fetch({
|
|
37
|
+
url: "/v1/front/shop/info/id/" + config.tenant + "/" + shopId,
|
|
38
|
+
method: "GET",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
17
41
|
}
|
|
18
42
|
|
|
19
43
|
const shopApi = new ShopApiImpl();
|
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
|
package/src/app.mpx
CHANGED
|
@@ -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
|
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 组织组件
|
|
3
|
+
* @props organInfo 组织信息
|
|
4
|
+
* @props defaultClick 是否默认点击跳转
|
|
5
|
+
* @events click 组织详情事件,参数为组织信息
|
|
6
|
+
*/
|
|
7
|
+
<template>
|
|
8
|
+
<view class="organ-item" data-id="{{ shopInfo.shopId }}" data-tenant="{{ shopInfo.organTenant }}"
|
|
9
|
+
bind:tap="handleInfo">
|
|
10
|
+
<image wx:if="{{ baseUrl && shopInfo.picUrl }}" class="organ-logo" src="{{ baseUrl + shopInfo.picUrl }}"
|
|
11
|
+
mode="aspectFit" />
|
|
12
|
+
<image wx:if="{{ resourceUrl && !shopInfo.picUrl }}" class="organ-logo"
|
|
13
|
+
src="{{ resourceUrl + 'gray_logo_upload.png' }}" mode="aspectFit" />
|
|
14
|
+
<view class="organ-item-right">
|
|
15
|
+
<view class="organ-item-title">
|
|
16
|
+
<text class="organ-title-c">{{ shopInfo.shopName }}</text>
|
|
17
|
+
<text>{{ shopInfo.createTime }}</text>
|
|
18
|
+
</view>
|
|
19
|
+
<view>{{ shopInfo.remark }}</view>
|
|
20
|
+
</view>
|
|
21
|
+
</view>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import mpx, { createComponent } from "@mpxjs/core";
|
|
26
|
+
import type { EventBase } from "../../api/types";
|
|
27
|
+
import { useShopStore } from "../../store/shop";
|
|
28
|
+
|
|
29
|
+
createComponent({
|
|
30
|
+
properties: {
|
|
31
|
+
// 电商信息
|
|
32
|
+
shopInfo: {
|
|
33
|
+
type: Object,
|
|
34
|
+
value: {}
|
|
35
|
+
},
|
|
36
|
+
defaultClick: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
value: true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
setup() {
|
|
42
|
+
const config = getApp().globalData.config;
|
|
43
|
+
// 资源路径
|
|
44
|
+
let resourceUrl = config.resourceUrl + "/images/components/";
|
|
45
|
+
// 图片路径
|
|
46
|
+
let baseUrl = config.baseUrl + "/v1/file/image/resize/100/100/";
|
|
47
|
+
return { resourceUrl, baseUrl }
|
|
48
|
+
},
|
|
49
|
+
methods: {
|
|
50
|
+
// 店铺详情
|
|
51
|
+
handleInfo(e: EventBase) {
|
|
52
|
+
console.log("选择电商", this.shopInfo);
|
|
53
|
+
const shopStore = useShopStore();
|
|
54
|
+
shopStore.switchShop(this.shopInfo).then(() => {
|
|
55
|
+
if (this.defaultClick) {
|
|
56
|
+
mpx.reLaunch({
|
|
57
|
+
url: "/pages/tabbar/home"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
this.triggerEvent("click", this.shopInfo);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<style lang="scss">
|
|
68
|
+
@use "../../styles/index.scss" as *;
|
|
69
|
+
|
|
70
|
+
.organ-item {
|
|
71
|
+
background-color: $white-color;
|
|
72
|
+
border-radius: $border-radius;
|
|
73
|
+
padding: 20rpx 30rpx;
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
gap: 20rpx;
|
|
77
|
+
margin-bottom: 20rpx;
|
|
78
|
+
box-shadow: 0 8rpx 24rpx 0 rgba(44, 19, 19, 0.08);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.organ-logo {
|
|
82
|
+
width: 80rpx;
|
|
83
|
+
height: 80rpx;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.organ-item-right {
|
|
87
|
+
width: 90%;
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
gap: 10rpx;
|
|
91
|
+
color: $font-color-grey;
|
|
92
|
+
font-size: $font-size-mini;
|
|
93
|
+
font-weight: 400;
|
|
94
|
+
|
|
95
|
+
.organ-item-title {
|
|
96
|
+
display: flex;
|
|
97
|
+
justify-content: space-between;
|
|
98
|
+
|
|
99
|
+
.organ-title-c {
|
|
100
|
+
color: $font-color;
|
|
101
|
+
font-size: $font-size;
|
|
102
|
+
font-weight: bold;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
</style>
|
|
107
|
+
|
|
108
|
+
<script type="application/json">
|
|
109
|
+
{
|
|
110
|
+
"component": true,
|
|
111
|
+
"usingComponents": {}
|
|
112
|
+
}
|
|
113
|
+
</script>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 店铺搜索组件
|
|
3
|
+
* @param top 顶部安全距离(px)Number 默认0
|
|
4
|
+
* @param placeholder 搜索框占位符 String 默认"搜索店铺"
|
|
5
|
+
* @events click 店铺点击事件,参数为当前店铺租户 tenant
|
|
6
|
+
*/
|
|
7
|
+
<template>
|
|
8
|
+
<view class="organ-main" style="margin-top: {{ top }}px; height: calc(100vh - 100px - {{ top }}px);">
|
|
9
|
+
<!-- 搜索框 -->
|
|
10
|
+
<view class="search-box">
|
|
11
|
+
<jmash-search placeholder="{{ placeholder }}" isSearchBtn="{{ true }}"
|
|
12
|
+
likeName="{{ queryParams.likeShopName }}" bind:handleSearch="searchEvent">
|
|
13
|
+
<button class="search-right" bind:tap="querySearchShopList">搜索</button>
|
|
14
|
+
</jmash-search>
|
|
15
|
+
</view>
|
|
16
|
+
<!-- 搜索店铺列表 -->
|
|
17
|
+
<scroll-view class="organ-content-h" scroll-y>
|
|
18
|
+
<view class="organ-content">
|
|
19
|
+
<view wx:if="{{ mySearchList.length > 0 }}">
|
|
20
|
+
<shop-item wx:for="{{ mySearchList }}" wx:key="index" shopInfo="{{ item }}"
|
|
21
|
+
defaultClick="{{ defaultClick }}" bind:click="handleItemClick" />
|
|
22
|
+
</view>
|
|
23
|
+
<jmash-none-data wx:else imgUrl="/mall/no-data.png" content="暂无搜索内容" contentColor="#5A94F1" />
|
|
24
|
+
</view>
|
|
25
|
+
</scroll-view>
|
|
26
|
+
</view>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
import { createComponent, ref } from "@mpxjs/core";
|
|
31
|
+
import { formatDateTime } from "../../utils/common";
|
|
32
|
+
import type { ShopInfoModel } from "../../api/shop/types";
|
|
33
|
+
import { shopApi } from "../../api/shop/index";
|
|
34
|
+
import type { EventBase } from "../../api/types";
|
|
35
|
+
|
|
36
|
+
createComponent({
|
|
37
|
+
properties: {
|
|
38
|
+
// 顶部安全距离
|
|
39
|
+
top: {
|
|
40
|
+
type: Number,
|
|
41
|
+
value: 0
|
|
42
|
+
},
|
|
43
|
+
// 搜索框占位符
|
|
44
|
+
placeholder: {
|
|
45
|
+
type: String,
|
|
46
|
+
value: "搜索电商"
|
|
47
|
+
},
|
|
48
|
+
// 是否默认点击跳转
|
|
49
|
+
defaultClick: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
value: true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
setup(props) {
|
|
55
|
+
// 搜索参数
|
|
56
|
+
let queryParams = ref({
|
|
57
|
+
likeShopName: "",
|
|
58
|
+
});
|
|
59
|
+
// 搜索店铺列表
|
|
60
|
+
let mySearchList = ref([] as ShopInfoModel[]);
|
|
61
|
+
|
|
62
|
+
// 搜索店铺列表
|
|
63
|
+
function querySearchShopList() {
|
|
64
|
+
shopApi.findShopPage(queryParams.value).then(({ data }) => {
|
|
65
|
+
data.results.forEach((item) => {
|
|
66
|
+
item.createTime = formatDateTime(item.createTime as string, "YYYY-MM-DD")
|
|
67
|
+
});
|
|
68
|
+
mySearchList.value = data.results;
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
// 输入搜索关键字
|
|
72
|
+
function searchEvent(e: EventBase) {
|
|
73
|
+
queryParams.value.likeShopName = e.detail;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// 主动刷新列表(供外部调用)
|
|
77
|
+
function refresh() {
|
|
78
|
+
querySearchShopList();
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// 初始化加载
|
|
82
|
+
querySearchShopList();
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
queryParams,
|
|
86
|
+
mySearchList,
|
|
87
|
+
querySearchShopList,
|
|
88
|
+
searchEvent,
|
|
89
|
+
refresh,
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
methods: {
|
|
93
|
+
// 店铺点击事件,向上抛出 tenant
|
|
94
|
+
handleItemClick(item: ShopInfoModel) {
|
|
95
|
+
this.triggerEvent("click", item);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<style lang="scss">
|
|
102
|
+
@use "../../styles/index.scss" as *;
|
|
103
|
+
|
|
104
|
+
.organ-main {
|
|
105
|
+
padding: 40rpx 0;
|
|
106
|
+
box-sizing: border-box;
|
|
107
|
+
|
|
108
|
+
.search-box {
|
|
109
|
+
padding: 0 30rpx;
|
|
110
|
+
|
|
111
|
+
.search-right {
|
|
112
|
+
background: linear-gradient(#3B82F6, #2563EB);
|
|
113
|
+
color: $white-color;
|
|
114
|
+
font-size: $font-size-mini;
|
|
115
|
+
padding: 0 60rpx;
|
|
116
|
+
border-radius: 40rpx;
|
|
117
|
+
height: 54rpx;
|
|
118
|
+
line-height: 54rpx;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.organ-content-h {
|
|
123
|
+
height: 90%;
|
|
124
|
+
padding-top: 20rpx;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.organ-content {
|
|
128
|
+
margin: 0 30rpx;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
</style>
|
|
132
|
+
|
|
133
|
+
<script type="application/json">
|
|
134
|
+
{
|
|
135
|
+
"component": true,
|
|
136
|
+
"usingComponents": {
|
|
137
|
+
"jmash-search": "../common/jmash-search",
|
|
138
|
+
"jmash-none-data": "../common/jmash-none-data",
|
|
139
|
+
"shop-item": "./shop-item"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
</script>
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 搜索店铺 -->
|
|
3
|
+
<jmash-top-navigation id="nav" indexBg title="{{ navigationTitle }}" leftIcon="back" />
|
|
4
|
+
|
|
5
|
+
<shop-search id="shop-search" top="{{ top }}" />
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { createPage, ref } from "@mpxjs/core";
|
|
10
|
+
import { getHeight } from "../utils/common";
|
|
11
|
+
|
|
12
|
+
createPage({
|
|
13
|
+
|
|
14
|
+
setup() {
|
|
15
|
+
let config = getApp().globalData.config;
|
|
16
|
+
// 顶部安全距离
|
|
17
|
+
let top = ref(getHeight().MenuButtonBottom);
|
|
18
|
+
// 小程序名称
|
|
19
|
+
let navigationTitle = ref(config.xcxName);
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
top,
|
|
23
|
+
navigationTitle,
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 页面显示时刷新搜索列表
|
|
29
|
+
*/
|
|
30
|
+
onShow() {
|
|
31
|
+
const comp = this.selectComponent('#branch-search');
|
|
32
|
+
comp && comp.refresh();
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 页面滚动时调用
|
|
37
|
+
*/
|
|
38
|
+
onPageScroll(e) {
|
|
39
|
+
this.selectComponent('#nav').calculateOpacity(e.scrollTop);
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style lang="scss">
|
|
45
|
+
@use "../styles/index.scss" as *;
|
|
46
|
+
|
|
47
|
+
page {
|
|
48
|
+
background: linear-gradient(#EDF5FF, $white-color);
|
|
49
|
+
}
|
|
50
|
+
</style>
|
|
51
|
+
|
|
52
|
+
<script type="application/json">
|
|
53
|
+
{
|
|
54
|
+
"usingComponents": {
|
|
55
|
+
"jmash-top-navigation": "../components/common/jmash-top-navigation",
|
|
56
|
+
"shop-search": "../components/shop/shop-search"
|
|
57
|
+
},
|
|
58
|
+
"navigationStyle": "custom"
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
<view class="page-body">
|
|
3
3
|
<shop-selected-item></shop-selected-item>
|
|
4
4
|
<jmash-menu menuGroups="{{ menuGroups }}" bind:itemClick="handleMenuClick"></jmash-menu>
|
|
5
|
-
<view class="logout-section">
|
|
6
|
-
<button type="warn" bind:tap="loginOut">退出登录</button>
|
|
7
|
-
</view>
|
|
8
5
|
</view>
|
|
9
6
|
</template>
|
|
10
7
|
|
|
@@ -20,11 +17,11 @@ createPage({
|
|
|
20
17
|
id: 1,
|
|
21
18
|
items: [
|
|
22
19
|
{ key: 'organ', title: '选择组织', icon: '🏠', iconBg: '#409eff', path: '/pages/organ' },
|
|
23
|
-
{ key: '
|
|
20
|
+
{ key: 'shop', title: '选择电商', icon: '🏠', iconBg: '#409eff', path: '/pages/shop-search' },
|
|
21
|
+
{ key: 'branch', title: '选择门店', icon: '🏠', iconBg: '#409eff', path: '/pages/branch-search' },
|
|
24
22
|
{ key: 'home', title: '主页(全屏登录检查)', icon: '🏠', iconBg: '#409eff', path: '/pages/home' },
|
|
25
23
|
{ key: 'home2', title: '主页(全屏登录)', icon: '🏠', iconBg: '#67c23a', path: '/pages/home2' },
|
|
26
24
|
{ key: 'half-home', title: '主页(半屏登录)', icon: '🏠', iconBg: '#e6a23c', path: '/pages/half-home' },
|
|
27
|
-
{ key: 'comp-test', title: '组件演示', icon: '🧩', iconBg: '#f56c6c', path: '/pages/basic-component' },
|
|
28
25
|
{
|
|
29
26
|
key: 'cms-location-list', title: '位置列表', icon: '📝', iconBg: '#409eff', path: '/jmash/pages/cms/cms-location-list'
|
|
30
27
|
},
|
|
@@ -55,13 +52,6 @@ createPage({
|
|
|
55
52
|
mpx.navigateTo({ url: item.path })
|
|
56
53
|
}
|
|
57
54
|
},
|
|
58
|
-
loginOut() {
|
|
59
|
-
this.userStore.logout();
|
|
60
|
-
mpx.showToast({
|
|
61
|
-
title: '已退出登录',
|
|
62
|
-
icon: 'success'
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
55
|
}
|
|
66
56
|
})
|
|
67
57
|
</script>
|
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();
|