|
|
|
@ -129,13 +129,16 @@ |
|
|
|
<el-upload |
|
|
|
class="upload-demo" |
|
|
|
action="#" |
|
|
|
:limit="1" |
|
|
|
:on-change="handleLandingPageUpload" |
|
|
|
:show-file-list="false" |
|
|
|
:on-remove="handleLandingPageDel" |
|
|
|
list-type="picture" |
|
|
|
:file-list="form.landingPageFiles" |
|
|
|
> |
|
|
|
<el-button type="primary" icon="Plus">上传</el-button> |
|
|
|
<template #tip> |
|
|
|
<div class="upload-tip"> |
|
|
|
宽度≤375像素,支持PNG、JPG、GIF格式,图片需小于2M |
|
|
|
支持PNG、JPG、GIF格式 |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</el-upload> |
|
|
|
@ -148,13 +151,14 @@ |
|
|
|
action="#" |
|
|
|
:limit="1" |
|
|
|
:on-change="handlePopupUpload" |
|
|
|
:on-remove="handlePoppDel" |
|
|
|
list-type="picture" |
|
|
|
:file-list="form.popupFiles" |
|
|
|
> |
|
|
|
<el-button type="primary" icon="Plus">上传</el-button> |
|
|
|
<template #tip> |
|
|
|
<div class="upload-tip"> |
|
|
|
宽度≤375像素,支持PNG、JPG格式,图片需小于2M |
|
|
|
支持PNG、JPG格式 |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</el-upload> |
|
|
|
@ -181,6 +185,8 @@ export default { |
|
|
|
name: 'LandingList', |
|
|
|
data() { |
|
|
|
return { |
|
|
|
landingPageImgFlag:false, |
|
|
|
popupImgFlag:false, |
|
|
|
// 表格数据 |
|
|
|
tableData: [], |
|
|
|
// 分页参数 |
|
|
|
@ -311,39 +317,37 @@ export default { |
|
|
|
] |
|
|
|
this.dialogVisible = true; |
|
|
|
}, |
|
|
|
|
|
|
|
handleLandingPageDel(){ |
|
|
|
this.form.landingPage = "" |
|
|
|
this.form.landingPageFiles = [] |
|
|
|
}, |
|
|
|
handlePopupDel(){ |
|
|
|
this.form.popup = "" |
|
|
|
this.form.popupFiles = [] |
|
|
|
}, |
|
|
|
// 处理落地页上传(宽度校验≤375px) |
|
|
|
handleLandingPageUpload(file) { |
|
|
|
const reader = new FileReader(); |
|
|
|
reader.onload = (e) => { |
|
|
|
const img = new Image(); |
|
|
|
img.onload = () => { |
|
|
|
if (img.width > 375) { |
|
|
|
ElMessage.error('图片宽度不能超过375px'); |
|
|
|
this.form.landingPageFiles = []; |
|
|
|
} else { |
|
|
|
this.landingPageImgFlag = true |
|
|
|
this.form.landingPage = file.raw; |
|
|
|
this.form.landingPageFiles = [file]; |
|
|
|
} |
|
|
|
}; |
|
|
|
img.src = e.target.result; |
|
|
|
}; |
|
|
|
reader.readAsDataURL(file.raw); |
|
|
|
}, |
|
|
|
|
|
|
|
// 处理弹窗上传(宽度校验≤375px) |
|
|
|
handlePopupUpload(file) { |
|
|
|
const reader = new FileReader(); |
|
|
|
reader.onload = (e) => { |
|
|
|
const img = new Image(); |
|
|
|
img.onload = () => { |
|
|
|
if (img.width > 375) { |
|
|
|
ElMessage.error('图片宽度不能超过375px'); |
|
|
|
this.form.popupFiles = []; |
|
|
|
} else { |
|
|
|
this.popupImgFlag = true |
|
|
|
this.form.popup = file.raw; |
|
|
|
this.form.popupFiles = [file]; |
|
|
|
} |
|
|
|
}; |
|
|
|
img.src = e.target.result; |
|
|
|
}; |
|
|
|
@ -354,40 +358,56 @@ export default { |
|
|
|
async submitForm() { |
|
|
|
this.$refs.formRef.validate( async (valid) => { |
|
|
|
if (valid) { |
|
|
|
let landingPageFlag = false |
|
|
|
const formData = new FormData(); |
|
|
|
formData.append('file', this.form.landingPageFiles[0].raw); |
|
|
|
formData.append("type", "image"); |
|
|
|
formData.append("app_from", "toujiao"); |
|
|
|
const landingPageRes = await axios.post( |
|
|
|
'http://39.101.133.168:8828/hljwgo/api/file/upload', |
|
|
|
formData, |
|
|
|
{ |
|
|
|
headers: { "Content-Type": "multipart/form-data" } |
|
|
|
let landingPageFlag = true |
|
|
|
if(this.landingPageImgFlag){ |
|
|
|
try{ |
|
|
|
const formData = new FormData(); |
|
|
|
formData.append('file', this.form.landingPageFiles[0].raw); |
|
|
|
formData.append("type", "image"); |
|
|
|
formData.append("app_from", "toujiao"); |
|
|
|
const landingPageRes = await axios.post( |
|
|
|
'http://39.101.133.168:8828/hljwgo/api/file/upload', |
|
|
|
formData, |
|
|
|
{ |
|
|
|
headers: { "Content-Type": "multipart/form-data" } |
|
|
|
} |
|
|
|
); |
|
|
|
if(landingPageRes.data.code === 200){ |
|
|
|
this.form.landingPage = landingPageRes.data.data.url |
|
|
|
// this.form.popup = resp.data.file_name |
|
|
|
landingPageFlag = true |
|
|
|
} else{ |
|
|
|
landingPageFlag = false |
|
|
|
} |
|
|
|
); |
|
|
|
if(landingPageRes.data.code === 200){ |
|
|
|
this.form.landingPage = landingPageRes.data.data.url |
|
|
|
// this.form.popup = resp.data.file_name |
|
|
|
landingPageFlag = true |
|
|
|
}catch{ |
|
|
|
landingPageFlag = false |
|
|
|
} |
|
|
|
let popupFlag = false |
|
|
|
const popupFormData = new FormData(); |
|
|
|
popupFormData.append('file', this.form.popupFiles[0].raw); |
|
|
|
popupFormData.append("type", "image"); |
|
|
|
popupFormData.append("app_from", "toujiao"); |
|
|
|
const popupRes =await axios.post( |
|
|
|
'http://39.101.133.168:8828/hljwgo/api/file/upload', |
|
|
|
popupFormData, |
|
|
|
{ |
|
|
|
headers: { "Content-Type": "multipart/form-data" } |
|
|
|
} |
|
|
|
let popupFlag = true |
|
|
|
if(this.popupImgFlag){ |
|
|
|
try{ |
|
|
|
const popupFormData = new FormData(); |
|
|
|
popupFormData.append('file', this.form.popupFiles[0].raw); |
|
|
|
popupFormData.append("type", "image"); |
|
|
|
popupFormData.append("app_from", "toujiao"); |
|
|
|
const popupRes =await axios.post( |
|
|
|
'http://39.101.133.168:8828/hljwgo/api/file/upload', |
|
|
|
popupFormData, |
|
|
|
{ |
|
|
|
headers: { "Content-Type": "multipart/form-data" } |
|
|
|
} |
|
|
|
); |
|
|
|
if(popupRes.data.code === 200){ |
|
|
|
this.form.popup = popupRes.data.data.url |
|
|
|
// this.form.popup = popupRes.data.file_name |
|
|
|
popupFlag = true |
|
|
|
} else{ |
|
|
|
popupFlag = false |
|
|
|
} |
|
|
|
); |
|
|
|
if(popupRes.data.code === 200){ |
|
|
|
this.form.popup = popupRes.data.data.url |
|
|
|
// this.form.popup = popupRes.data.file_name |
|
|
|
popupFlag = true |
|
|
|
} catch { |
|
|
|
popupFlag = false |
|
|
|
} |
|
|
|
} |
|
|
|
if(!landingPageFlag || !popupFlag){ |
|
|
|
ElMessage.error('图片上传失败'); |
|
|
|
return |
|
|
|
|