Authored by huangyi

Merge branch 'feature/wheel-surf' of http://git.yoho.cn/fe/yoho-activity-platfor…

…m into feature/wheel-surf
... ... @@ -49,6 +49,10 @@ module.exports = function(Sequelize, DataTypes) {
type: DataTypes.INTEGER(8),
allowNull: true
},
times_type: {
type: DataTypes.INTEGER(8),
allowNull: true
},
act_total_times: {
type: DataTypes.INTEGER(8),
allowNull: true
... ...
... ... @@ -3,30 +3,30 @@
<div class="add-area-split">
<Split v-model="split">
<div slot="left" class="split-pane">
<Form ref="formValidate" :label-width="120">
<FormItem label="奖品位置" prop="prize_idx" required>
<Form ref="prizeForm" :model="prize" :rules="prizeRules" :label-width="120">
<FormItem label="奖品位置" prop="prize_idx">
<Input v-model="prize.prize_idx" placeholder="奖品位置序号(竖直方向顺时针从1开始)"></Input>
</FormItem>
<FormItem label="奖品名称" prop="name" required>
<FormItem label="奖品名称" prop="name">
<Input v-model="prize.name" placeholder="奖品名称"></Input>
</FormItem>
<FormItem label="奖品类型" prop="type" required>
<FormItem label="奖品类型" prop="type">
<Select v-model="prize.type">
<Option :value="1">谢谢惠顾</Option>
<Option :value="2">红包</Option>
<Option :value="3">优惠券</Option>
</Select>
</FormItem>
<FormItem label="奖品值" prop="value" required>
<FormItem label="奖品值" prop="value">
<Input v-model="prize.value" placeholder="口令或面值等"></Input>
</FormItem>
<FormItem label="奖品总数" prop="total" required>
<FormItem label="奖品总数" prop="total">
<Input v-model="prize.total" placeholder="奖品总数"></Input>
</FormItem>
<FormItem label="中奖概率" prop="chance" required>
<FormItem label="中奖概率" prop="chance">
<Input v-model="prize.chance" placeholder="中奖概率"></Input>
</FormItem>
<FormItem label="中奖背景图" prop="prize_bg" required>
<FormItem label="中奖背景图" prop="prize_bg">
<img class="win-prize-bg" v-show="prize.prize_bg" :src="prize.prize_bg">
<Button v-show="!prize.prize_bg">
<span ref="winPrizeBg">添加中奖背景图</span>
... ... @@ -127,11 +127,34 @@
prize_bg: '',
prize_idx: ''
},
prizeRules: {
prize_idx: [
{ required: true, message: '奖品位置序号不能为空', trigger: 'blur' }
],
name: [
{ required: true, message: '奖品名称不能为空', trigger: 'blur' }
],
type: [
{ required: true}
],
value: [
{ required: true, message: '奖品值不能为空', trigger: 'blur' }
],
total: [
{ required: true, message: '奖品总数不能为空', trigger: 'blur' }
],
chance: [
{ required: true, message: '中奖概率不能为空', trigger: 'blur' }
]
},
prizes: []
}
},
methods: {
addPrize() {
const form = 'prizeForm';
this.validateForm(form).then(() => {
$.ajax({
method: 'post',
url: '/admin/wheelSurf/api/prize/create',
... ... @@ -140,11 +163,13 @@
}).then(res => {
if (res.code === 200) {
this.$Message.success('奖品新增成功');
this.formReset(form);
this.prizeList();
} else {
this.$Message.error(res.msg);
}
});
}).catch(() => {});
},
deletePrize(id) {
this.$Modal.warning({
... ... @@ -177,8 +202,22 @@
window.qn_dynamic_el_upload(this.$refs.winPrizeBg, url => {
this.prize.prize_bg = url;
});
},
validateForm (name) {
return new Promise((resolve, reject) => {
console.log(this)
this.$refs[name].validate(valid => {
if (valid) {
resolve();
} else {
reject();
}
})
});
},
formReset (name) {
this.$refs[name].resetFields();
}
},
mounted() {
this.actId = this.$route.query.actId;
... ...
... ... @@ -3,36 +3,43 @@
<TabPane label="基础配置">
<div class="base-conf">
<div class="base-left">
<Form :label-width="120">
<FormItem label="活动规则" required>
<Form ref="confForm" :models="conf" :rules="confRules" :label-width="120">
<FormItem label="活动规则" prop="rule">
<Input type="textarea" v-model="conf.rule"
placeholder="请输入活动规则" :maxlength="2000"></Input>
</FormItem>
<FormItem label="分享链接" required>
<FormItem label="分享链接" prop="rule">
<Input type="text" v-model="conf.share_url"
placeholder="活动分享链接"></Input>
</FormItem>
<FormItem label="提示文案(上)" required>
<FormItem label="提示文案(上)" prop="btm_tip_one">
<Input type="text" v-model="conf.btm_tip_one"
placeholder="提示文案(上)"></Input>
</FormItem>
<FormItem label="提示文案(下)" required>
<FormItem label="提示文案(下)" prop="btm_tip_two">
<Input type="text" v-model="conf.btm_tip_two"
placeholder="提示文案(下)"></Input>
</FormItem>
<FormItem label="跳转链接(左)" required>
<FormItem label="跳转链接(左)" prop="jump_url_left">
<Input type="text" v-model="conf.jump_url_left"
placeholder="活动底部链接(左)"></Input>
</FormItem>
<FormItem label="跳转链接(右)" required>
<FormItem label="跳转链接(右)" prop="jump_url_right">
<Input type="text" v-model="conf.jump_url_right"
placeholder="活动底部链接(右)"></Input>
</FormItem>
<FormItem label="活动最大参与次数" required>
<FormItem label="活动次数限制" prop="times_type">
<Select v-model="conf.times_type">
<Option :value="0">只限制每天最大参与次数</Option>
<Option :value="1">只限制每人参与活动最大次数</Option>
<Option :value="2">同时限制以上两种</Option>
</Select>
</FormItem>
<FormItem label="活动最大参与次数" prop="act_total_times">
<Input type="text" v-model="conf.act_total_times"
placeholder="活动最大参与次数"></Input>
</FormItem>
<FormItem label="每天最大抽奖次数" required>
<FormItem label="每天最大抽奖次数" prop="day_limit_times">
<Input type="text" v-model="conf.day_limit_times"
placeholder="每天最大抽奖次数"></Input>
</FormItem>
... ... @@ -40,62 +47,62 @@
</div>
<div class="base-middle">
<Form :label-width="120">
<FormItem label="主背景图" prop="prize_bg" required>
<FormItem label="主背景图" prop="main_bg">
<img class="preview-img" v-show="conf.main_bg" :src="conf.main_bg">
<Button v-show="!conf.main_bg">
<span ref="mainBg" img-key="main_bg">添加</span>
<span ref="upload_img_mainBg" img-key="main_bg">添加</span>
</Button>
</FormItem>
<FormItem label="转盘背景图" prop="prize_bg" required>
<FormItem label="转盘背景图" prop="wheel_bg">
<img class="preview-img" v-show="conf.wheel_bg" :src="conf.wheel_bg">
<Button v-show="!conf.wheel_bg">
<span ref="wheelBg" img-key="wheel_bg">添加</span>
<span ref="upload_img_wheelBg" img-key="wheel_bg">添加</span>
</Button>
</FormItem>
<FormItem label="活动规则按钮" prop="prize_bg" required>
<FormItem label="活动规则按钮" prop="rule_btn_bg">
<img class="preview-img" v-show="conf.rule_btn_bg" :src="conf.rule_btn_bg">
<Button v-show="!conf.rule_btn_bg">
<span ref="ruleBg" img-key="rule_btn_bg">添加</span>
<span ref="upload_img_ruleBg" img-key="rule_btn_bg">添加</span>
</Button>
</FormItem>
<FormItem label="分享按钮" prop="prize_bg" required>
<FormItem label="分享按钮" prop="share_btn_bg">
<img class="preview-img" v-show="conf.share_btn_bg" :src="conf.share_btn_bg">
<Button v-show="!conf.share_btn_bg">
<span ref="shareBg" img-key="share_btn_bg">添加</span>
<span ref="upload_img_shareBg" img-key="share_btn_bg">添加</span>
</Button>
</FormItem>
<FormItem label="抽奖按钮" prop="prize_bg" required>
<FormItem label="抽奖按钮" prop="prize_btn_bg">
<img class="preview-img" v-show="conf.prize_btn_bg" :src="conf.prize_btn_bg">
<Button v-show="!conf.prize_btn_bg">
<span ref="tryBg" img-key="prize_btn_bg">添加</span>
<span ref="upload_img_tryBg" img-key="prize_btn_bg">添加</span>
</Button>
</FormItem>
</Form>
</div>
<div class="base-right">
<Form :label-width="120">
<FormItem label="次数上限背景图" prop="prize_bg" required>
<FormItem label="次数上限背景图" prop="day_over_limit_bg">
<img class="preview-img" v-show="conf.day_over_limit_bg" :src="conf.day_over_limit_bg">
<Button v-show="!conf.day_over_limit_bg">
<span ref="overBg" img-key="day_over_limit_bg">添加</span>
<span ref="upload_img_overBg" img-key="day_over_limit_bg">添加</span>
</Button>
</FormItem>
<FormItem label="我的奖品" prop="prize_bg" required>
<FormItem label="我的奖品" prop="my_prize_btn_bg">
<img class="preview-img" v-show="conf.my_prize_btn_bg" :src="conf.my_prize_btn_bg">
<Button v-show="!conf.my_prize_btn_bg">
<span ref="myPrizeBg" img-key="my_prize_btn_bg">添加</span>
<span ref="upload_img_myPrizeBg" img-key="my_prize_btn_bg">添加</span>
</Button>
</FormItem>
<FormItem label="提示中奖背景图" prop="prize_bg" required>
<FormItem label="提示中奖背景图" prop="win_prize_bg">
<img class="preview-img" v-show="conf.win_prize_bg" :src="conf.win_prize_bg">
<Button v-show="!conf.win_prize_bg">
<span ref="winPrizeBg" img-key="win_prize_bg">添加</span>
<span ref="upload_img_winPrizeBg" img-key="win_prize_bg">添加</span>
</Button>
</FormItem>
<FormItem label="再来一次按钮" prop="prize_bg" required>
<FormItem label="再来一次按钮" prop="try_again_bg">
<img class="preview-img" v-show="conf.try_again_bg" :src="conf.try_again_bg">
<Button v-show="!conf.try_again_bg">
<span ref="tryAgainBg" img-key="try_again_bg">添加</span>
<span ref="upload_img_tryAgainBg" img-key="try_again_bg">添加</span>
</Button>
</FormItem>
</Form>
... ... @@ -135,9 +142,30 @@
prize_btn_bg: '',
rule_btn_bg: '',
share_btn_bg: '',
times_type: 0,
day_over_limit_bg: '',
my_prize_btn_bg: '',
win_prize_bg: ''
},
confRules: {
rule: [
{ required: true, message: '活动规则不能为空', trigger: 'blur' }
],
name: [
{ required: true, message: '奖品名称不能为空', trigger: 'blur' }
],
type: [
{ required: true}
],
value: [
{ required: true, message: '奖品值不能为空', trigger: 'blur' }
],
total: [
{ required: true, message: '奖品总数不能为空', trigger: 'blur' }
],
chance: [
{ required: true, message: '中奖概率不能为空', trigger: 'blur' }
]
}
}
},
... ... @@ -150,7 +178,7 @@
data: JSON.stringify(Object.assign(this.conf, {act_id: this.actId}))
}).then(res => {
if (res.code === 200) {
this.$Message.success('奖品新增成功');
this.$Message.success('基础配置更新成功');
this.prizeList();
} else {
this.$Message.error(res.msg);
... ... @@ -170,7 +198,9 @@
});
},
bindUpload() {
Object.keys(this.$refs).map(key => {
Object.keys(this.$refs)
.filter(key => /^upload_img_/ig.test(key))
.map(key => {
let $el = this.$refs[key];
let imgKey = $el.getAttribute('img-key');
... ...