chenxiaofeng лет назад: 5
Родитель
Сommit
b3dfd0115a
2 измененных файлов с 27 добавлено и 9 удалено
  1. 13 8
      pages/information/chat/chat.js
  2. 14 1
      utils/websocket.js

+ 13 - 8
pages/information/chat/chat.js

@@ -591,14 +591,19 @@ Page({
591
     }
591
     }
592
   }, 
592
   }, 
593
   onUnload: function (e) {
593
   onUnload: function (e) {
594
-    let url = 'imsocket/imchatmessage/clearunreadmsg';
595
-    let datas = {
596
-      to_id: this.data.to_id, form_id: getApp().UserId()
597
-    };
598
-    //清除未读信息
599
-    getApp().postRequest(url, datas, function (res) {
600
-      console.log(res, 11111);
601
-    })
594
+    let _that = this;
595
+    _that.SocketSend({
596
+      type: 'clearChatTotal'
597
+      });
598
+
599
+    // let url = 'imsocket/imchatmessage/clearunreadmsg';
600
+    // let datas = {
601
+    //   to_id: this.data.to_id, form_id: getApp().UserId()
602
+    // };
603
+    // //清除未读信息
604
+    // getApp().postRequest(url, datas, function (res) {
605
+    //   console.log(res, 11111);
606
+    // })
602
     console.log('销毁页面');
607
     console.log('销毁页面');
603
   },
608
   },
604
   // ceshi: function (e) {
609
   // ceshi: function (e) {

+ 14 - 1
utils/websocket.js

@@ -145,6 +145,12 @@ var webSocket = {
145
     if (!heart) {
145
     if (!heart) {
146
       return;
146
       return;
147
     }
147
     }
148
+
149
+    self.sendSocketMessage({
150
+      msg: JSON.stringify({
151
+        form_id: getApp().UserId(),
152
+        type: 'resetChatTotal'})})
153
+
148
     self.sendSocketMessage({
154
     self.sendSocketMessage({
149
       msg: JSON.stringify({
155
       msg: JSON.stringify({
150
         form_id: getApp().UserId(),
156
         form_id: getApp().UserId(),
@@ -217,8 +223,15 @@ wx.onSocketMessage(function (res) {
217
       if (data.data.message_exists == true){
223
       if (data.data.message_exists == true){
218
         wx.setTabBarBadge({
224
         wx.setTabBarBadge({
219
           index: 0,
225
           index: 0,
220
-          text: '   1'
226
+          text: '1'
221
         })  
227
         })  
228
+      }else{
229
+        wx.removeTabBarBadge({
230
+          index: 0,
231
+        });
232
+        // wx.setTabBarBadge({
233
+        //   index: 0
234
+        // })  
222
       }
235
       }
223
     break;
236
     break;
224
   }
237
   }