Browse Source

接口对接

milestone-20251021-双11活动后台
liruiqiang 3 months ago
parent
commit
32504b4f1c
  1. 11
      src/router/index.js
  2. 5
      src/views/admin/landingList.vue
  3. 54
      src/views/admin/landingManagement.vue

11
src/router/index.js

@ -5,7 +5,7 @@ const router = createRouter({
routes: [ routes: [
{ {
path: '/', path: '/',
redirect: '/admin/landingList'
redirect: '/admin/landingManagement'
}, },
// 落地页活动管理 // 落地页活动管理
{ {
@ -16,6 +16,15 @@ const router = createRouter({
title: '落地页活动管理', title: '落地页活动管理',
} }
}, },
// 落地页活动管理
{
path: '/admin/landingManagement',
name: 'landingManagement',
component: () => import('../views/admin/landingManagement.vue'),
meta: {
title: '落地页活动管理',
}
},
// 落地页活动详情 // 落地页活动详情
{ {
path: '/admin/landingDetail/:id', path: '/admin/landingDetail/:id',

5
src/views/admin/landingList.vue

@ -176,7 +176,7 @@
</template> </template>
<script> <script>
import { getLandingListApi, addLandingApi, editLandingtApi } from '../../api/member.js';
import { getLandingListApi, addLandingApi } from '../../api/member.js';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
export default { export default {
@ -399,8 +399,7 @@ export default {
submitForm() { submitForm() {
this.$refs.formRef.validate((valid) => { this.$refs.formRef.validate((valid) => {
if (valid) { if (valid) {
const api = this.form.id ? editLandingtApi : addLandingApi;
api({
addLandingApi({
id: this.form.id, id: this.form.id,
name: this.form.name, name: this.form.name,
intro: this.form.intro, intro: this.form.intro,

54
src/views/admin/landingManagement.vue

@ -129,13 +129,16 @@
<el-upload <el-upload
class="upload-demo" class="upload-demo"
action="#" action="#"
:limit="1"
:on-change="handleLandingPageUpload" :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> <el-button type="primary" icon="Plus">上传</el-button>
<template #tip> <template #tip>
<div class="upload-tip"> <div class="upload-tip">
宽度375像素支持PNGJPGGIF格式图片需小于2M
支持PNGJPGGIF格式
</div> </div>
</template> </template>
</el-upload> </el-upload>
@ -148,13 +151,14 @@
action="#" action="#"
:limit="1" :limit="1"
:on-change="handlePopupUpload" :on-change="handlePopupUpload"
:on-remove="handlePoppDel"
list-type="picture" list-type="picture"
:file-list="form.popupFiles" :file-list="form.popupFiles"
> >
<el-button type="primary" icon="Plus">上传</el-button> <el-button type="primary" icon="Plus">上传</el-button>
<template #tip> <template #tip>
<div class="upload-tip"> <div class="upload-tip">
宽度375像素支持PNGJPG格式图片需小于2M
支持PNGJPG格式
</div> </div>
</template> </template>
</el-upload> </el-upload>
@ -181,6 +185,8 @@ export default {
name: 'LandingList', name: 'LandingList',
data() { data() {
return { return {
landingPageImgFlag:false,
popupImgFlag:false,
// //
tableData: [], tableData: [],
// //
@ -311,39 +317,37 @@ export default {
] ]
this.dialogVisible = true; this.dialogVisible = true;
}, },
handleLandingPageDel(){
this.form.landingPage = ""
this.form.landingPageFiles = []
},
handlePopupDel(){
this.form.popup = ""
this.form.popupFiles = []
},
// 375px // 375px
handleLandingPageUpload(file) { handleLandingPageUpload(file) {
const reader = new FileReader(); const reader = new FileReader();
reader.onload = (e) => { reader.onload = (e) => {
const img = new Image(); const img = new Image();
img.onload = () => { img.onload = () => {
if (img.width > 375) {
ElMessage.error('图片宽度不能超过375px');
this.form.landingPageFiles = [];
} else {
this.landingPageImgFlag = true
this.form.landingPage = file.raw; this.form.landingPage = file.raw;
this.form.landingPageFiles = [file]; this.form.landingPageFiles = [file];
}
}; };
img.src = e.target.result; img.src = e.target.result;
}; };
reader.readAsDataURL(file.raw); reader.readAsDataURL(file.raw);
}, },
// 375px
handlePopupUpload(file) { handlePopupUpload(file) {
const reader = new FileReader(); const reader = new FileReader();
reader.onload = (e) => { reader.onload = (e) => {
const img = new Image(); const img = new Image();
img.onload = () => { img.onload = () => {
if (img.width > 375) {
ElMessage.error('图片宽度不能超过375px');
this.form.popupFiles = [];
} else {
this.popupImgFlag = true
this.form.popup = file.raw; this.form.popup = file.raw;
this.form.popupFiles = [file]; this.form.popupFiles = [file];
}
}; };
img.src = e.target.result; img.src = e.target.result;
}; };
@ -354,7 +358,9 @@ export default {
async submitForm() { async submitForm() {
this.$refs.formRef.validate( async (valid) => { this.$refs.formRef.validate( async (valid) => {
if (valid) { if (valid) {
let landingPageFlag = false
let landingPageFlag = true
if(this.landingPageImgFlag){
try{
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.form.landingPageFiles[0].raw); formData.append('file', this.form.landingPageFiles[0].raw);
formData.append("type", "image"); formData.append("type", "image");
@ -370,8 +376,16 @@ export default {
this.form.landingPage = landingPageRes.data.data.url this.form.landingPage = landingPageRes.data.data.url
// this.form.popup = resp.data.file_name // this.form.popup = resp.data.file_name
landingPageFlag = true landingPageFlag = true
} else{
landingPageFlag = false
}
}catch{
landingPageFlag = false
} }
let popupFlag = false
}
let popupFlag = true
if(this.popupImgFlag){
try{
const popupFormData = new FormData(); const popupFormData = new FormData();
popupFormData.append('file', this.form.popupFiles[0].raw); popupFormData.append('file', this.form.popupFiles[0].raw);
popupFormData.append("type", "image"); popupFormData.append("type", "image");
@ -387,6 +401,12 @@ export default {
this.form.popup = popupRes.data.data.url this.form.popup = popupRes.data.data.url
// this.form.popup = popupRes.data.file_name // this.form.popup = popupRes.data.file_name
popupFlag = true popupFlag = true
} else{
popupFlag = false
}
} catch {
popupFlag = false
}
} }
if(!landingPageFlag || !popupFlag){ if(!landingPageFlag || !popupFlag){
ElMessage.error('图片上传失败'); ElMessage.error('图片上传失败');

Loading…
Cancel
Save