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

数据处理

上级 6d9f7fb6
......@@ -96,14 +96,19 @@
</div>
<div v-if="item.showType == 2" class="mid-img" v-viewer>
<div class="img-box">
<img class="img" :src="item.url" :style="{width: item.newW + 'px', height: item.newH + 'px' }" alt />
<img
class="img"
:src="item.url"
:style="{width: item.newW + 'px', height: item.newH + 'px' }"
alt
/>
</div>
<!-- <img-size
:imgUrl="item.url"
:imgData="item"
:index="index"
@imgHandle="imgHandle"
></img-size> -->
></img-size>-->
</div>
<div v-if="item.showType == 3" class="mid-pdf" @click="openPDF(item)">
<div class="midp-left">
......@@ -273,7 +278,7 @@ export default {
},
imgWidth: 0,
imgHeight: 0,
imgProportion: 0,
imgProportion: 0
};
},
......@@ -377,7 +382,6 @@ export default {
}
},
// 查询医生和居民的消息 - 向前查找
getMSGForwardForAC(msg) {
let session = this.currentSession;
......@@ -435,6 +439,10 @@ export default {
msg.realTimestamp = this.realTimestamp;
msg.taskLogId = this.currentTaskLogId;
console.log("####msg####", msg);
// 处理图片的大小
if(msg.type == 1) {
this.handleSendMsg(msg, msg.width, msg.height);
}
this.messageList.push(msg);
this.$nextTick(() => {
var element = document.querySelector(".scroll-box");
......@@ -578,6 +586,7 @@ export default {
url = content.url;
text = content.name;
showType = 2;
this.imgSizeHandle(msg, content.w, content.h);
} else {
showType = 1;
text = msg.content;
......@@ -589,11 +598,12 @@ export default {
msg.url = url;
msg.sessionFlag = false;
cMessageList.push(msg);
if(msg.type.toLowerCase() == "image" ||
msg.type.toLowerCase() == "picture") {
this.imgSizeHandle(msg)
}
if (
msg.type.toLowerCase() == "image" ||
msg.type.toLowerCase() == "picture"
) {
this.imgSizeHandle(msg);
}
});
if (directFlag === 1) {
......@@ -602,7 +612,7 @@ export default {
forwardMsgIntervalId && clearInterval(forwardMsgIntervalId);
this.messageList = cMessageList;
this.$forceUpdate();
setTimeout( () => {
setTimeout(() => {
this.$nextTick(() => {
const scrollBoxDom = document.querySelector(".scroll-box");
scrollBoxDom.scrollTop = scrollBoxDom.scrollHeight;
......@@ -1060,47 +1070,88 @@ export default {
// 图片处理
imgSizeHandle(item) {
let lw, lh, newW, newH;
this.imgWidth = JSON.parse(item.content).w;
this.imgHeight = JSON.parse(item.content).h;
this.imgProportion = (this.imgWidth / this.imgHeight).toFixed(1);
if(this.imgProportion > 0.6) {
if(this.imgWidth > 192) {
lw = 192;
lh = (this.imgHeight * lw) / this.imgWidth;
} else if(this.imgWidth <= 192) {
lw = this.imgWidth;
lh = this.imgHeight;
}
} else if(this.imgProportion == 0.6) {
if(this.imgHeight > 320) {
lh = 320;
}else {
lh = this.imgHeight;
}
lw = lh * 0.6;
}else {
if(this.imgHeight > 320) {
lh = 320;
lw = (this.imgWidth * lh) / this.imgHeight;
}else if(this.imgHeight <= 320) {
lh = this.imgHeight;
lw = this.imgWidth;
}
let lw, lh, newW, newH;
this.imgWidth = JSON.parse(item.content).w;
this.imgHeight = JSON.parse(item.content).h;
this.imgProportion = (this.imgWidth / this.imgHeight).toFixed(1);
if (this.imgProportion > 0.6) {
if (this.imgWidth > 192) {
lw = 192;
lh = (this.imgHeight * lw) / this.imgWidth;
} else if (this.imgWidth <= 192) {
lw = this.imgWidth;
lh = this.imgHeight;
}
if((lh < 32) && (lh < lw)) {
newH = 32;
newW = (lw * 32) / lh;
}else if((lw < 32) && (lw < lh)) {
newW = 32;
newH = (lh * 32) / lw;
}else {
newH = lh;
newW = lw;
} else if (this.imgProportion == 0.6) {
if (this.imgHeight > 320) {
lh = 320;
} else {
lh = this.imgHeight;
}
lw = lh * 0.6;
} else {
if (this.imgHeight > 320) {
lh = 320;
lw = (this.imgWidth * lh) / this.imgHeight;
} else if (this.imgHeight <= 320) {
lh = this.imgHeight;
lw = this.imgWidth;
}
this.$set(item, "newW", newW);
this.$set(item, "newH", newH);
}
if (lh < 32 && lh < lw) {
newH = 32;
newW = (lw * 32) / lh;
} else if (lw < 32 && lw < lh) {
newW = 32;
newH = (lh * 32) / lw;
} else {
newH = lh;
newW = lw;
}
this.$set(item, "newW", newW);
this.$set(item, "newH", newH);
},
// 图片处理-新
imgSizeHandle(item, imgWidth, imgHeight) {
let lw, lh, newW, newH, imgProportion = (imgWidth / imgHeight).toFixed(1);
if (this.imgProportion > 0.6) {
if (imgWidth > 192) {
lw = 192;
lh = (imgHeight * lw) / imgWidth;
} else if (imgWidth <= 192) {
lw = imgWidth;
lh = imgHeight;
}
} else if (this.imgProportion == 0.6) {
if (imgHeight > 320) {
lh = 320;
} else {
lh = imgHeight;
}
lw = lh * 0.6;
} else {
if (imgHeight > 320) {
lh = 320;
lw = (imgWidth * lh) / imgHeight;
} else if (imgHeight <= 320) {
lh = imgHeight;
lw = imgWidth;
}
}
if (lh < 32 && lh < lw) {
newH = 32;
newW = (lw * 32) / lh;
} else if (lw < 32 && lw < lh) {
newW = 32;
newH = (lh * 32) / lw;
} else {
newH = lh;
newW = lw;
}
this.$set(item, "newW", newW);
this.$set(item, "newH", newH);
}
},
beforeDestroy() {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册