Commit 3a710b9e authored by leiqingsong's avatar leiqingsong

抽奖功能完善

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