提交 69d7e404 编写于 作者: huangwensu's avatar huangwensu

群聊接口联调

上级 2dcb1bbe
......@@ -25,7 +25,7 @@ export default [{
children: [
{
path: '',
redirect: '/diagnosisList'
redirect: '/diagnosis-list'
},{
path: '/diagnosis-list',
component: diagnosisList
......
......@@ -18,7 +18,7 @@ export const envConfig = {
innerLoginUrl: 'https://dev-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html',
yuequeyiIndexUrl: 'https://dev-saas.yunqueyi.com/pica_index.html',
phomeDemain: 'https://dev-phome.yunqueyi.com',
picakfAccId: 'picakf_dev',
picakfAccId: 'picaop_dev',
},
dev: {
baseUrl: 'https://dev-sc.yunqueyi.com',
......@@ -29,7 +29,7 @@ export const envConfig = {
innerLoginUrl: 'https://dev-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html',
yuequeyiIndexUrl: 'https://dev-saas.yunqueyi.com/pica_index.html',
phomeDemain: 'https://dev-phome.yunqueyi.com',
picakfAccId: 'picakf_dev',
picakfAccId: 'picaop_dev',
},
test: {
baseUrl: 'https://test1-sc.yunqueyi.com',
......@@ -40,7 +40,7 @@ export const envConfig = {
innerLoginUrl: 'https://test1-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html',
yuequeyiIndexUrl: 'https://test1.yunqueyi.com/pica_index.html',
phomeDemain: 'https://test1-phome.yunqueyi.com',
picakfAccId: 'picakf_test',
picakfAccId: 'picaop_test',
},
uat: {
baseUrl: 'https://uat-sc.yunqueyi.com',
......@@ -53,7 +53,7 @@ export const envConfig = {
innerLoginUrl: 'https://uat-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html',
yuequeyiIndexUrl: 'https://uat.yunqueyi.com/pica_index.html',
phomeDemain: 'https://uat-phome.yunqueyi.com',
picakfAccId: 'picakf_uat',
picakfAccId: 'picaop_uat',
},
pro: {
baseUrl: 'https://sc.yunqueyi.com',
......@@ -64,6 +64,6 @@ export const envConfig = {
innerLoginUrl: 'https://sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html',
yuequeyiIndexUrl: 'https://www.yunqueyi.com/pica_index.html',
phomeDemain: 'https://phome.yunqueyi.com',
picakfAccId: 'picakf',
picakfAccId: 'picaop',
}
}
......@@ -2,15 +2,11 @@
<div class="current-session-wrap">
<section class="component-content screenSet" id="screenSet">
<article
v-show="sessionListData.sessionList.length"
class="center"
v-loadmore="getOldMSGHistory"
>
<section class="c-header">
<div class="c-header-l">
<!-- <img :src="currentSession.avatarImageUrl" alt />
<span class="name">{{doctorInfo.name}}</span>
<span class="time-tip">当前会话时长:{{currentContinueTimes | continueTimesFilter}}</span> -->
<span class="time-tip">问诊医生XX医生的问诊群聊</span>
</div>
</section>
......@@ -18,16 +14,15 @@
<section id="msgContentId" class="msg-content scroll-box">
<article
v-for="(item, index) in messageList"
:key="index"
:style="{'text-align': item.sendOrReceive ? 'right' : 'left'}"
>
:key="index">
<div class="split-line" v-if="item.sessionFlag">本次会话结束</div>
<!-- sendOrReceive 为true在右边 -->
<div class="msg-item" :class="{'cr': item.sendOrReceive}">
<div class="msg-item-img">
<img :src="item.avatarImg" alt />
</div>
<div class="msg-item-detail">
<span class="mid-time">{{item.timestampStr}}</span>
<span class="mid-time">{{item.name}} {{item.timestampStr}}</span>
<div class="send-warpper">
<img
v-if="item.sendOrReceive && item.isShowErrorIcon"
......@@ -168,14 +163,12 @@
</div>
</template>
<script>
import { mapGetters, mapMutations } from "vuex";
import BreadCrumb from "@/components/breadcrumb.vue";
import { doUpload, getFilePath } from "@/utils/qiniu-util";
import { openLoading, closeLoading, betaHandle } from "@/utils/utils";
import { getPicaKFAccid, getPhomeDemain } from "@/utils";
const CONTAINER_HEIGHT = 700;
let forwardMsgIntervalId = null,
sessionIntervalId = null,
continueIntervalId = null,
autoCompletionIntervalId = null,
cacheMap = {};
......@@ -204,11 +197,6 @@ export default {
picakfAccId: "",
historyTimestamp: 0,
realTimestamp: 0,
doctorInfo: {
name: "",
mobilePhone: "",
isShowCopyBtn: true
},
containerHeight: CONTAINER_HEIGHT,
showSelectDialog: false,
linkForm: {
......@@ -216,8 +204,7 @@ export default {
info: "",
url: ""
},
linkList: [],
// 消息列表 showType 1: 文本; 2: 图片; 3: PDF; 4: 链接; 5: 不支持类型;
linkList: [], // 消息列表 showType 1: 文本; 2: 图片; 3: PDF; 4: 链接; 5: 不支持类型;
messageList: [],
rules: {
info: [
......@@ -229,11 +216,12 @@ export default {
imgHeight: 0,
imgProportion: 0,
hasNoHistoryData: false,
tid: '',
teamMemberList: []
};
},
computed: {
// ...mapGetters(["isFromAssignTask"]),
canSend() {
return !!this.sendText;
}
......@@ -262,15 +250,10 @@ export default {
created() {
_this = this;
this.picakfAccId = getPicaKFAccid();
this.picakfAccId = getPicaKFAccid();
this.tid = this.$route.query.tid || '';
this.kfAvatar = require("../../../assets/image/IM/kf-avatar.png");
this.getSessionList();
sessionIntervalId && clearInterval(sessionIntervalId);
sessionIntervalId = setInterval(() => {
this.getSessionList();
}, 3000);
this.getFiveContentList();
autoCompletionIntervalId && clearInterval(autoCompletionIntervalId);
autoCompletionIntervalId = setInterval(() => {
this.autoCompletionInterval();
......@@ -289,28 +272,19 @@ export default {
mounted() {
cacheMap = {};
this.$nextTick(() => {
_this.containerHeight = document.body.clientHeight - 80;
_this.getElmByID("screenSet").style.height =
_this.containerHeight - 76 + "px";
// console.log('_this.containerHeight', _this.containerHeight);
// _this.getElmByID("sessionListId").style.height =
// _this.containerHeight - 176 + "px";
// _this.getElmByID("userInfoId").style.height =
// _this.containerHeight - 76 + "px";
_this.getElmByID("msgContentId").style.height =
_this.containerHeight - 211 + "px";
_this.containerHeight = document.body.clientHeight - 80;
_this.getElmByID("screenSet").style.height = _this.containerHeight - 76 + "px";
_this.getElmByID("msgContentId").style.height = _this.containerHeight - 211 + "px";
});
this.getMembersList(); // 获取群聊成员信息
this.getMSGHistory(); // 查询群聊历史消息
},
methods: {
//
// ...mapMutations(["SET_IS_FROM_ASSIGN_TASK"]),
// 含有敏感信息的消息,自行补全提示文案
// 每30秒监测敏感信息
autoCompletionInterval() {
if (!this.messageList.length) return;
// console.log('in autoCompletionInterval');
// 将带有loading的消息转成失败的
this.messageList.forEach(item => {
if (item.isShowLoadingIcon) {
......@@ -318,8 +292,7 @@ export default {
item.isShowErrorIcon = true;
}
});
let flag = false,
msg;
let flag = false, msg;
for (let i = 0; i < this.messageList.length; i++) {
msg = this.messageList[i];
if (msg.isShowErrorIcon && !msg.isShowErrorMsg) {
......@@ -332,20 +305,24 @@ export default {
}
},
// 查询群组成员列表
getMembersList() {
this.GET("/im/team/member/list", {tid: this.tid}).then(res => {
if (res.code === "000000") {
this.teamMemberList = res.data;
}
});
},
// 查询医生和居民的消息 - 向前查找
getMSGForwardForAC(msg) {
let session = this.currentSession;
let params = {
doctorAccId: this.currentToAccId,
includeFlag: 0,
lastClientIdServer: session.lastMsgIdClient,
lastMsgIdServer: session.lastMsgIdServer,
lastMsgTimestamp: msg.realTimestamp,
limit: 50,
patientAccId: this.picakfAccId,
unionId: ""
tid: this.tid
};
this.POST("/im/msg/forward", params).then(res => {
this.POST("/im/team/message/forward", params).then(res => {
if (res.code === "000000") {
this.contactForwardMessage(res.data, false);
}
......@@ -357,11 +334,12 @@ export default {
return document.getElementById(elmId);
},
// 处理发送消息
// 1: 先将消息体直接显示在对话框中
// 2: 设置一个时间戳,以便再次找回
// 3: 保存再次发送的数据
// 4: 设置各种状态(1:isShowErrorIcon; 2:isShowLoadingIcon; 3:isShowErrorMsg)
/* 处理发送消息
1: 先将消息体直接显示在对话框中
2: 设置一个时间戳,以便再次找回
3: 保存再次发送的数据
4: 设置各种状态(1:isShowErrorIcon; 2:isShowLoadingIcon; 3:isShowErrorMsg)
*/
handleSendMsg(params, sendId) {
let text = "";
let msg = Object.assign({}, params);
......@@ -382,14 +360,12 @@ export default {
msg.isShowErrorIcon = false;
msg.isShowErrorMsg = false; // 只有在下次拉取新数据时才有可能是为ture
msg.extData = Object.assign({}, params); // 再将发送时的数据
msg.sendId = sendId; //
msg.sendOrReceive = true;
msg.sendId = sendId;
msg.sendOrReceive = false;
msg.avatarImg = this.kfAvatar;
msg.timestampStr = new Date().format("hh:mm");
msg.realTimestamp = this.realTimestamp;
msg.taskLogId = this.currentTaskLogId;
console.log("####msg####", msg);
//
if(msg.type == 1) {
this.imgSizeHandleNew(msg, msg.width, msg.height);
}
......@@ -402,20 +378,14 @@ export default {
// 查询医生和居民的消息历史(下拉刷新时调用)
getOldMSGHistory() {
console.log('this.hasNoHistoryData', this.hasNoHistoryData);
if(this.hasNoHistoryData) return;
let session = this.currentSession;
let params = {
doctorAccId: this.currentToAccId,
includeFlag: 0, // 不带本条消息
lastClientIdServer: session.lastMsgIdClient,
lastMsgIdServer: session.lastMsgIdServer,
lastMsgTimestamp: this.historyTimestamp,
limit: 20,
patientAccId: this.picakfAccId,
unionId: ""
tid: this.tid
};
this.POST("/im/msg/history", params).then(res => {
this.POST("/im/team/message/history", params).then(res => {
if (res.code === "000000") {
// 将新消息合并到之前的消息中, 并且重置最后一条消息
if(res.data && res.data.length > 0) {
......@@ -435,16 +405,11 @@ export default {
// 查询医生和居民的消息历史(第一次进来时就调用)
getMSGHistory(session) {
let params = {
doctorAccId: this.currentToAccId,
includeFlag: 1, // 带本条消息
lastClientIdServer: session.lastMsgIdClient,
lastMsgIdServer: session.lastMsgIdServer,
lastMsgTimestamp: session.lastMsgTime,
limit: 20,
patientAccId: this.picakfAccId,
unionId: ""
tid: this.tid
};
this.POST("/im/msg/history", params).then(res => {
this.POST("/im/team/message/history", params).then(res => {
if (res.code === "000000") {
this.convertMessageList(res.data, 1);
} else {
......@@ -459,23 +424,15 @@ export default {
// 查询医生和居民的消息 - 向前查找
// 将获取消息列表插入到当前消息列表的最后
getMSGForward() {
let session = this.currentSession;
let params = {
doctorAccId: this.currentToAccId,
includeFlag: 0,
lastClientIdServer: session.lastMsgIdClient,
lastMsgIdServer: session.lastMsgIdServer,
lastMsgTimestamp: this.realTimestamp,
limit: 20,
patientAccId: this.picakfAccId,
unionId: ""
tid: this.tid
};
this.POST("/im/msg/forward", params).then(res => {
this.POST("/im/team/message/forward", params).then(res => {
if (res.code === "000000") {
this.convertMessageList(res.data, 2);
if (res.data.length) {
this.readAllMsg();
}
} else {
this.$message({
message: res.message,
......@@ -485,12 +442,13 @@ export default {
});
},
// 转换消息格式
// 处理的消息类型只有5种:
// type == TEXT(showType:1)
// type == image 或 picture(showType:2)
// type == custom时,18: PDF文件(showType:3); 19: 链接信息(showType:4); 1 ~ 17: 不支持的消息类型(showType:5);
// directFlag 1: 第一次取数据; 2: 拼接实时消息(push); 3: 拼接历史消息(unshift);
/* 转换消息格式
处理的消息类型只有5种:
type == TEXT(showType:1)
type == image 或 picture(showType:2)
type == custom时,18: PDF文件(showType:3); 19: 链接信息(showType:4); 1 ~ 17: 不支持的消息类型(showType:5);
directFlag 1: 第一次取数据; 2: 拼接实时消息(push); 3: 拼接历史消息(unshift);
*/
convertMessageList(messageList, directFlag = 1) {
messageList.sort((a, b) => {
return a.timestamp - b.timestamp;
......@@ -510,40 +468,41 @@ export default {
size = 0;
url = "";
msg = Object.assign({}, rawMsg);
msg.sendOrReceive = rawMsg.fromAccId !== this.currentToAccId;
msg.avatarImg = msg.sendOrReceive
? this.kfAvatar
: this.currentSession.avatarImageUrl;
msg.sendOrReceive = rawMsg.fromAccId === this.picakfAccId; // 判断消息是显示在左边还是右边, true 右
//msg.avatarImg = msg.sendOrReceive ? this.kfAvatar : this.currentSession.avatarImageUrl;
for(let i = 0; i < this.teamMemberList.length; i++) {
if(rawMsg.fromAccId == this.teamMemberList[i].accId) {
msg.avatarImg = this.teamMemberList[i].avatarImageUrl;
msg.name = this.teamMemberList[i].name;
break
}
}
if (msg.type.toLowerCase() == "custom") {
content = JSON.parse(msg.content);
text = content.content;
// 系统消息:消息由于违规未发送成功(可以不处理)
if (content.bizType == -1) {
if (content.bizType == -1) { // 系统消息:消息由于违规未发送成功(可以不处理)
showType = -1;
text = content.content;
} else if (content.bizType == 18) {
} else if (content.bizType == 18) { // PDF
showType = 3;
text = content.name;
size = content.size;
url = content.url;
} else if (content.bizType == 19) {
} else if (content.bizType == 19) { // 链接
showType = 4;
text = content.content;
suffix = content.suffix;
} else {
showType = 5;
}
} else if (
msg.type.toLowerCase() == "image" ||
msg.type.toLowerCase() == "picture"
) {
} else if( msg.type.toLowerCase() == "image" || msg.type.toLowerCase() == "picture") { // 图片
content = JSON.parse(msg.content);
url = content.url;
text = content.name;
showType = 2;
this.imgSizeHandleNew(msg, content.w, content.h);
} else {
showType = 1;
showType = 1; // 文本
text = msg.content;
}
msg.text = text;
......@@ -567,9 +526,7 @@ export default {
scrollBoxDom.scrollTop = scrollBoxDom.scrollHeight;
});
}, 100);
this.currentContinueTimes =
this.sessionListData.currentTimestamp -
this.currentSession.handleStartTime;
this.currentContinueTimes = this.sessionListData.currentTimestamp - this.currentSession.handleStartTime;
continueIntervalId && clearInterval(continueIntervalId);
continueIntervalId = setInterval(() => {
this.currentContinueTimes += 1000;
......@@ -658,115 +615,6 @@ export default {
window.open(item.url, "__blank");
},
// 获取会话列表
getSessionList() {
this.GET("/im/session/kf/list").then(res => {
if (res.code === "000000") {
this.sessionListData = res.data || {
currentTimestamp: 0,
myTaskCount: 0,
sessionList: [],
waitingTaskCount: 0
};
let sLength = this.sessionListData.sessionList.length;
let cIndex = sLength - 1;
// if (!this.isFromAssignTask) {
// this.SET_IS_FROM_ASSIGN_TASK(false);
// cIndex = 0;
// }
// 第一次进入页面
if (sLength && !this.currentTaskLogId) {
// this.currentSession = this.sessionListData.sessionList[0];
// this.currentSessionIndex = 0;
this.currentSession = this.sessionListData.sessionList[cIndex];
this.currentSessionIndex = cIndex;
this.sendText = cacheMap[this.currentSession.id];
this.currentTaskLogId = this.currentSession.taskLogId;
this.currentToAccId = this.currentSession.toAccId;
this.getDoctorInfo(this.currentToAccId);
this.getMSGHistory(this.currentSession);
this.readAllMsg();
// 如果是点击“再来一个”或“给我一个任务吧”按钮分配的任务,则要滚动到最后
// if (this.isFromAssignTask) {
// this.$nextTick(() => {
// let element = this.getElmByID("sessionListId");
// if (element) {
// element.scrollTop = element.scrollHeight;
// }
// });
// }
}
if (sLength) {
//this.convertSessions(this.sessionListData.sessionList);
this.$forceUpdate();
}
} else {
this.$message({
message: res.message,
type: "error"
});
}
});
},
// 将会话列表的数据进行处理,主要是显示文本(text)字段
// convertSessions(sessions) {
// let convertSessionList = [];
// let text = "",
// cc;
// sessions.forEach((session, index) => {
// if (session.lastMsgType.toLowerCase() == "custom") {
// cc = JSON.parse(session.lastMsgContent);
// text = cc.suffix || cc.content || cc.title || cc.name;
// } else if (
// session.lastMsgType.toLowerCase() == "image" ||
// session.lastMsgType.toLowerCase() == "picture"
// ) {
// text = "[图片]";
// } else {
// text = session.lastMsgContent;
// }
// session.text = text;
// convertSessionList.push(session);
// });
// this.sessionListData.sessionList = convertSessionList;
// },
// 根据云信id获取医生信息
getDoctorInfo(accId) {
this.GET(`/im/account/accid/doctorinfo?accId=${accId}`).then(res => {
if (res.code === "000000") {
this.doctorInfo = res.data || {};
} else {
this.$message({
message: res.message,
type: "error"
});
}
});
},
// 设置全部消息已读
readAllMsg() {
let fromAccount = this.currentToAccId,
toAccount = this.picakfAccId;
let params = {
fromAccount,
toAccount
};
this.POST(`/im/msg/read/all`, params).then(res => {
if (res.code === "000000") {
this.currentSession.unreadCount = 0;
} else {
this.$message({
message: res.message,
type: "error"
});
}
});
},
// 根据字段名及其值,从数组中查找对象
findItemByKeyAndVal(arr, key, value, flag = 0) {
if (flag == 0) {
......@@ -895,12 +743,10 @@ export default {
forwardMsgIntervalId && clearInterval(forwardMsgIntervalId);
let sendId = new Date().getTime();
this.handleSendMsg(params, sendId);
// console.log("sendMsgParams", params);
await this.POST("/im/msg/sendMessage", params)
await this.POST("/im/team/message/sendMessage", params)
.then(res => {
if (res.code === "000000") {
// 校验结果:1校验通过 2校验不通过
// console.log(res.data.checkFlag);
let msg = this.messageList[this.messageList.length - 1];
if (msg.sendId !== sendId) {
msg = this.getMsgBySendId(sendId);
......@@ -961,7 +807,6 @@ export default {
},
beforeDestroy() {
sessionIntervalId && clearInterval(sessionIntervalId);
forwardMsgIntervalId && clearInterval(forwardMsgIntervalId);
autoCompletionIntervalId && clearInterval(autoCompletionIntervalId);
}
......
......@@ -311,7 +311,7 @@ export default {
},
// 发送消息
sendMessage(row) {
this.$router.push('/diagnosis-im')
this.$router.push({path: '/diagnosis-im', query: {tid: row.imTeamId}})
},
// 选择
selectBtn(row) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册