zhaoxiaohai 3 years ago
parent
commit
6245cc4953
4 changed files with 45 additions and 6 deletions
  1. 1 1
      pages/chatRoom/dialogbox.js
  2. 2 1
      pages/chatRoom/dialogbox.wxml
  3. 40 2
      pages/chatRoom/index.js
  4. 2 2
      pages/chatRoom/index.wxml

+ 1 - 1
pages/chatRoom/dialogbox.js

@@ -34,7 +34,7 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
-        app.initSocket(); //链接websocket 用于测试
+        //app.initSocket(); 链接websocket 用于测试
         const that = this;
         this.setData({
             timdialogid: options.id,

+ 2 - 1
pages/chatRoom/dialogbox.wxml

@@ -25,7 +25,8 @@
 <!-- 底部输入 -->
 <view class="input-box" style="bottom:{{keyboardHeight}}px;" wx:if="{{fimuserid==userid||fimdialogtype!='话题'}}">
     <!-- 普通输入框 -->
-    <textarea class="input-text" bindfocus="textareaFocus" bindblur="sendMsg" adjust-position='{{false}}' bindconfirm='sendMsg' show-confirm-bar='{{false}}' confirm-type='send' confirm-hold='true' cursor-spacing='45' bindinput='sendInput' value='{{sendText}}' maxlength='-1' fixed='true' type="text" bindlinechange='linechange' bindkeyboardheightchange='keyboardheightchange'>
+    <!-- bindblur="sendMsg" -->
+    <textarea class="input-text" bindfocus="textareaFocus" adjust-position='{{false}}' bindconfirm='sendMsg' show-confirm-bar='{{false}}' confirm-type='send' confirm-hold='true' cursor-spacing='45' bindinput='sendInput' value='{{sendText}}' maxlength='-1' fixed='true' type="text" bindlinechange='linechange' bindkeyboardheightchange='keyboardheightchange'>
     <!-- 话题 -->
     <block wx:if="{{fimdialogtype=='话题'}}">
         <view class="gambit" wx:if="{{timsubjectid==0}}" catchtap="createGambit">

+ 40 - 2
pages/chatRoom/index.js

@@ -10,8 +10,11 @@ Page({
     data: {
         iosX: false, //判断是否具有安全距离
         optionItem: 0, //底部选中
-        reltionList: [], //沟通列表
+        relationList: [], //沟通列表
         discussionGroupList: [], //讨论组列表
+        relationListCopy: [], //备份
+        discussionGroupListCopy: [], //备份
+        searchText: '', //搜索文本
     },
 
     /**
@@ -24,6 +27,39 @@ Page({
             iosX
         })
     },
+    /* 列表搜索 */
+    listSearch(e) {
+        const value = e.detail.value.trim();
+        if (value == this.data.searchText) return;
+        this.setData({
+            searchText: value
+        })
+        if (value == '') {
+            this.setData({
+                relationList: this.data.relationListCopy,
+                discussionGroup: this.data.discussionGroupListCopy
+            })
+        } else {
+            let relationList = this.data.relationListCopy,
+                discussionGroup = this.data.discussionGroupListCopy,
+                newRelationList = [],
+                newDiscussionGroup = [];
+            for (let i = 0; i < relationList.length; i++) {
+                let data = relationList[i];
+                data.users = ''
+                if (JSON.stringify(data).includes(value)) newRelationList.push(relationList[i])
+            };
+            for (let i = 0; i < discussionGroup.length; i++) {
+                let data = discussionGroup[i];
+                data.users = ''
+                if (JSON.stringify(data).includes(value)) newDiscussionGroup.push(discussionGroup[i])
+            }
+            this.setData({
+                relationList: newRelationList,
+                discussionGroupList: newDiscussionGroup
+            })
+        }
+    },
     /* 创建对话 */
     createDialogue() {
         wx.navigateTo({
@@ -82,7 +118,9 @@ Page({
             }
             this.setData({
                 relationList,
-                discussionGroupList
+                relationListCopy: relationList,
+                discussionGroupList,
+                discussionGroupListCopy: discussionGroupList
             })
         })
     },

+ 2 - 2
pages/chatRoom/index.wxml

@@ -2,7 +2,7 @@
 <view class="search-box">
     <view class="search-input">
         <image src="/static/icon-16.png"></image>
-        <input type="text" confirm-type='search' placeholder="{{optionItem==0?'搜索成员':'搜索群'}}" placeholder-class="input-placeholder" />
+        <input type="text" confirm-type='search' placeholder="{{optionItem==0?'搜索成员':'搜索群'}}" bindconfirm="listSearch" placeholder-class="input-placeholder" />
     </view>
     <view class="newly-built">
         <van-button custom-class='newButton' catchtap="createDialogue">
@@ -57,7 +57,7 @@
             </view>
         </navigator>
     </view>
-    <My_pageReachBottom dummyStatus="{{relationList.length>0}}" loadMore='{{5>=0}}'></My_pageReachBottom>
+    <My_pageReachBottom dummyStatus="{{discussionGroupList.length>0}}" loadMore='{{5>=0}}'></My_pageReachBottom>
 </view>
 <!-- 底部 -->
 <view class="footer">