zhaoxiaohai 3 years ago
parent
commit
9803a8ab5f

+ 32 - 0
pages/threadedTree/modules/search/search.js

@@ -0,0 +1,32 @@
+let count = null;
+Component({
+    properties: {
+        inputSharch: {
+            type: Function
+        }
+    },
+    data: {
+        isClear: false
+    },
+    options: {
+        addGlobalClass: true,
+    },
+    methods: {
+        textChange(e) {
+            clearTimeout(count);
+            if (this.data.isClear) {
+                this.triggerEvent("inputSharch");
+                this.setData({
+                    isClear: false
+                })
+                return;
+            }
+            e.type == "change" ? count = setTimeout(() => this.triggerEvent("inputSharch", e.detail.trim()), 1000) : this.triggerEvent("inputSharch", e.detail.trim());
+        },
+        onClear() {
+            this.setData({
+                isClear: true
+            })
+        }
+    }
+})

+ 4 - 0
pages/threadedTree/modules/search/search.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 12 - 0
pages/threadedTree/modules/search/search.scss

@@ -0,0 +1,12 @@
+.right {
+    position: relative;
+    width: 40px;
+    height: 100%;
+    text-align: center;
+    line-height: 100%;
+    color: #ffffff;
+    padding-top: 6rpx;
+    text{
+        font-size: 46rpx;
+    }
+}

+ 5 - 0
pages/threadedTree/modules/search/search.wxml

@@ -0,0 +1,5 @@
+<van-search value="{{ value }}" shape="round" bind:change='textChange' bind:clear='onClear' bind:search='textChange' background="var(--bgColor)" use-action-slot placeholder="请输入搜索关键词">
+    <view slot='action' class="right">
+        <text class="iconfont icon-paixu" />
+    </view>
+</van-search>