提交 8df2616a 编写于 作者: guangjun.yang's avatar guangjun.yang

获取消息等

上级 e091e98a
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
<section class="component-content screenSet" id="screenSet"> <section class="component-content screenSet" id="screenSet">
<article class="left"> <article class="left">
<div class="l-header"> <div class="l-header">
<span>我的任务(3)</span> <span>我的任务({{this.sessionListData.myTaskCount}})</span>
<span @click="fetchOneTask">再来一个</span> <span @click="fetchOneTask">再来一个</span>
</div> </div>
<p class="c-num">当前等待会话:4</p> <p class="c-num">当前等待会话:{{this.sessionListData.waitingTaskCount}}</p>
<ul class="session-list" :style="{'height': containerHeight + 'px'}"> <ul class="session-list" :style="{'height': containerHeight + 'px'}">
<li <li
class="item" class="item"
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<article class="center"> <article class="center">
<section class="c-header"> <section class="c-header">
<div class="c-header-l"> <div class="c-header-l">
<img src="../../../assets/image/img.jpg" alt /> <img :src="currentSession.avatarImageUrl" alt />
<span class="name">{{doctorInfo.name}}</span> <span class="name">{{doctorInfo.name}}</span>
<span class="time-tip">当前会话时长:3分08秒</span> <span class="time-tip">当前会话时长:3分08秒</span>
</div> </div>
...@@ -53,38 +53,38 @@ ...@@ -53,38 +53,38 @@
<section class="msg-content" :style="{'height': (containerHeight - 35) + 'px'}"> <section class="msg-content" :style="{'height': (containerHeight - 35) + 'px'}">
<article <article
class="msg-item" class="msg-item"
:class="{'cr': item.sendOrReceive == 'send'}" :class="{'cr': item.sendOrReceive}"
v-for="(item, index) in messageList" v-for="(item, index) in messageList"
:key="index" :key="index"
> >
<div class="msg-item-img"> <div class="msg-item-img">
<img src="../../../assets/image/img.jpg" alt /> <img :src="item.avatarImg" alt />
</div> </div>
<div class="msg-item-detail"> <div class="msg-item-detail">
<span class="mid-time">1:16 pm</span> <span class="mid-time">{{item.timestamp}}</span>
<div v-if="item.bizType == 1" class="mid-text-wrapper" style="max-width: 520px;"> <div v-if="item.showType == 1" class="mid-text-wrapper" style="max-width: 520px;">
<img v-show="item.sendFlag" src="../../../assets/image/IM/icon-no-send.png" alt /> <img v-show="item.sendFlag" src="../../../assets/image/IM/icon-no-send.png" alt />
<div class="mid-text">{{item.text}}</div> <div class="mid-text">{{item.text}}</div>
</div> </div>
<div v-if="item.bizType == 2" class="mid-img" v-viewer> <div v-if="item.showType == 2" class="mid-img" v-viewer>
<img src="../../../assets/image/img.jpg" alt /> <img :src="item.url" alt />
<!-- <img :src="item.imgUrl" alt /> --> <!-- <img :src="item.imgUrl" alt /> -->
</div> </div>
<div v-if="item.bizType == 3" class="mid-pdf" @click="openPDF(item)"> <div v-if="item.showType == 3" class="mid-pdf" @click="openPDF(item)">
<div class="midp-left"> <div class="midp-left">
<span class="name">{{item.text}}</span> <span class="name">{{item.text}}</span>
<span class="size">{{item.fileSize}} MB</span> <span class="size">{{item.size}} MB</span>
</div> </div>
<div class="midp-icon"> <div class="midp-icon">
<img src="../../../assets/image/IM/icon-pdf.png" alt /> <img src="../../../assets/image/IM/icon-pdf.png" alt />
</div> </div>
</div> </div>
<div v-if="item.bizType == 4" class="mid-text"> <div v-if="item.showType == 4" class="mid-text">
{{item.remark}} {{item.suffix}}
<span class="link">{{item.text}}</span> <span class="link">{{item.text}}</span>
</div> </div>
<div v-if="item.bizType == 5" class="mid-text no-support"> <div v-if="item.showType == 5" class="mid-text no-support">
<img src="../../../assets/image/IM/icon-warning-circle.png" alt /> <img src="../../../assets/image/IM/icon-warning-circle.png" alt />
<span>该消息类型PC端暂不支持</span> <span>该消息类型PC端暂不支持</span>
</div> </div>
...@@ -176,6 +176,7 @@ import * as commonUtil from "@/utils/utils"; ...@@ -176,6 +176,7 @@ import * as commonUtil from "@/utils/utils";
import { getPicaKFAccid } from "@/utils"; import { getPicaKFAccid } from "@/utils";
import UserInfo from "@/components/IM/user-info.vue"; import UserInfo from "@/components/IM/user-info.vue";
const CONTAINER_HEIGHT = 700; const CONTAINER_HEIGHT = 700;
let forwardMsgIntervalId = null;
let vm = null; let vm = null;
export default { export default {
...@@ -228,145 +229,8 @@ export default { ...@@ -228,145 +229,8 @@ export default {
value: "https://www.baidu.com4" value: "https://www.baidu.com4"
} }
], ],
// 消息列表 bizType 1: 文本; 2: 图片; 3: PDF; 4: 链接; 5: 不支持类型; // 消息列表 showType 1: 文本; 2: 图片; 3: PDF; 4: 链接; 5: 不支持类型;
messageList: [ messageList: []
{
bizType: 1,
time: 1000,
showType: 1,
title: "测试title",
content: "测试content",
imgUrl: "https://file.yunqueyi.com/File/doctor_default.png",
sendOrReceive: "send", // send receive
displayTimeHeader: "4分20秒",
url: "https://file.yunqueyi.com/File/doctor_default.png",
file: "https://file.yunqueyi.com/File/doctor_default.png",
type: 1,
extData: "/pages/im/advisory/evalution",
sourceId: 1,
displayFlag: 1,
sendFlag: true
},
{
bizType: 1,
time: 1000,
showType: 1,
title: "测试title",
content: "测试content",
imgUrl: "https://file.yunqueyi.com/File/doctor_default.png",
sendOrReceive: "receive", // send receive
displayTimeHeader: "4分20秒",
url: "https://file.yunqueyi.com/File/doctor_default.png",
file: "https://file.yunqueyi.com/File/doctor_default.png",
type: 1,
extData: "/pages/im/advisory/evalution",
sourceId: 1,
displayFlag: 1,
sendFlag: false
},
{
bizType: 1,
time: 1000,
showType: 1,
title: "测试title",
content: "测试content",
imgUrl: "https://file.yunqueyi.com/File/doctor_default.png",
sendOrReceive: "receive", // send receive
displayTimeHeader: "4分20秒",
url: "https://file.yunqueyi.com/File/doctor_default.png",
file: "https://file.yunqueyi.com/File/doctor_default.png",
type: 1,
extData: "/pages/im/advisory/evalution",
sourceId: 1,
displayFlag: 1,
sendFlag: false
},
{
bizType: 2,
time: 1000,
showType: 1,
title: "测试title",
content: "测试content",
imgUrl: "https://file.yunqueyi.com/File/doctor_default.png",
sendOrReceive: "receive", // send receive
displayTimeHeader: "4分20秒",
url: "https://file.yunqueyi.com/File/doctor_default.png",
file: "https://file.yunqueyi.com/File/doctor_default.png",
type: 1,
extData: "/pages/im/advisory/evalution",
sourceId: 1,
displayFlag: 1,
sendFlag: false
},
{
bizType: 2,
time: 1000,
showType: 1,
title: "测试title",
content: "测试content",
imgUrl: "https://file.yunqueyi.com/File/doctor_default.png",
sendOrReceive: "send", // send receive
displayTimeHeader: "4分20秒",
url: "https://file.yunqueyi.com/File/doctor_default.png",
file: "https://file.yunqueyi.com/File/doctor_default.png",
type: 1,
extData: "/pages/im/advisory/evalution",
sourceId: 1,
displayFlag: 1,
sendFlag: false
},
{
bizType: 3,
time: 1000,
showType: 1,
title: "测试title",
content: "测试content",
imgUrl: "https://file.yunqueyi.com/File/doctor_default.png",
sendOrReceive: "send", // send receive
displayTimeHeader: "4分20秒",
url: "https://file.yunqueyi.com/File/doctor_default.png",
file: "https://file.yunqueyi.com/File/doctor_default.png",
type: 1,
extData: "/pages/im/advisory/evalution",
sourceId: 1,
displayFlag: 1,
sendFlag: false
},
{
bizType: 4,
time: 1000,
showType: 1,
title: "测试title",
content: "测试content",
imgUrl: "https://file.yunqueyi.com/File/doctor_default.png",
sendOrReceive: "send", // send receive
displayTimeHeader: "4分20秒",
url: "https://file.yunqueyi.com/File/doctor_default.png",
file: "https://file.yunqueyi.com/File/doctor_default.png",
type: 1,
extData: "/pages/im/advisory/evalution",
sourceId: 1,
displayFlag: 1,
sendFlag: false
},
{
bizType: 5,
time: 1000,
showType: 1,
title: "测试title",
content: "测试content",
imgUrl: "https://file.yunqueyi.com/File/doctor_default.png",
sendOrReceive: "receive", // send receive
displayTimeHeader: "4分20秒",
url: "https://file.yunqueyi.com/File/doctor_default.png",
file: "https://file.yunqueyi.com/File/doctor_default.png",
type: 1,
extData: "/pages/im/advisory/evalution",
sourceId: 1,
displayFlag: 1,
sendFlag: false
}
]
}; };
}, },
...@@ -378,13 +242,41 @@ export default { ...@@ -378,13 +242,41 @@ export default {
created() { created() {
this.picakfAccId = getPicaKFAccid(); this.picakfAccId = getPicaKFAccid();
this.kfAvatar = require("../../../assets/image/IM/kf-avatar.png");
this.getSessionList(); this.getSessionList();
}, },
mounted: function() {}, mounted: function() {},
methods: { methods: {
// 查询医生和居民的消息历史
// 查询医生和居民的消息历史(下拉刷新时调用)
getOldMSGHistory() {
let session = this.currentSession;
let params = {
doctorAccId: this.currentToAccId,
includeFlag: 0, // 不带本条消息
lastClientIdServer: session.lastMsgIdClient,
lastMsgIdServer: session.lastMsgIdServer,
lastMsgTimestamp: session.lastMsgTime,
limit: 20,
patientAccId: this.picakfAccId,
unionId: ""
};
this.POST("/im/msg/history", params).then(res => {
if (res.code === "000000") {
// 将新消息合并到之前的消息中, 并且重置最后一条消息
// this.convertMessageList(res.data);
} else {
this.$message({
message: res.message,
type: "warning"
});
}
});
},
// 查询医生和居民的消息历史(第一次进来时就调用)
getMSGHistory(session) { getMSGHistory(session) {
let params = { let params = {
doctorAccId: this.currentToAccId, doctorAccId: this.currentToAccId,
...@@ -398,8 +290,7 @@ export default { ...@@ -398,8 +290,7 @@ export default {
}; };
this.POST("/im/msg/history", params).then(res => { this.POST("/im/msg/history", params).then(res => {
if (res.code === "000000") { if (res.code === "000000") {
// this.convertMessageList(res.data); this.convertMessageList(res.data);
this.messageList = res.data;
} else { } else {
this.$message({ this.$message({
message: res.message, message: res.message,
...@@ -411,7 +302,8 @@ export default { ...@@ -411,7 +302,8 @@ export default {
// 查询医生和居民的消息 - 向前查找 // 查询医生和居民的消息 - 向前查找
// 将获取消息列表插入到当前消息列表的最后 // 将获取消息列表插入到当前消息列表的最后
getMSGForward(session) { getMSGForward() {
let session = this.currentSession;
let params = { let params = {
doctorAccId: this.currentToAccId, doctorAccId: this.currentToAccId,
includeFlag: 0, includeFlag: 0,
...@@ -424,6 +316,7 @@ export default { ...@@ -424,6 +316,7 @@ export default {
}; };
this.POST("/im/msg/forward", params).then(res => { this.POST("/im/msg/forward", params).then(res => {
if (res.code === "000000") { if (res.code === "000000") {
this.convertMessageList(res.data, 2);
} else { } else {
this.$message({ this.$message({
message: res.message, message: res.message,
...@@ -434,28 +327,70 @@ export default { ...@@ -434,28 +327,70 @@ export default {
}, },
// 转换消息格式 // 转换消息格式
convertMessageList(messageList) { // 处理的消息类型只有5种:
// bizType: 1, // type == custom时,1 ~ 17: 不支持(showType:5); 18: PDF文件(showType:3); 19: 链接信息(showType:4);
// time: 1000, // type == TEXT(showType:1)
// showType: 1, // type == image 或 picture(showType:2)
// title: "测试title", // directFlag 1: 拼接历史消息(push); 2: 拼接实时消息(unshift)
// content: "测试content", convertMessageList(messageList, directFlag = 1) {
// imgUrl: "https://file.yunqueyi.com/File/doctor_default.png", messageList.sort((a, b) => {
// sendOrReceive: "send", // send receive return a.timestamp - b.timestamp;
// displayTimeHeader: "4分20秒", });
// url: "https://file.yunqueyi.com/File/doctor_default.png", let msg = null,
// file: "https://file.yunqueyi.com/File/doctor_default.png", content = null,
// type: 1, text = '',
// extData: "/pages/im/advisory/evalution", suffix = '',
// sourceId: 1, showType = 1,
// displayFlag: 1, size = 0,
// sendFlag: true url = '',
let msg = null, cMessageList = []; cMessageList = [];
messageList.forEach((rawMsg, index) => { messageList.forEach((rawMsg, index) => {
text = '';
suffix = '';
showType = 1;
size = 0;
url = '';
msg = Object.assign({}, rawMsg); msg = Object.assign({}, rawMsg);
msg.sendOrReceive = rawMsg.fromAccId == this.currentToAccId; msg.sendOrReceive = rawMsg.fromAccId !== this.currentToAccId;
msg.avatarImg = msg.sendOrReceive
? this.kfAvatar
: this.currentSession.avatarImageUrl;
if (msg.type.toLowerCase() == "custom") {
content = JSON.parse(msg.content);
text = content.content;
if (content.bizType == 18) {
showType = 3;
text = content.name;
size = content.size;
url = content.url;
}else if (content.bizType == 19) {
showType = 4;
suffix = content.suffix;
} else {
showType = 5;
}
} else if (msg.type.toLowerCase() == "image" || msg.type.toLowerCase() == "picture") {
content = JSON.parse(msg.content);
url = content.url;
showType = 2;
} else {
showType = 1;
text = msg.content;
}
msg.text = text;
msg.showType = showType;
msg.suffix = suffix;
msg.size = size;
msg.url = url;
cMessageList.push(msg); cMessageList.push(msg);
}); });
if(directFlag === 1) {
this.messageList.unshift(...cMessageList);
} else {
this.messageList.push(...cMessageList);
}
console.log('this.messageList', this.messageList);
}, },
// 发送带链接消息 // 发送带链接消息
...@@ -498,20 +433,23 @@ export default { ...@@ -498,20 +433,23 @@ export default {
}); });
}, },
// 打开一个会话 // 选择一个会话
selectSession(session, index) { selectSession(session, index) {
console.log("selectSession"); console.log("selectSession");
this.currentTaskLogId = session.id; this.currentTaskLogId = session.id;
this.currentToAccId = session.toAccId; this.currentToAccId = session.toAccId;
this.currentSession = session;
this.currentSessionIndex = index; this.currentSessionIndex = index;
// 获取当前消息列表(最新的历史消息) // 获取当前消息列表(最新的历史消息)
// TODO // TODO
this.getMSGHistory(this.currentSession);
// 获取医生信息 // 获取医生信息
this.getDoctorInfo(this.currentToAccId); this.getDoctorInfo(this.currentToAccId);
// 调用全部已读 // 调用全部已读
if (session.unreadCount) { if (session.unreadCount) {
this.readAllMsg(this.currentToAccId, this.picakfAccId); this.readAllMsg(this.currentToAccId, this.picakfAccId);
} }
}, },
// 打开PDF // 打开PDF
...@@ -580,10 +518,11 @@ export default { ...@@ -580,10 +518,11 @@ export default {
waitingTaskCount: 0 waitingTaskCount: 0
}; };
if ( if (
// !this.currentTaskLogId && !this.currentTaskLogId &&
this.sessionListData.sessionList.length this.sessionListData.sessionList.length
) { ) {
this.convertSessions(this.sessionListData.sessionList); this.convertSessions(this.sessionListData.sessionList);
this.$forceUpdate();
this.currentSession = this.sessionListData.sessionList[0]; this.currentSession = this.sessionListData.sessionList[0];
this.currentSessionIndex = 0; this.currentSessionIndex = 0;
this.currentTaskLogId = this.currentSession.id; this.currentTaskLogId = this.currentSession.id;
...@@ -591,6 +530,9 @@ export default { ...@@ -591,6 +530,9 @@ export default {
console.log("this.currentSession", this.currentSession); console.log("this.currentSession", this.currentSession);
this.getMSGHistory(this.currentSession); this.getMSGHistory(this.currentSession);
this.getDoctorInfo(this.currentToAccId); this.getDoctorInfo(this.currentToAccId);
forwardMsgIntervalId = setInterval( () => {
this.getMSGForward();
}, 10000)
} }
} else { } else {
this.$message({ this.$message({
...@@ -610,13 +552,13 @@ export default { ...@@ -610,13 +552,13 @@ export default {
if (session.lastMsgType.toLowerCase() == "custom") { if (session.lastMsgType.toLowerCase() == "custom") {
text = ""; text = "";
cc = JSON.parse(session.lastMsgContent); cc = JSON.parse(session.lastMsgContent);
if (cc.bizType == 1) { if (cc.showType == 1) {
text = cc.title; text = cc.title;
// } else if (cc.bizType == 18) { // } else if (cc.showType == 18) {
} else { } else {
text = cc.content || ""; text = cc.content || "";
} }
// if (cc.bizType != 8) { // if (cc.showType != 8) {
// text = `${text}`; // text = `${text}`;
// } // }
} else if ( } else if (
...@@ -703,7 +645,12 @@ export default { ...@@ -703,7 +645,12 @@ export default {
}); });
} }
} }
} },
beforeDestroy() {
console.log('in beforeDestroy', forwardMsgIntervalId);
forwardMsgIntervalId && clearInterval(forwardMsgIntervalId);
console.log('in beforeDestroy', forwardMsgIntervalId);
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册