Skip to content

Commit

Permalink
显示时间
Browse files Browse the repository at this point in the history
  • Loading branch information
SR.李 committed Dec 15, 2023
1 parent aa44f7c commit 4c501f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions application/chat/view/index/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
</script>
<script src="/static/chat/js/jquery.min.js"></script>
<script src="/static/chat/js/face.js?v=3345"></script>
<script src="/static/chat/js/create.div.js?v=32"></script>
<script src="/static/chat/js/chat.script.js?v=32"></script>
<script src="/static/chat/js/create.div.js?v=33"></script>
<script src="/static/chat/js/chat.script.js?v=33"></script>
<script src="/static/chat/js/functions.js?v=2115"></script>
<script src="/static/chat/js/xlyjs.js?v=215"></script>
<script src="/static/layui/layui.js?4"></script>
Expand Down
8 changes: 6 additions & 2 deletions public/static/chat/js/chat.script.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var chat = {
chat.wsSend(JSON.stringify(json));
},
initMessage: function(data, isHistory) {
data.create_time = getDateDiff(new Date(data.create_time).getTime()/1000)
data.ctime = getDateDiff(new Date(data.create_time).getTime()/1000)
if(data.fromuid == chat.data.uid){
chat.addChatLine('mymessage',data,data.listtagid);
} else {
Expand Down Expand Up @@ -203,7 +203,11 @@ var chat = {
chat.addChatLine('chatLine',data,data.listtagid);
// $("#user-"+chat.data.fromid).children('.layui-badge').css('display', 'block')
// 增加消息

}
if (!isHistory) {
$("#chatLineHolder-"+data.listtagid+ " .msg-box .chat-time").slice(-10).each(function () {
$(this).html(getDateDiff(new Date($(this).attr("data-ctime")).getTime()/1000))
})
}
},
wsMessage : function(){
Expand Down
2 changes: 1 addition & 1 deletion public/static/chat/js/create.div.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var cdiv = {

case 'chatLine':
arr = [
'<div style="display: block;" class="msg-box"><div class="chat-item not-me"><div class="chat-profile-info clearfix"><span class="profile-wrp"><span class="name clearfix"><span class="name-text">',params.nickname,'</span></span></span><span class="chat-time">',params.create_time,'</span></div><div class="clearfix"><div class="head_image"><div class="normal user-head_image" onclick="chat.changeUser(this)" uid="',params.touid,'" uname="',params.nickname,'" style="background-image: url(\'',params.head_image,'\');"></div></div><div class="msg-bubble-box"><div class="msg-bubble-area"><div class="msg-bubble"><pre class="text">',params.content,'</pre></div></div></div></div></div></div>'
'<div style="display: block;" class="msg-box"><div class="chat-item not-me"><div class="chat-profile-info clearfix"><span class="profile-wrp"><span class="name clearfix"><span class="name-text">',params.nickname,'</span></span></span><span class="chat-time" data-ctime="',params.create_time,'">',params.ctime,'</span></div><div class="clearfix"><div class="head_image"><div class="normal user-head_image" onclick="chat.changeUser(this)" uid="',params.touid,'" uname="',params.nickname,'" style="background-image: url(\'',params.head_image,'\');"></div></div><div class="msg-bubble-box"><div class="msg-bubble-area"><div class="msg-bubble"><pre class="text">',params.content,'</pre></div></div></div></div></div></div>'
];
break;

Expand Down

0 comments on commit 4c501f7

Please sign in to comment.