Commit 3732acb8 authored by xd's avatar xd

Merge branch 'master' of http://114.67.93.201/xulili/ybf

parents f844f059 5c12e612
......@@ -121,4 +121,15 @@ export function getTemplateData(id) {
url: `template/getTemplate?templateId=${id}`,
method: 'post'
})
}
/**
* 删除模板
* @param {} id 模板id
*/
export function deleteTemplate(id) {
return request({
url: `template/delete?id=${id}`,
method: 'delete'
})
}
\ No newline at end of file
......@@ -14,10 +14,6 @@ export function CoutDown(Endtime) {
if (days >= 0 || hours >= 0 || minutes >= 0 || seconds >= 0) {
document.getElementById("timer").innerHTML = days + "天" + hours + "小时" + minutes + "分" + seconds + "秒";
}
if (days <= 0 || hours <= 0) {
console.log('已结束');
document.getElementById("timer").innerHTML = '已结束'
}
function checkTime(i) { //将0-9的数字前面加上0,例1变为01
if (i < 10) {
i = "0" + i;
......
......@@ -8,14 +8,17 @@
<div class="coupon-content">
<img src="../../../public/img/coupon.png" alt="coupon_bg" />
<div class="content">
<div class="money">10</div>
<div class="money">{{ couponDetail.unit }}</div>
<div class="split">
<img src="../../../public/img/split.png" alt="split" />
</div>
<div class="other">
<p>满50元可用</p>
<p>有效期:09.09-09.10</p>
<p>全店通用</p>
<p>{{couponDetail.salesUnit}}元可用</p>
<p>
有效期:
<span style="font-size: 12px;">{{ couponDetail.end_date }}</span>
</p>
<p>{{ couponDetail.deptId }}号店通用</p>
</div>
</div>
</div>
......@@ -28,7 +31,7 @@
<div class="wheel">
<div class="wheel-point" @click="Start_Game"></div>
<img src="../../../public/img/wheel.png" alt="wheel" />
<div class="circle"></div>
<!-- <div class="circle"></div> -->
<div
class="wheel-bg"
:class="{freeze: freeze}"
......@@ -50,13 +53,15 @@
</div>
</div>
<div class="awards">
<ul>
<li>
<span>{{ prizeDesc }}</span>
<!-- <span>一等奖:</span>
<span>价值280元的优惠券</span>-->
</li>
</ul>
<van-field
class="area"
v-model="prizeDesc"
rows="2"
autosize
type="textarea"
show-word-limit
:disabled="false"
/>
</div>
<div class="time-line">
距离结束仅剩
......@@ -76,6 +81,16 @@
<van-overlay :show="showAward && !res_error" @click="showAward = false">
<div class="wrapper" @click.stop>
<div v-if="isAward" class="block">
<div class="award-coupon">
<img class="bg_img" src="/img/coupon.png" alt="coupon" />
<div class="other">
<p>{{ awardGood.coupon.type }}</p>
<div class="split">
<img src="../../../public/img/split.png" alt="split" />
</div>
<p>{{ awardGood.coupon.unit }}元</p>
</div>
</div>
<p style="font-size: 20px;font-weight: bold;">OLAY全场通用抵扣券</p>
<p style="font-size: 20px;font-weight: bold;">{{ awardGood.prizeName }}!</p>
<p style="font-size: 20px;font-weight: bold;">恭喜您中奖!</p>
......@@ -102,6 +117,7 @@ export default {
components: { wxAuth },
data() {
return {
couponDetail: {},
game_end: false,
res_error: false,
error_message: "",
......@@ -175,7 +191,6 @@ export default {
if (this.$route.query.unionid === undefined) {
this.getUnionid();
} else {
console.log("有unionid");
this.userBaseInfo.unionid = JSON.stringify(this.$route.query.unionid);
this.userBaseInfo.openid = JSON.stringify(this.$route.query.openid);
let params = {
......@@ -195,16 +210,6 @@ export default {
mounted() {
this.getAgentAuth();
this.GET_DetailById(this.active_id);
let cur_date = new Date();
let end_time = new Date(this.timeLine);
if (end_time - cur_date > 0) {
this.timer = setInterval(() => {
CoutDown(this.timeLine);
}, 1000);
} else {
document.getElementById("timer").innerHTML = '已结束';
this.game_end = true;
}
},
watch: {
prizeNumber() {
......@@ -222,14 +227,20 @@ export default {
}
},
methods: {
// 领取
// 领取(
handleGet() {
console.log("中奖奖品信息", this.awardGood);
if (this.$route.query.iswxClient === "false") {
this.$toast("企业微信端不能领取");
return;
}
let params = {
couponId: this.awardGood.activityPrize.couponId,
couponId: this.awardGood.activityPrize
? this.awardGood.coupon.id
: this.couponDetail.id,
unionId: this.userBaseInfo.unionid,
vipId: this.userBaseInfo.vipId
};
console.log("领取", params);
APi_Active.collectMyCoupon(params).then(res => {
this.showAward = false;
this.$toast(
......@@ -249,6 +260,30 @@ export default {
8
)}` + time.substring(8);
this.prizeListOrigin = res.data.list;
this.prizeNumber = res.data.list.length;
if (this.active_type === "coupon") {
let time2 = res.data.coupon.end_date;
res.data.coupon.end_date =
`${time2.substring(0, 4)}-${time2.substring(
4,
6
)}-${time2.substring(6, 8)}` + time2.substring(8);
this.couponDetail = res.data.coupon;
}
if (this.active_type === "wheel") {
let cur_date = new Date();
let end_time = new Date(this.timeLine);
console.log(cur_date);
console.log(end_time);
if (end_time - cur_date > 0) {
this.timer = setInterval(() => {
CoutDown(this.timeLine);
}, 1000);
} else {
document.getElementById("timer").innerHTML = "已结束";
this.game_end = true;
}
}
});
},
handleCheckAuth() {
......@@ -262,11 +297,14 @@ export default {
window.location.href = `http://wxsyls.oysd.cn/getwxuserinfo.aspx?jump=${redirect_uri}`;
},
Start_Game() {
if (this.$route.query.iswxClient === "false") {
this.$toast("企业微信端不能参与抽奖活动");
return;
}
if (this.game_end) {
this.$toast('活动已结束');
this.$toast("活动已结束");
return;
}
console.log("会员基本信息", this.userBaseInfo);
if (!this.userBaseInfo.vipId) {
this.$toast("非会员,");
let url = "http://oysales.oywanhao.com/register";
......@@ -280,12 +318,12 @@ export default {
unionId: this.userBaseInfo.unionid,
userName: this.userBaseInfo.name
};
console.log("params", params);
if (this.rolling) return;
if (this.rolling) {
this.$toast("抽奖中,请勿多次点击!");
return;
}
APi_Active.play(params)
.then(res => {
// const random = parseInt(6 * Math.random(0, 5));
console.log("抽奖结果", res.data);
if (!res.data.prizedId) {
this.res_error = true;
this.$toast(res.data.message);
......@@ -293,16 +331,15 @@ export default {
}
const { wheelDeg, prizeList } = this;
this.rolling = true;
const random = prizeList
.map(item => item.id)
.indexOf(res.data.prizeId);
const random = prizeList.map(item => item.id).indexOf(res.data.prizedId);
this.wheelDeg =
wheelDeg -
(wheelDeg % 360) +
6 * 360 -
(360 / prizeList.length) * random;
setTimeout(() => {
this.awardGood = res.data;
this.awardGood = prizeList[random];
this.awardGood.coupon = JSON.parse(this.awardGood.coupon);
this.rolling = false;
this.showAward = true;
this.isAward = res.data.prizeName !== "谢谢惠顾";
......@@ -396,7 +433,7 @@ export default {
left: 0;
right: 0;
bottom: 0;
width: 80%;
width: 85%;
height: 92%;
margin: 0 auto;
display: flex;
......@@ -520,13 +557,10 @@ export default {
.awards {
width: 80%;
min-height: 100px;
background: #ff9;
margin: 0 auto 10px;
border-radius: 10px;
li {
padding: 10px 20px;
font-size: 0.5rem;
.van-cell {
background: #ff9;
border-radius: 10px;
font-weight: bold;
}
}
......@@ -599,7 +633,32 @@ export default {
align-items: center;
flex-direction: column;
width: 70%;
padding: 10px 0;
background-color: #fff;
.award-coupon {
position: relative;
width: 80%;
.bg_img {
width: 100%;
height: 100%;
}
.other {
display: flex;
justify-content: space-between;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 90%;
height: 60%;
margin: auto;
color: #f00;
p {
margin: 0;
}
}
}
p {
margin-bottom: 8px;
}
......
......@@ -127,7 +127,8 @@ export default {
path: "/activeDetail",
query: {
id: active_id,
active_type: type
active_type: type,
iswxClient: 'false'
}
});
}
......
......@@ -21,6 +21,7 @@
<van-datetime-picker
v-model="startTime"
type="datetime"
:min-date="minStartDate"
@cancel="startShow = false"
@confirm="handleStartTime"
@change="startTimeChange"
......@@ -43,6 +44,7 @@
<van-datetime-picker
v-model="endTime"
type="datetime"
:min-date="minEndDate"
@cancel="endShow = false"
@confirm="handleEndTime"
@change="endTimeChange"
......@@ -107,7 +109,7 @@
/>
</van-cell-group>
<!-- 活动描述 -->
<div class="detail">
<van-cell :required="true" class="detail">
<div class="border">
<div class="des">活动描述</div>
<van-field
......@@ -120,7 +122,7 @@
show-word-limit
/>
</div>
</div>
</van-cell>
<!-- 活动图片 -->
<div class="detail" style="margin-top:0;">
<div class="des">活动图片</div>
......@@ -137,10 +139,12 @@ import * as API_Active from "@/api/active";
export default {
data() {
return {
minStartDate: null,
minEndDate: null,
checked_coupon: {},
logo_imgs: [],
bg_imgs: [],
title: "送券",
title: "",
title2: "",
coupon: "",
newCustomer: "",
......@@ -151,26 +155,26 @@ export default {
cashCoupon: "",
limit: "",
startTime: new Date(),
startTime1: "2020-04-09 08:25:25",
startTime1: "",
endTime: new Date(),
endTime1: "2020-04-10 08:25:25",
endTime1: "",
startShow: false,
endShow: false,
message: "123",
message: "",
fileList: [],
fileList_show: [],
showCoupon: false,
coupons: [
{ name: "选项" },
{ name: "选项" },
{ name: "选项", subname: "描述信息" }
],
maxNumber: "1",
coupons: [],
maxNumber: "",
maxNumber_show: false,
totalLimit: "2",
totalLimit: "",
totalLimit_show: false
};
},
created() {
this.minStartDate = new Date();
this.minEndDate = new Date((new Date()/1000+86400)*1000);
},
methods: {
getTemplateDate(id) {
API_Active.getTemplateData(id).then(res => {
......@@ -191,7 +195,8 @@ export default {
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.checked_coupon = JSON.parse(res.data.activityInfo.coupon);
this.checked_coupon.couponId = res.data.activityInfo.couponId;
this.message = res.activityInfo.des;
let imgs = JSON.parse(res.data.activityInfo.image);
let img_list = [];
......@@ -208,7 +213,6 @@ export default {
this.showCoupon = false;
},
afterImgRead(file) {
console.log("image");
if (file.length) {
file.forEach(e => {
let params = new FormData();
......@@ -229,9 +233,17 @@ export default {
}
},
getCoupons() {
console.log('获取优惠券');
let id = sessionStorage.getItem("oyStallCode") || 1;
API_Active.getAllCouponsByOyStallCode(id).then(res => {
this.coupons = res.data;
if (res.data.length === 0 || !res.data.length) {
this.$toast('您所在店铺没有优惠券,请先去创建');
setTimeout(()=>{
this.$router.push('/');
}, 500);
} else {
this.coupons = res.data;
}
});
},
async afterLogoRead(file) {
......@@ -262,6 +274,19 @@ export default {
return urls;
},
handleCreate() {
if (
this.title === '' ||
this.startTime1 == '' ||
this.endTime1 == '' ||
this.logo_imgs.length == 0 ||
this.maxNumber == '' ||
this.totalLimit == '' ||
this.checked_coupon == {} ||
this.message == ''
) {
this.$toast('请完整填写活动表单!');
return;
}
if (new Date(this.startTime1) >= new Date(this.endTime1)) {
this.$toast("活动开始时间应小于活动开始时间");
return;
......@@ -280,7 +305,8 @@ export default {
joinLimit: Number(this.maxNumber),
// 总发放数量
totalLimit: Number(this.totalLimit),
couponId: this.checked_coupon.couponId,
coupon: JSON.stringify(this.checked_coupon),
couponId: this.checked_coupon.id,
des: this.message,
image: JSON.stringify(this.fileList)
......
......@@ -26,6 +26,7 @@
<van-datetime-picker
v-model="basicInfo.startTime"
type="datetime"
:min-date="minStartDate"
@cancel="basicInfo.startShow = false"
@confirm="handleBasicSTime"
@change="startTimeChange"
......@@ -48,6 +49,7 @@
<van-datetime-picker
v-model="basicInfo.endTime"
type="datetime"
:min-date="minEndDate"
@cancel="basicInfo.endShow = false"
@confirm="handleBasicETime"
@change="endTimeChange"
......@@ -268,6 +270,8 @@ import { Toast } from "vant";
export default {
data() {
return {
minStaetDate: null,
minEndDate: null,
// 选择优惠券 当前下标
current_index: -1,
logo_imgs: [],
......@@ -346,6 +350,10 @@ export default {
confirmTime: new Date()
};
},
created() {
this.minStartDate = new Date();
this.minEndDate = new Date((new Date()/1000+86400)*1000);
},
methods: {
// 获取模板数据
getTemplateDate(id) {
......@@ -367,8 +375,8 @@ export default {
)}-${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.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 = [];
......@@ -419,7 +427,7 @@ export default {
item.limit = p.personLimit?.toString();
item.probability = p.probability?.toString();
item.preLimit = p.limitReceive?.toString();
item.checked_coupon.couponId = p.coupon_id;
this.checked_coupon = JSON.parse(p.coupon);
prizes.push(item);
});
this.prizeList = prizes;
......@@ -493,7 +501,45 @@ export default {
// console.log(val);
},
handleCreate() {
if (new Date(this.basicInfo.startTime1) >= new Date(this.basicInfo.endTime1)) {
if (
this.basicInfo.title == '' ||
this.basicInfo.startTime1 == '' ||
this.basicInfo.endTime1 == '' ||
this.logo_imgs.length == 0 ||
this.basicInfo.jointimes == '' ||
this.basicInfo.total_join == '' ||
this.message == '' ||
this.prize_produce == ''
) {
this.$toast('请完整填写表单!');
return;
}
this.prizeList.forEach(item => {
if (item.type == "") {
this.$toast('奖项类型必选!');
return;
}
if (item.type == 1) {
if (item.name == '' ||
item.checked_coupon == {} ||
item.total_limit == '' ||
item.limit == '' ||
item.preLimit == '' ||
item.probability == ''
) {
this.$toast('请填写完整奖项设置!');
return;
}
} else {
if(item.probability === '') {
this.$toast('奖项概率不允许为空');
return;
}
}
})
if (
new Date(this.basicInfo.startTime1) >= new Date(this.basicInfo.endTime1)
) {
this.$toast("活动开始时间应小于活动开始时间");
return;
}
......@@ -514,7 +560,8 @@ export default {
temp.probability = p.probability;
total_probability += Number(p.probability);
temp.limitReceive = p.preLimit;
temp.coupon_id = p.checked_coupon.couponId;
temp.couponId = p.checked_coupon.id;
temp.coupon = JSON.stringify(p.checked_coupon);
params_prizeList.push(temp);
});
if (total_probability != 100) {
......
......@@ -224,7 +224,7 @@ export default {
userInfoResOld: "",
userInfoResNew: ""
},
flag: 2
flag: 1
};
},
created() {
......
<template>
<div class="lists">
<div v-for="(item, index) of active" :key="index">
<div class="list" @click="listClick(index, item)">
<div class="list-logos">
<img class="list-logo" :src="item.logo" />
<van-swipe-cell>
<div class="list" @click="listClick(index, item)">
<div class="list-logos">
<img class="list-logo" :src="item.logo" />
</div>
<div class="list-infos">
<div class="list-title">{{item.templateName}}</div>
<div class="list-dsc">{{item.des}}</div>
</div>
</div>
<div class="list-infos">
<div class="list-title">{{item.templateName}}</div>
<div class="list-dsc">{{item.des}}</div>
</div>
</div>
<template #right v-if="index > 1">
<van-button square type="danger" text="删除" @click="deleteTemplate(item.id, index)" />
</template>
</van-swipe-cell>
</div>
<span class="more" v-if="active.length && !list_finished" @click="handleMore">
查看更多
......@@ -53,6 +58,14 @@ export default {
this.getTemplate(this.params);
},
methods: {
deleteTemplate(tem_id, index) {
API_Active.deleteTemplate(id).then(res=>{
if(res.result === 'success') {
this.active.splice(index, 1);
this.$toast('删除成功!');
}
})
},
handleMore() {
this.params.pageNo += 1;
this.getTemplate(this.params);
......
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