Przeglądaj źródła

通告添加搜索和筛选逻辑

zhaoxiaohai 3 lat temu
rodzic
commit
129f48dd53

+ 59 - 9
pages/annunciate/index.js

@@ -2,6 +2,7 @@ const _Http = getApp().globalData.http;
 Page({
     data: {
         list: [],
+        filtrate: false,
         "content": {
             nocache: true,
             "pageNumber": 1,
@@ -11,7 +12,16 @@ Page({
                 "condition": ""
             }
         },
-        unreadNum: 0
+        unreadNum: 0,
+        filtratelist: [{
+            label: "板块",
+            index: null,
+            showName: "classname", //显示字段
+            valueKey: "sat_notice_classid", //返回Key
+            selectKey: "sat_notice_classid", //传参 代表选着字段 不传参返回整个选择对象
+            value: "", //选中值
+            list: null
+        }]
     },
     onLoad(options) {
         const auth = options.auth ? JSON.parse(options.auth) : getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['通告'])[0].apps;
@@ -22,16 +32,14 @@ Page({
         })
         this.getList();
     },
-
     getList(init = false) {
         if (init.detail != undefined) init = init.detail;
-        if (init) this.setData({
-            ['content.pageNumber']: 1
-        })
-        if (this.data.content.pageNumber > this.data.content.pageTotal) return;
+        let content = this.data.content;
+        if (init) content.pageNumber = 1;
+        if (content.pageNumber > content.pageTotal) return;
         _Http.basic({
             id: 20221111090904,
-            content: this.data.content
+            content: content
         }).then(res => {
             console.log("通告列表", res)
             this.selectComponent('#ListBox').RefreshToComplete();
@@ -42,8 +50,8 @@ Page({
             this.setData({
                 total: res.total,
                 list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
-                ['content.pageNumber']: res.pageNumber + 1,
-                ['content.pageTotal']: res.pageTotal,
+                'content.pageNumber': res.pageNumber + 1,
+                'content.pageTotal': res.pageTotal,
                 unreadNum: res.total - res.tips.readNum
             })
         })
@@ -60,4 +68,46 @@ Page({
     onReady() {
         this.selectComponent("#ListBox").setHeight(".top", this);
     },
+    startSearch({
+        detail
+    }) {
+        if (detail == this.data.content.where.condition) return;
+        this.data.content.where.condition = detail;
+        this.getList(true);
+    },
+    /* 取消搜索 */
+    onClear() {
+        this.data.content.where.condition = "";
+        this.getList(true);
+    },
+    openFiltrate() {
+        if (this.data.filtratelist[0].list == null) {
+            _Http.basic({
+                id: 20221101094603,
+                "content": {
+                    nocache: true,
+                    "pageNumber": 1,
+                    "pageSize": 999,
+                    "where": {
+                        "condition": ""
+                    }
+                }
+            }).then(res => {
+                console.log("通告板块", res)
+                this.setData({
+                    "filtratelist[0].list": res.data,
+                    filtrate: true
+                })
+            })
+        } else {
+            this.setData({
+                filtrate: true
+            })
+        }
+    },
+    /* 处理筛选 */
+    handleFilter(e) {
+        this.data.content.where.sat_notice_classid = e.detail.sat_notice_classid || "";
+        this.getList(true)
+    },
 })

+ 9 - 2
pages/annunciate/index.scss

@@ -1,8 +1,8 @@
 @import "../../static/unread.wxss";
 
 page {
-	height: 100vh;
-	overflow: hidden;
+    height: 100vh;
+    overflow: hidden;
 }
 
 .list-box {
@@ -11,4 +11,11 @@ page {
     border-radius: 16rpx;
     margin: 20rpx auto 0;
     padding: 30rpx 0;
+}
+
+.iconfont {
+    font-size: 28rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #666666;
+    padding: 0 10rpx;
 }

+ 15 - 7
pages/annunciate/index.wxml

@@ -1,9 +1,17 @@
+<van-search value="{{ content.where.condition }}" shape='round' placeholder="请输入搜索关键词" use-action-slot bind:clear='onClear' bind:search="startSearch">
+	<navigator url="#" slot="action" class="iconfont icon-shaixuan" bindtap="openFiltrate">
+		筛选
+	</navigator>
+</van-search>
+
 <view class="top" />
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
-  <view class="unread">总共{{total}}条,未读{{unreadNum}}条</view>
-  <navigator class="list-box" url="#" wx:for="{{list}}" data-item="{{item}}" bindtap="toDetails">
-    <Item item="{{item}}" />
-  </navigator>
-  <My_empty wx:if="{{!list.length}}" />
-  <view style="height: 40px;" />
-</Yl_ListBox>
+	<!-- ,未读{{unreadNum||0}}条 -->
+	<view class="unread">总共{{total}}条</view>
+	<navigator class="list-box" url="#" wx:for="{{list}}" data-item="{{item}}" bindtap="toDetails">
+		<Item item="{{item}}" />
+	</navigator>
+	<My_empty wx:if="{{!list.length}}" />
+</Yl_ListBox>
+
+<Yl_Filtrate1 show='{{filtrate}}' list="{{filtratelist}}" bindhandle="handleFilter" />