提交 0d9ea6aa 编写于 作者: huangwensu's avatar huangwensu

当前会话图片处理

上级 f8eba1de
...@@ -271,6 +271,11 @@ ...@@ -271,6 +271,11 @@
// height: 108px; // height: 108px;
// border-radius: 8px; // border-radius: 8px;
// } // }
.img-box {
max-width: 192px;
max-height: 320px;
overflow: hidden;
}
} }
} }
......
...@@ -95,13 +95,15 @@ ...@@ -95,13 +95,15 @@
<div class="mid-text">{{item.text}}</div> <div class="mid-text">{{item.text}}</div>
</div> </div>
<div v-if="item.showType == 2" class="mid-img" v-viewer> <div v-if="item.showType == 2" class="mid-img" v-viewer>
<!-- <img class="img" :src="item.url" alt /> --> <div class="img-box">
<img-size <img class="img" :src="item.url" :style="{width: item.newW + 'px', height: item.newH + 'px' }" alt />
</div>
<!-- <img-size
:imgUrl="item.url" :imgUrl="item.url"
:imgData="item" :imgData="item"
:index="index" :index="index"
@imgHandle="imgHandle" @imgHandle="imgHandle"
></img-size> ></img-size> -->
</div> </div>
<div v-if="item.showType == 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">
...@@ -268,7 +270,10 @@ export default { ...@@ -268,7 +270,10 @@ export default {
{ required: true, message: "请填写链接显示文案", trigger: "blur" } { required: true, message: "请填写链接显示文案", trigger: "blur" }
], ],
url: [{ required: true, message: "请选择链接", trigger: "change" }] url: [{ required: true, message: "请选择链接", trigger: "change" }]
} },
imgWidth: 0,
imgHeight: 0,
imgProportion: 0,
}; };
}, },
...@@ -372,6 +377,7 @@ export default { ...@@ -372,6 +377,7 @@ export default {
} }
}, },
// 查询医生和居民的消息 - 向前查找 // 查询医生和居民的消息 - 向前查找
getMSGForwardForAC(msg) { getMSGForwardForAC(msg) {
let session = this.currentSession; let session = this.currentSession;
...@@ -583,6 +589,11 @@ export default { ...@@ -583,6 +589,11 @@ export default {
msg.url = url; msg.url = url;
msg.sessionFlag = false; msg.sessionFlag = false;
cMessageList.push(msg); cMessageList.push(msg);
if(msg.type.toLowerCase() == "image" ||
msg.type.toLowerCase() == "picture") {
this.imgSizeHandle(msg)
}
}); });
if (directFlag === 1) { if (directFlag === 1) {
...@@ -1037,10 +1048,54 @@ export default { ...@@ -1037,10 +1048,54 @@ export default {
return betaHandle(val); return betaHandle(val);
}, },
imgHandle(data) { // imgHandle(data) {
this.$set(this.messageList[data.index], "newW", data.width); // this.$set(this.messageList[data.index], "newW", data.width);
this.$set(this.messageList[data.index], "newH", data.height); // this.$set(this.messageList[data.index], "newH", data.height);
} // },
// 图片处理
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;
}
}
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() { beforeDestroy() {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册