Commit 920c80e0 authored by leiqingsong's avatar leiqingsong

活动模板接口

parent 1309cfee
...@@ -89,3 +89,36 @@ export function collectMyCoupon(params) { ...@@ -89,3 +89,36 @@ export function collectMyCoupon(params) {
params params
}) })
} }
/**
* 保存模板
*/
export function saveTemplate(params) {
return request({
url: 'template/save',
method: 'post',
data: params
})
}
/**
* 获取模板
* @param {*} params
*/
export function getTemplate(params) {
return request({
url: `template/list`,
method: 'post',
params
})
}
/**
* 获取模板详情
*/
export function getTemplateData(id) {
return request({
url: `template/getTemplate?templateId=${id}`,
method: 'post'
})
}
\ No newline at end of file
<template> <template>
<div class="container"> <div class="container">
<div class="title"> <div v-if="wheelList.length > 0" class="title">
<span>大转盘抽奖</span> <span>大转盘抽奖</span>
</div> </div>
<div class="active"> <div class="active">
<template v-for="(item, index) in activeList"> <template v-for="(item, index) in wheelList">
<div <div
v-if="index < wheelActive_limit" v-if="index < wheelActive_limit"
class="list" class="list"
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
</template> </template>
<span <span
class="more" class="more"
v-if="activeList.length && !activeList_finished" v-if="wheelList.length && !wheelList_finished"
@click="handleWheelActiveMore" @click="handleActiveMore('wheel')"
> >
查看更多 查看更多
<span class="icon">></span> <span class="icon">></span>
...@@ -31,18 +31,25 @@ ...@@ -31,18 +31,25 @@
</div> </div>
<div v-if="couponList.length > 0" class="fg">送券活动</div> <div v-if="couponList.length > 0" class="fg">送券活动</div>
<div class="active"> <div class="active">
<div <template v-for="(item, index) in couponList">
class="list" <div v-if="index < couponActive_limit" class="list" :key="item.id" @click="toDetail(item.id, item.activityType)">
v-for="item in couponList" <div class="left">
:key="item.id" <img :src="item.logo" alt="logo" style="width:100%;height:100%;" />
@click="toDetail(item.id, item.activityType)" </div>
>
<div class="left"></div>
<div class="right"> <div class="right">
<h3>{{ item.activityName }}</h3> <h3>{{ item.activityName }}</h3>
<p>{{ item.des }}</p> <p>{{ item.des }}</p>
</div> </div>
</div> </div>
</template>
<span
class="more"
v-if="couponList.length && !couponList_finished"
@click="handleActiveMore('coupon')"
>
查看更多
<span class="icon">></span>
</span>
</div> </div>
</div> </div>
</template> </template>
...@@ -53,58 +60,66 @@ export default { ...@@ -53,58 +60,66 @@ export default {
data() { data() {
return { return {
wheelActive_limit: 3, wheelActive_limit: 3,
activeList_finished: false, wheelList_finished: false,
activeList: [ couponActive_limit: 3,
{ couponList_finished: false,
id: 1, wheelList: [],
activityType: "coupon", couponList: [],
activityName: "砍价", wheel_params: {
des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。" pageNo: 1,
}, pageSize: 3
{
id: 2,
activityType: "wheel",
activityName: "集赞",
des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
}
],
couponList: [
{
id: 1,
activityType: "coupon",
activityName: "砍价",
des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
}, },
{ coupon_params: {
id: 2,
activityType: "wheel",
activityName: "集赞",
des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
}
],
params: {
pageNo: 1, pageNo: 1,
pageSize: 10 pageSize: 3
} }
}; };
}, },
mounted() { mounted() {
this.getActiveList(this.params); this.getWheelActive();
this.getCouponActive();
}, },
methods: { methods: {
handleWheelActiveMore() { async getCouponActive() {
let res = await this.getActiveList("coupon");
this.couponList.push.apply(this.couponList, res.data.list);
if (res.data.list === []) {
this.couponList_finished = true
}
},
async getWheelActive() {
let res = await this.getActiveList("wheel");
this.wheelList.push.apply(this.wheelList, res.data.list);
if (res.data.list === []) {
this.wheelList_finished = true
}
},
handleActiveMore(type) {
if (type === "wheel") {
this.wheelActive_limit += 3; this.wheelActive_limit += 3;
if (this.wheelActive_limit === this.activeList.length - 3) { this.wheel_params.pageNo += 1;
this.activeList_finished = true; this.getWheelActive();
return; } else if (type === "coupon") {
this.couponActive_limit += 3;
this.coupon_params.pageNo += 1;
this.getCouponActive()
} }
}, },
// 获取 活动列表 // 获取 活动列表
getActiveList(params) { async getActiveList(type) {
API_Active.getActiveList(params).then(res => { let page_params = {};
console.log("获取到数据"); if (type === 'wheel') {
this.activeList = res.data.list; page_params = this.wheel_params;
}); }
else if (type === 'coupon') {
page_params = this.coupon_params;
}
let params = {
activityType: type,
...page_params
};
let res = await API_Active.getActiveList(params);
return res;
}, },
// 跳转到 活动详情 // 跳转到 活动详情
toDetail(active_id, type) { toDetail(active_id, type) {
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
<div class="container"> <div class="container">
<div class="title">活动设置</div> <div class="title">活动设置</div>
<van-cell-group class="all"> <van-cell-group class="all">
<van-cell title="活动标题" style="font-size:14px;"> <van-cell :required="true" title="活动标题" style="font-size:14px;">
<template slot="default"> <template slot="default">
<van-field v-model="title" placeholder="请输入活动标题" class="right" style="font-size:14px;" /> <van-field v-model="title" placeholder="请输入活动标题" class="right" style="font-size:14px;" />
</template> </template>
</van-cell> </van-cell>
<van-cell title="活动开始时间" style="font-size:14px;"> <van-cell :required="true" title="活动开始时间" style="font-size:14px;">
<template slot="default"> <template slot="default">
<div class="nobr"> <div class="nobr">
<van-field <van-field
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<van-popup v-model="startShow" position="bottom" :overlay="true"> <van-popup v-model="startShow" position="bottom" :overlay="true">
<van-datetime-picker <van-datetime-picker
v-model="startTime" v-model="startTime"
type="date" type="datetime"
@cancel="startShow = false" @cancel="startShow = false"
@confirm="handleStartTime" @confirm="handleStartTime"
@change="startTimeChange" @change="startTimeChange"
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
</div> </div>
</template> </template>
</van-cell> </van-cell>
<van-cell title="活动结束时间" style="font-size:14px;"> <van-cell :required="true" title="活动结束时间" style="font-size:14px;">
<template slot="default"> <template slot="default">
<div class="jpsl"> <div class="jpsl">
<van-field <van-field
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<van-popup v-model="endShow" position="bottom" :overlay="true"> <van-popup v-model="endShow" position="bottom" :overlay="true">
<van-datetime-picker <van-datetime-picker
v-model="endTime" v-model="endTime"
type="date" type="datetime"
@cancel="endShow = false" @cancel="endShow = false"
@confirm="handleEndTime" @confirm="handleEndTime"
@change="endTimeChange" @change="endTimeChange"
...@@ -54,10 +54,10 @@ ...@@ -54,10 +54,10 @@
<van-cell title="背景图片" style="font-size: 14px"> <van-cell title="背景图片" style="font-size: 14px">
<van-uploader v-model="bg_imgs" :max-count="1" :after-read="afterBGRead" /> <van-uploader v-model="bg_imgs" :max-count="1" :after-read="afterBGRead" />
</van-cell> </van-cell>
<van-cell title="活动Logo" style="font-size: 14px"> <van-cell :required="true" title="活动Logo" style="font-size: 14px">
<van-uploader :max-count="1" v-model="logo_imgs" :after-read="afterLogoRead"></van-uploader> <van-uploader :max-count="1" v-model="logo_imgs" :after-read="afterLogoRead"></van-uploader>
</van-cell> </van-cell>
<van-cell title="单日最大发放数量"> <van-cell :required="true" title="单日最大发放数量">
<template slot="default"> <template slot="default">
<div class="jpsl"> <div class="jpsl">
<van-field <van-field
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
</div> </div>
</template> </template>
</van-cell> </van-cell>
<van-cell title="总发放数量"> <van-cell :required="true" title="总发放数量">
<template slot="default"> <template slot="default">
<div class="jpsl"> <div class="jpsl">
<van-field <van-field
...@@ -97,7 +97,14 @@ ...@@ -97,7 +97,14 @@
</div> </div>
</template> </template>
</van-cell> </van-cell>
<van-cell title="选择优惠券" value="1" is-link @click="showCoupon = true" center /> <van-cell
:required="true"
title="选择优惠券"
:value="checked_coupon.name"
is-link
@click="showCoupon = true"
center
/>
</van-cell-group> </van-cell-group>
<!-- 活动描述 --> <!-- 活动描述 -->
<div class="detail"> <div class="detail">
...@@ -117,18 +124,20 @@ ...@@ -117,18 +124,20 @@
<!-- 活动图片 --> <!-- 活动图片 -->
<div class="detail" style="margin-top:0;"> <div class="detail" style="margin-top:0;">
<div class="des">活动图片</div> <div class="des">活动图片</div>
<van-uploader v-model="fileList" multiple :max-count="9" /> <van-uploader v-model="fileList_show" multiple :max-count="9" :after-read="afterImgRead" />
</div> </div>
<div class="creat" @click="handleCreate">创建活动</div> <div class="creat" @click="handleCreate">创建活动</div>
<van-action-sheet v-model="showCoupon" :actions="coupons" cancel-text="取消" /> <van-action-sheet v-model="showCoupon" :actions="coupons" cancel-text="取消" @select="onSelect" />
</div> </div>
</template> </template>
<script> <script>
import axios from "axios";
import * as API_Active from "@/api/active"; import * as API_Active from "@/api/active";
export default { export default {
data() { data() {
return { return {
checked_coupon: {},
logo_imgs: [], logo_imgs: [],
bg_imgs: [], bg_imgs: [],
title: "送券", title: "送券",
...@@ -149,6 +158,7 @@ export default { ...@@ -149,6 +158,7 @@ export default {
endShow: false, endShow: false,
message: "123", message: "123",
fileList: [], fileList: [],
fileList_show: [],
showCoupon: false, showCoupon: false,
coupons: [ coupons: [
{ name: "选项" }, { name: "选项" },
...@@ -162,6 +172,62 @@ export default { ...@@ -162,6 +172,62 @@ export default {
}; };
}, },
methods: { methods: {
getTemplateDate(id) {
API_Active.getTemplateData(id).then(res => {
this.title = res.data.activityInfo.activityName;
let time1 = res.data.activityInfo.startTime;
this.startTime1 =
`${time1.substring(0, 4)}-${time1.substring(4, 6)}-${time1.substring(
6,
8
)}` + time1.substring(8);
let time2 = res.data.activityInfo.endTime;
this.endTime1 =
`${time2.substring(0, 4)}-${time2.substring(4, 6)}-${time2.substring(
6,
8
)}` + time2.substring(8);
this.bg_imgs[0] = { url: res.data.activityInfo.backImage };
this.logo_imgs[0] = { url: res.data.activityInfo.logo };
this.maxNumber = res.data.activityInfo.joinLimit?.toString();
this.totalLimit = res.data.activityInfo.totalLimit?.toString();
this.couponId = res.data.activityInfo.couponId;
this.message = res.activityInfo.des;
let imgs = JSON.parse(res.data.activityInfo.image);
let img_list = [];
imgs.forEach(i => {
let item = {};
item.url = i;
img_list.push(item);
});
this.fileList = img_list;
});
},
onSelect(val) {
this.checked_coupon = val;
this.showCoupon = false;
},
afterImgRead(file) {
console.log("image");
if (file.length) {
file.forEach(e => {
let params = new FormData();
params.append("file", e.file);
let url = "http://139.155.48.151:8084/admin/auth/util/saveImg";
axios.post(url, params).then(res => {
let img_url = JSON.parse(JSON.stringify(res.data.data.imgPath));
this.fileList.push(img_url);
});
});
} else {
let params = new FormData();
params.append("file", file.file);
let url = "http://139.155.48.151:8084/admin/auth/util/saveImg";
axios.post(url, params).then(res => {
this.fileList.push(JSON.parse(JSON.stringify(res.data.data.imgPath)));
});
}
},
getCoupons() { getCoupons() {
let id = sessionStorage.getItem("oyStallCode") || 1; let id = sessionStorage.getItem("oyStallCode") || 1;
API_Active.getAllCouponsByOyStallCode(id).then(res => { API_Active.getAllCouponsByOyStallCode(id).then(res => {
...@@ -170,57 +236,74 @@ export default { ...@@ -170,57 +236,74 @@ export default {
}, },
async afterLogoRead(file) { async afterLogoRead(file) {
let logo_img = await this.getImgUrl(file.file); let logo_img = await this.getImgUrl(file.file);
if (logo_img.result === "success") {
let item = { let item = {
url: bg_img.data.imgPath, url: logo_img,
status: "done", status: "done",
message: "上传成功" message: "上传成功"
}; };
this.logo_imgs.push(item); this.logo_imgs[0] = item;
}
}, },
async afterBGRead(file) { async afterBGRead(file) {
let bg_img = await this.getImgUrl(file.file); let bg_img = await this.getImgUrl(file.file);
if (bg_img.result === "success") {
let item = { let item = {
url: bg_img.data.imgPath, url: bg_img,
status: "done", status: "done",
message: "上传成功" message: "上传成功"
}; };
this.bg_imgs.push(item); this.bg_imgs[0] = item;
}
}, },
// 上传图片 // 上传图片
async getImgUrl(file) { async getImgUrl(file) {
let params = new FormData(); let params = new FormData();
params.append("file", file); params.append("file", file);
let url = "http://139.155.48.151:8084/admin/auth/util/saveImg"; let url = "http://139.155.48.151:8084/admin/auth/util/saveImg";
const res = await axios.post(url, params); const img = await axios.post(url, params);
return res; let urls = img.data.data.imgPath;
return urls;
}, },
handleCreate() { handleCreate() {
if (new Date(this.startTime1) >= new Date(this.endTime1)) {
this.$toast("活动开始时间应小于活动开始时间");
return;
}
let params = { let params = {
activityInfo: { activityInfo: {
id: 0,
activityName: this.title, activityName: this.title,
activityType: "coupon",
startTime: this.startTime1, startTime: this.startTime1,
endTime: this.endTime1, endTime: this.endTime1,
backImage: this.bg_imgs[0] ? this.bg_imgs[0].url : "", backImage: this.bg_imgs[0] ? this.bg_imgs[0].url : "",
logo: this.logo_imgs[0] ? this.logo_imgs[0].url : "", logo: this.logo_imgs[0] ? this.logo_imgs[0].url : "",
joinLimit: this.maxNumber, // 单日最大发放数量
totalLimit: this.totalLimit, joinLimit: Number(this.maxNumber),
// 总发放数量
totalLimit: Number(this.totalLimit),
couponId: this.checked_coupon.couponId,
des: this.message, des: this.message,
image: JSON.stringify(this.fileList) image: JSON.stringify(this.fileList)
} }
}; };
console.log("params", params);
API_Active.createActive(params).then(res => { API_Active.createActive(params).then(res => {
if (res.result === "fail") { if (res.result === "fail") {
this.$toast(res.errorMsg); this.$toast(res.errorMsg);
return; return;
} }
Toast.success("创建成功"); this.$toast.success("创建成功");
setTimeout(() => { setTimeout(() => {
this.$router.push("/createSuccess"); this.$router.push({
name: "createSuccess",
params: {
id: 0,
activityId: res.data.activityInfo.id,
activityType: "coupon",
logo: this.logo_imgs[0].url,
des: this.message
}
});
}, 200); }, 200);
}); });
}, },
...@@ -260,7 +343,14 @@ export default { ...@@ -260,7 +343,14 @@ export default {
this.endTime1 = `${endTimeArr[0]}-${endTimeArr[1]}-${endTimeArr[2]}`; this.endTime1 = `${endTimeArr[0]}-${endTimeArr[1]}-${endTimeArr[2]}`;
} }
}, },
mounted() {} mounted() {
if (this.$route.query.activityId) {
console.log("有模板数据");
let template_id = this.$route.query.templateId;
this.getTemplateDate(template_id);
}
this.getCoupons();
}
}; };
</script> </script>
<style></style> <style></style>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="container"> <div class="container">
<div class="title">活动设置</div> <div class="title">活动设置</div>
<van-cell-group class="all"> <van-cell-group class="all">
<van-cell title="活动标题" style="font-size:14px;"> <van-cell :required="true" title="活动标题" style="font-size:14px;">
<template slot="default"> <template slot="default">
<van-field <van-field
v-model="basicInfo.title" v-model="basicInfo.title"
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
/> />
</template> </template>
</van-cell> </van-cell>
<van-cell title="活动开始时间" style="font-size:14px;"> <van-cell :required="true" title="活动开始时间" style="font-size:14px;">
<template slot="default"> <template slot="default">
<div class="nobr"> <div class="nobr">
<van-field <van-field
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</div> </div>
</template> </template>
</van-cell> </van-cell>
<van-cell title="活动结束时间" style="font-size:14px;"> <van-cell :required="true" title="活动结束时间" style="font-size:14px;">
<template slot="default"> <template slot="default">
<div class="jpsl"> <div class="jpsl">
<van-field <van-field
...@@ -59,10 +59,10 @@ ...@@ -59,10 +59,10 @@
<van-cell title="背景图片" style="font-size: 14px"> <van-cell title="背景图片" style="font-size: 14px">
<van-uploader v-model="bg_imgs" :max-count="1" :after-read="afterBGRead" /> <van-uploader v-model="bg_imgs" :max-count="1" :after-read="afterBGRead" />
</van-cell> </van-cell>
<van-cell title="活动Logo" style="font-size: 14px"> <van-cell :required="true" title="活动Logo" style="font-size: 14px">
<van-uploader :max-count="1" v-model="logo_imgs" :after-read="afterLogoRead"></van-uploader> <van-uploader :max-count="1" v-model="logo_imgs" :after-read="afterLogoRead"></van-uploader>
</van-cell> </van-cell>
<van-cell title="会员单日参与次数" style="font-size: 14px"> <van-cell :required="true" title="会员单日参与次数" style="font-size: 14px">
<template slot="default"> <template slot="default">
<div class="jpsl"> <div class="jpsl">
<van-field <van-field
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
</div> </div>
</template> </template>
</van-cell> </van-cell>
<van-cell title="会员总参与次数" style="font-size: 14px"> <van-cell :required="true" title="会员总参与次数" style="font-size: 14px">
<template slot="default"> <template slot="default">
<div class="jpsl"> <div class="jpsl">
<van-field <van-field
...@@ -112,14 +112,14 @@ ...@@ -112,14 +112,14 @@
class="close" class="close"
@click="removePrice(index)" @click="removePrice(index)"
/> />
<van-cell title="奖项设置"> <van-cell :required="true" title="奖项设置">
<van-radio-group v-model="prizeList[index].type" class="right"> <van-radio-group v-model="prizeList[index].type" class="right">
<van-radio name="1" style="float:left;margin-right:10px;">优惠券</van-radio> <van-radio name="1" style="float:left;margin-right:10px;">优惠券</van-radio>
<van-radio name="2" style="float:right;">谢谢参与</van-radio> <van-radio name="2" style="float:right;">谢谢参与</van-radio>
</van-radio-group> </van-radio-group>
</van-cell> </van-cell>
<template v-if="prizeList[index].type == 1"> <template v-if="prizeList[index].type == 1">
<van-cell center> <van-cell :required="true" center>
<template slot="title"> <template slot="title">
<span class="custom-title">奖项名称</span> <span class="custom-title">奖项名称</span>
</template> </template>
...@@ -128,13 +128,14 @@ ...@@ -128,13 +128,14 @@
</template> </template>
</van-cell> </van-cell>
<van-cell <van-cell
:required="true"
title="选择优惠券" title="选择优惠券"
:value="prizeList[index].checked_coupon.name" :value="prizeList[index].checked_coupon.name"
is-link is-link
@click="handleCheckCoupon(index)" @click="handleCheckCoupon(index)"
center center
/> />
<van-cell title="总发放数量限制" style="font-size:14px;"> <van-cell :required="true" title="总发放数量限制" style="font-size:14px;">
<template slot="default"> <template slot="default">
<div class="jpsl"> <div class="jpsl">
<van-field <van-field
...@@ -154,7 +155,7 @@ ...@@ -154,7 +155,7 @@
</div> </div>
</template> </template>
</van-cell> </van-cell>
<van-cell title="每日发放数量限制" style="font-size:14px;"> <van-cell :required="true" title="每日发放数量限制" style="font-size:14px;">
<template slot="default"> <template slot="default">
<div class="jpsl"> <div class="jpsl">
<van-field <van-field
...@@ -174,7 +175,7 @@ ...@@ -174,7 +175,7 @@
</div> </div>
</template> </template>
</van-cell> </van-cell>
<van-cell title="每人限领数量" style="font-size:14px;"> <van-cell :required="true" title="每人限领数量" style="font-size:14px;">
<template slot="default"> <template slot="default">
<div class="jpsl"> <div class="jpsl">
<van-field <van-field
...@@ -195,7 +196,7 @@ ...@@ -195,7 +196,7 @@
</template> </template>
</van-cell> </van-cell>
</template> </template>
<van-cell style="font-size:14px;" class="cs gl"> <van-cell :required="true" style="font-size:14px;" class="cs gl">
<template slot="title"> <template slot="title">
<span class="custom-title">中奖概率</span> <span class="custom-title">中奖概率</span>
</template> </template>
...@@ -220,7 +221,7 @@ ...@@ -220,7 +221,7 @@
<div class="add" @click="addPrice">添加奖项</div> <div class="add" @click="addPrice">添加奖项</div>
</van-cell-group> </van-cell-group>
<!-- 活动描述 --> <!-- 活动描述 -->
<div class="detail"> <van-cell :required="true" class="detail">
<div class="border"> <div class="border">
<div class="des">活动描述</div> <div class="des">活动描述</div>
<van-field <van-field
...@@ -233,14 +234,14 @@ ...@@ -233,14 +234,14 @@
show-word-limit show-word-limit
/> />
</div> </div>
</div> </van-cell>
<!-- 活动图片 --> <!-- 活动图片 -->
<div class="detail" style="margin-top:0;"> <div class="detail" style="margin-top:0;">
<div class="des">活动图片</div> <div class="des">活动图片</div>
<van-uploader v-model="fileList_show" multiple :max-count="9" :after-read="afterImgRead" /> <van-uploader v-model="fileList_show" multiple :max-count="9" :after-read="afterImgRead" />
</div> </div>
<!-- 奖品介绍 --> <!-- 奖品介绍 -->
<div class="detail"> <van-cell :required="true" class="detail">
<div class="border"> <div class="border">
<div class="des">奖品介绍</div> <div class="des">奖品介绍</div>
<van-field <van-field
...@@ -253,7 +254,7 @@ ...@@ -253,7 +254,7 @@
show-word-limit show-word-limit
/> />
</div> </div>
</div> </van-cell>
<div class="creat" @click="handleCreate">创建活动</div> <div class="creat" @click="handleCreate">创建活动</div>
<van-action-sheet v-model="show" :actions="coupons" cancel-text="取消" @select="onSelect" /> <van-action-sheet v-model="show" :actions="coupons" cancel-text="取消" @select="onSelect" />
...@@ -346,6 +347,84 @@ export default { ...@@ -346,6 +347,84 @@ export default {
}; };
}, },
methods: { methods: {
// 获取模板数据
getTemplateDate(id) {
API_Active.getTemplateData(id).then(res => {
// 构造数据
// res.activityInfo
this.basicInfo.title = res.data.activityInfo.activityName;
let start_time = res.data.activityInfo.startTime;
this.basicInfo.startTime1 =
`${start_time.substring(0, 4)}-${start_time.substring(
4,
6
)}-${start_time.substring(6, 8)}` + start_time.substring(8);
let end_time = res.data.activityInfo.endTime;
this.basicInfo.endTime1 =
`${end_time.substring(0, 4)}-${end_time.substring(
4,
6
)}-${end_time.substring(6, 8)}` + end_time.substring(8);
this.bg_imgs[0] = { url: res.data.activityInfo.backImage };
this.logo_imgs[0] = { url: res.data.activityInfo.logo };
this.basicInfo.jointimes = res.data.activityInfo.joinLimit.toString();
this.basicInfo.total_join = res.data.activityInfo.totalLimit.toString();
this.message = res.data.activityInfo.des;
let imgs = JSON.parse(res.data.activityInfo.image);
let img_list = [];
imgs.forEach(i => {
let item = {};
item.url = i;
img_list.push(item);
});
this.fileList = img_list;
this.prize_produce = res.data.activityInfo.prizeDesc;
// this.prizeList = res.data.activityPrizes;
let prizes = [];
res.data.activityPrizes.forEach((p, index) => {
let item = {
name: "",
timeLine_type: "",
type: "",
discountsMoney: "",
discountsShow: false,
full: "",
fullMoney: "",
fullShow: false,
validity: "",
startTime: new Date(),
startTime1: "",
startShow: false,
endTime: new Date(),
endTime1: "",
endShow: false,
total_limit: "",
total_limit_show: false,
preLimit: "",
preLimit_show: false,
limit: "",
limit_show: false,
probability: "",
probability_show: false,
checked_coupon: {}
};
if (p.prizeType === 2) {
item.type = "1";
} else if (p.prizeType === 1) {
item.type = "2";
}
item.name = p.prizeName;
item.id = index;
item.total_limit = p.quantity?.toString();
item.limit = p.personLimit?.toString();
item.probability = p.probability?.toString();
item.preLimit = p.limitReceive?.toString();
item.checked_coupon.couponId = p.coupon_id;
prizes.push(item);
});
this.prizeList = prizes;
});
},
handleCheckCoupon(index) { handleCheckCoupon(index) {
this.show = true; this.show = true;
this.current_index = index; this.current_index = index;
...@@ -414,6 +493,10 @@ export default { ...@@ -414,6 +493,10 @@ export default {
// console.log(val); // console.log(val);
}, },
handleCreate() { handleCreate() {
if (new Date(this.basicInfo.startTime1) >= new Date(this.basicInfo.endTime1)) {
this.$toast("活动开始时间应小于活动开始时间");
return;
}
let params_prizeList = []; let params_prizeList = [];
let total_probability = 0; let total_probability = 0;
this.prizeList.forEach((p, index) => { this.prizeList.forEach((p, index) => {
...@@ -435,7 +518,7 @@ export default { ...@@ -435,7 +518,7 @@ export default {
params_prizeList.push(temp); params_prizeList.push(temp);
}); });
if (total_probability != 100) { if (total_probability != 100) {
this.$toast('所有奖项概率之和必须为100%'); this.$toast("所有奖项概率之和必须为100%");
return; return;
} }
let params = { let params = {
...@@ -463,7 +546,15 @@ export default { ...@@ -463,7 +546,15 @@ export default {
} }
Toast.success("创建成功"); Toast.success("创建成功");
setTimeout(() => { setTimeout(() => {
this.$router.push("/createSuccess"); this.$router.push({
name: "createSuccess",
params: {
activityId: res.data.activityInfo.id,
activityType: "wheel",
logo: this.logo_imgs[0].url,
des: this.message
}
});
}, 200); }, 200);
}); });
}, },
...@@ -623,6 +714,12 @@ export default { ...@@ -623,6 +714,12 @@ export default {
} }
}, },
mounted() { mounted() {
if (this.$route.query.activityId) {
// 有模板数据
console.log("有模板数据");
let template_id = this.$route.query.templateId;
this.getTemplateDate(template_id);
}
this.pTime = this.timeFormat(this.pTime); this.pTime = this.timeFormat(this.pTime);
console.log(this.pTime, "time"); console.log(this.pTime, "time");
this.getCoupons(); this.getCoupons();
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
<div class="btn-group"> <div class="btn-group">
<template v-if="step === 1"> <template v-if="step === 1">
<van-button type="info" @click="saveNewTemplate">保存为新的模板</van-button> <van-button type="info" @click="saveNewTemplate">保存为新的模板</van-button>
<van-button type="info" @click="$router.push('/ActTemplate')">完成</van-button> <van-button type="info" @click="$router.push('/')">完成</van-button>
</template> </template>
<template v-if="step === 2"> <template v-if="step === 2">
<van-button type="info" @click="$router.push('/ActTemplate')">取消</van-button> <van-button type="info" @click="$router.push('/ActTemplate')">取消</van-button>
<van-button type="info">完成</van-button> <van-button type="info" @click="save">完成</van-button>
</template> </template>
</div> </div>
</div> </div>
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
</template> </template>
<script> <script>
import * as API_Active from '@/api/active';
export default { export default {
name: "createSuccess", name: "createSuccess",
components: {}, components: {},
...@@ -37,6 +38,22 @@ export default { ...@@ -37,6 +38,22 @@ export default {
}; };
}, },
methods: { methods: {
save() {
let params = {
id: 0,
activityId: this.$route.params.activityId,
logo: this.$route.params.logo,
des: this.$route.params.des,
activityType: this.$route.params.activityType,
templateName: this.newTemplateName
}
API_Active.saveTemplate(params).then(res=>{
this.$toast('模板保存成功');
setTimeout(() => {
this.$router.push('/ActTemplate')
}, 2000)
})
},
saveNewTemplate() { saveNewTemplate() {
this.step = 2; this.step = 2;
} }
......
<template>
<div id="more">
</div>
</template>
<script>
export default {
name: 'more',
components: {},
data() {
return {
}
}
}
</script>
<style lang="scss">
</style>
<template> <template>
<div class="lists"> <div class="lists">
<div v-for="(item, index) of list.active" :key="index"> <div v-for="(item, index) of active" :key="index">
<div class="list" @click="listClick(index)"> <div class="list" @click="listClick(index, item)">
<div class="list-logos"> <div class="list-logos">
<img class="list-logo" :src="item.logoUrl"> <img class="list-logo" :src="item.logo" />
</div> </div>
<div class="list-infos"> <div class="list-infos">
<div class="list-title">{{item.name}}</div> <div class="list-title">{{item.templateName}}</div>
<div class="list-dsc">{{item.dsc}}</div> <div class="list-dsc">{{item.des}}</div>
</div> </div>
</div> </div>
</div> </div>
<span class="more" v-if="active.length && !list_finished" @click="handleMore">
查看更多
<span class="icon">></span>
</span>
</div> </div>
</template> </template>
<script> <script>
// ZKit // ZKit
// const log = console.log.bind(console) // const log = console.log.bind(console)
import * as API_Active from "@/api/active";
export default { export default {
name: "discountIndex", name: "discountIndex",
data() { data() {
return { return {
list: { list_finished: false,
active: [ active: [
{ {
name: "大转盘活动", templateName: "大转盘活动",
logoUrl: "/mainSale/icon-active-1.png", activityType: "wheel",
dsc: "有各种物质组成的举行球状天体,叫做星球。星球有一定的形状。", logo: "/mainSale/icon-active-1.png",
des: "有各种物质组成的举行球状天体,叫做星球。星球有一定的形状。",
reDirect: "turntableDetail" reDirect: "turntableDetail"
}, },
{ {
name: "送券活动", templateName: "送券活动",
logoUrl: "/mainSale/icon-active-2.png", activityType: "coupon",
dsc: "有各种物质组成的举行球状天体,叫做星球。星球有一定的形状。", logo: "/mainSale/icon-active-2.png",
des: "有各种物质组成的举行球状天体,叫做星球。星球有一定的形状。",
reDirect: "couponDetail" reDirect: "couponDetail"
} }
], ],
}, params: {
pageNo: 1,
pageSize: 10
}
}; };
}, },
created() { created() {
this.getTemplate(this.params);
}, },
methods: { methods: {
listClick(inIndex){ handleMore() {
this.params.pageNo += 1;
this.getTemplate(this.params);
},
// 获取模板
getTemplate(params) {
API_Active.getTemplate(params).then(res => {
this.active.push(...res.data.list);
if (res.data.list === []) {
this.list_finished = true;
}
});
},
listClick(inIndex, item) {
// log('--->click: inIndex =', inIndex) // log('--->click: inIndex =', inIndex)
// log('--->click: reDirect =', this.list.active[inIndex].reDirect) // log('--->click: reDirect =', this.list.active[inIndex].reDirect)
this.$router.push(this.list.active[inIndex].reDirect) if (inIndex < 2) {
}, this.$router.push(this.active[inIndex].reDirect);
} else {
this.$router.push({
path: `/createBigWheelActive`,
query: {
activityId: item.activityId,
activityType: item.activityType,
templateId: item.id
} }
}; });
}
}
}
};
</script> </script>
<style scoped> <style scoped>
.lists { .more {
font-size: 12px;
float: right;
}
.lists {
padding: 4px 16px 20px 16px; padding: 4px 16px 20px 16px;
} }
.list { .list {
padding: 12px 0px; padding: 12px 0px;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: start; justify-content: start;
align-items: center; align-items: center;
border-bottom: 1px solid #EEEEEE; border-bottom: 1px solid #eeeeee;
} }
.list-logos { .list-logos {
width: 80px; width: 80px;
height: 80px; height: 80px;
background-color: #F8F8F8; background-color: #f8f8f8;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.list-logo { .list-logo {
width: 56px; width: 56px;
height: 56px; height: 56px;
} }
.list-infos { .list-infos {
width: 251px; width: 251px;
height: 80px; height: 80px;
display: flex; display: flex;
...@@ -96,28 +130,28 @@ ...@@ -96,28 +130,28 @@
align-items: start; align-items: start;
margin-left: 12px; margin-left: 12px;
} }
.list-title { .list-title {
font-size: 14px; font-size: 14px;
height: 16px; height: 16px;
line-height: 16px; line-height: 16px;
font-weight: bold; font-weight: bold;
color: #2D476A; color: #2d476a;
width: 100%; width: 100%;
text-align: left; text-align: left;
margin-bottom: 8px; margin-bottom: 8px;
} }
.list-dsc { .list-dsc {
font-size: 12px; font-size: 12px;
height: 14px; height: 14px;
line-height: 14px; line-height: 14px;
font-weight: normal; font-weight: normal;
color: #2D476A; color: #2d476a;
width: 100%; width: 100%;
text-align: left; text-align: left;
overflow: auto; overflow: auto;
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment