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

获取消息等

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