Commit 392736e5 authored by leiqingsong's avatar leiqingsong

活动创建表单里面的次数限制

parent 43181b6e
......@@ -4,7 +4,7 @@
<template v-if="active_type === 'coupon'">
<div class="coupon">
<div class="user-icon">
<img :src="userIcon" alt="icon">
<img :src="userIcon" alt="icon" />
</div>
<p class="slogan">送你限量优惠券,手慢无~</p>
<div class="coupon-content">
......@@ -119,7 +119,7 @@ export default {
components: { wxAuth },
data() {
return {
userIcon: '/img/photo.png',
userIcon: "/img/photo.png",
couponDetail: {},
game_end: false,
res_error: false,
......@@ -188,12 +188,13 @@ export default {
this.currentUrl = location.href;
this.active_id = this.$route.query.id;
this.active_type = this.$route.query.active_type;
this.userIcon = this.$route.query.headurl ? decodeURIComponent(this.$route.query.headurl) : '';
this.userIcon = this.$route.query.headurl
? decodeURIComponent(this.$route.query.headurl)
: "";
// 验证用户是否登录
if (!sessionStorage.getItem("userId")) {
// 1.获取code
if (this.$route.query.unionid === undefined) {
console.log('query', this.$route.query);
this.getUnionid();
} else {
this.userBaseInfo.unionid = JSON.stringify(this.$route.query.unionid);
......@@ -277,8 +278,7 @@ export default {
}
if (this.active_type === "wheel") {
let cur_date = new Date();
let end_time = new Date(this.timeLine.replace(/-/g, '/'));
console.log('ios date', this.timeLine.replace(/-/g, '/'));
let end_time = new Date(this.timeLine.replace(/-/g, "/"));
if (end_time > cur_date) {
this.timer = setInterval(() => {
CoutDown(this.timeLine);
......@@ -303,17 +303,21 @@ export default {
// 在微信端打开 会有身份验证 路径中会带上 unionid
if (this.$route.query.unionid === undefined) {
this.$toast("企业微信端不能参与抽奖活动");
return;
return false;
}
if (this.game_end) {
this.$toast("活动已结束");
return;
return false;
}
if (!this.userBaseInfo.vipId) {
this.$toast("非会员,");
let url = "http://oysales.oywanhao.com/register";
window.location.href = url;
return;
return false;
}
if (this.rolling) {
this.$toast("抽奖中,请勿多次点击!");
return false;
}
let params = {
activityId: this.active_id,
......@@ -322,20 +326,18 @@ export default {
unionId: this.userBaseInfo.unionid,
userName: this.userBaseInfo.name
};
if (this.rolling) {
this.$toast("抽奖中,请勿多次点击!");
return;
}
APi_Active.play(params)
.then(res => {
if (!res.data.prizedId) {
this.res_error = true;
this.$toast(res.data.message);
return;
return false;
}
const { wheelDeg, prizeList } = this;
this.rolling = true;
const random = prizeList.map(item => item.id).indexOf(res.data.prizedId);
const random = prizeList
.map(item => item.id)
.indexOf(res.data.prizedId);
this.wheelDeg =
wheelDeg -
(wheelDeg % 360) +
......
......@@ -15,7 +15,7 @@
v-model="startTime1"
placeholder="请选择开始时间"
readonly="readonly"
@click="startShow = true"
@click="openStartTime"
/>
<van-popup v-model="startShow" position="bottom" :overlay="true">
<van-datetime-picker
......@@ -38,7 +38,7 @@
v-model="endTime1"
placeholder="请选择结束时间"
readonly="readonly"
@click="endShow = true"
@click="openEndTime"
/>
<van-popup v-model="endShow" position="bottom" :overlay="true">
<van-datetime-picker
......@@ -60,7 +60,17 @@
<van-uploader :max-count="1" v-model="logo_imgs" :after-read="afterLogoRead"></van-uploader>
</van-cell>
<van-cell :required="true" title="单日最大发放数量">
<template slot="default">
<van-stepper
v-model="maxNumber"
:show-plus="false"
:show-minus="false"
input-width="140px"
step="1"
min="1"
max="999999"
integer
/>
<!-- <template slot="default">
<div class="jpsl">
<van-field
class="right noborder"
......@@ -77,10 +87,20 @@
@blur="maxNumber_show = false"
/>
</div>
</template>
</template>-->
</van-cell>
<van-cell :required="true" title="总发放数量">
<template slot="default">
<van-stepper
v-model="totalLimit"
:show-plus="false"
:show-minus="false"
input-width="140px"
step="1"
min="1"
max="999999"
integer
/>
<!-- <template slot="default">
<div class="jpsl">
<van-field
class="right noborder"
......@@ -97,7 +117,7 @@
@blur="totalLimit_show = false"
/>
</div>
</template>
</template> -->
</van-cell>
<van-cell
:required="true"
......@@ -172,10 +192,16 @@ export default {
};
},
created() {
},
methods: {
openStartTime() {
this.startShow = true;
this.minStartDate = new Date();
},
openEndTime() {
this.endShow = true;
this.minEndDate = new Date();
},
methods: {
getTemplateDate(id) {
API_Active.getTemplateData(id).then(res => {
this.title = res.data.activityInfo.activityName;
......@@ -233,13 +259,13 @@ export default {
}
},
getCoupons() {
console.log('获取优惠券');
console.log("获取优惠券");
let id = sessionStorage.getItem("oyStallCode") || 1;
API_Active.getAllCouponsByOyStallCode(id).then(res => {
if (res.data.length === 0 || !res.data.length) {
this.$toast('您所在店铺没有优惠券,请先去创建');
setTimeout(()=>{
this.$router.push('/');
this.$toast("您所在店铺没有优惠券,请先去创建");
setTimeout(() => {
this.$router.push("/");
}, 500);
} else {
this.coupons = res.data;
......@@ -275,23 +301,26 @@ export default {
},
handleCreate() {
if (
this.title === '' ||
this.startTime1 == '' ||
this.endTime1 == '' ||
this.title === "" ||
this.startTime1 == "" ||
this.endTime1 == "" ||
this.logo_imgs.length == 0 ||
this.maxNumber == '' ||
this.totalLimit == '' ||
this.checked_coupon == {} ||
this.message == ''
this.maxNumber == "" ||
this.totalLimit == "" ||
!this.checked_coupon.id ||
this.message == ""
) {
this.$toast('请完整填写活动表单!');
return;
this.$toast("请完整填写活动表单!");
return false;
}
if (new Date(this.startTime1) >= new Date(this.endTime1)) {
this.$toast("活动开始时间应小于活动开始时间");
return;
return false;
}
if (this.maxNumber > this.totalLimit) {
this.$toast("单日最大发放数量应不大于总发放数量");
return false;
}
let params = {
activityInfo: {
id: 0,
......
......@@ -65,7 +65,18 @@
<van-uploader :max-count="1" v-model="logo_imgs" :after-read="afterLogoRead"></van-uploader>
</van-cell>
<van-cell :required="true" title="会员单日参与次数" style="font-size: 14px">
<template slot="default">
<van-stepper
v-model="basicInfo.jointimes"
placeholder="请输入限制次数"
:show-plus="false"
:show-minus="false"
input-width="140px"
step="1"
min="1"
max="999999"
integer
/>
<!-- <template slot="default">
<div class="jpsl">
<van-field
class="right noborder"
......@@ -82,10 +93,22 @@
@blur="basicInfo.jointimes_show = false"
/>
</div>
</template>
</template>-->
</van-cell>
<van-cell :required="true" title="会员总参与次数" style="font-size: 14px">
<template slot="default">
<van-stepper
v-model="basicInfo.total_join"
placeholder="请输入限制次数"
:show-plus="false"
:show-minus="false"
input-width="140px"
step="1"
min="1"
max="999999"
integer
/>
<!-- <template slot="default">
<div class="jpsl">
<van-field
class="right noborder"
......@@ -102,7 +125,7 @@
@blur="basicInfo.total_join_show = false"
/>
</div>
</template>
</template>-->
</van-cell>
</van-cell-group>
<div class="title">奖品设置</div>
......@@ -138,7 +161,18 @@
center
/>
<van-cell :required="true" title="总发放数量限制" style="font-size:14px;">
<template slot="default">
<van-stepper
v-model="prizeList[index].total_limit"
placeholder="请输入限制次数"
:show-plus="false"
:show-minus="false"
input-width="140px"
step="1"
min="1"
max="999999"
integer
/>
<!-- <template slot="default">
<div class="jpsl">
<van-field
class="right noborder"
......@@ -155,10 +189,20 @@
@blur="prizeList[index].total_limit_show = false"
/>
</div>
</template>
</template>-->
</van-cell>
<van-cell :required="true" title="每日发放数量限制" style="font-size:14px;">
<template slot="default">
<van-stepper
v-model="prizeList[index].preLimit"
placeholder="请输入限制次数"
:show-plus="false"
:show-minus="false"
input-width="140px"
step="1"
min="1"
integer
/>
<!-- <template slot="default">
<div class="jpsl">
<van-field
class="right noborder"
......@@ -175,10 +219,21 @@
@blur="prizeList[index].preLimit_show = false"
/>
</div>
</template>
</template>-->
</van-cell>
<van-cell :required="true" title="每人限领数量" style="font-size:14px;">
<template slot="default">
<van-stepper
v-model="prizeList[index].limit"
placeholder="请输入限制次数"
:show-plus="false"
:show-minus="false"
input-width="140px"
step="1"
min="1"
max="999999"
integer
/>
<!-- <template slot="default">
<div class="jpsl">
<van-field
class="right noborder"
......@@ -195,7 +250,7 @@
@blur="prizeList[index].limit_show = false"
/>
</div>
</template>
</template>-->
</van-cell>
</template>
<van-cell :required="true" style="font-size:14px;" class="cs gl">
......@@ -204,19 +259,31 @@
</template>
<template slot="default">
<div class="jpsl">
<van-field
<!-- <van-field
class="right noborder"
readonly
clickable
:value="prizeList[index].probability"
@touchstart.native.stop="prizeList[index].probability_show = true"
/>-->
<van-stepper
class="right noborder"
style="padding-right: 20px;"
v-model="prizeList[index].probability"
:show-plus="false"
:show-minus="false"
input-width="40px"
step="1"
min="1"
max="100"
integer
/>
<span class="bfb">%</span>
<van-number-keyboard
<!-- <van-number-keyboard
v-model="prizeList[index].probability"
:show="prizeList[index].probability_show"
@blur="prizeList[index].probability_show = false"
/>
/>-->
</div>
</template>
</van-cell>
......@@ -270,7 +337,7 @@ import { Toast } from "vant";
export default {
data() {
return {
minStaetDate: null,
minStartDate: null,
minEndDate: null,
// 选择优惠券 当前下标
current_index: -1,
......@@ -350,8 +417,7 @@ export default {
confirmTime: new Date()
};
},
created() {
},
created() {},
methods: {
openStartTime() {
this.basicInfo.startShow = true;
......@@ -508,46 +574,68 @@ export default {
},
handleCreate() {
if (
this.basicInfo.title == '' ||
this.basicInfo.startTime1 == '' ||
this.basicInfo.endTime1 == '' ||
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.basicInfo.jointimes == "" ||
this.basicInfo.total_join == "" ||
this.message == "" ||
this.prize_produce == ""
) {
this.$toast('请完整填写表单!');
return;
this.$toast("请完整填写表单!");
return false;
}
this.prizeList.forEach(item => {
if (item.type == "") {
this.$toast('奖项类型必选!');
return;
if (this.basicInfo.jointimes > this.basicInfo.to) {
this.$toast("会员单日参与次数 <= 会员总参与次数");
return false;
}
let validate = null;
for (let i in this.prizeList) {
if (this.prizeList[i].type == "") {
this.$toast(`奖项${i}类型必选!`);
validate = false;
break;
}
if (item.type == 1) {
if (item.name == '' ||
item.checked_coupon == {} ||
item.total_limit == '' ||
item.limit == '' ||
item.preLimit == '' ||
item.probability == ''
if (this.prizeList[i].type == 1) {
if (
this.prizeList[i].name == "" ||
!this.prizeList[i].checked_coupon.id ||
this.prizeList[i].total_limit == "" ||
this.prizeList[i].limit == "" ||
this.prizeList[i].preLimit == "" ||
this.prizeList[i].probability == ""
) {
this.$toast('请填写完整奖项设置!');
return;
this.$toast("请填写完整奖项设置!");
validate = false;
break;
}
if (this.prizeList[i].total_limit < this.prizeList[i].limit) {
this.$toast("总发放数量应大于每日发放数量");
validate = false;
break;
}
if (this.prizeList[i].total_limit < this.prizeList[i].preLimit) {
this.$toast("总发放数量应大于每人限领数量");
validate = false;
break;
}
} else {
if(item.probability === '') {
this.$toast('奖项概率不允许为空');
return;
if (this.prizeList[i].probability === "") {
this.$toast("奖项概率不允许为空");
validate = false;
break;
}
}
}
if (validate === false) {
return false;
}
})
if (
new Date(this.basicInfo.startTime1) >= new Date(this.basicInfo.endTime1)
) {
this.$toast("活动开始时间应小于活动开始时间");
return;
return false;
}
let params_prizeList = [];
let total_probability = 0;
......@@ -572,7 +660,7 @@ export default {
});
if (total_probability != 100) {
this.$toast("所有奖项概率之和必须为100%");
return;
return false;
}
let params = {
activityInfo: {
......@@ -595,7 +683,7 @@ export default {
API_Active.createActive(params).then(res => {
if (res.result === "fail") {
this.$toast(res.errorMsg);
return;
return false;
}
Toast.success("创建成功");
setTimeout(() => {
......
......@@ -238,7 +238,7 @@ export default {
this.flag = sessionStorage.getItem("role");
}
} else {
this.zReadyUserId()
// this.zReadyUserId()
this.zTestGetNowUrlInfo()
}
this.GET_CurrentActive()
......
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