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

Merge branch 'dev-phase1-0111' of...

Merge branch 'dev-phase1-0111' of 192.168.110.53:com.pica.cloud.education.frontend/pica-admin-IM into dev-phase1-0111

* 'dev-phase1-0111' of 192.168.110.53:com.pica.cloud.education.frontend/pica-admin-IM:
  上传图片添加宽高
  图片上传添加宽高
...@@ -188,11 +188,10 @@ export default { ...@@ -188,11 +188,10 @@ export default {
this.fileIndex = index; this.fileIndex = index;
}, },
uploadImportFile(file) { uploadImportFile(file) {
console.log("================",file)
let _this = this; let _this = this;
const isLt5M = file.size / 1024 / 1024 < 6; const isLt5M = file.size / 1024 / 1024 < 6;
if (!isLt5M) { if (!isLt5M) {
this.$message.error('上传文件不能超过 5MB!'); this.$message.error('上传文件不能超过5MB!');
return isLt5M return isLt5M
} }
_this.searchParam.contentModelList[this.fileIndex].info = file.name; _this.searchParam.contentModelList[this.fileIndex].info = file.name;
...@@ -200,12 +199,13 @@ export default { ...@@ -200,12 +199,13 @@ export default {
_this.searchParam.contentModelList[this.fileIndex].type = 1; // 图片 _this.searchParam.contentModelList[this.fileIndex].type = 1; // 图片
let imgFile = new FileReader(); let imgFile = new FileReader();
imgFile.readAsDataURL(file); imgFile.readAsDataURL(file);
imgFile.onload = function(e) { imgFile.onload = function(theFile) {
let image = new Image(); let image = new Image();
image.src = e.target.result; image.src = theFile.target.result;
image.onload = function() { image.onload = function() {
_this.searchParam.contentModelList[this.fileIndex].width = this.width; let cox = this;
_this.searchParam.contentModelList[this.fileIndex].height = this.height; _this.searchParam.contentModelList[_this.fileIndex].width = cox.width;
_this.searchParam.contentModelList[_this.fileIndex].height = cox.height;
} }
} }
}else if(file.type == 'application/pdf') { }else if(file.type == 'application/pdf') {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册