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

代码优化

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