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

代码优化

上级 a1f7ae70
......@@ -62,7 +62,7 @@ export default {
},
// 挂载到Dom完成时
mounted() {
commonUtil.resizeHeight();
commonUtil.resizeHeight(92);
this.getData();
},
......
......@@ -1149,8 +1149,10 @@ export default {
newH = lh;
newW = lw;
}
this.$set(item, "newW", newW);
this.$set(item, "newH", newH);
item.newW = newW;
item.newH = newH;
// this.$set(item, "newW", newW);
// this.$set(item, "newH", newH);
}
},
......
......@@ -22,11 +22,16 @@
</div>
<div v-if="item.type == 'PICTURE'" class="img-content" v-viewer>
<!-- <img :src="item.content.url" /> -->
<img-size
:imgUrl="item.content.url"
<div class="img-handle-container">
<div class="img-box">
<img :src="item.content.url" :style="{width: item.newW + 'px', height: item.newH + 'px'}"/>
</div>
</div>
<!-- <img-size
:imgUrl="item.content.url"
:imgData="item"
:index="index"
@imgHandle="imgHandle"></img-size>
@imgHandle="imgHandle"></img-size> -->
</div>
<div v-if="item.type == 'CUSTOM'">
<div v-if="item.content.bizType == 18" class="file-content">
......@@ -221,10 +226,56 @@ export default {
this.$set(element, index, 'sessionFlag');
if(element.type == 'CUSTOM' || element.type == 'PICTURE') {
element.content = JSON.parse(element.content);
if(element.type == 'PICTURE') {
this.imgSizeHandleNew(element, element.content.w, element.content.h);
}
}
});
return data;
},
// 图片处理-新
imgSizeHandleNew(item, imgWidth, imgHeight) {
let lw, lh, newW, newH, imgProportion = (imgWidth / imgHeight).toFixed(1);
if (imgProportion > 0.6) {
if (imgWidth > 192) {
lw = 192;
lh = (imgHeight * lw) / imgWidth;
} else if (imgWidth <= 192) {
lw = imgWidth;
lh = imgHeight;
}
} else if (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;
}
item.newW = newW;
item.newH = newH;
// this.$set(item, "newW", newW);
// this.$set(item, "newH", newH);
},
// 时间格式转换
timeChange(data) {
return timeHandle(data)
......@@ -313,11 +364,13 @@ export default {
.img-content {
padding: 10px 0 16px;
cursor: pointer;
// & > img {
// width: 170px;
// height: 108px;
// border-radius: 8px;
// }
.img-handle-container {
.img-box {
max-width: 192px;
max-height: 320px;
overflow: hidden;
}
}
}
.file-content {
padding: 10px 0 16px;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册