conf.vue
15.5 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
<template>
<Tabs size="small">
<TabPane label="基础配置">
<div class="base-conf">
<div class="base-left">
<Form ref="confForm" :model="conf" :rules="confRules" :label-width="120">
<FormItem label="活动规则页链接" prop="rule_url">
<Input type="text" v-model="conf.rule_url"
placeholder="请输入活动规则" :maxlength="500"></Input>
</FormItem>
<FormItem label="分享标题" prop="share_title">
<Input type="text" v-model="conf.share_title"
placeholder="分享标题" :maxlength="500"></Input>
</FormItem>
<FormItem label="分享描述" prop="share_desc">
<Input type="text" v-model="conf.share_desc"
placeholder="分享描述" :maxlength="100"></Input>
</FormItem>
<FormItem label="分享链接" prop="share_url">
<Input type="text" v-model="conf.share_url"
placeholder="分享链接" :maxlength="500"></Input>
</FormItem>
<FormItem v-if="false" label="提示文案(下)" prop="btm_tip_two">
<Input type="text" v-model="conf.btm_tip_two"
placeholder="提示文案(下)"></Input>
</FormItem>
<FormItem label="底部按钮1链接" prop="jump_btn_left_url">
<Input type="text" v-model="conf.jump_btn_left_url"
placeholder="底部按钮1链接"></Input>
</FormItem>
<FormItem label="底部按钮2链接" prop="jump_btn_middle_url">
<Input type="text" v-model="conf.jump_btn_middle_url"
placeholder="底部按钮2链接"></Input>
</FormItem>
<FormItem label="底部按钮3链接" prop="jump_btn_right_url">
<Input type="text" v-model="conf.jump_btn_right_url"
placeholder="底部按钮3链接"></Input>
</FormItem>
<FormItem label="每天最大抽奖次数" prop="day_limit_times">
<Input type="text"
v-model="conf.day_limit_times"
placeholder="每天最大抽奖次数" number></Input>
</FormItem>
<FormItem label="底部资源位码" prop="bottomContentCode">
<Input type="text" v-model="conf.bottomContentCode"
placeholder="底部资源码"></Input>
</FormItem>
</Form>
</div>
<div class="base-middle">
<Form :label-width="120">
<FormItem label="主背景图" prop="main_bg">
<div class="preview-wrap" v-show="conf.main_bg">
<Icon type="ios-close" class="del-img" @click="delPreview" img-key="main_bg"/>
<img class="preview-img" :src="conf.main_bg">
</div>
<Button v-show="!conf.main_bg">
<span ref="upload_img_mainBg" img-key="main_bg">添加(750x1680)</span>
</Button>
</FormItem>
<FormItem label="转盘背景图" prop="wheel_bg">
<div class="preview-wrap" v-show="conf.wheel_bg">
<Icon type="ios-close" class="del-img" @click="delPreview" img-key="wheel_bg"/>
<img class="preview-img" :src="conf.wheel_bg">
</div>
<Button v-show="!conf.wheel_bg">
<span ref="upload_img_wheelBg" img-key="wheel_bg">添加(630x630)</span>
</Button>
</FormItem>
<FormItem label="抽奖按钮" prop="prize_btn_bg">
<div class="preview-wrap" v-show="conf.prize_btn_bg">
<Icon type="ios-close" class="del-img" @click="delPreview" img-key="prize_btn_bg"/>
<img class="preview-img" :src="conf.prize_btn_bg">
</div>
<Button v-show="!conf.prize_btn_bg">
<span ref="upload_img_tryBg" img-key="prize_btn_bg">添加(200x218)</span>
</Button>
</FormItem>
<FormItem label="中奖蒙层" prop="win_prize_bg">
<div class="preview-wrap" v-show="conf.win_prize_bg">
<Icon type="ios-close" class="del-img" @click="delPreview" img-key="win_prize_bg"/>
<img class="preview-img" :src="conf.win_prize_bg">
</div>
<Button v-show="!conf.win_prize_bg">
<span ref="upload_img_winPrizeBg" img-key="win_prize_bg">添加(750x1680)</span>
</Button>
</FormItem>
</Form>
</div>
<div class="base-right">
<Form :label-width="120">
<FormItem label="活动规则按钮" prop="rule_btn_bg">
<div class="preview-wrap" v-show="conf.rule_btn_bg">
<Icon type="ios-close" class="del-img" @click="delPreview" img-key="rule_btn_bg"/>
<img class="preview-img" :src="conf.rule_btn_bg">
</div>
<Button v-show="!conf.rule_btn_bg">
<span ref="upload_img_ruleBg" img-key="rule_btn_bg">添加(154x62)</span>
</Button>
</FormItem>
<FormItem label="分享按钮" prop="share_btn_bg">
<div class="preview-wrap" v-show="conf.share_btn_bg">
<Icon type="ios-close" class="del-img" @click="delPreview" img-key="share_btn_bg"/>
<img class="preview-img" :src="conf.share_btn_bg">
</div>
<Button v-show="!conf.share_btn_bg">
<span ref="upload_img_shareBg" img-key="share_btn_bg">添加(154x62)</span>
</Button>
</FormItem>
<FormItem label="分享缩略图" prop="share_btn_bg">
<div class="preview-wrap" v-show="conf.share_img">
<Icon type="ios-close" class="del-img" @click="delPreview" img-key="share_img"/>
<img class="preview-img" :src="conf.share_img">
</div>
<Button v-show="!conf.share_img">
<span ref="upload_img_shareImg" img-key="share_img">添加(300x300)</span>
</Button>
</FormItem>
<FormItem label="底部按钮1" prop="jump_btn_left_bg">
<div class="preview-wrap" v-show="conf.jump_btn_left_bg">
<Icon type="ios-close" class="del-img" @click="delPreview" img-key="jump_btn_left_bg"/>
<img class="preview-img" :src="conf.jump_btn_left_bg">
</div>
<Button v-show="!conf.jump_btn_left_bg">
<span ref="upload_img_jumpBtnLeftBg" img-key="jump_btn_left_bg">添加</span>
</Button>
</FormItem>
<FormItem label="底部按钮2" prop="jump_btn_middle_bg">
<div class="preview-wrap" v-show="conf.jump_btn_middle_bg">
<Icon type="ios-close" class="del-img" @click="delPreview" img-key="jump_btn_middle_bg"/>
<img class="preview-img" :src="conf.jump_btn_middle_bg">
</div>
<Button v-show="!conf.jump_btn_middle_bg">
<span ref="upload_img_jumpBtnMiddleBg" img-key="jump_btn_middle_bg">添加</span>
</Button>
</FormItem>
<FormItem label="底部按钮3" prop="jump_btn_right_bg">
<div class="preview-wrap" v-show="conf.jump_btn_right_bg">
<Icon type="ios-close" class="del-img" @click="delPreview" img-key="jump_btn_right_bg"/>
<img class="preview-img" :src="conf.jump_btn_right_bg">
</div>
<Button v-show="!conf.jump_btn_right_bg">
<span ref="upload_img_jumpBtnRightBg" img-key="jump_btn_right_bg">添加</span>
</Button>
</FormItem>
</Form>
</div>
<div class="bottom-btn">
<Button type="primary" @click="save" class="save">保存</Button>
<Button type="warning" @click="save" class="preview">预览</Button>
</div>
</div>
</TabPane>
<TabPane label="奖品配置">
<add-prize></add-prize>
</TabPane>
</Tabs>
</template>
<script>
import AddPrize from './components/add-prize';
export default {
data () {
return {
actId: 0,
confId: 0,
conf: {
act_id: 0,
id: 0,
rule_url: '',
share_url: '',
day_limit_times: '',
act_total_times: '',
btm_tip_one: '',
btm_tip_two: '',
jump_btn_left_url: '',
jump_btn_middle_url: '',
jump_btn_right_url: '',
jump_btn_left_bg: '',
jump_btn_middle_bg: '',
jump_btn_right_bg: '',
wheel_bg: '',
main_bg: '',
prize_btn_bg: '',
rule_btn_bg: '',
share_btn_bg: '',
times_type: 1,
day_over_limit_bg: '',
my_prize_btn_bg: '',
win_prize_bg: '',
bottomContentCode: ''
},
confRules: {
share_url: [
{ required: false, message: '分享链接不能为空'}
],
day_limit_times: [
{ required: true, message: '每天最大次数不能为空'},
{ type: 'integer', message: '每天最大次数必须是整数', trigger: 'blur'}
],
bottomContentCode: [
{ required: true, message: '底部资源码不能为空'}
]
}
}
},
methods: {
save() {
const form = 'confForm';
this.validateForm(form).then(() => {
$.ajax({
method: 'post',
url: '/admin/wheelSurf/api/config/modify',
contentType: 'application/json',
data: JSON.stringify(Object.assign(this.conf, {act_id: this.actId}))
}).then(res => {
if (res.code === 200) {
this.$Message.success('基础配置更新成功');
this.prizeList();
} else {
this.$Message.error(res.msg);
}
});
}).catch(() => {});
},
getConf() {
$.ajax({
url: '/admin/wheelSurf/api/config/detail',
data: {act_id: this.actId}
}).then(res => {
if (res.code === 200 && res.data && res.data.id) {
this.conf = res.data;
} else {
this.$Message.error(res.msg);
}
});
},
delPreview(e) {
this.conf[e.currentTarget.getAttribute('img-key')] = '';
},
bindUpload() {
Object.keys(this.$refs)
.filter(key => /^upload_img_/ig.test(key))
.map(key => {
let $el = this.$refs[key];
let imgKey = $el.getAttribute('img-key');
if (!imgKey) return;
window.qn_dynamic_el_upload($el, url => {
this.conf[imgKey] = url;
});
});
},
limitChange() {
},
validateForm(name) {
return new Promise((resolve, reject) => {
this.$refs[name].validate(valid => {
if (valid) {
resolve();
} else {
reject();
}
});
});
},
},
mounted() {
this.actId = this.$route.query.actId;
this.bindUpload();
this.getConf();
},
components: {
AddPrize
}
}
</script>
<style lang="scss">
.ivu-tabs {
height: 100%;
overflow-y: auto;
}
.bottom-btn {
position: absolute;
bottom: 0;
left: 0;
right: 0;
text-align: center;
}
.base-conf {
padding-bottom: 40px;
display: flex;
.base-left {
display: inline-block;
box-sizing: border-box;
flex: 2;
}
.base-middle {
display: inline-block;
box-sizing: border-box;
flex: 1;
}
.base-right {
display: inline-block;
box-sizing: border-box;
flex: 1;
}
.save {
margin-right: 20px;
}
}
.preview-wrap {
position: relative;
max-width: 200px;
.del-img {
position: absolute;
top: -10px;
left: -4px;
font-size: 24px;
font-weight: bold;
cursor: pointer;
border-radius: 50%;
background-color: #000;
opacity: 0.3;
width: 24px;
height: 24px;
color: #ffffff;
}
}
.preview-img {
max-width: 100px;
max-height: 100px;
width: auto;
}
</style>