jmash-core-mp 0.1.59 → 0.1.60

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.
@@ -1,7 +1,8 @@
1
1
  import { ResponseData } from "../../api/types";
2
- import { BranchPage, BranchPageReq } from "./types";
2
+ import { BranchPage, BranchPageReq, ShopInfoModel } from "./types";
3
3
  declare class ShopApiImpl {
4
4
  findShopBranchPage(data: BranchPageReq): Promise<ResponseData<BranchPage>>;
5
+ findShopInfoById(organTenant: string): Promise<ResponseData<ShopInfoModel>>;
5
6
  }
6
7
  declare const shopApi: ShopApiImpl;
7
8
  export { shopApi };
@@ -11,6 +11,13 @@ class ShopApiImpl {
11
11
  header: { Authorization: false },
12
12
  });
13
13
  }
14
+ // 查询店铺管理
15
+ findShopInfoById(organTenant) {
16
+ return mpx.xfetch.fetch({
17
+ url: "/v1/front/shop/info/shop_info/" + organTenant,
18
+ method: "GET",
19
+ });
20
+ }
14
21
  }
15
22
  const shopApi = new ShopApiImpl();
16
23
  export { shopApi };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  import mpx from "@mpxjs/core";
2
2
  import { ResponseData } from "../../api/types";
3
- import { BranchPage, BranchPageReq } from "./types";
3
+ import { BranchPage, BranchPageReq, ShopInfoModel } from "./types";
4
4
 
5
5
  class ShopApiImpl {
6
6
  // 查询分页信息门店管理
@@ -14,6 +14,14 @@ class ShopApiImpl {
14
14
  header: { Authorization: false },
15
15
  });
16
16
  }
17
+
18
+ // 查询店铺管理
19
+ findShopInfoById(organTenant: string): Promise<ResponseData<ShopInfoModel>> {
20
+ return mpx.xfetch.fetch({
21
+ url: "/v1/front/shop/info/shop_info/" + organTenant,
22
+ method: "GET",
23
+ });
24
+ }
17
25
  }
18
26
 
19
27
  const shopApi = new ShopApiImpl();
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/shop-search",
38
39
  "./pages/branch-search",
39
40
  ],
40
41
  "packages": [
@@ -43,7 +43,7 @@ createComponent({
43
43
  // 搜索框占位符
44
44
  placeholder: {
45
45
  type: String,
46
- value: "搜索店铺"
46
+ value: "搜索门店"
47
47
  },
48
48
  // 是否默认点击跳转
49
49
  defaultClick: {
@@ -0,0 +1,118 @@
1
+ /**
2
+ * 组织组件
3
+ * @props organInfo 组织信息
4
+ * @props defaultClick 是否默认点击跳转
5
+ * @events click 组织详情事件,参数为组织信息
6
+ */
7
+ <template>
8
+ <view class="organ-item" data-id="{{ organInfo.storageId }}" data-tenant="{{ organInfo.organTenant }}"
9
+ bind:tap="handleInfo">
10
+ <image wx:if="{{ baseUrl && organInfo.logoUrl }}" class="organ-logo" src="{{ baseUrl + organInfo.logoUrl }}"
11
+ mode="aspectFit" />
12
+ <image wx:if="{{ resourceUrl && !organInfo.logoUrl }}" 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">{{ organInfo.organName }}</text>
17
+ <text>{{ organInfo.createTime }}</text>
18
+ </view>
19
+ <view>{{ organInfo.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
+ import { shopApi } from "../../api/shop/index";
29
+
30
+ createComponent({
31
+ properties: {
32
+ // 组织信息
33
+ organInfo: {
34
+ type: Object,
35
+ value: {}
36
+ },
37
+ defaultClick: {
38
+ type: Boolean,
39
+ value: true
40
+ }
41
+ },
42
+ setup() {
43
+ const config = getApp().globalData.config;
44
+ // 资源路径
45
+ let resourceUrl = config.resourceUrl + "/images/components/";
46
+ // 图片路径
47
+ let baseUrl = config.baseUrl + "/v1/file/image/resize/100/100/";
48
+ return { resourceUrl, baseUrl }
49
+ },
50
+ methods: {
51
+ // 店铺详情
52
+ handleInfo(e: EventBase) {
53
+ console.log("选择店铺", this.organInfo);
54
+ const shopStore = useShopStore();
55
+ shopApi.findShopInfoById(this.organInfo.organTenant).then((res) => {
56
+ if (res.statusCode === 200) {
57
+ shopStore.switchShop(res.data).then(() => {
58
+ if (this.defaultClick) {
59
+ mpx.reLaunch({
60
+ url: "/pages/tabbar/home"
61
+ });
62
+ }
63
+ this.triggerEvent("click", res.data);
64
+ });
65
+ }
66
+ });
67
+ }
68
+ }
69
+ })
70
+ </script>
71
+
72
+ <style lang="scss">
73
+ @use "../../styles/index.scss" as *;
74
+
75
+ .organ-item {
76
+ background-color: $white-color;
77
+ border-radius: $border-radius;
78
+ padding: 20rpx 30rpx;
79
+ display: flex;
80
+ align-items: center;
81
+ gap: 20rpx;
82
+ margin-bottom: 20rpx;
83
+ box-shadow: 0 8rpx 24rpx 0 rgba(44, 19, 19, 0.08);
84
+ }
85
+
86
+ .organ-logo {
87
+ width: 80rpx;
88
+ height: 80rpx;
89
+ }
90
+
91
+ .organ-item-right {
92
+ width: 90%;
93
+ display: flex;
94
+ flex-direction: column;
95
+ gap: 10rpx;
96
+ color: $font-color-grey;
97
+ font-size: $font-size-mini;
98
+ font-weight: 400;
99
+
100
+ .organ-item-title {
101
+ display: flex;
102
+ justify-content: space-between;
103
+
104
+ .organ-title-c {
105
+ color: $font-color;
106
+ font-size: $font-size;
107
+ font-weight: bold;
108
+ }
109
+ }
110
+ }
111
+ </style>
112
+
113
+ <script type="application/json">
114
+ {
115
+ "component": true,
116
+ "usingComponents": {}
117
+ }
118
+ </script>
@@ -0,0 +1,148 @@
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.likeOrganName }}" bind:handleSearch="searchEvent">
13
+ <button class="search-right" bind:tap="querySearchStorageList">搜索</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" organInfo="{{ 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 { StorageOrganInfoModel } from "../../api/storage/types";
33
+ import { storageApi } from "../../api/storage/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
+ serviceType: {
50
+ type: String,
51
+ value: "mall"
52
+ },
53
+ // 是否默认点击跳转
54
+ defaultClick: {
55
+ type: Boolean,
56
+ value: true
57
+ }
58
+ },
59
+ setup(props) {
60
+ // 搜索参数
61
+ let queryParams = ref({
62
+ serviceType: props.serviceType,
63
+ likeOrganName: "",
64
+ });
65
+ // 搜索店铺列表
66
+ let mySearchList = ref([] as StorageOrganInfoModel[]);
67
+
68
+ // 搜索店铺列表
69
+ function querySearchStorageList() {
70
+ storageApi.findStorageOrganInfoList(queryParams.value).then(({ data }) => {
71
+ data.results.forEach((item) => {
72
+ item.createTime = formatDateTime(item.createTime as string, "YYYY-MM-DD")
73
+ });
74
+ mySearchList.value = data.results;
75
+ });
76
+ };
77
+ // 输入搜索关键字
78
+ function searchEvent(e: EventBase) {
79
+ queryParams.value.likeOrganName = e.detail;
80
+ };
81
+
82
+ // 主动刷新列表(供外部调用)
83
+ function refresh() {
84
+ querySearchStorageList();
85
+ };
86
+
87
+ // 初始化加载
88
+ querySearchStorageList();
89
+
90
+ return {
91
+ queryParams,
92
+ mySearchList,
93
+ querySearchStorageList,
94
+ searchEvent,
95
+ refresh,
96
+ }
97
+ },
98
+ methods: {
99
+ // 店铺点击事件,向上抛出 tenant
100
+ handleItemClick(item: StorageOrganInfoModel) {
101
+ this.triggerEvent("click", item);
102
+ }
103
+ }
104
+ })
105
+ </script>
106
+
107
+ <style lang="scss">
108
+ @use "../../styles/index.scss" as *;
109
+
110
+ .organ-main {
111
+ padding: 40rpx 0;
112
+ box-sizing: border-box;
113
+
114
+ .search-box {
115
+ padding: 0 30rpx;
116
+
117
+ .search-right {
118
+ background: linear-gradient(#3B82F6, #2563EB);
119
+ color: $white-color;
120
+ font-size: $font-size-mini;
121
+ padding: 0 60rpx;
122
+ border-radius: 40rpx;
123
+ height: 54rpx;
124
+ line-height: 54rpx;
125
+ }
126
+ }
127
+
128
+ .organ-content-h {
129
+ height: 90%;
130
+ padding-top: 20rpx;
131
+ }
132
+
133
+ .organ-content {
134
+ margin: 0 30rpx;
135
+ }
136
+ }
137
+ </style>
138
+
139
+ <script type="application/json">
140
+ {
141
+ "component": true,
142
+ "usingComponents": {
143
+ "jmash-search": "../common/jmash-search",
144
+ "jmash-none-data": "../common/jmash-none-data",
145
+ "shop-item": "./shop-item"
146
+ }
147
+ }
148
+ </script>
@@ -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: 'branch', title: '选择店铺', icon: '🏠', iconBg: '#409eff', path: '/pages/branch-search' },
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>