Browse Source

工具切换品牌

zhaoxiaohai 2 years ago
parent
commit
66020e6ee9
2 changed files with 23 additions and 12 deletions
  1. 22 11
      packageA/tool/index.js
  2. 1 1
      packageA/tool/index.wxml

+ 22 - 11
packageA/tool/index.js

@@ -95,6 +95,11 @@ Page({
       this.getTypeList();
     })
   },
+  /* 切换品牌 */
+  brandChange(e) {
+    this.data.brand = e.detail.item;
+    this.getTypeList();
+  },
   /* 获取分类 */
   getTypeList() {
     _Http.basic({
@@ -106,13 +111,21 @@ Page({
       }
     }).then(res => {
       console.log("工具营销类别", res)
-      if (res.data[0].ttemclass) this.setData({
-        ['typeList[0]']: {
-          active: 0,
-          list: res.data[0].ttemclass
-        },
-        "cType": res.data[0].ttemclass[0]
-      });
+      if (res.data[0].ttemclass) {
+        res.data[0].ttemclass.unshift({
+          itemclassid: "",
+          itemclassfullname: "全部",
+          itemclassname: "全部",
+          subdep: []
+        })
+        this.setData({
+          ['typeList[0]']: {
+            active: 0,
+            list: res.data[0].ttemclass
+          },
+          "cType": res.data[0].ttemclass[0]
+        });
+      }
       this.getList(true);
     })
   },
@@ -122,15 +135,13 @@ Page({
     let content = this.data.content;
     if (init) content.pageNumber = 1;
     if (content.pageNumber > content.pageTotal) return;
-
     content.brandids = [this.data.brand.sa_brandid];
-    content.itemclassids = [this.data.cType.itemclassid];
-
+    content.itemclassids = this.data.cType.itemclassid ? [this.data.cType.itemclassid] : "";
     _Http.basic({
       "id": 20220924163802,
       content
     }).then(res => {
-      console.log("商品列表", res)
+      console.log("工具列表", res)
       this.selectComponent('#ListBox').RefreshToComplete();
       this.setData({
         list: res.data,

+ 1 - 1
packageA/tool/index.wxml

@@ -1,6 +1,6 @@
 <Yl_HeadNav styleType="1" sort='{{content.sort}}' bindonSearch="onSearch" />
 <!-- 品牌列表 -->
-<Tabs list="{{brandList}}" box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' />
+<Tabs list="{{brandList}}" box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' bind:onChange="brandChange" />
 <!-- 产品列表 -->
 <Tabs wx:for="{{typeList}}" active="{{item.active}}" wx:key="{{index}}" rowIndex="{{index}}" list="{{item.list}}" bind:onChange="typeChange" name='itemclassname' box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' />
 <view class="division" />