jmash-core-mp 0.1.77 → 0.1.79

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.
Files changed (28) hide show
  1. package/lib/utils/common.d.ts +2 -0
  2. package/lib/utils/common.js +13 -0
  3. package/package.json +1 -1
  4. package/src/components/common/jmash-form-cell.mpx +32 -66
  5. package/src/index.ts +1 -0
  6. package/src/utils/common.ts +20 -2
  7. package/lib/components/cms/jmash-cms-activity-list.mpx.d.ts +0 -1
  8. package/lib/components/cms/jmash-cms-article-item.mpx.d.ts +0 -1
  9. package/lib/components/cms/jmash-cms-article-list.mpx.d.ts +0 -1
  10. package/lib/components/cms/jmash-cms-article-view.mpx.d.ts +0 -1
  11. package/lib/components/cms/jmash-cms-like.mpx.d.ts +0 -1
  12. package/lib/components/cms/jmash-cms-location-list.mpx.d.ts +0 -1
  13. package/lib/components/cms/jmash-cms-product-item.mpx.d.ts +0 -1
  14. package/lib/components/cms/jmash-cms-product-list.mpx.d.ts +0 -1
  15. package/lib/components/common/jmash-search.mpx.d.ts +0 -1
  16. package/lib/components/core/jmash-login.mpx.d.ts +0 -1
  17. package/lib/components/organ/organ-item.mpx.d.ts +0 -1
  18. package/lib/components/shop/branch-item.mpx.d.ts +0 -1
  19. package/lib/components/shop/shop-item.mpx.d.ts +0 -1
  20. package/lib/packages/pages/auth/setting-page.mpx.d.ts +0 -1
  21. package/lib/packages/pages/cms/cms-activity-list.mpx.d.ts +0 -1
  22. package/lib/packages/pages/cms/cms-article-list.mpx.d.ts +0 -1
  23. package/lib/packages/pages/cms/cms-location-list.mpx.d.ts +0 -1
  24. package/lib/packages/pages/cms/cms-product-list.mpx.d.ts +0 -1
  25. package/lib/packages/pages/share/scan.mpx.d.ts +0 -1
  26. /package/lib/{components/auth-user/jmash-update-user.mpx.d.ts → pages/branch-search.mpx.d.ts} +0 -0
  27. /package/lib/{components/auth-user/jmash-user.mpx.d.ts → pages/organ-search.mpx.d.ts} +0 -0
  28. /package/lib/{components/cms/jmash-cms-activity-item.mpx.d.ts → pages/shop-search.mpx.d.ts} +0 -0
@@ -33,3 +33,5 @@ export declare const validateRules: (value: string, message: string, rules: any)
33
33
  * @param {string} message 错误提示信息
34
34
  */
35
35
  export declare const validateRequired: (value: string | number, message: string) => boolean;
36
+ export declare function hasCategoryFeature(dictCode: string, feature: string): boolean;
37
+ export declare const categoryFeatures: Record<string, string[]>;
@@ -163,3 +163,16 @@ export const validateRequired = (value, message) => {
163
163
  }
164
164
  return true;
165
165
  };
