浏览代码

添加搜索框

xiaohaizhao 2 年之前
父节点
当前提交
fc18546756
共有 2 个文件被更改,包括 14 次插入3 次删除
  1. 10 2
      pages/classroom/index.js
  2. 4 1
      pages/classroom/index.wxml

+ 10 - 2
pages/classroom/index.js

@@ -1,5 +1,6 @@
 const _Http = getApp().globalData.http;
 let content = null;
+let condition = "";
 Page({
     data: {
 
@@ -10,7 +11,10 @@ Page({
             "classname": "saletool.courseware.courseware",
             "method": "selectMenu",
             "content": {
-                pageSize: 999
+                pageSize: 999,
+                "where": {
+                    condition
+                }
             }
         }).then(res => {
             console.log('分类', res)
@@ -30,7 +34,7 @@ Page({
                 "pageNumber": 1,
                 "pageSize": 15,
                 "where": {
-                    "condition": ""
+                    condition
                 }
             }
         }).then(res => {
@@ -44,6 +48,10 @@ Page({
             })
         })
     },
+    onSearch({detail}){
+        condition = detail;
+        this.getList()
+    },
     onShow() {
         this.getList()
     },

+ 4 - 1
pages/classroom/index.wxml

@@ -1,4 +1,7 @@
-<van-tabs class="tabs" tab-class='tab-class' color='#3874F6' title-active-color='#3874F6' bind:change="tabsChange">
+<view style="position: sticky;top: 0;width: 100vw;z-index: 999;">
+    <van-search shape="round" background="#085CDF" placeholder="请输入搜索关键词" bind:search='onSearch' bind:clear='onSearch' sticky />
+</view>
+<van-tabs sticky class="tabs" tab-class='tab-class' color='#3874F6' title-active-color='#3874F6' bind:change="tabsChange" offset-top='54'>
     <van-tab title="课程列表">
         <view class="main-1">
             <navigator url="./list?id={{item.sat_courseware_classid}}" class="item" wx:for="{{list}}" wx:key="sat_courseware_classid">