提交 790800f1 编写于 作者: huangwensu's avatar huangwensu

图片显示规则

上级 f7e56287
<template> <template>
<div class="img-container"> <div class="img-handle-container">
<img :src="imgData.url" /> <div class="img-box">
<img :src="imgUrl" :style="{width: imgData.newW + 'px', height: imgData.newH + 'px' }"/>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'imgSize', name: 'imgSize',
props: { props: {
imgUrl: {
type: String,
default: ''
},
imgData: { imgData: {
type: Object, type: Object,
default: {} default: {}
},
index: {
type: Number,
default: 0
} }
}, },
data() { data() {
return { return {
imgWidth: 0, imgWidth: 0,
imgHeight: 0, imgHeight: 0,
imgProportion: 0 imgProportion: 0,
lw: 0,
lh: 0,
newW: 0,
newH: 0,
} }
}, },
mounted() { mounted() {
this.imgWidth = this.imgData.width; console.log("222222222222222", this.imgData)
this.imgHeight = this.imgData.height; let {lw, lh, newW, newH} = this;
this.imgWidth = this.imgData.width || JSON.parse(this.imgData.content).w;
this.imgHeight = this.imgData.height || JSON.parse(this.imgData.content).h;
this.imgProportion = (this.imgWidth / this.imgHeight).toFixed(1); this.imgProportion = (this.imgWidth / this.imgHeight).toFixed(1);
console.log("==========dddddddddd",this.imgProportion)
if(this.imgProportion > 0.6) { 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) {
lh = 320;
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.$emit('imgHandle', {width: newW, height: newH, index: this.index});
}, },
methods: { methods: {
...@@ -34,5 +77,11 @@ export default { ...@@ -34,5 +77,11 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.img-handle-container {
.img-box {
max-width: 192px;
max-height: 320px;
overflow: hidden;
}
}
</style> </style>
\ No newline at end of file
...@@ -9,8 +9,11 @@ ...@@ -9,8 +9,11 @@
<div>{{item.info}}</div> <div>{{item.info}}</div>
</div> </div>
<div v-if="item.type == 1" class="img-content" v-viewer> <div v-if="item.type == 1" class="img-content" v-viewer>
<img :src="item.url" /> <img-size
<!-- <img-size :imgData="item"></img-size> --> :imgUrl="item.url"
:imgData="item"
:index="index"
@imgHandle="imgHandle"></img-size>
</div> </div>
<div v-if="item.type == 2" class="file-content"> <div v-if="item.type == 2" class="file-content">
<div class="file-con" @click="openPDF(item.url)"> <div class="file-con" @click="openPDF(item.url)">
...@@ -61,6 +64,7 @@ export default { ...@@ -61,6 +64,7 @@ export default {
mounted() { mounted() {
commonUtil.resizeHeight(); commonUtil.resizeHeight();
this.getData(); this.getData();
}, },
methods: { methods: {
// 获取历史群发数据 // 获取历史群发数据
...@@ -72,13 +76,17 @@ export default { ...@@ -72,13 +76,17 @@ export default {
if (res.code == "000000") { if (res.code == "000000") {
this.detailData = res.data; this.detailData = res.data;
this.detailData.contentModelList.map((item) => { this.detailData.contentModelList.map((item) => {
if(item.type == 2) { if(item.type == 2) { // 0 文本 1 图片 2PDF 3链接
item.fileSize = betaHandle(item.fileSize); item.fileSize = betaHandle(item.fileSize);
} }
}) })
} }
}); });
}, },
imgHandle(data) {
this.$set(this.detailData.contentModelList[data.index], 'newW', data.width)
this.$set(this.detailData.contentModelList[data.index], 'newH', data.height)
},
// 下载目标文件 // 下载目标文件
downFile() { downFile() {
let a = document.createElement('a'); let a = document.createElement('a');
...@@ -121,11 +129,17 @@ export default { ...@@ -121,11 +129,17 @@ export default {
padding: 16px 0; padding: 16px 0;
border-bottom: 1px solid #F0F1F2; border-bottom: 1px solid #F0F1F2;
cursor: pointer; cursor: pointer;
& > img { // .img-box {
width: 170px; // max-width: 192px;
height: 108px; // max-height: 320px;
border-radius: 8px; // overflow: hidden;
} // // & > img {
// // // width: 170px;
// // // height: 108px;
// // border-radius: 8px;
// // }
// }
} }
.file-content { .file-content {
padding: 16px 0; padding: 16px 0;
......
...@@ -248,11 +248,11 @@ ...@@ -248,11 +248,11 @@
// width: 20px; // width: 20px;
// height: 20px; // height: 20px;
// } // }
& > .img { // & > .img {
width: 170px; // width: 170px;
height: 108px; // height: 108px;
border-radius: 8px; // border-radius: 8px;
} // }
} }
} }
......
...@@ -91,8 +91,12 @@ ...@@ -91,8 +91,12 @@
<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 /> <!-- <img class="img" :src="item.url" alt /> -->
<!-- <img :src="item.imgUrl" alt /> --> <img-size
:imgUrl="item.url"
:imgData="item"
:index="index"
@imgHandle="imgHandle"></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">
...@@ -200,6 +204,7 @@ ...@@ -200,6 +204,7 @@
<script> <script>
import { mapGetters, mapMutations } from "vuex"; import { mapGetters, mapMutations } from "vuex";
import BreadCrumb from "@/components/breadcrumb.vue"; import BreadCrumb from "@/components/breadcrumb.vue";
import ImgSize from "@/components/IM/img-size.vue";
import { doUpload, getFilePath } from "@/utils/qiniu-util"; import { doUpload, getFilePath } from "@/utils/qiniu-util";
import { validateWord } from "@/utils/validate.js"; import { validateWord } from "@/utils/validate.js";
import { import {
...@@ -220,7 +225,8 @@ let _this = null; ...@@ -220,7 +225,8 @@ let _this = null;
export default { export default {
components: { components: {
BreadCrumb, BreadCrumb,
UserInfo UserInfo,
ImgSize
}, },
data() { data() {
return { return {
...@@ -1026,9 +1032,17 @@ export default { ...@@ -1026,9 +1032,17 @@ export default {
// 文件大小单位转换 // 文件大小单位转换
fileSizeChange(val) { fileSizeChange(val) {
return betaHandle(val); return betaHandle(val);
} },
imgHandle(data) {
this.$set(this.messageList[data.index], 'newW', data.width)
this.$set(this.messageList[data.index], 'newH', data.height)
},
}, },
beforeDestroy() { beforeDestroy() {
console.log("in beforeDestroy", forwardMsgIntervalId); console.log("in beforeDestroy", forwardMsgIntervalId);
sessionIntervalId && clearInterval(sessionIntervalId); sessionIntervalId && clearInterval(sessionIntervalId);
......
...@@ -21,7 +21,12 @@ ...@@ -21,7 +21,12 @@
<div>{{item.content}}</div> <div>{{item.content}}</div>
</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
:imgUrl="item.content.url"
:imgData="item"
:index="index"
@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">
...@@ -52,12 +57,14 @@ ...@@ -52,12 +57,14 @@
</template> </template>
<script> <script>
import BreadCrumb from "@/components/breadcrumb.vue"; import BreadCrumb from "@/components/breadcrumb.vue";
import ImgSize from "@/components/IM/img-size.vue";
import { doUpload, getFilePath } from "@/utils/qiniu-util"; import { doUpload, getFilePath } from "@/utils/qiniu-util";
import { openLoading, closeLoading, betaHandle, timeHandle } from "@/utils/utils"; import { openLoading, closeLoading, betaHandle, timeHandle } from "@/utils/utils";
import { getPicaKFAccid } from "@/utils"; import { getPicaKFAccid } from "@/utils";
export default { export default {
components: { components: {
BreadCrumb BreadCrumb,
ImgSize
}, },
data() { data() {
return { return {
...@@ -188,6 +195,10 @@ export default { ...@@ -188,6 +195,10 @@ export default {
} }
}) })
}, },
imgHandle(data) {
this.$set(this.detailData[data.index], 'newW', data.width)
this.$set(this.detailData[data.index], 'newH', data.height)
},
// 按照时间大小排序 // 按照时间大小排序
timeSort(arrList) { timeSort(arrList) {
arrList.sort((a, b) => { arrList.sort((a, b) => {
...@@ -302,11 +313,11 @@ export default { ...@@ -302,11 +313,11 @@ export default {
.img-content { .img-content {
padding: 16px 0; padding: 16px 0;
cursor: pointer; cursor: pointer;
& > img { // & > img {
width: 170px; // width: 170px;
height: 108px; // height: 108px;
border-radius: 8px; // border-radius: 8px;
} // }
} }
.file-content { .file-content {
padding: 16px 0; padding: 16px 0;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册