166
+ // 判断当前商家分类是否支持某功能
167
+ export function hasCategoryFeature(dictCode, feature) {
168
+ if (!dictCode)
169
+ return false;
170
+ const keywords = categoryFeatures[feature] || [];
171
+ return keywords.some((i) => dictCode.includes(i));
172
+ }
173
+ // 商家分类功能配置:功能名 -> 分类code关键词列表
174
+ export const categoryFeatures = {
175
+ // AI换发型 - 0504美容美发
176
+ aiHairstyle: ["0504"],
177
+ // - 0502洗车保养- 0503足疗/按摩- 0506鲜花/园艺
178
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.77",
3
+ "version": "0.1.79",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -66,20 +66,18 @@
66
66
 
67
67
  <!-- 选择器选项类型 -->
68
68
  <block wx:elif="{{ type === 'picker-option' }}">
69
- <!-- 展示区 -->
70
- <view class="form-cell-picker"
71
- style="{{ label ? 'justify-content: flex-end;' : 'justify-content: flex-start;' }}"
72
- data-field="{{ field }}" bind:tap="{{ readonly ? '' : 'handlePickerOptTap' }}">
73
- <view class="form-cell-picker-text {{ pickerOptDisplayText ? '' : 'form-cell-picker-empty' }}"
74
- style="{{ label ? '' : 'margin-right: auto;' }}">
75
- {{ pickerOptDisplayText || placeholder }}
69
+ <!-- 原生选择器:点击展示区唤起系统选择器,取消不触发 change,无需手动管理显隐 -->
70
+ <picker class="form-cell-picker-wrap" mode="selector" range="{{ pickerOptList }}" range-key="text"
71
+ value="{{ pickerOptSelectedIndex }}" disabled="{{ readonly }}" bind:change="handlePickerOptChange"
72
+ style="{{ label ? 'justify-content: flex-end;' : 'justify-content: flex-start;' }}">
73
+ <view class="form-cell-picker">
74
+ <view class="form-cell-picker-text {{ pickerOptDisplayText ? '' : 'form-cell-picker-empty' }}"
75
+ style="{{ label ? '' : 'margin-right: auto;' }}">
76
+ {{ pickerOptDisplayText || placeholder }}
77
+ </view>
78
+ <text class="form-cell-arrow">›</text>
76
79
  </view>
77
- <text class="form-cell-arrow">›</text>
78
- </view>
79
- <!-- 弹出选择列表 -->
80
- <cube-picker-popup wx:ref="pickerOption" show="{{ pickerOptShow }}" list="{{ pickerOptList }}"
81
- selectedIndex="{{ pickerOptSelectedIndex }}" fullyStop="true" bind:change="handlePickerOptChange"
82
- bind:confirm="handlePickerOptConfirm" bind:cancel="handlePickerOptClose" />
80
+ </picker>
83
81
  </block>
84
82
 
85
83
  <!-- 上传图片类型 -->
@@ -187,23 +185,19 @@ createComponent({
187
185
  },
188
186
  },
189
187
  setup(props) {
190
- // 自动选择器弹框显隐
191
- let pickerOptShow = ref(false);
192
188
  // 自动选择器当前选中索引
193
- let pickerOptSelectedIndex = ref([0]);
189
+ let pickerOptSelectedIndex = ref(0);
194
190
  // 自动选择器展示文本
195
191
  let pickerOptDisplayText = ref("");
196
- // 自动选择器数据转 cube-picker-popup 格式(二维数组)
192
+ // 自动选择器数据转原生 picker range 格式
197
193
  let pickerOptList = computed(() => {
198
194
  const { pickerData, pickerOptions } = props;
199
- if (!pickerData || !pickerData.length) return [[]];
200
- return [
201
- pickerData.map((item: any) => ({
202
- text: item[pickerOptions.valueLable],
203
- value: item[pickerOptions.valueKey],
204
- ...item,
205
- })),
206
- ];
195
+ if (!pickerData || !pickerData.length) return [];
196
+ return pickerData.map((item: any) => ({
197
+ text: item[pickerOptions.valueLable],
198
+ value: item[pickerOptions.valueKey],
199
+ ...item,
200
+ }));
207
201
  });
208
202
 
209
203
  // 单选选项 value 是否为 boolean 类型
@@ -234,7 +228,6 @@ createComponent({
234
228
  }, { immediate: true });
235
229
 
236
230
  return {
237
- pickerOptShow,
238
231
  pickerOptSelectedIndex,
239
232
  pickerOptDisplayText,
240
233
  pickerOptList,
@@ -247,15 +240,13 @@ createComponent({
247
240
  // 当 value、data 或 options 变化时,刷新展示文本和选中索引
248
241
  "value, pickerData, pickerOptions"(value: any, pickerData: any[], pickerOptions: any) {
249
242
  if (!pickerData || !pickerData.length || !pickerOptions || !pickerOptions.valueKey) {
250
- this.pickerOptSelectedIndex = [0];
243
+ this.pickerOptSelectedIndex = 0;
251
244
  this.pickerOptDisplayText = "";
252
245
  return;
253
246
  }
254
247
  const index = pickerData.findIndex((item) => item[pickerOptions.valueKey] === value);
255
- const selectedIndex = index >= 0 ? index : 0;
256
- const displayText = index >= 0 ? pickerData[index][pickerOptions.valueLable] : "";
257
- this.pickerOptSelectedIndex = [selectedIndex];
258
- this.pickerOptDisplayText = displayText;
248
+ this.pickerOptSelectedIndex = index >= 0 ? index : 0;
249
+ this.pickerOptDisplayText = index >= 0 ? pickerData[index][pickerOptions.valueLable] : "";
259
250
  },
260
251
  },
261
252
  methods: {
@@ -296,32 +287,13 @@ createComponent({
296
287
 
297
288
  // === 自动选择器方法 ===
298
289
 
299
- // 点击展示区,打开选择弹框
300
- handlePickerOptTap() {
301
- // 同步当前 value 对应的索引
302
- this._feedbackPickerOpt();
303
- this.pickerOptShow = true;
304
- if (this.$refs.pickerOption) this.$refs.pickerOption.show();
305
- },
306
- // 关闭弹框(未确认,索引回滚到当前值对应项)
307
- handlePickerOptClose() {
308
- this.pickerOptShow = false;
309
- if (this.$refs.pickerOption) this.$refs.pickerOption.hide();
310
- this._feedbackPickerOpt();
311
- },
312
- // 滚动选择(仅记录索引,显示文本保持已确认值,避免未确认关闭时显示与数据不一致)
290
+ // 确认选择(原生 picker 的 change 在点击确定后触发,取消不触发任何回调,无需回滚索引)
313
291
  handlePickerOptChange(e: EventBase) {
314
- const index = e.detail.selectedIndex as number[];
315
- this.pickerOptSelectedIndex = index;
316
- },
317
- // 确认选择
318
- handlePickerOptConfirm(e: EventBase) {
319
- const index = e.detail.selectedIndex as number[];
320
- const item = this.pickerData[index[0]];
292
+ const index = e.detail.value as number;
293
+ const item = this.pickerData[index];
294
+ if (!item) return;
321
295
  this.pickerOptSelectedIndex = index;
322
296
  this.pickerOptDisplayText = item[this.pickerOptions.valueLable];
323
- // 关闭弹框
324
- this.handlePickerOptClose();
325
297
  this.triggerEvent("change", {
326
298
  field: this.field,
327
299
  value: item[this.pickerOptions.valueKey],
@@ -329,17 +301,6 @@ createComponent({
329
301
  info: item,
330
302
  });
331
303
  },
332
- // 同步 value 到选中索引
333
- _feedbackPickerOpt() {
334
- if (!this.pickerData || !this.pickerData.length || !this.pickerOptions || !this.pickerOptions.valueKey) {
335
- this.pickerOptSelectedIndex = [0];
336
- return;
337
- }
338
- const index = this.pickerData.findIndex(
339
- (item: any) => item[this.pickerOptions.valueKey] === this.value
340
- );
341
- this.pickerOptSelectedIndex = [index >= 0 ? index : 0];
342
- },
343
304
  },
344
305
  });
345
306
  </script>
@@ -423,6 +384,12 @@ createComponent({
423
384
  }
424
385
  }
425
386
 
387
+ // 原生选择器包裹层
388
+ .form-cell-picker-wrap {
389
+ flex: 1;
390
+ display: flex;
391
+ }
392
+
426
393
  // 自动选择器
427
394
  .form-cell-picker {
428
395
  flex: 1;
@@ -517,7 +484,6 @@ createComponent({
517
484
  "usingComponents": {
518
485
  "jmash-upload-picture": "./jmash-upload-picture",
519
486
  "cube-popup": "@mpxjs/mpx-cube-ui/lib/components/popup/index",
520
- "cube-picker-popup": "@mpxjs/mpx-cube-ui/lib/components/picker-popup/index",
521
487
  "cube-radio-group": "@mpxjs/mpx-cube-ui/lib/components/radio-group/index",
522
488
  "cube-radio": "@mpxjs/mpx-cube-ui/lib/components/radio/index",
523
489
  }
package/src/index.ts CHANGED
@@ -86,6 +86,7 @@ export {
86
86
  formatDateTime,
87
87
  validateRules,
88
88
  validateRequired,
89
+ hasCategoryFeature,
89
90
  } from "./utils/common";
90
91
 
91
92
  import * as dayjsLocaleZhCn from "dayjs/locale/zh-cn";
@@ -141,7 +141,7 @@ export const formatDateTime = (dateTimeString: string, format?: any) => {
141
141
  export const validateRules = (
142
142
  value: string,
143
143
  message: string,
144
- rules: any
144
+ rules: any,
145
145
  ): boolean => {
146
146
  if (value && !rules.test(value)) {
147
147
  // 显示错误提示
@@ -162,7 +162,7 @@ export const validateRules = (
162
162
  */
163
163
  export const validateRequired = (
164
164
  value: string | number,
165
- message: string
165
+ message: string,
166
166
  ): boolean => {
167
167
  const valueStr = typeof value === "number" ? String(value) : value;
168
168
  if (!valueStr || valueStr.trim() === "") {
@@ -176,3 +176,21 @@ export const validateRequired = (
176
176
  }
177
177
  return true;
178
178
  };
179
+
180
+ // 判断当前商家分类是否支持某功能
181
+ export function hasCategoryFeature(dictCode: string, feature: string): boolean {
182
+ if (!dictCode) return false;
183
+ const keywords = categoryFeatures[feature] || [];
184
+ return keywords.some((i) => dictCode.includes(i));
185
+ }
186
+ // 商家分类功能配置:功能名 -> 分类code关键词列表
187
+ export const categoryFeatures: Record<string, string[]> = {
188
+ // 0502洗车保养
189
+ serveCar: ["0502"],
190
+ // 0503足疗/按摩
191
+ serveFoot: ["0503"],
192
+ // 0504美容美发
193
+ serveHair: ["0504"],
194
+ // 0506鲜花/园艺
195
+ serveFlower: ["0506"],
196
+ };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};