jmash-core-mp 0.1.74 → 0.1.76

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 @@
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 {};
@@ -9,7 +9,9 @@ interface UserState {
9
9
  referee: string;
10
10
  }
11
11
  export declare const useUserStore: import("@mpxjs/pinia").StoreDefinition<"user", UserState, {}, {
12
- /** 登录检查 */
12
+ /** 尝试登录,无需处理异常 */
13
+ loginTry(): Promise<boolean>;
14
+ /** 登录检查(需处理异常) */
13
15
  loginOnlyAC(): Promise<boolean>;
14
16
  /** 登录检查并跳转登录 */
15
17
  loginAC(backurl: string, tabbar: boolean, loginurl?: string): Promise<boolean>;
package/lib/store/user.js CHANGED
@@ -14,7 +14,17 @@ export const useUserStore = defineStore("user", {
14
14
  referee: db.getReferee() || "",
15
15
  }),
16
16
  actions: {
17
- /** 登录检查 */
17
+ /** 尝试登录,无需处理异常 */
18
+ loginTry() {
19
+ return this.loginOnlyAC()
20
+ .then((res) => {
21
+ return res;
22
+ })
23
+ .catch(() => {
24
+ return false;
25
+ });
26
+ },
27
+ /** 登录检查(需处理异常) */
18
28
  loginOnlyAC() {
19
29
  // 1. 已登录 → 直接返回成功
20
30
  if (this.checkLogin()) {
@@ -45,7 +45,7 @@ class ShareUtil {
45
45
  .findShopBranchById(options.organTenant, options.branchId)
46
46
  .then((res) => {
47
47
  return shopStore.switchBranch(res.data).then(() => {
48
- return userStore.loginOnlyAC();
48
+ return userStore.loginTry();
49
49
  });
50
50
  });
51
51
  }
@@ -54,7 +54,7 @@ class ShareUtil {
54
54
  console.log("商城ID", options.shopId);
55
55
  return shopApi.findShopInfoById(options.shopId).then((res) => {
56
56
  return shopStore.switchShop(res.data).then(() => {
57
- return userStore.loginOnlyAC();
57
+ return userStore.loginTry();
58
58
  });
59
59
  });
60
60
  }
@@ -64,11 +64,11 @@ class ShareUtil {
64
64
  console.log("组织Token", options.organTenant);
65
65
  return organStore.setOrganTenant(options.organTenant).then(() => {
66
66
  //静默登录
67
- return userStore.loginOnlyAC();
67
+ return userStore.loginTry();
68
68
  });
69
69
  }
70
70
  //静默登录
71
- return userStore.loginOnlyAC();
71
+ return userStore.loginTry();
72
72
  }
73
73
  // 分享用户页给好友
74
74
  shareUserPath(pagePath, query) {
@@ -91,7 +91,7 @@ class ShareUtil {
91
91
  userStore.setReferee(options.referee);
92
92
  }
93
93
  //静默登录
94
- return userStore.loginOnlyAC();
94
+ return userStore.loginTry();
95
95
  }
96
96
  // 分享组织页给好友
97
97
  shareOrganPath(pagePath, query) {
@@ -122,11 +122,11 @@ class ShareUtil {
122
122
  if (options.organTenant) {
123
123
  return organStore.setOrganTenant(options.organTenant).then(() => {
124
124
  //静默登录
125
- return userStore.loginOnlyAC();
125
+ return userStore.loginTry();
126
126
  });
127
127
  }
128
128
  //静默登录
129
- return userStore.loginOnlyAC();
129
+ return userStore.loginTry();
130
130
  }
131
131
  // 分享电商页给好友
132
132
  shareMallPath(pagePath, query) {
@@ -175,7 +175,7 @@ class ShareUtil {
175
175
  .findShopBranchById(options.organTenant, options.branchId)
176
176
  .then((res) => {
177
177
  return shopStore.switchBranch(res.data).then(() => {
178
- return userStore.loginOnlyAC();
178
+ return userStore.loginTry();
179
179
  });
180
180
  });
181
181
  }
@@ -184,12 +184,12 @@ class ShareUtil {
184
184
  console.log("商城ID", options.shopId);
185
185
  return shopApi.findShopInfoById(options.shopId).then((res) => {
186
186
  return shopStore.switchShop(res.data).then(() => {
187
- return userStore.loginOnlyAC();
187
+ return userStore.loginTry();
188
188
  });
189
189
  });
190
190
  }
191
191
  //静默登录
192
- return userStore.loginOnlyAC();
192
+ return userStore.loginTry();
193
193
  }
194
194
  }
195
195
  const share = new ShareUtil();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.74",
3
+ "version": "0.1.76",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -0,0 +1,152 @@
1
+ /**
2
+ * 通用状态下拉筛选组件
3
+ * @param {Array} props.options - 下拉选项列表 [{ value: "", text: "" }] - 默认值为[]
4
+ * @param {String} props.value - 当前选中值 - 默认值为""
5
+ * @param {String} props.placeholder - 无匹配项时的占位文本 - 默认值为"全部"
6
+ * @event bind:change - 选择某项时触发,事件 detail 为 { value, text }
7
+ */
8
+ <template>
9
+ <view class="status-filter">
10
+ <view class="status-filter-current" bind:tap="handleToggle">
11
+ {{ currentText }}
12
+ <cube-icon type="{{ selectStatus ? 'collapse' : 'expand' }}" size="22rpx" color="#333" />
13
+ </view>
14
+ <!-- 下拉框 -->
15
+ <view wx:if="{{ selectStatus }}" class="status-filter-dropdown" catch:tap>
16
+ <view class="status-filter-dropdown-item" wx:for="{{ options }}" wx:key="value"
17
+ data-value="{{ item.value }}" bind:tap="handleSelect">
18
+ {{ item.text }}
19
+ </view>
20
+ </view>
21
+ </view>
22
+
23
+ <!-- 透明遮罩:点击其他区域关闭下拉框 -->
24
+ <view wx:if="{{ selectStatus }}" class="status-filter-mask" catch:tap="handleToggle" />
25
+ </template>
26
+
27
+ <script lang="ts">
28
+ import { createComponent, ref } from "@mpxjs/core";
29
+ import { EventBase } from "../../api/types";
30
+
31
+ createComponent({
32
+ properties: {
33
+ // 下拉选项列表
34
+ options: {
35
+ type: Array,
36
+ value: [],
37
+ observer() {
38
+ this.updateCurrentText();
39
+ },
40
+ },
41
+ // 当前选中值
42
+ value: {
43
+ type: String,
44
+ value: "",
45
+ observer() {
46
+ this.updateCurrentText();
47
+ },
48
+ },
49
+ // 占位文本
50
+ placeholder: {
51
+ type: String,
52
+ value: "全部",
53
+ },
54
+ },
55
+ setup() {
56
+ // 是否展开下拉框
57
+ let selectStatus = ref(false);
58
+ // 当前显示文本
59
+ let currentText = ref("");
60
+
61
+ return { selectStatus, currentText }
62
+ },
63
+ lifetimes: {
64
+ ready() {
65
+ this.updateCurrentText();
66
+ },
67
+ },
68
+ methods: {
69
+ // 根据当前 value 在 options 中查找对应文本
70
+ updateCurrentText() {
71
+ const item = (this.options as Array<{ value: string; text: string }>)
72
+ .find((o) => o.value === this.value);
73
+ this.currentText = item ? item.text : this.placeholder;
74
+ },
75
+ // 切换下拉框展开/收起
76
+ handleToggle() {
77
+ this.selectStatus = !this.selectStatus;
78
+ },
79
+ // 选择某项
80
+ handleSelect(e: EventBase) {
81
+ const value = e.currentTarget.dataset.value as string;
82
+ const item = (this.options as Array<{ value: string; text: string }>)
83
+ .find((o) => o.value === value);
84
+ this.currentText = item ? item.text : this.placeholder;
85
+ this.selectStatus = false;
86
+ this.triggerEvent("change", { value, text: item ? item.text : this.placeholder });
87
+ },
88
+ },
89
+ })
90
+ </script>
91
+
92
+ <style lang="scss">
93
+ @use "../../styles/index.scss" as *;
94
+
95
+ .status-filter {
96
+ display: flex;
97
+ align-items: center;
98
+ gap: 10rpx;
99
+ font-weight: 400;
100
+ font-size: 26rpx;
101
+ color: $font-color-grey;
102
+ line-height: 37rpx;
103
+ position: relative;
104
+
105
+ .status-filter-current {
106
+ display: flex;
107
+ align-items: center;
108
+ gap: 6rpx;
109
+ }
110
+
111
+ // 下拉框
112
+ .status-filter-dropdown {
113
+ position: absolute;
114
+ top: 50rpx;
115
+ right: 0;
116
+ background: $background-white-color;
117
+ border-radius: 8rpx;
118
+ padding: 10rpx 0;
119
+ z-index: 101;
120
+ white-space: nowrap;
121
+ box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
122
+
123
+ .status-filter-dropdown-item {
124
+ padding: 14rpx 28rpx;
125
+ font-weight: 400;
126
+ font-size: 26rpx;
127
+ color: $font-color;
128
+ line-height: 37rpx;
129
+ }
130
+ }
131
+ }
132
+
133
+ // 透明遮罩
134
+ .status-filter-mask {
135
+ position: fixed;
136
+ top: 0;
137
+ left: 0;
138
+ right: 0;
139
+ bottom: 0;
140
+ z-index: 99;
141
+ background: transparent;
142
+ }
143
+ </style>
144
+
145
+ <script type="application/json">
146
+ {
147
+ "component": true,
148
+ "usingComponents": {
149
+ "cube-icon": "@mpxjs/mpx-cube-ui/lib/components/icon/index"
150
+ }
151
+ }
152
+ </script>
@@ -19,19 +19,16 @@ createPage({
19
19
  * 生命周期函数--监听页面加载
20
20
  */
21
21
  onLoad(async (options) => {
22
- // 判断是否登录-静默登录
23
- userStore.loginOnlyAC().then(() => {
24
- // 处理页面参数
25
- if (options.q) {
26
- const q = decodeURIComponent(options.q);
27
- if (q.includes("share?")) {
28
- const params = _URIParams(q);
29
- onRedirectTo(params, _ReturnParams(params));
30
- }
31
- } else {
32
- onRedirectTo(options, _ReturnParams(options));
22
+ // 处理页面参数
23
+ if (options.q) {
24
+ const q = decodeURIComponent(options.q);
25
+ if (q.includes("share?")) {
26
+ const params = _URIParams(q);
27
+ onRedirectTo(params, _ReturnParams(params));
33
28
  }
34
- });
29
+ } else {
30
+ onRedirectTo(options, _ReturnParams(options));
31
+ }
35
32
  });
36
33
 
37
34
  // 跳转页面
@@ -45,7 +42,10 @@ createPage({
45
42
  mpx.switchTab({ url: options.action });
46
43
  });
47
44
  } else {
48
- mpx.navigateTo({ url: `${options.action}${query}` });
45
+ // 判断是否登录-静默登录
46
+ userStore.loginTry().then(() => {
47
+ mpx.navigateTo({ url: `${options.action}${query}` });
48
+ });
49
49
  }
50
50
  };
51
51
 
package/src/store/user.ts CHANGED
@@ -40,7 +40,17 @@ export const useUserStore = defineStore("user", {
40
40
  referee: db.getReferee() || "",
41
41
  }),
42
42
  actions: {
43
- /** 登录检查 */
43
+ /** 尝试登录,无需处理异常 */
44
+ loginTry(): Promise<boolean> {
45
+ return this.loginOnlyAC()
46
+ .then((res) => {
47
+ return res;
48
+ })
49
+ .catch(() => {
50
+ return false;
51
+ });
52
+ },
53
+ /** 登录检查(需处理异常) */
44
54
  loginOnlyAC(): Promise<boolean> {
45
55
  // 1. 已登录 → 直接返回成功
46
56
  if (this.checkLogin()) {
@@ -46,7 +46,7 @@ class ShareUtil {
46
46
  .findShopBranchById(options.organTenant, options.branchId)
47
47
  .then((res) => {
48
48
  return shopStore.switchBranch(res.data).then(() => {
49
- return userStore.loginOnlyAC();
49
+ return userStore.loginTry();
50
50
  });
51
51
  });
52
52
  } else if (options.shopId) {
@@ -54,7 +54,7 @@ class ShareUtil {
54
54
  console.log("商城ID", options.shopId);
55
55
  return shopApi.findShopInfoById(options.shopId).then((res) => {
56
56
  return shopStore.switchShop(res.data).then(() => {
57
- return userStore.loginOnlyAC();
57
+ return userStore.loginTry();
58
58
  });
59
59
  });
60
60
  } else if (options.organTenant) {
@@ -63,11 +63,11 @@ class ShareUtil {
63
63
  console.log("组织Token", options.organTenant);
64
64
  return organStore.setOrganTenant(options.organTenant).then(() => {
65
65
  //静默登录
66
- return userStore.loginOnlyAC();
66
+ return userStore.loginTry();
67
67
  });
68
68
  }
69
69
  //静默登录
70
- return userStore.loginOnlyAC();
70
+ return userStore.loginTry();
71
71
  }
72
72
 
73
73
  // 分享用户页给好友
@@ -91,7 +91,7 @@ class ShareUtil {
91
91
  userStore.setReferee(options.referee);
92
92
  }
93
93
  //静默登录
94
- return userStore.loginOnlyAC();
94
+ return userStore.loginTry();
95
95
  }
96
96
  // 分享组织页给好友
97
97
  shareOrganPath(pagePath: string, query: string): string {
@@ -122,11 +122,11 @@ class ShareUtil {
122
122
  if (options.organTenant) {
123
123
  return organStore.setOrganTenant(options.organTenant).then(() => {
124
124
  //静默登录
125
- return userStore.loginOnlyAC();
125
+ return userStore.loginTry();
126
126
  });
127
127
  }
128
128
  //静默登录
129
- return userStore.loginOnlyAC();
129
+ return userStore.loginTry();
130
130
  }
131
131
 
132
132
  // 分享电商页给好友
@@ -174,7 +174,7 @@ class ShareUtil {
174
174
  .findShopBranchById(options.organTenant, options.branchId)
175
175
  .then((res) => {
176
176
  return shopStore.switchBranch(res.data).then(() => {
177
- return userStore.loginOnlyAC();
177
+ return userStore.loginTry();
178
178
  });
179
179
  });
180
180
  } else if (options.shopId) {
@@ -182,12 +182,12 @@ class ShareUtil {
182
182
  console.log("商城ID", options.shopId);
183
183
  return shopApi.findShopInfoById(options.shopId).then((res) => {
184
184
  return shopStore.switchShop(res.data).then(() => {
185
- return userStore.loginOnlyAC();
185
+ return userStore.loginTry();
186
186
  });
187
187
  });
188
188
  }
189
189
  //静默登录
190
- return userStore.loginOnlyAC();
190
+ return userStore.loginTry();
191
191
  }
192
192
  }
193
193
  const share = new ShareUtil();