create.vue
5.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<template>
<div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>签到活动创建</h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
<Form>
<FormItem label="活动名称">
<Input v-model="title" placeholder="活动名称" style="width: 400px"></Input>
</FormItem>
<FormItem label="活动时间">
<DatePicker type="daterange" placeholder="开始时间-结束时间"
style="width: 400px" @on-change="dateTimeChange"></DatePicker>
</FormItem>
<FormItem label="每日领取大转盘ID">
<Input v-model="normalWheelId" placeholder="平时每日领取对应的大转盘id" style="width: 400px;"></Input>
</FormItem>
<FormItem label="第一次累计天数">
<Input v-model="days1.count" placeholder="第一次累计天数" style="width: 100px;"></Input>
转盘ID
<Input v-model="days1.wheelId" placeholder="对应的大转盘id" style="width: 200px;"></Input>
</FormItem>
<FormItem label="第二次累计天数">
<Input v-model="days2.count" placeholder="第二次累计天数" style="width: 100px;"></Input>
转盘ID
<Input v-model="days2.wheelId" placeholder="对应的大转盘id" style="width: 200px;"></Input>
</FormItem>
<FormItem label="第三次累计天数">
<Input v-model="days3.count" placeholder="第二次累计天数" style="width: 100px;"></Input>
转盘ID
<Input v-model="days3.wheelId" placeholder="对应的大转盘id" style="width: 200px;"></Input>
</FormItem>
<FormItem>
<Button type="primary" @click="save">保存</Button>
<Button style="margin-left: 8px" @click="cancel">取消</Button>
</FormItem>
</Form>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import moment from 'moment';
export default {
data() {
return {
title: '',
startTime: '',
endTime: '',
normalWheelId: '',
days1: {
count: 0,
wheelId: ''
},
days2: {
count: 0,
wheelId: ''
},
days3: {
count: 0,
wheelId: ''
}
};
},
mounted() {
},
methods: {
dateTimeChange(range) {
this.startTime = range[0];
this.endTime = range[1];
},
save() {
let prizeDayArr = [];
if (parseInt(this.days1.count, 10) && this.days1.wheelId) { // 第一次累计
prizeDayArr.push(this.days1);
if (parseInt(this.days2.count, 10) && this.days2.wheelId) { // 第二次累计
if (parseInt(this.days2.count, 10) <= parseInt(this.days1.count, 10)) {
return alert('第二次的天数必须大于第一次的天数');
} else {
prizeDayArr.push(this.days2);
if (parseInt(this.days3.count, 10) && this.days3.wheelId) { // 第三次累计
if (parseInt(this.days3.count, 10) <= parseInt(this.days2.count, 10)) {
return alert('第三次的天数必须大于第二次的天数');
} else {
prizeDayArr.push(this.days3);
}
}
}
}
}
if (!this.title) {
return alert('清填写标题');
}
if (!this.startTime || !this.endTime) {
return alert('请选择开始结束时间');
}
if (!this.normalWheelId) {
return alert('请填写每日领取的大转盘ID');
}
$.ajax({
method: 'post',
url: '/admin/dailyCheckIn/api/create',
data: {
title: this.title,
startTime: moment(this.startTime).format('X'),
endTime: moment(this.endTime).format('X'),
normalWheelId: this.normalWheelId,
prizeDayArr: JSON.stringify(prizeDayArr)
}
}).then(res => {
if (res.code === 200) {
this.$router.push({name: 'list'});
} else {
alert('创建失败');
}
});
},
cancel() {
this.$router.push({name: 'list'});
}
},
components: {
}
};
</script>
<style>
</style>