Procházet zdrojové kódy

自定义分类选择页支持搜索

xiaohaizhao před 1 rokem
rodič
revize
baa3067733
2 změnil soubory, kde provedl 20 přidání a 2 odebrání
  1. 18 2
      packageA/options/index.js
  2. 2 0
      packageA/options/index.wxml

+ 18 - 2
packageA/options/index.js

@@ -5,6 +5,9 @@ Page({
             "pageNumber": 1,
             "pageSize": 20,
             "pageTotal": 1,
+            "where": {
+                "condition": ""
+            }
         },
         result: [],
         list: []
@@ -44,7 +47,8 @@ Page({
         let {
             pageNumber,
             pageTotal,
-            pageSize
+            pageSize,
+            where
         } = this.data.paging;
         if (init) {
             pageNumber = 1;
@@ -60,7 +64,8 @@ Page({
                 "typename": this.data.item.optionNmae,
                 "parameter": {
                     "siteid": wx.getStorageSync('siteP').siteid
-                }
+                },
+                where
             }
         }).then(res => {
             console.log("可选项查询", res)
@@ -95,4 +100,15 @@ Page({
     onReachBottom() {
         this.getList();
     },
+    onSearch({
+        detail
+    }) {
+        this.data.paging.where.condition = detail;
+        this.getList(true);
+    },
+    onClear() {
+        this.onSearch({
+            detail: ""
+        })
+    }
 })

+ 2 - 0
packageA/options/index.wxml

@@ -1,3 +1,5 @@
+<van-search custom-class='search' value="{{ paging.where.condition }}" shape="round" background="#fff" placeholder="请输入搜索关键字" bind:search='onSearch' bind:clear='onClear' />
+<view style="height: 20rpx;" />
 <van-checkbox-group value="{{ result }}" bind:change="onChange">
     <van-cell-group>
         <van-cell wx:for="{{ list }}" wx:key="value" title="{{ item.value }}" label="{{item.remarks}}" value-class="value-class" clickable data-item="{{ item }}" bind:click="toggle">