|
@@ -12,7 +12,7 @@
|
|
|
<span :class="{'active': tabIndex === 1 }" @click="onClickTab(1)">已结束用户({{getEndList.length || 0}})</span>
|
|
|
</div>
|
|
|
<div v-if="tabIndex === 0">
|
|
|
- <message-list :list="dialogueList" @select="onSelectCurMsg($event, '会话')"></message-list>
|
|
|
+ <message-list :list="loadingList" @select="onSelectCurMsg($event, '会话')"></message-list>
|
|
|
<message-list :title="'排队中(' + queueList.length + ')'" :list="queueList" @select="onSelectCurMsg($event, '排队')"></message-list>
|
|
|
</div>
|
|
|
<div v-else-if="tabIndex === 1">
|
|
@@ -42,7 +42,7 @@
|
|
|
>
|
|
|
</ChatView>
|
|
|
<div class="message--info-group" v-if="showInfo">
|
|
|
- <customer-info :userId="other.userId" :sessionId="other.sessionId" @end-session="onEndSession" :key="other.userId"></customer-info>
|
|
|
+ <customer-info :userId="other.userId" :sessionId="other.sessionId" @end-session="onEndSession" :key="other.sessionId"></customer-info>
|
|
|
</div>
|
|
|
</el-container>
|
|
|
<el-container class="message--empty-group" v-else>
|
|
@@ -61,7 +61,7 @@ import SearchFilter from '@/components/search/'
|
|
|
import AsideView from '@/components/aside/'
|
|
|
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
|
|
|
import { getUserList, getMessageCount, findMessage, getServiceInfo, getWebSocketNode } from '@/api/modules/'
|
|
|
-import { dateFormatter, isJSON, isHyperlink, momentTime, imgReg } from '@/utils/'
|
|
|
+import { dateFormatter, isJSON, getLink, momentTime, imgReg } from '@/utils/'
|
|
|
|
|
|
export default {
|
|
|
name: 'CustomerView',
|
|
@@ -117,7 +117,8 @@ export default {
|
|
|
lastMsgId: '0',
|
|
|
selectItem: '', // 当前点击的是哪个列表 '会话' '排队' '结束'
|
|
|
loadingMsg: true,
|
|
|
- resetSession: {} // 客服从已结束会话发起聊天 发送聊天要存的参数 key为userId, value为保存发送消息所用到的参数
|
|
|
+ resetSession: {}, // 客服从已结束会话发起聊天 发送聊天要存的参数 key为userId, value为保存发送消息所用到的参数
|
|
|
+ badgeMap: {}
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -187,6 +188,13 @@ export default {
|
|
|
} else {
|
|
|
return 0
|
|
|
}
|
|
|
+ },
|
|
|
+ loadingList () {
|
|
|
+ this.dialogueList.forEach(v => {
|
|
|
+ console.log(v, this.badgeMap)
|
|
|
+ v.badge = this.badgeMap[v.userId]
|
|
|
+ })
|
|
|
+ return this.dialogueList
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -271,7 +279,7 @@ export default {
|
|
|
/**
|
|
|
* 处理websocket接收到的消息 根据type值判断
|
|
|
*/
|
|
|
- todoMessage (res) {
|
|
|
+ async todoMessage (res) {
|
|
|
const data = JSON.parse(res.data)
|
|
|
console.log(data)
|
|
|
if (data.type === 2) {
|
|
@@ -358,14 +366,6 @@ export default {
|
|
|
this.showInfo = true
|
|
|
this.tabIndex = 0
|
|
|
}
|
|
|
- // // 更新会话列表
|
|
|
- // this.webSocketSend({
|
|
|
- // type: 10
|
|
|
- // })
|
|
|
- // // 更新排队列表
|
|
|
- // this.webSocketSend({
|
|
|
- // type: 9
|
|
|
- // })
|
|
|
}
|
|
|
} else if (data.type === 7) {
|
|
|
// 认领失败
|
|
@@ -379,9 +379,12 @@ export default {
|
|
|
if (v.userId === sUserId) {
|
|
|
v.msgType = contentType
|
|
|
v.message = content
|
|
|
+ v.badge = v.badge ? v.badge : 0
|
|
|
v.lastTime = momentTime(new Date().getTime(), 'HH:mm:ss')
|
|
|
if (sUserId !== this.other.userId) {
|
|
|
v.badge++
|
|
|
+ this.badgeMap[sUserId] = v.badge
|
|
|
+ // console.log(this.badgeMap, v.badge, 'mao')
|
|
|
} else {
|
|
|
v.badge = 0
|
|
|
// 未读消息变已读
|
|
@@ -467,6 +470,7 @@ export default {
|
|
|
* 切换用户聊天窗口
|
|
|
*/
|
|
|
onSelectCurMsg (data, e) {
|
|
|
+ console.log(this.badgeMap, '333')
|
|
|
// 点击添加节流,3s内不能重复点击
|
|
|
// 设置定时器
|
|
|
// 设置现在的时间
|
|
@@ -516,7 +520,6 @@ export default {
|
|
|
})
|
|
|
} else {
|
|
|
this.other.sessionId = sessionId
|
|
|
- console.log(this.other.sessionId, 'this.other.sessionId')
|
|
|
this.showMsgBox = true
|
|
|
}
|
|
|
this.showInfo = true
|
|
@@ -555,6 +558,13 @@ export default {
|
|
|
active: false
|
|
|
}
|
|
|
})
|
|
|
+ const temp = {}
|
|
|
+ data.forEach(s => {
|
|
|
+ if (s.number) {
|
|
|
+ temp[s.userId] = s.number
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.badgeMap = temp
|
|
|
} else {
|
|
|
this.userList = []
|
|
|
}
|
|
@@ -621,19 +631,20 @@ export default {
|
|
|
onSendMsg (data) {
|
|
|
const { content } = data
|
|
|
// 保存接口所需参数
|
|
|
+ const isLink = getLink(content) === content
|
|
|
const apiParams = {
|
|
|
receiveId: this.other.userId,
|
|
|
sendId: this.other.sessionId,
|
|
|
ownType: this.other.userType, // 对方身份
|
|
|
- title: isHyperlink(content) ? '链接' : '文本',
|
|
|
+ title: isLink ? '链接' : '文本',
|
|
|
item: 8,
|
|
|
itemType: 5,
|
|
|
- link: isHyperlink(content) ? content : '',
|
|
|
+ link: isLink ? content : '',
|
|
|
fool: 1,
|
|
|
- type: isHyperlink(content) ? 2 : 1,
|
|
|
+ type: isLink ? 2 : 1,
|
|
|
...data
|
|
|
}
|
|
|
- const contentType = isHyperlink(content) ? 2 : 1 // contentType 1: 文本 2.链接 3.附件
|
|
|
+ const contentType = isLink ? 2 : 1 // contentType 1: 文本 2.链接 3.附件
|
|
|
// websocket发送消息所需参数
|
|
|
const socketParams = {
|
|
|
type: 6,
|
|
@@ -654,20 +665,21 @@ export default {
|
|
|
* 发送答案
|
|
|
*/
|
|
|
onSendAnswer (data) {
|
|
|
+ const isLink = getLink(data) === data
|
|
|
const apiParams = {
|
|
|
receiveId: this.other.userId,
|
|
|
sendId: this.other.sessionId,
|
|
|
ownType: this.other.userType, // 对方身份
|
|
|
- title: isHyperlink(data) ? '链接' : '文本',
|
|
|
+ title: isLink ? '链接' : '文本',
|
|
|
content: data,
|
|
|
item: 8,
|
|
|
itemType: 5,
|
|
|
- link: isHyperlink(data) ? data : '',
|
|
|
+ link: isLink ? data : '',
|
|
|
fool: 1,
|
|
|
- type: isHyperlink(data) ? 2 : 1,
|
|
|
+ type: isLink ? 2 : 1,
|
|
|
create_time: dateFormatter(new Date().getTime())
|
|
|
}
|
|
|
- const contentType = isHyperlink(data) ? 2 : 1
|
|
|
+ const contentType = isLink ? 2 : 1
|
|
|
const socketParams = {
|
|
|
type: 6,
|
|
|
contentType: contentType,
|