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. 110
      src/views/admin/landingManagement.vue

11
src/router/index.js

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

5
src/views/admin/landingList.vue

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

110
src/views/admin/landingManagement.vue

@ -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像素支持PNGJPGGIF格式图片需小于2M
支持PNGJPGGIF格式
</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像素支持PNGJPG格式图片需小于2M
支持PNGJPG格式
</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

Loading…
Cancel
Save