Your Name 5 years ago
parent
commit
59d32c91b6

+ 90 - 30
pages/information/chat/chat.js

@@ -1,4 +1,5 @@
1
 const app = getApp();
1
 const app = getApp();
2
+const time = require('../../../utils/time.js');
2
 const ImageType = 'images';
3
 const ImageType = 'images';
3
 const TextType = 'text';
4
 const TextType = 'text';
4
 Page({
5
 Page({
@@ -7,6 +8,8 @@ Page({
7
    * 页面的初始数据
8
    * 页面的初始数据
8
    */
9
    */
9
   data: {
10
   data: {
11
+    codedata: true,  //用来判断code
12
+    frequency:true, //多次加载次数限制
10
     hiddenName:true, // 加载更多显示隐藏
13
     hiddenName:true, // 加载更多显示隐藏
11
     toView:'Stop',   //锚点
14
     toView:'Stop',   //锚点
12
     scrollTopVal: 1,    //滚动条
15
     scrollTopVal: 1,    //滚动条
@@ -72,6 +75,8 @@ Page({
72
 
75
 
73
 
76
 
74
 
77
 
78
+
79
+    
75
   },
80
   },
76
 
81
 
77
 
82
 
@@ -127,7 +132,7 @@ Page({
127
   //input输入框
132
   //input输入框
128
   Telephone: function (e) {
133
   Telephone: function (e) {
129
     var that = this;
134
     var that = this;
130
-    console.log(e.detail.value);
135
+    // console.log(e.detail.value);
131
     that.setData({
136
     that.setData({
132
       news: e.detail.value,     //获取输入文字
137
       news: e.detail.value,     //获取输入文字
133
     })
138
     })
@@ -166,7 +171,7 @@ Page({
166
               console.log(con, 1);
171
               console.log(con, 1);
167
 
172
 
168
               // console.log(ImgRes.tempFilePaths[0], 1222222);
173
               // console.log(ImgRes.tempFilePaths[0], 1222222);
169
-              that.SocketSend({ type: ImageType, content: con });
174
+              that.SocketSend({ type: ImageType, content: con.img_name });
170
 
175
 
171
               // that.msgManager.sendMsg({ type: IMOperator.ImageType, content: con })
176
               // that.msgManager.sendMsg({ type: IMOperator.ImageType, content: con })
172
 
177
 
@@ -224,16 +229,24 @@ Page({
224
 
229
 
225
       success: function (res) {   //发送成功
230
       success: function (res) {   //发送成功
226
 
231
 
232
+        var current_time = Date.now();
233
+        var _time = time.TimeFormatting(current_time);   // 时间格式化
234
+        // console.log(_time);
235
+
227
         // 我跟他人说话
236
         // 我跟他人说话
228
         switch (msg.type) {
237
         switch (msg.type) {
229
 
238
 
230
           case "alone":     //  发送文本
239
           case "alone":     //  发送文本
231
 
240
 
241
+
242
+
243
+
244
+            
232
             console.log(' 发送文本');
245
             console.log(' 发送文本');
233
             var obj = {     //创建对象,用来合并历史消息对象
246
             var obj = {     //创建对象,用来合并历史消息对象
234
               content: that.data.news,     //发送消息内容  
247
               content: that.data.news,     //发送消息内容  
235
               type: 1,                            //类型 1 : 文字类型     类型 2 : 图片
248
               type: 1,                            //类型 1 : 文字类型     类型 2 : 图片
236
-              time: Date.now(),         //时间
249
+              time: _time,         //时间
237
               isMy: true,   //自己
250
               isMy: true,   //自己
238
               send: true,   //    发送成功  为true   失败false 
251
               send: true,   //    发送成功  为true   失败false 
239
             };
252
             };
@@ -252,12 +265,13 @@ Page({
252
 
265
 
253
           case "images":   //  发送图片
266
           case "images":   //  发送图片
254
 
267
 
268
+
255
             console.log(' 发送图片');
269
             console.log(' 发送图片');
256
 
270
 
257
             var obj = {     //创建对象,用来合并历史消息对象
271
             var obj = {     //创建对象,用来合并历史消息对象
258
               content: that.data.photo,     //发送消息内容  
272
               content: that.data.photo,     //发送消息内容  
259
               type: 2,                            //类型 1 : 文字类型     类型 2 : 图片
273
               type: 2,                            //类型 1 : 文字类型     类型 2 : 图片
260
-              time: Date.now(),         //时间
274
+              time: _time,         //时间
261
               isMy: true,   //自己
275
               isMy: true,   //自己
262
               send: true,   //    发送成功  为true   失败false 
276
               send: true,   //    发送成功  为true   失败false 
263
             };
277
             };
@@ -293,27 +307,48 @@ Page({
293
   // 接收消息
307
   // 接收消息
294
   onSocketMessageCallback: function (e) {
308
   onSocketMessageCallback: function (e) {
295
     var that = this;
309
     var that = this;
296
-    let data = JSON.parse(e);
310
+    let data  = JSON.parse(e);
297
   
311
   
298
-    //  console.log(data,'接受消息成功');
312
+     console.log(data,'接受消息成功');
299
 
313
 
300
-    var arrData = data.data;
314
+    var arrData = data.data.data;
301
 
315
 
316
+   
302
     switch (data.type) {
317
     switch (data.type) {
303
       // 接收历史消息
318
       // 接收历史消息
304
       case "get_history":
319
       case "get_history":
305
         // console.log(arrData,111112222);
320
         // console.log(arrData,111112222);
306
 
321
 
322
+        var _code = data.code;
323
+
324
+        if (_code == 201){
325
+       
307
         // let total = arrData.length - 1;
326
         // let total = arrData.length - 1;
308
         // console.log(total);
327
         // console.log(total);
328
+
329
+          // var vasd = time.TimeFormatting(1561186210);
330
+          // console.log(vasd)
331
+
332
+          console.log(arrData);
333
+
309
         for (var index in arrData) {     //二次赋值  
334
         for (var index in arrData) {     //二次赋值  
310
           if (arrData[index].form_id == getApp().UserToken()) {   //判断  如果等于自己 true  ,等于他人  false。
335
           if (arrData[index].form_id == getApp().UserToken()) {   //判断  如果等于自己 true  ,等于他人  false。
311
             arrData[index].isMy = true;    //自己
336
             arrData[index].isMy = true;    //自己
312
           } else {
337
           } else {
313
             arrData[index].isMy = false;   //他人
338
             arrData[index].isMy = false;   //他人
314
           }
339
           }
315
-      
316
-          that.ArrMsg.push(arrData[index]);   //每次接到的数据拼接
340
+
341
+          if (arrData[index].type == 2){
342
+               arrData[index].content = data.data.url + arrData[index].content + data.data.stylename;
343
+          }
344
+
345
+          if (arrData[index].create_at){
346
+            var _time = time.TimeFormatting(arrData[index].create_at);   // 时间格式化
347
+            arrData[index].time = _time;  //时间从新赋值
348
+          }
349
+        
350
+          that.ArrMsg.push(arrData[index]);
351
+
317
         }
352
         }
318
 
353
 
319
         for (var index in that.ArrMsg) {     //二次赋值   把所有的数据 hooks参数 清空
354
         for (var index in that.ArrMsg) {     //二次赋值   把所有的数据 hooks参数 清空
@@ -329,10 +364,6 @@ Page({
329
     
364
     
330
         console.log(Arrs1, 111112222);
365
         console.log(Arrs1, 111112222);
331
         
366
         
332
-        that.setData({   
333
-          hiddenName: true,
334
-        });
335
-
336
 
367
 
337
         if (that.data.limit_page == 1) {   //判断  分页 1 的时候 
368
         if (that.data.limit_page == 1) {   //判断  分页 1 的时候 
338
           that.setData({
369
           that.setData({
@@ -347,22 +378,38 @@ Page({
347
             toView: 'Stop'      //开启锚点 赋值
378
             toView: 'Stop'      //开启锚点 赋值
348
           });
379
           });
349
         }
380
         }
350
-
351
-
381
+    
352
         that.setData({     //最后关闭锚点   方便每次进来  在开启 修复 描点会闪动
382
         that.setData({     //最后关闭锚点   方便每次进来  在开启 修复 描点会闪动
353
           toView: false,
383
           toView: false,
384
+          frequency: true,
385
+          hiddenName: true,    //隐藏加载更多图片  
354
         });
386
         });
355
-    
387
+
388
+
389
+        }else{
390
+          that.setData({ 
391
+            hiddenName: true,    //隐藏加载更多图片  
392
+            codedata: false     //code 301  
393
+          });
394
+
395
+        }
356
         break;
396
         break;
357
 
397
 
358
 
398
 
359
       case "alone":       // 接收他人文本
399
       case "alone":       // 接收他人文本
360
-        console.log(arrData, "aaasd");
400
+
401
+        var arrDatatext = data.data;
402
+        console.log(arrDatatext, "aaasd");
403
+
404
+
405
+        var current_time = Date.now();
406
+        var _time = time.TimeFormatting(current_time);   // 时间格式化
407
+        // console.log(_time);
361
 
408
 
362
         var obj = {     //创建对象,用来合并历史消息对象
409
         var obj = {     //创建对象,用来合并历史消息对象
363
-          content: arrData.content,   //发送消息内容
410
+          content: arrDatatext.content,   //发送消息内容
364
           type: 1,          //类型 1 : 文字类型     类型 2 : 图片
411
           type: 1,          //类型 1 : 文字类型     类型 2 : 图片
365
-          time: Date.now(),    //时间
412
+          time: _time,    //时间
366
           isMy: false,   //他人
413
           isMy: false,   //他人
367
         };
414
         };
368
 
415
 
@@ -378,13 +425,20 @@ Page({
378
         break;
425
         break;
379
 
426
 
380
       case "images":   // 接收他人图片
427
       case "images":   // 接收他人图片
381
-        console.log(arrData, "接收图片");
428
+        var arrDataimg = data.data;
429
+
430
+        console.log(arrDataimg, "接收图片");
431
+
432
+        var current_time = Date.now();
433
+        var _time = time.TimeFormatting(current_time);   // 时间格式化
434
+        // console.log(_time);
382
 
435
 
383
         var obj = {     //创建对象,用来合并历史消息对象
436
         var obj = {     //创建对象,用来合并历史消息对象
384
-          content: arrData.content,   //发送消息内容
437
+          content: arrDataimg.content,   //发送消息内容
385
           type: 2,          //类型 1 : 文字类型     类型 2 : 图片
438
           type: 2,          //类型 1 : 文字类型     类型 2 : 图片
386
-          time: Date.now(),    //时间
439
+          time: _time,    //时间
387
           isMy: false,   //他人
440
           isMy: false,   //他人
441
+          
388
         };
442
         };
389
 
443
 
390
         let _Receive_img = that.data.Receive_news;
444
         let _Receive_img = that.data.Receive_news;
@@ -472,18 +526,24 @@ Page({
472
     var that = this;
526
     var that = this;
473
     // console.log(e,'加载')
527
     // console.log(e,'加载')
474
 
528
 
475
-    that.setData({   //  显示加载更多图片
476
-          hiddenName:false,    
477
-    })
529
+    if (that.data.codedata == true){
530
+      that.setData({   //  显示加载更多图片
531
+        hiddenName: false,
532
+      })
533
+    }
534
+
535
+  
536
+ if (that.data.frequency == true){
478
 
537
 
479
-   setTimeout(function () {
538
+  //  setTimeout(function () {
480
         that.setData({
539
         that.setData({
481
-          limit_page: that.data.limit_page * 1 + 1
540
+          limit_page: that.data.limit_page * 1 + 1,
541
+          frequency:false
482
         })
542
         })
483
         console.log(that.data.limit_page * 1 + 1)
543
         console.log(that.data.limit_page * 1 + 1)
484
         that.SocketSend({ type: 'get_history', page: that.data.limit_page,limit:10})
544
         that.SocketSend({ type: 'get_history', page: that.data.limit_page,limit:10})
485
-    }, 3000);
486
-
545
+    // }, 1000);
546
+    }
487
     // console.log('执行')
547
     // console.log('执行')
488
   },
548
   },
489
 
549
 
@@ -515,7 +575,7 @@ Page({
515
       menu: false,
575
       menu: false,
516
       KeyboardHeight: e.detail.height,
576
       KeyboardHeight: e.detail.height,
517
     })
577
     })
518
-    console.log(e.detail.height);
578
+    // console.log(e.detail.height);
519
   },
579
   },
520
 
580
 
521
   // 发送键切换
581
   // 发送键切换

+ 6 - 4
pages/information/chat/chat.wxml

@@ -4,11 +4,13 @@
4
     bindscrolltolower="lower"
4
     bindscrolltolower="lower"
5
     bindscroll="scroll" -->
5
     bindscroll="scroll" -->
6
    <!-- bindscroll="ceshi" -->
6
    <!-- bindscroll="ceshi" -->
7
-<scroll-view class="history"     scroll-top="{{scrollTopVal}}"    scroll-y="true"  bindtap="resetInputStatus"  bindscrolltoupper="upper"   scroll-into-view="{{toView}}">
7
+   <!-- bindtouchend="cheshi" -->
8
 
8
 
9
-          <view class='Load_img_box' hidden="{{hiddenName}}">
10
-               <view class='Load_img'><image src='/image/jz.png' mode="aspectFill"></image></view>
11
-           </view>
9
+<view class='Load_img_box' hidden="{{hiddenName}}">
10
+    <view class='Load_img'><image src='/image/jz.png' mode="aspectFill"></image></view>
11
+</view>
12
+
13
+<scroll-view class="history"     scroll-top="{{scrollTopVal}}"    scroll-y="true"  bindtap="resetInputStatus"  bindscrolltoupper="upper"   scroll-into-view="{{toView}}" >
12
           <!-- 自己 -->
14
           <!-- 自己 -->
13
            <block  wx:for='{{Receive_news}}' wx:key="item">
15
            <block  wx:for='{{Receive_news}}' wx:key="item">
14
                 <view class='my_right c' wx:if="{{item.isMy === true}}" id="{{item.hooks}}">
16
                 <view class='my_right c' wx:if="{{item.isMy === true}}" id="{{item.hooks}}">

+ 9 - 9
pages/information/chat/chat.wxss

@@ -7,16 +7,16 @@ page {background-color: #EDEDED; height: 100%;}
7
 
7
 
8
 .history { 
8
 .history { 
9
   /* border:1px solid; */
9
   /* border:1px solid; */
10
-  height: 88%;  
10
+  height: 89.5%;  
11
   font-size: 30rpx;  
11
   font-size: 30rpx;  
12
   word-break: break-all;  
12
   word-break: break-all;  
13
   margin: auto;
13
   margin: auto;
14
 }  
14
 }  
15
 /* 自己 */
15
 /* 自己 */
16
-.my_right{padding:20rpx;}
17
-.my_right .time{text-align:center;display:block;}
16
+.my_right{padding:0 20rpx;margin-top:50rpx;}
17
+.my_right .time{text-align:center;display:block;font-size:24rpx;}
18
 /* 文字 */
18
 /* 文字 */
19
-.my_right .information{margin-top:30rpx;float:right;}
19
+.my_right .information{margin-top:50rpx;float:right;}
20
 .my_right .information text{max-width:474rpx;display:block;float:left;margin-right:20rpx;background:#8FCBF7;border-radius:10rpx;overflow:hidden;padding:18rpx 18rpx;}
20
 .my_right .information text{max-width:474rpx;display:block;float:left;margin-right:20rpx;background:#8FCBF7;border-radius:10rpx;overflow:hidden;padding:18rpx 18rpx;}
21
 .my_right  .m_tx{width:80rpx;height:80rpx;border-radius:6rpx;overflow:hidden;}
21
 .my_right  .m_tx{width:80rpx;height:80rpx;border-radius:6rpx;overflow:hidden;}
22
 
22
 
@@ -24,20 +24,20 @@ page {background-color: #EDEDED; height: 100%;}
24
 .my_right .m_state  .m_jz{width:30rpx;height:30rpx;position:relative;top:22rpx;}
24
 .my_right .m_state  .m_jz{width:30rpx;height:30rpx;position:relative;top:22rpx;}
25
 
25
 
26
 /* 图片*/
26
 /* 图片*/
27
-.my_right .m_img{margin-top:30rpx;float:right;}
27
+.my_right .m_img{margin-top:50rpx;float:right;}
28
 .my_right .m_img .m_picture{max-width:260rpx;float:left;margin-right:24rpx;border-radius:6rpx;max-height:260rpx;}
28
 .my_right .m_img .m_picture{max-width:260rpx;float:left;margin-right:24rpx;border-radius:6rpx;max-height:260rpx;}
29
 
29
 
30
 /* 他人 */
30
 /* 他人 */
31
-.my_left{padding:20rpx;}
32
-.my_left .l_time{text-align:center;display:block;}
31
+.my_left{padding:0 20rpx;margin-top:50rpx;}
32
+.my_left .l_time{text-align:center;display:block;font-size:24rpx;}
33
 /* 文字 */
33
 /* 文字 */
34
-.my_left .l_information{margin-top:30rpx;float:left;}
34
+.my_left .l_information{margin-top:50rpx;float:left;}
35
 .my_left  .l_tx{width:80rpx;height:80rpx;border-radius:6rpx;overflow:hidden;float:left;}
35
 .my_left  .l_tx{width:80rpx;height:80rpx;border-radius:6rpx;overflow:hidden;float:left;}
36
 .my_left .l_information text{max-width:474rpx;display:block;float:left;margin-left:20rpx;background:#FFF;border-radius:10rpx;overflow:hidden;padding:18rpx 18rpx;}
36
 .my_left .l_information text{max-width:474rpx;display:block;float:left;margin-left:20rpx;background:#FFF;border-radius:10rpx;overflow:hidden;padding:18rpx 18rpx;}
37
 .my_right  .l_tx{width:80rpx;height:80rpx;border-radius:6rpx;overflow:hidden;float:left;}
37
 .my_right  .l_tx{width:80rpx;height:80rpx;border-radius:6rpx;overflow:hidden;float:left;}
38
 
38
 
39
 /* 图片*/
39
 /* 图片*/
40
-.my_left .l_img{margin-top:30rpx;float:left;}
40
+.my_left .l_img{margin-top:50rpx;float:left;}
41
 .my_left .l_img .l_picture{width:260rpx;float:left;margin-left:24rpx;border-radius:6rpx;max-height:260rpx;}
41
 .my_left .l_img .l_picture{width:260rpx;float:left;margin-left:24rpx;border-radius:6rpx;max-height:260rpx;}
42
 
42
 
43
 
43
 

+ 1 - 1
pages/personal_core/home/home.wxss

@@ -6,7 +6,7 @@
6
 .core_l_id{font-size:28rpx;margin-top:5rpx;}
6
 .core_l_id{font-size:28rpx;margin-top:5rpx;}
7
 .core_style{margin-top:10rpx;}
7
 .core_style{margin-top:10rpx;}
8
 .core_style text{font-size:18rpx;color:#FFF;background:#F55858;margin-right:12rpx;padding:4rpx 10rpx;float:left;border-radius:6rpx;}
8
 .core_style text{font-size:18rpx;color:#FFF;background:#F55858;margin-right:12rpx;padding:4rpx 10rpx;float:left;border-radius:6rpx;}
9
-.core_style  image{width:40rpx;display:block;float:left;margin-right:20rpx;}
9
+.core_style  image{width:40rpx;height:0;display:block;float:left;margin-right:20rpx;}
10
 
10
 
11
 .core_data{width:180rpx;height:180rpx;float:right;position:relative;border-radius:100rpx;overflow: hidden;background:#FFF;}
11
 .core_data{width:180rpx;height:180rpx;float:right;position:relative;border-radius:100rpx;overflow: hidden;background:#FFF;}
12
 
12
 

+ 9 - 1
project.config.json

@@ -9,8 +9,16 @@
9
 		"postcss": true,
9
 		"postcss": true,
10
 		"minified": true,
10
 		"minified": true,
11
 		"newFeature": true,
11
 		"newFeature": true,
12
+		"coverView": true,
12
 		"autoAudits": false,
13
 		"autoAudits": false,
13
-		"checkInvalidKey": true
14
+		"checkInvalidKey": true,
15
+		"checkSiteMap": true,
16
+		"uploadWithSourceMap": true,
17
+		"babelSetting": {
18
+			"ignore": [],
19
+			"disablePlugins": [],
20
+			"outputPath": ""
21
+		}
14
 	},
22
 	},
15
 	"compileType": "miniprogram",
23
 	"compileType": "miniprogram",
16
 	"libVersion": "2.4.0",
24
 	"libVersion": "2.4.0",

+ 135 - 33
utils/time.js

@@ -1,39 +1,141 @@
1
-let now = new Date();
2
-let year = now.getFullYear();
3
-let month = now.getMonth();//真实的月份需要再加上1
4
-let day = now.getDate();
5
-let currentTime = new Date();
6
-
7
-function dealChatTime(currentItemTimeStamp, frontItemTimeStamp) {
8
-    let ifShowTime = timeDivide(currentItemTimeStamp, frontItemTimeStamp);
9
-    return justSimpleDealTime(currentItemTimeStamp, ifShowTime);
10
-}
11
 
1
 
12
-function timeDivide(currentItemTimeStamp, frontItemTimeStamp) {
13
-    // console.log('时间戳显示时间', currentItemTimeStamp, frontItemTimeStamp);
14
-    return Math.abs(currentItemTimeStamp - frontItemTimeStamp) / 1000 > 300
15
-}
16
 
2
 
17
-function justSimpleDealTime(currentItemTimeStamp, ifShowTime) {
18
-    currentTime.setTime(currentItemTimeStamp);
19
-    let hoursAndMinutes = currentTime.getHours() + ':' + (currentTime.getMinutes() >= 10 ? currentTime.getMinutes() : ('0' + currentTime.getMinutes()));
20
-    let currentTimeDay = currentTime.getDate();
21
-    if (currentTime.getFullYear() === year && currentTime.getMonth() === month) {
22
-        if (currentTimeDay === day) {//当天显示时分
23
-            return {//5分钟内发送多条消息时不重复显示时间标签,大于5分钟显示时间标签
24
-                ifShowTime: ifShowTime,
25
-                timeStr: hoursAndMinutes
26
-            };
27
-        } else if (currentTimeDay === day - 1) {//昨天:昨天+时分(24小时制)
28
-            return {ifShowTime: ifShowTime, timeStr: '昨天 ' + hoursAndMinutes}
29
-        }
3
+function TimeFormatting(dateTimeStamp) {
4
+  var result;
5
+  var minute = 1000 * 60;
6
+  var hour = minute * 60;
7
+  var day = hour * 24;
8
+  var halfamonth = day * 15;
9
+  var month = day * 30;
10
+  var now = new Date();  //当前时间
11
+  // console.log('now', now);
12
+
13
+  var digit = String(dateTimeStamp).length;
14
+  if (digit == '10') {
15
+    var curTime = new Date(parseInt(dateTimeStamp) * 1000); //后端返回的是秒数      过去时间
16
+  } else {
17
+    var curTime = new Date(parseInt(dateTimeStamp)); //后端返回的是秒数      过去时间
18
+  }
19
+
20
+
21
+  // console.log('curTime',curTime);
22
+
23
+
24
+  var _year = now.getFullYear();   // 年
25
+  var _month = now.getMonth() + 1;  //月
26
+  var _day = now.getDate();   //日
27
+
28
+  var shitime = _year + '-' + _month + '-' + _day + ' 23:59:59';
29
+  // console.log(shitime);
30
+
31
+  var time_start = new Date(shitime.replace(/-/g, '/'));
32
+
33
+  time_start.getTime();
34
+
35
+  var diffValue = time_start.getTime() - curTime;
36
+
37
+  // 过去时间和现在时间对比  相差多少天
38
+  var CutOffDays = parseInt(diffValue / day);
39
+
40
+
41
+  var Now_hour = now.getHours();      //当前 小时数
42
+  var Now_mm = now.getMinutes();   //当前 分  
43
+  var Current_hour = curTime.getHours();       //过去 小时数
44
+  var Current_mm = curTime.getMinutes();     //过去 分  
45
+
46
+  var Differhour = Now_hour - Current_hour     //过去时间和现在时间相差小时
47
+  var DifferMinute = Now_mm - Current_mm     //过去时间和现在时间相差分钟
48
+
49
+  // console.log(Differhour)
50
+  // console.log(DifferMinute)
51
+
52
+
53
+  var timestr = '';
54
+  if (Current_hour < 11) {
55
+    timestr = " 早上 ";
56
+  }
57
+  else if (Current_hour < 13) {
58
+    timestr = " 中午 ";
59
+  }
60
+  else if (Current_hour < 17) {
61
+    timestr = " 下午 ";
62
+  }
63
+  else if (Current_hour < 19) {
64
+    timestr = " 晚上 ";
65
+  }
66
+  else {
67
+    timestr = " 晚上 ";
68
+  }
69
+
70
+  // 日
71
+  var currentTimeDay = curTime.getDate();
72
+
73
+  //历史记录年月日
74
+  var SpecificDate = curTime.getFullYear() + '年' + (curTime.getMonth() + 1) + '月' + currentTimeDay + '日 ';
75
+  //  console.log(SpecificDate);
76
+
77
+  //历史记录时间
78
+  var Historicaltime = curTime.getHours() + ':' + (curTime.getMinutes() >= 10 ? curTime.getMinutes() : ('0' + curTime.getMinutes()));
79
+  // console.log(Historicaltime);
80
+
81
+  var weekTime = (new Date(curTime)).getDay();    //星期   工作日
82
+  // console.log(weekTime);
83
+  var week = "";
84
+
85
+
86
+  // console.log(CutOffDays, '2222');
87
+
88
+  if (CutOffDays > 7) {   // 消息超过 7天    显示日期
89
+
90
+    result = SpecificDate + timestr + Historicaltime;
91
+
92
+  } else if (CutOffDays < 1) {    // 消息小于 1天   
93
+   
94
+      result = timestr + Historicaltime;
95
+
96
+  } else if (CutOffDays >= 1 && CutOffDays < 2) {   // 消息大于 1天   并且   小于 2天  显示昨天  
97
+
98
+    result = '昨天' + timestr + Historicaltime;
99
+
100
+  } else if (CutOffDays >= 2 && CutOffDays <= 7) {  // 消息大于 2天   并且   小于 7天  显示星期
101
+    // console.log(weekTime);
102
+    switch (weekTime) {
103
+      case 0:
104
+        week = '星期日'
105
+        break;
106
+      case 1:
107
+        week = '星期一'
108
+        break;
109
+      case 2:
110
+        week = '星期二'
111
+        break;
112
+      case 3:
113
+        week = '星期三'
114
+        break;
115
+      case 4:
116
+        week = '星期四'
117
+        break;
118
+      case 5:
119
+        week = '星期五'
120
+        break;
121
+      case 6:
122
+        week = '星期六'
123
+        break;
30
     }
124
     }
31
-    return {
32
-        ifShowTime: ifShowTime,
33
-        timeStr: currentTime.getFullYear() + '年' + (currentTime.getMonth() + 1) + '月' + currentTimeDay + '日 ' + hoursAndMinutes
34
-    };
125
+
126
+    result = week + timestr + Historicaltime;
127
+
128
+  }
129
+
130
+
131
+
132
+
133
+  // console.log(result);
134
+  return result;
35
 }
135
 }
36
 
136
 
137
+
138
+//最下面一定要加上你自定义的方法(作用:将模块接口暴露出来),否则会报错:util.trim is not a function;
37
 module.exports = {
139
 module.exports = {
38
-    dealChatTime
39
-};
140
+  TimeFormatting: TimeFormatting,
141
+}