diff --git a/src/utils/get-img-width.js b/src/utils/get-img-width.js index a315805..35a2bf2 100644 --- a/src/utils/get-img-width.js +++ b/src/utils/get-img-width.js @@ -1,5 +1,29 @@ import { Message } from 'element-ui' -export default function (file, width, height) { +export default function (file, id) { + let width = 0; + let height = 0; + switch (id) { + case 23: //深度解说 + width = 650; + height = 350; + break; + case 25: //行情分析 + width = 130; + height = 130; + break; + case 24: //热点追踪 + width = 130; + height = 130; + break; + case 7: //基础教程 + width = 380; + height = 220; + break; + case 6: //图文教程 + width = 380; + height = 220; + break; + }; return new Promise(resolve => { let reader = new FileReader(); reader.readAsDataURL(file); @@ -8,15 +32,20 @@ export default function (file, width, height) { let img = document.createElement("img"); img.src = txt; img.onload = function () { - if (img.width === width && img.height === height) { - resolve(true) + console.log(id, width, height); + if (width && height) { + if (img.width === width && img.height === height) { + resolve(true) + } else { + Message({ + message: `图片上传失败,宽高错误`, + type: "warning", + duration: 5000 + }); + resolve(false); + } } else { - Message({ - message: `图片上传失败,宽高错误`, - type: "warning", - duration: 5000 - }); - resolve(false); + resolve(true) } }; }; diff --git a/src/views/article/index.vue b/src/views/article/index.vue index 95ddc92..b1647ba 100644 --- a/src/views/article/index.vue +++ b/src/views/article/index.vue @@ -3,7 +3,7 @@ - +
{{ row.url }} + + +