jmash-core-mp 0.1.57 → 0.1.59

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,7 @@
1
+ import { ResponseData } from "../../api/types";
2
+ import { BranchPage, BranchPageReq } from "./types";
3
+ declare class ShopApiImpl {
4
+ findShopBranchPage(data: BranchPageReq): Promise<ResponseData<BranchPage>>;
5
+ }
6
+ declare const shopApi: ShopApiImpl;
7
+ export { shopApi };
@@ -0,0 +1,16 @@
1
+ import mpx from "@mpxjs/core";
2
+ class ShopApiImpl {
3
+ // 查询分页信息门店管理
4
+ findShopBranchPage(data) {
5
+ const config = getApp().globalData.config;
6
+ data.tenant = data.tenant || config.tenant;
7
+ return mpx.xfetch.fetch({
8
+ url: "/v1/front/shop/scene_branch/page/" + data.tenant,
9
+ method: "GET",
10
+ data: data,
11
+ header: { Authorization: false },
12
+ });
13
+ }
14
+ }
15
+ const shopApi = new ShopApiImpl();
16
+ export { shopApi };
@@ -27,6 +27,8 @@ export interface ShopInfoModel {
27
27
  accountName?: string;
28
28
  organId?: string;
29
29
  organTenant?: string;
30
+ createBy?: string;
31
+ createTime?: string;
30
32
  }
31
33
  export interface BranchModel {
32
34
  tenantId?: string;
@@ -55,3 +57,29 @@ export interface BranchModel {
55
57
  distanceMeter?: string;
56
58
  organTenant?: string;
57
59
  }
60
+ export interface BranchPageReq {
61
+ tenant?: string;
62
+ curPage?: number;
63
+ pageSize?: number;
64
+ orderName?: string;
65
+ orderAsc?: boolean;
66
+ shopId?: string;
67
+ likeFacadeName?: string;
68
+ facadeName?: string;
69
+ likeRegionCode?: string;
70
+ shopIds?: string[];
71
+ hasIsHq?: boolean;
72
+ isHq?: boolean;
73
+ hasStatus?: boolean;
74
+ status?: boolean;
75
+ longitude?: number;
76
+ latitude?: number;
77
+ likeCategory?: string;
78
+ }
79
+ export interface BranchPage {
80
+ results: Array<BranchModel>;
81
+ curPage: number;
82
+ pageSize: number;
83
+ totalSize: number;
84
+ pageCount: number;
85
+ }
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 } from "./api/shop/types";
9
+ export type { ShopInfoModel, BranchModel, BranchPageReq, BranchPage, } 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";
@@ -20,6 +20,7 @@ export { dictApi } from "./api/dict";
20
20
  export { fileApi } from "./api/files";
21
21
  export { regionApi } from "./api/region";
22
22
  export { storageApi } from "./api/storage";
23
+ export { shopApi } from "./api/shop";
23
24
  export { net } from "./utils/net";
24
25
  export { getHeight, formatDateTime, validateRules, validateRequired, } from "./utils/common";
25
26
  import * as dayjs from "dayjs";
package/lib/index.js CHANGED
@@ -13,6 +13,7 @@ export { dictApi } from "./api/dict";
13
13
  export { fileApi } from "./api/files";
14
14
  export { regionApi } from "./api/region";
15
15
  export { storageApi } from "./api/storage";
16
+ export { shopApi } from "./api/shop";
16
17
  export { net } from "./utils/net";
17
18
  export { getHeight, formatDateTime, validateRules, validateRequired, } from "./utils/common";
18
19
  import * as dayjsLocaleZhCn from "dayjs/locale/zh-cn";
@@ -6,8 +6,8 @@ interface ShopState {
6
6
  isShop: boolean;
7
7
  }
8
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;
9
+ switchShopBranch(shopInfo: ShopInfoModel, branchInfo: BranchModel): Promise<boolean>;
10
+ switchShop(shopInfo: ShopInfoModel): Promise<boolean>;
11
+ switchBranch(branchInfo: BranchModel): Promise<boolean>;
12
12
  }>;
13
13
  export {};
package/lib/store/shop.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { defineStore } from "@mpxjs/pinia";
2
2
  import { db } from "../utils/db";
