chenxiaofeng před 5 roky
rodič
revize
b3dfd0115a
2 změnil soubory, kde provedl 27 přidání a 9 odebrání
  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 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 607
     console.log('销毁页面');
603 608
   },
604 609
   // ceshi: function (e) {

+ 14 - 1
utils/websocket.js

@@ -145,6 +145,12 @@ var webSocket = {
145 145
     if (!heart) {
146 146
       return;
147 147
     }
148
+
149
+    self.sendSocketMessage({
150
+      msg: JSON.stringify({
151
+        form_id: getApp().UserId(),
152
+        type: 'resetChatTotal'})})
153
+
148 154
     self.sendSocketMessage({
149 155
       msg: JSON.stringify({
150 156
         form_id: getApp().UserId(),
@@ -217,8 +223,15 @@ wx.onSocketMessage(function (res) {
217 223
       if (data.data.message_exists == true){
218 224
         wx.setTabBarBadge({
219 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 236
     break;
224 237
   }