Commit 7456cc4e authored by yaya's avatar yaya

feat: 修改时间

parent 1b8fdae4
...@@ -34,6 +34,47 @@ export function parseTime(time, cFormat) { ...@@ -34,6 +34,47 @@ export function parseTime(time, cFormat) {
}) })
return time_str return time_str
} }
export function formatMessageTime(time) {
time = +time * 1000
const d = new Date(time)
const now = Date.now()
const hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours()
const minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes()
const date = d.getDate() < 10 ? '0' + d.getDate() : d.getDate()
const month = d.getMonth() + 1 < 10 ? '0' + d.getMonth() + 1 : d.getMonth()
const diff = (now - d) / 1000
if (diff < 3600 * 24) {
return (
hours +
':' +
minutes
)
} else if (isYear(time)) {
return (
month +
'-' +
date +
' ' +
hours +
':' +
minutes
)
} else {
return (
d.getFullYear() +
'-' +
month +
'-' +
date +
' ' +
hours +
':' +
minutes
)
}
}
export function formatTime(time, option) { export function formatTime(time, option) {
time = +time * 1000 time = +time * 1000
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
import { getUserSig, getUserList, sendChatMsg, findChatUserInfo, setHumanIntervene, stopHumanIntervene } from '@/api/business/chat' import { getUserSig, getUserList, sendChatMsg, findChatUserInfo, setHumanIntervene, stopHumanIntervene } from '@/api/business/chat'
import chat from '@/utils/chat' import chat from '@/utils/chat'
import { formatTime } from '@/utils/index' import { formatTime, parseTime } from '@/utils/index'
import TencentCloudChat from '@tencentcloud/chat' import TencentCloudChat from '@tencentcloud/chat'
import ChatMessageItem from './components/chatMessageItem' import ChatMessageItem from './components/chatMessageItem'
import store from '../../store' import store from '../../store'
...@@ -128,6 +128,7 @@ export default { ...@@ -128,6 +128,7 @@ export default {
return this.customerList[this.currentCustomerIndex] return this.customerList[this.currentCustomerIndex]
} }
} }
}, },
mounted() { mounted() {
...@@ -510,7 +511,8 @@ export default { ...@@ -510,7 +511,8 @@ export default {
fromUserId: item.from, fromUserId: item.from,
toAccount: item.to, toAccount: item.to,
avatar: item.avatar, avatar: item.avatar,
msgType: item.from === this.envText + userID ? 1 : 2 msgType: item.from === this.envText + userID ? 1 : 2,
time: parseTime(item.time)
} }
topList.push(object) topList.push(object)
}) })
......
<template> <template>
<div class="page_invite"> <div class="page_invite">
<div class="filter-container"> <div class="filter-container">
<el-input v-model="listQuery.nickName" clearable size="mini" class="filter-item" style="width: 200px;" placeholder="请输入用户昵称"/> <el-input v-model="listQuery.fromAccountName" clearable size="mini" class="filter-item" style="width: 200px;" placeholder="请输入用户昵称"/>
<el-select v-model="listQuery.toAccount" class="filter-item" size="mini" placeholder="请选择"> <el-select v-model="listQuery.toAccount" class="filter-item" size="mini" placeholder="请选择">
<el-option <el-option
v-for="item in customerList" v-for="item in customerList"
......
...@@ -2,14 +2,20 @@ ...@@ -2,14 +2,20 @@
<div class="message_components"> <div class="message_components">
<!--自己发送的消息--> <!--自己发送的消息-->
<div v-if="chatMessageItem.msgType === 1" class="message-self"> <div v-if="chatMessageItem.msgType === 1" class="message-self">
<div class="message-self_content">{{ chatMessageItem.messageContent }}</div> <div class="message-self-info">
<div class="message-self-info_content">{{ chatMessageItem.messageContent }}</div>
<div class="message-self-info_time">{{ chatMessageItem.time }}</div>
</div>
<img :src="chatMessageItem.avatar" class="message-self__avatar"> <img :src="chatMessageItem.avatar" class="message-self__avatar">
</div> </div>
<!--其他人发送的消息--> <!--其他人发送的消息-->
<div v-if="chatMessageItem.msgType === 2" class="message-other"> <div v-if="chatMessageItem.msgType === 2" class="message-other">
<img :src="chatMessageItem.avatar" class="message-other__avatar"> <img :src="chatMessageItem.avatar" class="message-other__avatar">
<div class="message-other_content"> <div class="message-other-info">
{{ chatMessageItem.messageContent }} <div class="message-other-info_content">
{{ chatMessageItem.messageContent }}
</div>
<div class="message-other-info_time">{{ chatMessageItem.time }}</div>
</div> </div>
</div> </div>
<!--人工接管聊天--> <!--人工接管聊天-->
...@@ -37,19 +43,35 @@ export default { ...@@ -37,19 +43,35 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.message-self { .message-self {
width: 100%;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
.message-self_content { justify-content: end;
width: fit-content; .message-self-info {
max-width: 60%; width: 100%;
background: #95EC69; display: flex;
border-radius: 11px 11px 0px 11px; flex-direction: column;
padding: 10px 12px; align-items: end;
font-size: 12px; .message-self-info_content {
font-family: PingFangSC-Regular, PingFang SC; width: fit-content;
color: #000000; max-width: 60%;
line-height: 20px; background: #95EC69;
margin-left:auto; border-radius: 11px 11px 0px 11px;
padding: 10px 12px;
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
color: #000000;
line-height: 20px;
margin-left:auto;
}
.message-self-info_time {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #6A6E7A;
line-height: 17px;
margin-top: 4px;
}
} }
.message-self__avatar { .message-self__avatar {
width: 30px; width: 30px;
...@@ -59,19 +81,33 @@ export default { ...@@ -59,19 +81,33 @@ export default {
} }
} }
.message-other { .message-other {
width: 100%;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
.message-other_content { .message-other-info {
width: fit-content; width: 100%;
max-width: 60%; display: flex;
background: #FFFFFF; flex-direction: column;
border-radius: 11px 11px 11px 0; .message-other-info_content {
padding: 10px 12px; width: fit-content;
font-size: 12px; max-width: 60%;
font-family: PingFangSC-Regular, PingFang SC; background: #FFFFFF;
color: #000000; border-radius: 11px 11px 11px 0;
line-height: 20px; padding: 10px 12px;
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
color: #000000;
line-height: 20px;
}
.message-other-info_time {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #6A6E7A;
line-height: 17px;
margin-top: 4px;
}
} }
.message-other__avatar { .message-other__avatar {
width: 30px; width: 30px;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment