Commit 392736e5 authored by leiqingsong's avatar leiqingsong

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

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