3
+ import { useOrganStore } from "./organ";
3
4
  export const useShopStore = defineStore("shop", {
4
5
  state: () => ({
5
6
  shopInfo: db.getShopInfo() || {},
@@ -16,6 +17,8 @@ export const useShopStore = defineStore("shop", {
16
17
  db.setShopInfo(shopInfo);
17
18
  db.setBranchInfo(branchInfo);
18
19
  db.setIsShop(false);
20
+ const organStore = useOrganStore();
21
+ return organStore.setOrganTenant(branchInfo.organTenant || "");
19
22
  },
20
23
  // 切换商户
21
24
  switchShop(shopInfo) {
@@ -26,6 +29,8 @@ export const useShopStore = defineStore("shop", {
26
29
  db.setShopInfo(shopInfo);
27
30
  db.setBranchInfo({});
28
31
  db.setIsShop(true);
32
+ const organStore = useOrganStore();
33
+ return organStore.setOrganTenant(shopInfo.organTenant || "");
29
34
  },
30
35
  // 切换门店
31
36
  switchBranch(branchInfo) {
@@ -36,6 +41,8 @@ export const useShopStore = defineStore("shop", {
36
41
  db.setShopInfo({});
37
42
  db.setBranchInfo(branchInfo);
38
43
  db.setIsShop(false);
44
+ const organStore = useOrganStore();
45
+ return organStore.setOrganTenant(branchInfo.organTenant || "");
39
46
  },
40
47
  },
41
48
  });
package/lib/utils/db.js CHANGED
@@ -105,13 +105,15 @@ class LocalStorage {
105
105
  const config = getApp().globalData.config;
106
106
  mpx.setStorageSync("OrganTenant:" + config.tenant, organTenant);
107
107
  }
108
- //获取组织信息
108
+ //获取组织信息 TODO
109
109
  getOrganInfo() {
110
- return mpx.getStorageSync("organInfo") || {};
110
+ const config = getApp().globalData.config;
111
+ return mpx.getStorageSync("OrganInfo:" + config.tenant) || {};
111
112
  }
112
113
  //设置组织信息
113
114
  setOrganInfo(data) {
114
- mpx.setStorageSync("organInfo", data);
115
+ const config = getApp().globalData.config;
116
+ mpx.setStorageSync("OrganInfo:" + config.tenant, data);
115
117
  }
116
118
  // 获取商铺信息
117
119
  getShopInfo() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.57",
3
+ "version": "0.1.59",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -0,0 +1,20 @@
1
+ import mpx from "@mpxjs/core";
2
+ import { ResponseData } from "../../api/types";
3
+ import { BranchPage, BranchPageReq } from "./types";
4
+
5
+ class ShopApiImpl {
6
+ // 查询分页信息门店管理
7
+ findShopBranchPage(data: BranchPageReq): Promise<ResponseData<BranchPage>> {
8
+ const config = getApp().globalData.config;
9
+ data.tenant = data.tenant || config.tenant;
10
+ return mpx.xfetch.fetch({
11
+ url: "/v1/front/shop/scene_branch/page/" + data.tenant,
12
+ method: "GET",
13
+ data: data,
14
+ header: { Authorization: false },
15
+ });
16
+ }
17
+ }
18
+
19
+ const shopApi = new ShopApiImpl();
20
+ export { shopApi };
@@ -56,6 +56,10 @@ export interface ShopInfoModel {
56
56
  organId?: string;
57
57
  // 组织租户
58
58
  organTenant?: string;
59
+ // 创建人
60
+ createBy?: string;
61
+ // 创建时间
62
+ createTime?: string;
59
63
  }
60
64
 
61
65
  // 门店管理实体
@@ -111,3 +115,55 @@ export interface BranchModel {
111
115
  // 组织租户
112
116
  organTenant?: string;
113
117
  }
118
+
119
+ // 门店管理查询
120
+ export interface BranchPageReq {
121
+ // 租户
122
+ tenant?: string;
123
+ // 当前页码
124
+ curPage?: number;
125
+ // 页尺寸
126
+ pageSize?: number;
127
+ // 排序名称
128
+ orderName?: string;
129
+ // 是否升序排序
130
+ orderAsc?: boolean;
131
+ // 店铺ID
132
+ shopId?: string;
133
+ // 门店名称模糊查询
134
+ likeFacadeName?: string;
135
+ // 门店名称精确查询
136
+ facadeName?: string;
137
+ // 地区编码模糊查询
138
+ likeRegionCode?: string;
139
+ // 店铺ID列表
140
+ shopIds?: string[];
141
+ // 是否有总部
142
+ hasIsHq?: boolean;
143
+ // 是否总部
144
+ isHq?: boolean;
145
+ // 是否有状态
146
+ hasStatus?: boolean;
147
+ // 状态
148
+ status?: boolean;
149
+ // 经度
150
+ longitude?: number;
151
+ // 纬度
152
+ latitude?: number;
153
+ // 门店分类模糊查询
154
+ likeCategory?: string;
155
+ }
156
+
157
+ // 门店管理分页
158
+ export interface BranchPage {
159
+ // 当前页内容
160
+ results: Array<BranchModel>;
161
+ // 当前页码
162
+ curPage: number;
163
+ // 页尺寸
164
+ pageSize: number;
165
+ // 总记录数
166
+ totalSize: number;
167
+ // 总页数
168
+ pageCount: number;
169
+ }
package/src/app.mpx CHANGED
@@ -35,6 +35,7 @@ createApp({
35
35
  "./pages/tabbar/my",
36
36
  "./pages/organ",
37
37
  "./pages/organ-search",
38
+ "./pages/branch-search",
38
39
  ],
39
40
  "packages": [
40
41
  "./packages/index?root=jmash"
@@ -12,6 +12,7 @@ import { createComponent, ref } from "@mpxjs/core";
12
12
  import { storageApi } from "../../api/storage/index";
13
13
  import { formatDateTime } from "../../utils/common";
14
14
  import type { StorageOrganInfoModel } from "../../api/storage/types";
15
+ import { useUserStore } from '../../store/user'
15
16
 
16
17
  createComponent({
17
18
  properties: {
@@ -28,11 +29,15 @@ createComponent({
28
29
  },
29
30
  setup(props) {
30
31
  let organList = ref([] as StorageOrganInfoModel[]);
31
- storageApi.findStorageBrowserOrganList({ serviceType: props.serviceType }).then(({ data }) => {
32
- data.results.forEach((item) => {
33
- item.createTime = formatDateTime(item.createTime as string, "YYYY-MM-DD")
32
+ const userStore = useUserStore();
33
+ // 检查登录并跳转登录
34
+ userStore.loginOnlyAC().then((res) => {
35
+ storageApi.findStorageBrowserOrganList({ serviceType: props.serviceType }).then(({ data }) => {
36
+ data.results.forEach((item) => {
37
+ item.createTime = formatDateTime(item.createTime as string, "YYYY-MM-DD")
38
+ });
39
+ organList.value = data.results;
34
40
  });
35
- organList.value = data.results;
36
41
  });
37
42
  return { organList };
38
43
  },
@@ -12,6 +12,7 @@ import { createComponent, ref } from "@mpxjs/core";
12
12
  import { storageApi } from "../../api/storage/index";
13
13
  import { formatDateTime } from "../../utils/common";
14
14
  import type { StorageOrganInfoModel } from "../../api/storage/types";
15
+ import { useUserStore } from '../../store/user'
15
16
 
16
17
  createComponent({
17
18
  properties: {
@@ -28,11 +29,15 @@ createComponent({
28
29
  },
29
30
  setup(props) {
30
31
  let organList = ref([] as StorageOrganInfoModel[]);
31
- storageApi.findMyOrganList({ serviceType: props.serviceType }).then(({ data }) => {
32
- data.results.forEach((item) => {
33
- item.createTime = formatDateTime(item.createTime as string, "YYYY-MM-DD")
32
+ const userStore = useUserStore();
33
+ // 检查登录并跳转登录
34
+ userStore.loginOnlyAC().then((res) => {
35
+ storageApi.findMyOrganList({ serviceType: props.serviceType }).then(({ data }) => {
36
+ data.results.forEach((item) => {
37
+ item.createTime = formatDateTime(item.createTime as string, "YYYY-MM-DD")
38
+ });
39
+ organList.value = data.results;
34
40
  });
35
- organList.value = data.results;
36
41
  });
37
42
  return { organList };
38
43
  },
@@ -0,0 +1,112 @@
1
+ /**
2
+ * 组织组件
3
+ * @props organInfo 组织信息
4
+ * @props defaultClick 是否默认点击跳转
5
+ * @events click 组织详情事件,参数为组织信息
6
+ */
7
+ <template>
8
+ <view class="organ-item" data-id="{{ branchInfo.branchId }}" data-tenant="{{ branchInfo.organTenant }}"
9
+ bind:tap="handleInfo">
10
+ <image wx:if="{{ resourceUrl }}" class="organ-logo" src="{{ resourceUrl + 'gray_logo_upload.png' }}"
11
+ mode="aspectFit" />
12
+ <view class="organ-item-right">
13
+ <view class="organ-item-title">
14
+ <text class="organ-title-c">{{ branchInfo.facadeName }}</text>
15
+ <text>{{ branchInfo.createTime }}</text>
16
+ </view>
17
+ <view>{{ branchInfo.note }}</view>
18
+ </view>
19
+ </view>
20
+ </template>
21
+
22
+ <script lang="ts">
23
+ import mpx, { createComponent } from "@mpxjs/core";
24
+ import type { EventBase } from "../../api/types";
25
+ import type { BranchModel } from "../../api/shop/types";
26
+ import { useShopStore } from "../../store/shop";
27
+
28
+ createComponent({
29
+ properties: {
30
+ // 门店信息
31
+ branchInfo: {
32
+ type: Object,
33
+ value: {}
34
+ },
35
+ defaultClick: {
36
+ type: Boolean,
37
+ value: true
38
+ }
39
+ },
40
+ setup() {
41
+ const config = getApp().globalData.config;
42
+ // 资源路径
43
+ let resourceUrl = config.resourceUrl + "/images/components/";
44
+ // 图片路径
45
+ let baseUrl = config.baseUrl + "/v1/file/image/resize/100/100/";
46
+ return { resourceUrl, baseUrl }
47
+ },
48
+ methods: {
49
+ // 店铺详情
50
+ handleInfo(e: EventBase) {
51
+ //console.log("选择门店", this.branchInfo);
52
+ const shopStore = useShopStore();
53
+ shopStore.switchBranch(this.branchInfo as BranchModel).then(() => {
54
+ if (this.defaultClick) {
55
+ mpx.reLaunch({
56
+ url: "/pages/tabbar/home"
57
+ });
58
+ }
59
+ this.triggerEvent("click", this.branchInfo);
60
+ });
61
+ }
62
+ }
63
+ })
64
+ </script>
65
+
66
+ <style lang="scss">
67
+ @use "../../styles/index.scss" as *;
68
+
69
+ .organ-item {
70
+ background-color: $white-color;
71
+ border-radius: $border-radius;
72
+ padding: 20rpx 30rpx;
73
+ display: flex;
74
+ align-items: center;
75
+ gap: 20rpx;
76
+ margin-bottom: 20rpx;
77
+ box-shadow: 0 8rpx 24rpx 0 rgba(44, 19, 19, 0.08);
78
+ }
79
+
80
+ .organ-logo {
81
+ width: 80rpx;
82
+ height: 80rpx;
83
+ }
84
+
85
+ .organ-item-right {
86
+ width: 90%;
87
+ display: flex;
88
+ flex-direction: column;
89
+ gap: 10rpx;
90
+ color: $font-color-grey;
91
+ font-size: $font-size-mini;
92
+ font-weight: 400;
93
+
94
+ .organ-item-title {
95
+ display: flex;
96
+ justify-content: space-between;
97
+
98
+ .organ-title-c {
99
+ color: $font-color;
100
+ font-size: $font-size;
101
+ font-weight: bold;
102
+ }
103
+ }
104
+ }
105
+ </style>
106
+
107
+ <script type="application/json">
108
+ {
109
+ "component": true,
110
+ "usingComponents": {}
111
+ }
112
+ </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.likeFacadeName }}" bind:handleSearch="searchEvent">
13
+ <button class="search-right" bind:tap="querySearchBranchList">搜索</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
+ <branch-item wx:for="{{ mySearchList }}" wx:key="index" branchInfo="{{ 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 { BranchModel } 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
+ likeFacadeName: "",
58
+ });
59
+ // 搜索店铺列表
60
+ let mySearchList = ref([] as BranchModel[]);
61
+
62
+ // 搜索店铺列表
63
+ function querySearchBranchList() {
64
+ shopApi.findShopBranchPage(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.likeFacadeName = e.detail;
74
+ };
75
+
76
+ // 主动刷新列表(供外部调用)
77
+ function refresh() {
78
+ querySearchBranchList();
79
+ };
80
+
81
+ // 初始化加载
82
+ querySearchBranchList();
83
+
84
+ return {
85
+ queryParams,
86
+ mySearchList,
87
+ querySearchBranchList,
88
+ searchEvent,
89
+ refresh,
90
+ }
91
+ },
92
+ methods: {
93
+ // 店铺点击事件,向上抛出 tenant
94
+ handleItemClick(item: BranchModel) {
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
+ "branch-item": "./branch-item"
140
+ }
141
+ }
142
+ </script>
@@ -0,0 +1,88 @@
1
+ <template>
2
+ <view wx:if="{{ branchInfo.branchId || shopInfo.shopId }}" class="organ-item"
3
+ data-id="{{ branchInfo.branchId || shopInfo.shopId }}"
4
+ data-tenant="{{ branchInfo.organTenant || shopInfo.organTenant }}">
5
+ <image wx:if="{{ baseUrl && branchInfo.picUrl }}" class="organ-logo" src="{{ baseUrl + branchInfo.picUrl }}"
6
+ mode="aspectFit" />
7
+ <image wx:if="{{ baseUrl && shopInfo.picUrl }}" class="organ-logo" src="{{ baseUrl + shopInfo.picUrl }}"
8
+ mode="aspectFit" />
9
+ <image wx:if="{{ resourceUrl && !branchInfo.picUrl && !shopInfo.picUrl }}" class="organ-logo"
10
+ src="{{ resourceUrl + 'gray_logo_upload.png' }}" mode="aspectFit" />
11
+ <view class="organ-item-right">
12
+ <view class="organ-item-title">
13
+ <text class="organ-title-c">{{ branchInfo.facadeName || shopInfo.shopName }}</text>
14
+ <text>{{ branchInfo.createTime || shopInfo.createTime }}</text>
15
+ </view>
16
+ <view>{{ branchInfo.note || shopInfo.note }}</view>
17
+ </view>
18
+ </view>
19
+ </template>
20
+
21
+ <script lang="ts">
22
+ import { createComponent } from "@mpxjs/core";
23
+ import { useShopStore } from "../../store/shop";
24
+
25
+ createComponent({
26
+ setup() {
27
+ const config = getApp().globalData.config;
28
+ // 资源路径
29
+ let resourceUrl = config.resourceUrl + "/images/components/";
30
+ // 图片路径
31
+ let baseUrl = config.baseUrl + "/v1/file/image/resize/100/100/";
32
+ const shopStore = useShopStore();
33
+ let branchInfo = shopStore.branchInfo;
34
+ let shopInfo = shopStore.shopInfo;
35
+ return { resourceUrl, baseUrl, branchInfo, shopInfo }
36
+ },
37
+ methods: {
38
+ }
39
+ })
40
+ </script>
41
+
42
+ <style lang="scss">
43
+ @use "../../styles/index.scss" as *;
44
+
45
+ .organ-item {
46
+ background-color: $white-color;
47
+ border-radius: $border-radius;
48
+ padding: 20rpx 30rpx;
49
+ display: flex;
50
+ align-items: center;
51
+ gap: 20rpx;
52
+ margin-bottom: 20rpx;
53
+ box-shadow: 0 8rpx 24rpx 0 rgba(44, 19, 19, 0.08);
54
+ }
55
+
56
+ .organ-logo {
57
+ width: 80rpx;
58
+ height: 80rpx;
59
+ }
60
+
61
+ .organ-item-right {
62
+ width: 90%;
63
+ display: flex;
64
+ flex-direction: column;
65
+ gap: 10rpx;
66
+ color: $font-color-grey;
67
+ font-size: $font-size-mini;
68
+ font-weight: 400;
69
+
70
+ .organ-item-title {
71
+ display: flex;
72
+ justify-content: space-between;
73
+
74
+ .organ-title-c {
75
+ color: $font-color;
76
+ font-size: $font-size;
77
+ font-weight: bold;
78
+ }
79
+ }
80
+ }
81
+ </style>
82
+
83
+ <script type="application/json">
84
+ {
85
+ "component": true,
86
+ "usingComponents": {}
87
+ }
88
+ </script>
package/src/index.ts CHANGED
@@ -54,7 +54,12 @@ export type {
54
54
  StorageOrganBrowserUpdateReq,
55
55
  StorageOrganBrowserModel,
56
56
  } from "./api/storage/types";
57
- export type { ShopInfoModel, BranchModel } from "./api/shop/types";
57
+ export type {
58
+ ShopInfoModel,
59
+ BranchModel,
60
+ BranchPageReq,
61
+ BranchPage,
62
+ } from "./api/shop/types";
58
63
 
59
64
  export { mpxFetch } from "./utils/request";
60
65
  export { config, initConfig, setConfig } from "./utils/config";
@@ -70,6 +75,7 @@ export { dictApi } from "./api/dict";
70
75
  export { fileApi } from "./api/files";
71
76
  export { regionApi } from "./api/region";
72
77
  export { storageApi } from "./api/storage";
78
+ export { shopApi } from "./api/shop";
73
79
  export { net } from "./utils/net";
74
80
  export {
75
81
  getHeight,
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <!-- 搜索店铺 -->
3
+ <jmash-top-navigation id="nav" indexBg title="{{ navigationTitle }}" leftIcon="back" />
4
+
5
+ <branch-search id="branch-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
+ "branch-search": "../components/shop/branch-search"
57
+ },
58
+ "navigationStyle": "custom"
59
+ }
60
+ </script>
@@ -22,6 +22,7 @@
22
22
  <script lang="ts">
23
23
  import mpx, { createPage, ref, onShow } from "@mpxjs/core";
24
24
  import { getHeight } from "../utils/common";
25
+ import { useUserStore } from '../store/user'
25
26
 
26
27
  createPage({
27
28
  setup() {
@@ -32,12 +33,13 @@ createPage({
32
33
  let searchPlaceholder = ref("搜索店铺");
33
34
  // 小程序名称
34
35
  let navigationTitle = ref(config.xcxName);
35
-
36
- /**
37
- * 页面显示时调用
38
- */
36
+ // 强制登录
39
37
  onShow(() => {
40
-
38
+ const userStore = useUserStore();
39
+ // 检查登录并跳转登录
40
+ userStore.loginAC("/pages/organ", false).then((res) => {
41
+ console.log(res);
42
+ });
41
43
  });
42
44
 
43
45
  // 搜索
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <view class="page-body">
3
+ <shop-selected-item></shop-selected-item>
3
4
  <jmash-menu menuGroups="{{ menuGroups }}" bind:itemClick="handleMenuClick"></jmash-menu>
4
5
  <view class="logout-section">
5
6
  <button type="warn" bind:tap="loginOut">退出登录</button>
@@ -19,6 +20,7 @@ createPage({
19
20
  id: 1,
20
21
  items: [
21
22
  { key: 'organ', title: '选择组织', icon: '🏠', iconBg: '#409eff', path: '/pages/organ' },
23
+ { key: 'branch', title: '选择店铺', icon: '🏠', iconBg: '#409eff', path: '/pages/branch-search' },
22
24
  { key: 'home', title: '主页(全屏登录检查)', icon: '🏠', iconBg: '#409eff', path: '/pages/home' },
23
25
  { key: 'home2', title: '主页(全屏登录)', icon: '🏠', iconBg: '#67c23a', path: '/pages/home2' },
24
26
  { key: 'half-home', title: '主页(半屏登录)', icon: '🏠', iconBg: '#e6a23c', path: '/pages/half-home' },
@@ -87,7 +89,8 @@ createPage({
87
89
  <script type="application/json">
88
90
  {
89
91
  "usingComponents": {
90
- "jmash-menu": "../../components/common/jmash-menu.mpx"
92
+ "jmash-menu": "../../components/common/jmash-menu.mpx",
93
+ "shop-selected-item": "../../components/shop/shop-selected-item.mpx"
91
94
  }
92
95
  }
93
96
  </script>
package/src/store/shop.ts CHANGED
@@ -2,6 +2,7 @@ import { defineStore } from "@mpxjs/pinia";
2
2
  import type { ShopInfoModel } from "../api/shop/types";
3
3
  import type { BranchModel } from "../api/shop/types";
4
4
  import { db } from "../utils/db";
5
+ import { useOrganStore } from "./organ";
5
6
 
6
7
  // 商户状态
7
8
  interface ShopState {
@@ -21,7 +22,10 @@ export const useShopStore = defineStore("shop", {
21
22
  }),
22
23
  actions: {
23
24
  // 切换商户门店
24
- switchShopBranch(shopInfo: ShopInfoModel, branchInfo: BranchModel) {
25
+ switchShopBranch(
26
+ shopInfo: ShopInfoModel,
27
+ branchInfo: BranchModel
28
+ ): Promise<boolean> {
25
29
  this.shopInfo = shopInfo;
26
30
  this.branchInfo = branchInfo;
27
31
  this.isShop = false;
@@ -29,9 +33,11 @@ export const useShopStore = defineStore("shop", {
29
33
  db.setShopInfo(shopInfo);
30
34
  db.setBranchInfo(branchInfo);
31
35
  db.setIsShop(false);
36
+ const organStore = useOrganStore();
37
+ return organStore.setOrganTenant(branchInfo.organTenant || "");
32
38
  },
33
39
  // 切换商户
34
- switchShop(shopInfo: ShopInfoModel) {
40
+ switchShop(shopInfo: ShopInfoModel): Promise<boolean> {
35
41
  this.shopInfo = shopInfo;
36
42
  this.branchInfo = {};
37
43
  this.isShop = true;
@@ -39,9 +45,11 @@ export const useShopStore = defineStore("shop", {
39
45
  db.setShopInfo(shopInfo);
40
46
  db.setBranchInfo({});
41
47
  db.setIsShop(true);
48
+ const organStore = useOrganStore();
49
+ return organStore.setOrganTenant(shopInfo.organTenant || "");
42
50
  },
43
51
  // 切换门店
44
- switchBranch(branchInfo: BranchModel) {
52
+ switchBranch(branchInfo: BranchModel): Promise<boolean> {
45
53
  this.shopInfo = {};
46
54
  this.branchInfo = branchInfo;
47
55
  this.isShop = false;
@@ -49,6 +57,8 @@ export const useShopStore = defineStore("shop", {
49
57
  db.setShopInfo({});
50
58
  db.setBranchInfo(branchInfo);
51
59
  db.setIsShop(false);
60
+ const organStore = useOrganStore();
61
+ return organStore.setOrganTenant(branchInfo.organTenant || "");
52
62
  },
53
63
  },
54
64
  });
package/src/utils/db.ts CHANGED
@@ -125,13 +125,15 @@ class LocalStorage {
125
125
  const config = getApp().globalData.config;
126
126
  mpx.setStorageSync("OrganTenant:" + config.tenant, organTenant);
127
127
  }
128
- //获取组织信息
128
+ //获取组织信息 TODO
129
129
  getOrganInfo(): StorageOrganInfoModel {
130
- return mpx.getStorageSync("organInfo") || {};
130
+ const config = getApp().globalData.config;
131
+ return mpx.getStorageSync("OrganInfo:" + config.tenant) || {};
131
132
  }
132
133
  //设置组织信息
133
134
  setOrganInfo(data: StorageOrganInfoModel) {
134
- mpx.setStorageSync("organInfo", data);
135
+ const config = getApp().globalData.config;
136
+ mpx.setStorageSync("OrganInfo:" + config.tenant, data);
135
137
  }
136
138
 
137
139
  // 获取商铺信息