Commit 3a710b9e authored by leiqingsong's avatar leiqingsong

抽奖功能完善

parent 46ea4c0b
...@@ -82,19 +82,19 @@ ...@@ -82,19 +82,19 @@
:style="active_type === 'coupon'? 'bottom: 0': ''" :style="active_type === 'coupon'? 'bottom: 0': ''"
@click="handleShare" @click="handleShare"
>立即分享</div> >立即分享</div>
<van-overlay :show="showAward" @click="showAward = false"> <van-overlay :show="showAward" @click="closeAward">
<div class="wrapper"> <div v-if="isAward" class="wrapper" @click.stop>
<div v-if="isAward" class="block"> <div class="block">
<div class="award-coupon"> <div class="award-coupon">
<img class="bg_img" src="/img/coupon.png" alt="coupon" /> <img class="bg_img" src="/img/coupon.png" alt="coupon" />
<div class="other"> <div class="other">
<p>{{ awardGood.coupon.type }}</p> <!-- <p>{{ awardGood.coupon.type }}</p> -->
<!-- <p>代金券</p> --> <p>代金券</p>
<div class="split"> <div class="split">
<img src="../../../public/img/split.png" alt="split" /> <img src="../../../public/img/split.png" alt="split" />
</div> </div>
<p>{{ awardGood.coupon.unit }}元</p> <!-- <p>{{ awardGood.coupon.unit }}元</p> -->
<!-- <p>2000元</p> --> <p>2000元</p>
</div> </div>
</div> </div>
<p style="font-size: 20px;font-weight: bold;">OLAY全场通用抵扣券</p> <p style="font-size: 20px;font-weight: bold;">OLAY全场通用抵扣券</p>
...@@ -103,7 +103,9 @@ ...@@ -103,7 +103,9 @@
<van-button style="background: #f00;color: #fff;" @click="handleGet">领取奖品</van-button> <van-button style="background: #f00;color: #fff;" @click="handleGet">领取奖品</van-button>
<van-button style="border-color: #7f7777;" @click="handleGoOn">继续抽奖</van-button> <van-button style="border-color: #7f7777;" @click="handleGoOn">继续抽奖</van-button>
</div> </div>
<div v-else class="block" style="background: #413d3de0;color: #fff;"> </div>
<div v-else class="wrapper">
<div class="block" style="background: #000;color: #fff;">
<p style="font-size: 22px;">谢谢惠顾!</p> <p style="font-size: 22px;">谢谢惠顾!</p>
<p style="font-size: 14px;">很遗憾,此次未能中奖,再接再厉!</p> <p style="font-size: 14px;">很遗憾,此次未能中奖,再接再厉!</p>
</div> </div>
...@@ -133,7 +135,7 @@ export default { ...@@ -133,7 +135,7 @@ export default {
timer: null, timer: null,
timeLine: "", timeLine: "",
isAward: false, isAward: false,
showAward: false, showAward: true,
userBaseInfo: {}, userBaseInfo: {},
isMember: false, isMember: false,
openid: "", openid: "",
...@@ -265,10 +267,13 @@ export default { ...@@ -265,10 +267,13 @@ export default {
} }
}, },
methods: { methods: {
closeAward() {
this.showAward = false;
},
// 继续抽奖 // 继续抽奖
handleGoOn() { handleGoOn() {
this.goOn = true; this.goOn = true;
this.showAward = false; this.closeAward();
}, },
// 领取( // 领取(
handleGet() { handleGet() {
...@@ -280,7 +285,6 @@ export default { ...@@ -280,7 +285,6 @@ export default {
return false; return false;
} }
if (!this.isMember) { if (!this.isMember) {
console.log("非会员");
Dialog.confirm({ Dialog.confirm({
title: "提示", title: "提示",
message: message:
...@@ -306,7 +310,7 @@ export default { ...@@ -306,7 +310,7 @@ export default {
vipId: this.userBaseInfo.vipId vipId: this.userBaseInfo.vipId
}; };
APi_Active.collectMyCoupon(params).then(res => { APi_Active.collectMyCoupon(params).then(res => {
this.showAward = false; this.closeAward()
if (res.data == "领取失败") { if (res.data == "领取失败") {
this.$toast("领取失败"); this.$toast("领取失败");
return false; return false;
...@@ -387,7 +391,6 @@ export default { ...@@ -387,7 +391,6 @@ export default {
}); });
return false; return false;
} }
// console.log('111');
if (this.game_end) { if (this.game_end) {
this.$toast("活动已结束"); this.$toast("活动已结束");
return false; return false;
...@@ -398,11 +401,13 @@ export default { ...@@ -398,11 +401,13 @@ export default {
} }
let params = { let params = {
activityId: this.active_id, activityId: this.active_id,
openId: this.userBaseInfo.openid, openId: this.userBaseInfo.openid || "ofoA-xMYdB2XA1Ss-ycCeRy9HV4A",
phone: this.userBaseInfo.phone, phone: this.userBaseInfo.phone,
unionId: this.userBaseInfo.unionid, unionId: this.userBaseInfo.unionid || "oCIMxuMlt5vxRZgl-pNIxOjyYQ20",
userName: this.userBaseInfo.name userName: this.userBaseInfo.name
}; };
const { wheelDeg, prizeList } = this;
this.rolling = true;
APi_Active.play(params) APi_Active.play(params)
.then(res => { .then(res => {
if (!res.data.prizeId) { if (!res.data.prizeId) {
...@@ -410,8 +415,6 @@ export default { ...@@ -410,8 +415,6 @@ export default {
this.$toast(res.data.message); this.$toast(res.data.message);
return false; return false;
} }
const { wheelDeg, prizeList } = this;
this.rolling = true;
const random = prizeList const random = prizeList
.map(item => item.id) .map(item => item.id)
.indexOf(res.data.prizeId); .indexOf(res.data.prizeId);
...@@ -421,18 +424,22 @@ export default { ...@@ -421,18 +424,22 @@ export default {
6 * 360 - 6 * 360 -
(360 / prizeList.length) * random; (360 / prizeList.length) * random;
setTimeout(() => { setTimeout(() => {
this.awardGood = prizeList[random]; this.isAward = res.data.prizeName !== "谢谢惠顾";
this.awardGood.coupon = JSON.parse(this.awardGood.coupon);
this.rolling = false; this.rolling = false;
this.showAward = true; this.showAward = true;
this.isAward = res.data.prizeName !== "谢谢惠顾";
if (!this.isAward) { if (!this.isAward) {
this.$toast(""); console.log('谢谢惠顾');
// this.showAward = false;
} else {
// this.showAward = true;
this.awardGood = prizeList[random];
this.awardGood.coupon = JSON.parse(prizeList[random].coupon);
console.log(this.awardGood);
} }
}, 4500); }, 4500);
}) })
.catch(err => { .catch(error => {
console.log("err", err); this.rolling = false;
}); });
}, },
getUrlParams(name) { getUrlParams(name) {
...@@ -785,10 +792,11 @@ export default { ...@@ -785,10 +792,11 @@ export default {
bottom: 0; bottom: 0;
left: 0; left: 0;
width: 90%; width: 90%;
height: 60%; height: 60px;
margin: auto; margin: auto;
text-align: center; text-align: center;
font-size: 32px; font-size: 26px;
line-height: 60px;
color: #f00; color: #f00;
p { p {
width: 50%; width: 50%;
......
...@@ -192,9 +192,7 @@ export default { ...@@ -192,9 +192,7 @@ export default {
totalLimit_show: false totalLimit_show: false
}; };
}, },
created() { created() {},
},
methods: { methods: {
openStartTime() { openStartTime() {
this.startShow = true; this.startShow = true;
...@@ -261,7 +259,7 @@ export default { ...@@ -261,7 +259,7 @@ export default {
} }
}, },
getCoupons() { getCoupons() {
let id = sessionStorage.getItem("oyStallCode"); let id = sessionStorage.getItem("oyStallCode") || 1;
API_Active.getAllCouponsByOyStallCode(id).then(res => { API_Active.getAllCouponsByOyStallCode(id).then(res => {
if (res.data.length === 0 || !res.data.length) { if (res.data.length === 0 || !res.data.length) {
this.$toast("您所在店铺没有优惠券,请先去创建"); this.$toast("您所在店铺没有优惠券,请先去创建");
...@@ -307,11 +305,6 @@ export default { ...@@ -307,11 +305,6 @@ export default {
return urls; return urls;
}, },
handleCreate() { handleCreate() {
if (--this.create_times < 0) {
this.$toast("已经过提交申请了,请等待处理!");
return false;
}
if ( if (
this.title === "" || this.title === "" ||
this.startTime1 == "" || this.startTime1 == "" ||
...@@ -329,7 +322,7 @@ export default { ...@@ -329,7 +322,7 @@ export default {
this.$toast("活动开始时间应小于活动开始时间"); this.$toast("活动开始时间应小于活动开始时间");
return false; return false;
} }
if (this.maxNumber > this.totalLimit) { if (Number(this.maxNumber) > Number(this.totalLimit)) {
this.$toast("单日最大发放数量应不大于总发放数量"); this.$toast("单日最大发放数量应不大于总发放数量");
return false; return false;
} }
...@@ -354,26 +347,35 @@ export default { ...@@ -354,26 +347,35 @@ export default {
} }
}; };
console.log("params", params); console.log("params", params);
API_Active.createActive(params).then(res => { if (--this.create_times < 0) {
this.create_times = 1; this.$toast("已经过提交申请了,请等待处理!");
if (res.result === "fail") { return false;
this.$toast(res.errorMsg); }
return false; API_Active.createActive(params)
} .then(res => {
this.$toast.success("创建成功"); this.create_times = 1;
setTimeout(() => { if (res.result === "fail") {
this.$router.push({ this.$toast(res.errorMsg);
name: "createSuccess", return false;
params: { }
id: 0, this.$toast.success("创建成功");
activityId: res.data.activityInfo.id, setTimeout(() => {
activityType: "coupon", this.$router.push({
logo: this.logo_imgs[0].url, name: "createSuccess",
des: this.message params: {
} id: 0,
}); activityId: res.data.activityInfo.id,
}, 200); activityType: "coupon",
}); logo: this.logo_imgs[0].url,
des: this.message
}
});
}, 200);
})
.catch(error => {
this.create_times = 1;
console.log(error);
});
}, },
timeFormat(time) { timeFormat(time) {
let year = 1900 + time.getYear(); let year = 1900 + time.getYear();
...@@ -412,12 +414,14 @@ export default { ...@@ -412,12 +414,14 @@ export default {
} }
}, },
mounted() { mounted() {
this.create_times = 1;
console.log("create_times", this.create_times);
if (this.$route.query.activityId) { if (this.$route.query.activityId) {
console.log("有模板数据"); console.log("有模板数据");
let template_id = this.$route.query.templateId; let template_id = this.$route.query.templateId;
this.getTemplateDate(template_id); this.getTemplateDate(template_id);
} }
// this.getCoupons(); this.getCoupons();
} }
}; };
</script> </script>
......
...@@ -422,7 +422,7 @@ export default { ...@@ -422,7 +422,7 @@ export default {
}; };
}, },
created() { created() {
// this.prizeList[0].probability = this.remain_probability; this.prizeList[0].probability = this.remain_probability;
}, },
methods: { methods: {
// 限制 vant stepper 输入长度 // 限制 vant stepper 输入长度
...@@ -526,12 +526,11 @@ export default { ...@@ -526,12 +526,11 @@ export default {
}, },
// 选择优惠券 // 选择优惠券
onSelect(val) { onSelect(val) {
console.log(val);
this.prizeList[this.current_index].checked_coupon = val; this.prizeList[this.current_index].checked_coupon = val;
this.show = false; this.show = false;
}, },
getCoupons() { getCoupons() {
let id = sessionStorage.getItem("oyStallCode"); let id = sessionStorage.getItem("oyStallCode") || 1;
API_Active.getAllCouponsByOyStallCode(id).then(res => { API_Active.getAllCouponsByOyStallCode(id).then(res => {
if (res.data.length === 0 || !res.data.length) { if (res.data.length === 0 || !res.data.length) {
this.$toast("您所在店铺没有优惠券,请先去创建"); this.$toast("您所在店铺没有优惠券,请先去创建");
...@@ -603,10 +602,6 @@ export default { ...@@ -603,10 +602,6 @@ export default {
// console.log(val); // console.log(val);
}, },
handleCreate() { handleCreate() {
if (--this.create_times < 0) {
this.$toast("已经过提交申请了,请等待处理!");
return false;
}
if ( if (
this.basicInfo.title == "" || this.basicInfo.title == "" ||
this.basicInfo.startTime1 == "" || this.basicInfo.startTime1 == "" ||
...@@ -620,7 +615,7 @@ export default { ...@@ -620,7 +615,7 @@ export default {
this.$toast("请完整填写表单!"); this.$toast("请完整填写表单!");
return false; return false;
} }
if (this.basicInfo.jointimes > this.basicInfo.total_join) { if (Number(this.basicInfo.jointimes) > Number(this.basicInfo.total_join)) {
this.$toast("会员单日参与次数应小于等于会员总参与次数"); this.$toast("会员单日参与次数应小于等于会员总参与次数");
return false; return false;
} }
...@@ -645,19 +640,21 @@ export default { ...@@ -645,19 +640,21 @@ export default {
break; break;
} }
if (this.prizeList[i].total_limit < this.prizeList[i].preLimit) { if (Number(this.prizeList[i].total_limit) < Number(this.prizeList[i].preLimit)) {
this.$toast("总发放数量应大于等于每日发放数量"); console.log(this.prizeList[i].total_limit);
console.log(this.prizeList[i].preLimit);
this.$toast(`奖项${i + 1},总发放数量应大于等于每日发放数量`);
validate = false; validate = false;
break; break;
} }
if (this.prizeList[i].total_limit < this.prizeList[i].limit) { if (Number(this.prizeList[i].total_limit) < Number(this.prizeList[i].limit)) {
this.$toast("总发放数量应大于每人限领数量"); this.$toast(`奖项${i + 1},总发放数量应大于每人限领数量`);
validate = false; validate = false;
break; break;
} }
} else { } else {
if (this.prizeList[i].probability === "") { if (this.prizeList[i].probability === "") {
this.$toast("奖项概率不允许为空"); this.$toast(`奖项${i + 1}概率不允许为空`);
validate = false; validate = false;
break; break;
} }
...@@ -697,6 +694,10 @@ export default { ...@@ -697,6 +694,10 @@ export default {
this.$toast("所有奖项概率之和必须为100%"); this.$toast("所有奖项概率之和必须为100%");
return false; return false;
} }
if (--this.create_times < 0) {
this.$toast("已经过提交申请了,请等待处理!");
return false;
}
let params = { let params = {
activityInfo: { activityInfo: {
id: 0, id: 0,
...@@ -733,6 +734,9 @@ export default { ...@@ -733,6 +734,9 @@ export default {
} }
}); });
}, 200); }, 200);
}).catch(error=>{
this.create_times = 1;
console.log(error);
}); });
}, },
startTimeChange(e) { startTimeChange(e) {
...@@ -856,9 +860,11 @@ export default { ...@@ -856,9 +860,11 @@ export default {
return; return;
} }
// 计算剩余 概率 // 计算剩余 概率
// this.prizeList.forEach(p => { let temp = 100;
// this.remain_probability -= Number(p.probability) this.prizeList.forEach(p => {
// }) temp -= Number(p.probability);
});
// this.remain_probability -= Number(this.prizeList[this.prizeList.length-1].probability)
this.prizeList.push({ this.prizeList.push({
name: "", name: "",
timeLine_type: "", timeLine_type: "",
...@@ -881,7 +887,7 @@ export default { ...@@ -881,7 +887,7 @@ export default {
preLimit_show: false, preLimit_show: false,
limit: "", limit: "",
limit_show: false, limit_show: false,
probability: "", probability: temp,
probability_show: false, probability_show: false,
checked_coupon: {} checked_coupon: {}
}); });
...@@ -895,9 +901,10 @@ export default { ...@@ -895,9 +901,10 @@ export default {
} }
}, },
mounted() { mounted() {
this.create_times = 1;
console.log("create_times", this.create_times);
if (this.$route.query.activityId) { if (this.$route.query.activityId) {
// 有模板数据 // 有模板数据
console.log("有模板数据");
let template_id = this.$route.query.templateId; let template_id = this.$route.query.templateId;
this.getTemplateDate(template_id); this.getTemplateDate(template_id);
} }
......
...@@ -236,7 +236,7 @@ export default { ...@@ -236,7 +236,7 @@ export default {
codeShow: false, codeShow: false,
// //
addForm: { addForm: {
cxcode: "", cxcode: Date.parse(new Date()).toString(),
cxsh: "", cxsh: "",
name: "", name: "",
begin_date: "", begin_date: "",
...@@ -265,6 +265,8 @@ export default { ...@@ -265,6 +265,8 @@ export default {
this.addForm.deptId = sessionStorage.getItem("oyStallCode"); this.addForm.deptId = sessionStorage.getItem("oyStallCode");
this.minStartDate = new Date((new Date() / 1000 + 3600) * 1000); this.minStartDate = new Date((new Date() / 1000 + 3600) * 1000);
this.minEndDate = new Date((new Date() / 1000 + 86400) * 1000); this.minEndDate = new Date((new Date() / 1000 + 86400) * 1000);
this.create_times = 1;
console.log("create_times", this.create_times);
}, },
methods: { methods: {
timeFormat(time) { timeFormat(time) {
...@@ -319,10 +321,6 @@ export default { ...@@ -319,10 +321,6 @@ export default {
this.$router.push("coupon"); this.$router.push("coupon");
}, },
handleSave() { handleSave() {
if (--this.create_times < 0) {
this.$toast("已经过提交申请了,请等待处理!");
return false;
}
if (!this.addForm.cxcode) { if (!this.addForm.cxcode) {
this.$toast("请输入欧亚活动编码"); this.$toast("请输入欧亚活动编码");
return false; return false;
...@@ -376,15 +374,24 @@ export default { ...@@ -376,15 +374,24 @@ export default {
this.$toast("请输入用券金额"); this.$toast("请输入用券金额");
return false; return false;
} }
addCoupon(this.addForm).then(res => { if (--this.create_times < 0) {
this.create_times = 1; this.$toast("已经过提交申请了,请等待处理!");
console.log(res, "res"); return false;
if (res.errorCode == "fail") { }
this.$toast("活动创建失败!"); addCoupon(this.addForm)
} else { .then(res => {
this.$router.push("coupon"); this.create_times = 1;
} console.log(res, "res");
}); if (res.errorCode == "fail") {
this.$toast("活动创建失败!");
} else {
this.$router.push("coupon");
}
})
.catch(error => {
this.create_times = 1;
console.log(error);
});
} }
} }
}; };
......
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