jufubao-mall 2.0.90 → 2.0.91-beta2

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,12 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(git checkout *)",
5
+ "Bash(npx lessc *)",
6
+ "Bash(python3 *)",
7
+ "Bash(sips -g pixelWidth -g pixelHeight \"/Users/zxd/Workspaces/jufubao-mall/temp_screenshot.jpg\")",
8
+ "Bash(identify \"/Users/zxd/Workspaces/jufubao-mall/temp_screenshot.jpg\")",
9
+ "Bash(sips *)"
10
+ ]
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jufubao-mall",
3
- "version": "2.0.90",
3
+ "version": "2.0.91-beta2",
4
4
  "private": false,
5
5
  "description": "聚福宝商城业务组件插件包",
6
6
  "main": "index.js",
@@ -306,6 +306,7 @@
306
306
  is_plus_site: false,
307
307
  productKey: 'productKey',
308
308
  curParentIndex: 0,
309
+ cateId: '',
309
310
 
310
311
  // 排序功能
311
312
  sortType: 'default',
@@ -469,6 +470,10 @@
469
470
  onJfbLoad(options) {
470
471
  this.setNameSpace(options);
471
472
  this.onLoadStatus = true;
473
+ // 路由带分类id时,保存用于定位对应分类
474
+ if (options.cateId) {
475
+ this.cateId = Number(options.cateId);
476
+ }
472
477
  this.getType2Nav()
473
478
  },
474
479
  init(container) {
@@ -667,6 +672,10 @@
667
672
  return item;
668
673
  });
669
674
  this.allNavList = items;
675
+ // 路由带分类id时,定位到对应分类
676
+ if (this.cateId && this.locateCategory(items)) {
677
+ return;
678
+ }
670
679
  // layoutStyle=2: 无顶部导航,左侧直接显示一级导航
671
680
  if (this.layoutStyle === '2') {
672
681
  this.navChildrenList = this.allNavList;
@@ -682,6 +691,43 @@
682
691
  })
683
692
  },
684
693
 
694
+ // 根据路由cateId在分类树中定位,命中则选中对应分类并返回true
695
+ locateCategory(items) {
696
+ // 1. 优先匹配二级分类
697
+ let parentIndex = -1;
698
+ let childIndex = -1;
699
+ items.forEach((item, pIndex) => {
700
+ const cIndex = (item.children || []).findIndex(child => Number(child.category_id) === this.cateId);
701
+ if (cIndex > -1) {
702
+ parentIndex = pIndex;
703
+ childIndex = cIndex;
704
+ }
705
+ });
706
+ if (parentIndex > -1) {
707
+ this.curParentIndex = parentIndex;
708
+ this.navChildrenList = items[parentIndex].children;
709
+ this.selectNav = this.navChildrenList[childIndex];
710
+ this.selectNavIndex = childIndex;
711
+ return true;
712
+ }
713
+ // 2. 匹配一级分类
714
+ const pIndex = items.findIndex(item => Number(item.category_id) === this.cateId);
715
+ if (pIndex > -1) {
716
+ this.curParentIndex = pIndex;
717
+ if (this.layoutStyle === '2') {
718
+ this.navChildrenList = this.allNavList;
719
+ this.selectNav = items[pIndex];
720
+ this.selectNavIndex = pIndex;
721
+ } else {
722
+ this.navChildrenList = items[pIndex].children;
723
+ this.selectNav = this.navChildrenList[0];
724
+ this.selectNavIndex = 0;
725
+ }
726
+ return true;
727
+ }
728
+ return false;
729
+ },
730
+
685
731
  getContentStyle(type = 'cont') {
686
732
  let outerWidth = (uni.getSystemInfoSync().safeArea.width * this.$pxNum) - 180;
687
733
 
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * @description 第三方库
5
- * @param threePackagePath {String} 第三方库所在项目路径存放路径路
6
- * @param packname {String} 包名字
7
- * @returns {string|*}
8
- */
9
- const getPackagePath = (threePackagePath, packname = 'gxd-commands-bussiness')=>{
10
- if(packname === 'gxd-commands-bussiness') {
11
- return `/Users/shiyonggao/Desktop/code/BASE/UNIAPP/xd-commands-bussiness/${threePackagePath}`;
12
- }
13
-
14
- if (packname === 'gxd-uni-library-editx') {
15
- return `/Users/shiyonggao/Desktop/code/BASE/UNIAPP/xd-uni-library-editx/${threePackagePath}`;
16
- }
17
-
18
- };
19
-
20
- module.exports = {
21
- getPackagePath
22
- }