提交 7bf4fce6 编写于 作者: guangjun.yang's avatar guangjun.yang

发图片与文件

上级 8df2616a
...@@ -17,6 +17,7 @@ export const envConfig = { ...@@ -17,6 +17,7 @@ export const envConfig = {
//innerLoginUrl: 'http://localhost:8090/PICA_SSO_FE/html/pica_index.html', //innerLoginUrl: 'http://localhost:8090/PICA_SSO_FE/html/pica_index.html',
innerLoginUrl: 'https://dev-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html', innerLoginUrl: 'https://dev-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html',
yuequeyiIndexUrl: 'https://dev-saas.yunqueyi.com/pica_index.html', yuequeyiIndexUrl: 'https://dev-saas.yunqueyi.com/pica_index.html',
phomeDemain: 'https://dev-phome.yunqueyi.com',
picakfAccId: 'picakf_dev', picakfAccId: 'picakf_dev',
}, },
dev: { dev: {
...@@ -27,6 +28,7 @@ export const envConfig = { ...@@ -27,6 +28,7 @@ export const envConfig = {
loginUrl: 'https://dev-saas.yunqueyi.com/pica-login/work_station.html', loginUrl: 'https://dev-saas.yunqueyi.com/pica-login/work_station.html',
innerLoginUrl: 'https://dev-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html', innerLoginUrl: 'https://dev-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html',
yuequeyiIndexUrl: 'https://dev-saas.yunqueyi.com/pica_index.html', yuequeyiIndexUrl: 'https://dev-saas.yunqueyi.com/pica_index.html',
phomeDemain: 'https://dev-phome.yunqueyi.com',
picakfAccId: 'picakf_dev', picakfAccId: 'picakf_dev',
}, },
test: { test: {
...@@ -37,6 +39,7 @@ export const envConfig = { ...@@ -37,6 +39,7 @@ export const envConfig = {
loginUrl: 'https://test1.yunqueyi.com/pica-login/work_station.html', loginUrl: 'https://test1.yunqueyi.com/pica-login/work_station.html',
innerLoginUrl: 'https://test1-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html', innerLoginUrl: 'https://test1-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html',
yuequeyiIndexUrl: 'https://test1.yunqueyi.com/pica_index.html', yuequeyiIndexUrl: 'https://test1.yunqueyi.com/pica_index.html',
phomeDemain: 'https://test1-phome.yunqueyi.com',
picakfAccId: 'picakf_test', picakfAccId: 'picakf_test',
}, },
uat: { uat: {
...@@ -49,6 +52,7 @@ export const envConfig = { ...@@ -49,6 +52,7 @@ export const envConfig = {
loginUrl: 'https://uat.yunqueyi.com/pica-login/work_station.html', loginUrl: 'https://uat.yunqueyi.com/pica-login/work_station.html',
innerLoginUrl: 'https://uat-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html', innerLoginUrl: 'https://uat-sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html',
yuequeyiIndexUrl: 'https://uat.yunqueyi.com/pica_index.html', yuequeyiIndexUrl: 'https://uat.yunqueyi.com/pica_index.html',
phomeDemain: 'https://uat-phome.yunqueyi.com',
picakfAccId: 'picakf_uat', picakfAccId: 'picakf_uat',
}, },
pro: { pro: {
...@@ -59,6 +63,7 @@ export const envConfig = { ...@@ -59,6 +63,7 @@ export const envConfig = {
loginUrl: 'https://yunqueyi.com/pica-login/work_station.html', loginUrl: 'https://yunqueyi.com/pica-login/work_station.html',
innerLoginUrl: 'https://sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html', innerLoginUrl: 'https://sso.yunqueyi.com/PICA_SSO_FE/html/pica_index.html',
yuequeyiIndexUrl: 'https://www.yunqueyi.com/pica_index.html', yuequeyiIndexUrl: 'https://www.yunqueyi.com/pica_index.html',
phomeDemain: 'https://phome.yunqueyi.com',
picakfAccId: 'picakf', picakfAccId: 'picakf',
} }
} }
...@@ -182,3 +182,9 @@ function getConfigByEnvType(urlType) { ...@@ -182,3 +182,9 @@ function getConfigByEnvType(urlType) {
export function getPicaKFAccid() { export function getPicaKFAccid() {
return getConfigByEnvType('picakfAccId') return getConfigByEnvType('picakfAccId')
} }
// 获取客服的云信ID
export function getPhomeDemain() {
return getConfigByEnvType('phomeDemain')
}
...@@ -92,24 +92,21 @@ ...@@ -92,24 +92,21 @@
</article> </article>
</section> </section>
<section class="c-bottom"> <section class="c-bottom">
<el-input placeholder="请输入内容" v-model="text"> <el-input placeholder="请输入内容" v-model="sendText">
<div slot="suffix" class="cb-icon-wrapper"> <div slot="suffix" class="cb-icon-wrapper">
<el-upload <el-upload
class="bg-uploader" class="bg-uploader"
action="#" action="#"
accept=".jpg,.png,.pdf"
:show-file-list="false" :show-file-list="false"
:before-upload="beforeUploadFile" :before-upload="beforeUploadFile"
> >
<img src="../../../assets/image/IM/icon-folder-open.png" alt /> <img src="../../../assets/image/IM/icon-folder-open.png" alt />
</el-upload> </el-upload>
<img <img src="../../../assets/image/IM/icon-link.png" @click="preSendLinkMsg" alt />
src="../../../assets/image/IM/icon-link.png"
@click="showSelectDialog = true"
alt
/>
</div> </div>
</el-input> </el-input>
<div class="send-btn" :class="{'active': canSend}" @click="sendCommonMsg"> <div class="send-btn" :class="{'active': canSend}" @click="sendTextMsg">
<img v-show="canSend" src="../../../assets/image/IM/send-yes.png" alt /> <img v-show="canSend" src="../../../assets/image/IM/send-yes.png" alt />
<img v-show="!canSend" src="../../../assets/image/IM/send-no.png" alt /> <img v-show="!canSend" src="../../../assets/image/IM/send-no.png" alt />
</div> </div>
...@@ -132,12 +129,12 @@ ...@@ -132,12 +129,12 @@
<el-form ref="linkFormRef" :model="linkForm" label-width="100px"> <el-form ref="linkFormRef" :model="linkForm" label-width="100px">
<el-form-item label="普通文本"> <el-form-item label="普通文本">
<el-col :span="20"> <el-col :span="20">
<el-input v-model="linkForm.subject" size="small" maxlength="20"></el-input> <el-input v-model="linkForm.remark" size="small" maxlength="20"></el-input>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label="链接文案" required> <el-form-item label="链接文案" required>
<el-col :span="20"> <el-col :span="20">
<el-input v-model="linkForm.subject" size="small" maxlength="20"></el-input> <el-input v-model="linkForm.info" size="small" maxlength="20"></el-input>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label="链接地址" required> <el-form-item label="链接地址" required>
...@@ -147,14 +144,14 @@ ...@@ -147,14 +144,14 @@
style="width: 300px" style="width: 300px"
clearable clearable
filterable filterable
v-model="linkForm.linkName" v-model="linkForm.url"
placeholder="请选择" placeholder="请选择"
> >
<el-option <el-option
v-for="item in linkList" v-for="item in linkList"
:key="item.value" :key="item.id"
:label="item.label" :label="item.title"
:value="item" :value="item.id"
></el-option> ></el-option>
</el-select> </el-select>
</el-col> </el-col>
...@@ -173,7 +170,7 @@ import { doUpload, getFilePath } from "@/utils/qiniu-util"; ...@@ -173,7 +170,7 @@ import { doUpload, getFilePath } from "@/utils/qiniu-util";
import { validateWord } from "@/utils/validate.js"; import { validateWord } from "@/utils/validate.js";
import { openLoading, closeLoading } from "@/utils/utils"; import { openLoading, closeLoading } from "@/utils/utils";
import * as commonUtil from "@/utils/utils"; import * as commonUtil from "@/utils/utils";
import { getPicaKFAccid } from "@/utils"; import { getPicaKFAccid, getPhomeDemain } 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 forwardMsgIntervalId = null;
...@@ -188,6 +185,7 @@ export default { ...@@ -188,6 +185,7 @@ export default {
return { return {
curmbFirst: "云鹊客服", curmbFirst: "云鹊客服",
curmbSecond: "当前会话", curmbSecond: "当前会话",
sendText: "",
sessionListData: { sessionListData: {
myTaskCount: 0, myTaskCount: 0,
sessionList: [], sessionList: [],
...@@ -195,7 +193,7 @@ export default { ...@@ -195,7 +193,7 @@ export default {
}, },
currentSessionIndex: 0, // 当前会话序号 currentSessionIndex: 0, // 当前会话序号
currentSession: {}, currentSession: {},
currentTaskLogId: 0, // 当前会话ID currentTaskLogId: "", // 当前会话ID
currentToAccId: "", currentToAccId: "",
picakfAccId: "", picakfAccId: "",
doctorInfo: { doctorInfo: {
...@@ -203,40 +201,22 @@ export default { ...@@ -203,40 +201,22 @@ export default {
mobilePhone: "138****7261", mobilePhone: "138****7261",
isShowCopyBtn: true isShowCopyBtn: true
}, },
text: "",
containerHeight: CONTAINER_HEIGHT, containerHeight: CONTAINER_HEIGHT,
showSelectDialog: false, showSelectDialog: false,
linkForm: { linkForm: {
subject: "", remark: "",
deriverName: "" info: "",
}, url: ""
qiniuUploadStatus: false,
linkList: [
{
label: "五分钟医学院",
value: "https://www.baidu.com1"
},
{
label: "课程直播",
value: "https://www.baidu.com2"
},
{
label: "云鹊小圈",
value: "https://www.baidu.com3"
}, },
{ linkList: [],
label: "精品课程",
value: "https://www.baidu.com4"
}
],
// 消息列表 showType 1: 文本; 2: 图片; 3: PDF; 4: 链接; 5: 不支持类型; // 消息列表 showType 1: 文本; 2: 图片; 3: PDF; 4: 链接; 5: 不支持类型;
messageList: [] messageList: [],
}; };
}, },
computed: { computed: {
canSend() { canSend() {
return !!this.text; return !!this.sendText;
} }
}, },
...@@ -244,12 +224,109 @@ export default { ...@@ -244,12 +224,109 @@ export default {
this.picakfAccId = getPicaKFAccid(); this.picakfAccId = getPicaKFAccid();
this.kfAvatar = require("../../../assets/image/IM/kf-avatar.png"); this.kfAvatar = require("../../../assets/image/IM/kf-avatar.png");
this.getSessionList(); this.getSessionList();
this.getFiveContentList();
}, },
mounted: function() {}, mounted: function() {},
methods: { methods: {
// 上传文件
beforeUploadFile(file) {
let vm = this;
console.log('file', file);
const isJPG = file.type === "image/jpeg";
const isPNG = file.type === "image/png";
const isPDF = file.type === "application/pdf";
doUpload(
vm,
file,
getFilePath(file, null),
"preview4",
"progress",
""
).then(function(resData) {
let params = {};
params.fileSize = resData.size;
params.fileExt = resData.ext;
params.url = resData.fullPath;
params.info = resData.name;
params.type = 2;
// 如果是图片,则要获取其宽与高
if(params.fileExt.toLowerCase() === '.jpg' || params.fileExt.toLowerCase() === '.png') {
params.type = 1;
let image = new Image();
image.src = params.url;
image.onload = function() {
let _this = this;
params.width = _this.width;
params.height = _this.height;
vm.sendCommonMsg(params);
};
} else {
vm.sendCommonMsg(params);
}
});
},
// 打开发送链接弹框
preSendLinkMsg() {
this.linkForm = {
remark: "",
info: "",
url: ""
};
this.showSelectDialog = true;
},
// 发送带链接消息
sendLinkMsg() {
let params = this.linkForm;
params.url = getPhomeDemain() + `/template_v2/?id=${params.url}`;
params.type = 3;
this.sendCommonMsg(params);
this.showSelectDialog = false;
},
// 发送文本消息
sendTextMsg() {
if (!this.canSend) return;
this.sendCommonMsg({ info: this.sendText });
this.sendText = '';
},
// 发送通用消息
sendCommonMsg(params) {
let sendMsgParams = {
fromAccount: this.picakfAccId,
toAccount: this.currentToAccId,
fileExt: "", // 文件扩展名称图片或PDF文件)
fileSize: 0, // 文件大小(图片或PDF文件)
height: 0, // 图片高度(仅图片)
width: 0, // 图片宽度(仅图片)
info: "", // 文本内容,图片的名称,pdf的名称,链接显示内容
md5: "", // 图片或文件MD5 暂时由后台生成
remark: "", // 其他信息(链接中的前缀文案)
type: 0, // 类型 0文本 1图片 2pdf 3链接
url: "" // url地址(图片、pdf,链接)
}
params = Object.assign(sendMsgParams, params);
console.log("sendMsgParams", params);
this.POST("/im/msg/sendMessage", params).then(res => {
if (res.code === "000000") {
// 校验结果:1校验通过 2校验不通过
console.log(res.data.checkFlag);
// this.getSessionList();
} else {
this.$message({
message: res.message,
type: "warning"
});
}
});
},
// 查询医生和居民的消息历史(下拉刷新时调用) // 查询医生和居民的消息历史(下拉刷新时调用)
getOldMSGHistory() { getOldMSGHistory() {
let session = this.currentSession; let session = this.currentSession;
...@@ -328,9 +405,9 @@ export default { ...@@ -328,9 +405,9 @@ export default {
// 转换消息格式 // 转换消息格式
// 处理的消息类型只有5种: // 处理的消息类型只有5种:
// type == custom时,1 ~ 17: 不支持(showType:5); 18: PDF文件(showType:3); 19: 链接信息(showType:4);
// type == TEXT(showType:1) // type == TEXT(showType:1)
// type == image 或 picture(showType:2) // type == image 或 picture(showType:2)
// type == custom时,1 ~ 17: 不支持(showType:5); 18: PDF文件(showType:3); 19: 链接信息(showType:4);
// directFlag 1: 拼接历史消息(push); 2: 拼接实时消息(unshift) // directFlag 1: 拼接历史消息(push); 2: 拼接实时消息(unshift)
convertMessageList(messageList, directFlag = 1) { convertMessageList(messageList, directFlag = 1) {
messageList.sort((a, b) => { messageList.sort((a, b) => {
...@@ -338,18 +415,18 @@ export default { ...@@ -338,18 +415,18 @@ export default {
}); });
let msg = null, let msg = null,
content = null, content = null,
text = '', text = "",
suffix = '', suffix = "",
showType = 1, showType = 1,
size = 0, size = 0,
url = '', url = "",
cMessageList = []; cMessageList = [];
messageList.forEach((rawMsg, index) => { messageList.forEach((rawMsg, index) => {
text = ''; text = "";
suffix = ''; suffix = "";
showType = 1; showType = 1;
size = 0; size = 0;
url = ''; 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 msg.avatarImg = msg.sendOrReceive
...@@ -363,13 +440,16 @@ export default { ...@@ -363,13 +440,16 @@ export default {
text = content.name; text = content.name;
size = content.size; size = content.size;
url = content.url; url = content.url;
}else if (content.bizType == 19) { } else if (content.bizType == 19) {
showType = 4; showType = 4;
suffix = content.suffix; suffix = content.suffix;
} else { } else {
showType = 5; 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); content = JSON.parse(msg.content);
url = content.url; url = content.url;
showType = 2; showType = 2;
...@@ -385,52 +465,13 @@ export default { ...@@ -385,52 +465,13 @@ export default {
cMessageList.push(msg); cMessageList.push(msg);
}); });
if(directFlag === 1) { if (directFlag === 1) {
this.messageList.unshift(...cMessageList); this.messageList = cMessageList;
// this.messageList.unshift(...cMessageList);
} else { } else {
this.messageList.push(...cMessageList); // this.messageList.push(...cMessageList);
} }
console.log('this.messageList', this.messageList); console.log("this.messageList", this.messageList);
},
// 发送带链接消息
sendLinkMsg() {
this.sendCommonMsg();
},
// 发送带文件消息(PDF文档)
sendFileMsg() {
this.sendCommonMsg();
},
// 发送通用消息
sendCommonMsg() {
if (!this.canSend) return;
let params = {
fileExt: "",
fileSize: 0,
fromAccount: this.picakfAccId,
height: 0,
info: "wefwef",
md5: "",
remark: "",
toAccount: this.currentToAccId,
type: 0,
url: "",
width: 0
};
this.POST("/im/msg/sendMessage", params).then(res => {
if (res.code === "000000") {
// 校验结果:1校验通过 2校验不通过
console.log(res.data.checkFlag);
this.getSessionList();
} else {
this.$message({
message: res.message,
type: "warning"
});
}
});
}, },
// 选择一个会话 // 选择一个会话
...@@ -449,7 +490,6 @@ export default { ...@@ -449,7 +490,6 @@ export default {
if (session.unreadCount) { if (session.unreadCount) {
this.readAllMsg(this.currentToAccId, this.picakfAccId); this.readAllMsg(this.currentToAccId, this.picakfAccId);
} }
}, },
// 打开PDF // 打开PDF
...@@ -457,42 +497,6 @@ export default { ...@@ -457,42 +497,6 @@ export default {
window.open(item.url, "__blank"); window.open(item.url, "__blank");
}, },
// 上传文件
beforeUploadFile(file) {
let vm = this;
const isJPG = file.type === "image/jpeg";
const isPNG = file.type === "image/png";
// const isLt2M = file.size / 1024 / 1024 < fileLimit.size;
if (!isJPG && !isPNG) {
vm.$message.error(
"图片必须是jpeg或png格式,同时长宽尺寸和图片大小需符合要求"
);
return;
}
// if (!isLt2M) {
// vm.$message.error("图片大小不符合规范,请根据规范上传图片 ");
// return;
// }
// 直接上传
// this.needShowUploadProcess = true;
// vm.uploadProgress = 0;
doUpload(
vm,
file,
getFilePath(file, null),
"preview4",
"progress",
""
).then(function(path) {
console.log(path);
let cName = path.name;
cName = cName.substr(0, cName.lastIndexOf("."));
cName = cName.substring(0, 21);
console.log("@@@@upload successful@@@@");
});
},
// 给我一个任务吧,如果当前没有任务,则要提示 // 给我一个任务吧,如果当前没有任务,则要提示
fetchOneTask() { fetchOneTask() {
this.GET("/im/session/kf/fetchOneTask").then(res => { this.GET("/im/session/kf/fetchOneTask").then(res => {
...@@ -530,9 +534,9 @@ export default { ...@@ -530,9 +534,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( () => { forwardMsgIntervalId = setInterval(() => {
this.getMSGForward(); this.getMSGForward();
}, 10000) }, 10000);
} }
} else { } else {
this.$message({ this.$message({
...@@ -644,13 +648,31 @@ export default { ...@@ -644,13 +648,31 @@ export default {
return item[key] == value; return item[key] == value;
}); });
} }
},
// 获取五分钟列表
getFiveContentList() {
this.GET(
"/contents/admin/template/queryTemplate?publishFlag=5&pageNo=1&pageSize=99999"
).then(res => {
if (res.code === "000000") {
console.log("in getFiveContentList", res);
this.linkList = res.data.templateList || [];
} else {
this.$message({
message: res.message,
type: "warning"
});
}
});
} }
}, },
beforeDestroy() { beforeDestroy() {
console.log('in beforeDestroy', forwardMsgIntervalId); console.log("in beforeDestroy", forwardMsgIntervalId);
forwardMsgIntervalId && clearInterval(forwardMsgIntervalId); forwardMsgIntervalId && clearInterval(forwardMsgIntervalId);
console.log('in beforeDestroy', forwardMsgIntervalId); console.log("in beforeDestroy", forwardMsgIntervalId);
}, }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册