add.vue
15.4 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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<template>
<div class="new-tmp">
<h2>新建活动模版</h2>
<hr/>
<div class="activity-wrap">
<div class="activity-content"><glsx-combi-form
ref="formRef"
:isEdit="true"
:isBlock="true"
:formObj="configForm"
:formData="formData"
:formRules="rule"
>
<template #merchantId>
<el-select
v-model="configForm.merchantId"
placeholder="请选择"
filterable
remote
:remote-method="remoteMethod"
v-reachbottom="onReachBottom"
@focus="selectFocus"
:loading="loading"
:disabled="disabled"
@change="change"
>
<el-option
v-for="item in merchantObj.data"
:key="item.confId"
:label="item.confName"
:value="item.confId"
></el-option>
<template v-if="merchantObj.nothing">
<div class="select-nothing">到底了!</div>
</template>
</el-select>
</template>
<template #pageTheme>
<div class="page-theme">
<el-form-item label="第一行" prop="theme1" >
<el-input v-model.trim="configForm.theme1" maxlength="5" show-word-limit></el-input>
</el-form-item>
<el-form-item label="第二行" prop="theme2" >
<el-input v-model.trim="configForm.theme2" maxlength="5" show-word-limit></el-input>
</el-form-item>
</div>
</template>
<p
slot="cardCover"
class="cover-tips"
>建议格式:高度88px,png</p>
<template #activityRuleDes>
<el-form-item >
<textBox style="width:45vw" @change="writeChange" ref="textBox" @forbid="forbidEdit"></textBox>
</el-form-item>
</template>
<template #physicalWinningCfg>
<div class="physical-winning">
<el-form-item
label="活动形式:"
prop="exchangeType"
class="m-t-20"
>
<el-radio-group
v-model="configForm.exchangeType"
class="fit-width radio"
>
<el-radio :label="0">快递到家</el-radio>
<el-radio :label="1">到店核销</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="填写信息:" prop="describeId" v-if="configForm.exchangeType == 0">
<el-checkbox-group class="checkboxs-setting" v-model="configForm.describeId">
<el-checkbox v-for="(item,index) in expressList" :key="index" :label="item"><span>{{ item.describeMsg }}</span></el-checkbox>
</el-checkbox-group>
</el-form-item>
</div>
</template>
</glsx-combi-form></div>
<div class="redEnvelope-bg">
<img v-if="configForm.logo" :src="configForm.logo">
<p v-html="configForm.theme1"></p>
<p class="p2" v-html="configForm.theme2"></p>
</div>
</div>
<GLFooter>
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSave">确定</el-button>
</GLFooter>
</div>
</template>
<script type="text/ecmascript-6">
import {getMerchantListMixin} from '@/mixins'
import textBox from '@/components/text-box'
export default {
name: 'add',
mixins: [getMerchantListMixin],
props: {
disabled: Boolean
},
components: {
textBox
},
data() {
return {
merchantObj: {
nothing: false,
data: [],
currentPage: 1,
name: '',
loading: false,
total: 0
},
expressList:[],
configForm: {
templateName: '',
merchantId: '',
activityType: '0',
theme1:'',
theme2:'',
logo: '',
merchantName: '',
pageTheme:'11',
exchangeType: '',
ruleDescribe:'',
describeId: [],
},
rule: {
templateName: [{required: true, message: '请输入模板名称', trigger: 'change'}],
merchantId: [{required: true, message: '请选择所属渠道', trigger: 'change'}],
activityType: [{required: true, message: '请选择活动形式', trigger: 'change'}],
logo: [{required: true, message: '请上传卡片封面', trigger: 'change'}],
ruleDescribe:[{required: true, message: '请填写活动规则描述', trigger: 'change'}],
pageTheme: [{required: true, message: '请输入页面主题'}],
exchangeType: [{required: true, message: '请选择活动形式', trigger: 'change'}],
describeId: [{required: true, message: '请选择填写信息', trigger: 'change'}]
},
formData: [
{
label: '模板名称',
name: 'templateName',
type: 'input',
maxlength: 25,
showLimit:true
},
{
label: '所属渠道',
type: 'select',
name: 'merchantId',
addHtml: 'merchantId'
},
{
label: '活动形式',
name: 'activityType',
type: 'radio',
optionList: [
{text: '随机红包', id: '0'}
],
optionId: 'id',
optionLabel: 'text',
},
{
label: '页面主题',
name: 'pageTheme',
addHtml: 'pageTheme'
},
{
label: 'logo图片',
name: 'logo',
type: 'upload',
width: '320px',
limitSize: 10,
maxPhotoNum: 1,
suffixSlot: 'cardCover',
handleUpload: async (e, file, targetItem) => {
let loading = this.$loading({
target: document.querySelector('.activity-img'),
})
try {
const imgFile = e.target.result,
arrBase64 = imgFile.split(',')[1],
str = file.name.split('.'),
base64 = str.at(-1) + '@' + arrBase64,
res = await this.$apis.common.pictureUpload({file: base64, fileType: 'image'})
if (res) {
this.configForm[targetItem.name] = res
this.formRef().validateField(targetItem.name)
loading.close()
} else throw '上传失败'
} catch (error) {
loading.close()
this.$message(error)
}
}
},
{
label: '活动规则描述',
name: 'ruleDescribe',
addHtml: 'activityRuleDes'
},
{
label: '实物中奖配置',
addHtml: 'physicalWinningCfg'
}
],
}
},
watch: {},
mounted() {
sessionStorage.setItem('returnFromAddPage', 'ActiveTemplateManagement')
this.getExpressInfo()
this.handleEditorReady()
},
methods: {
handleEditorReady() {
let defaultText = `一、活动期间:2024年1月20日~2024年2月29日。<br/>
二、活动范围:中海康城花园一期、中信领航里程花园小区福利群内客户。<br/>
三、活动产品:实物奖品 / 现金红包。<br/>
四、参与方式:打开微信,领取会员卡后,点击随机红包领取页即可领取。<br/>
五、参与限制:本次活动需授权手机号和微信昵称方可参与,仅限指定客户群内消费者参与,每个微信号仅可参与一次,实物奖品需提交资料后,前往物业管理处领取,现金红包在中奖后,金额会在24小时内到账。
现金红包中奖后请于24小时内领取,超过24小时逾期不领取,视为视为客户自愿放弃现金红包。<br/>
六、奖品内容:<br/>
本次活动总共2000+份礼品,综合中奖率99.99%,具体金额及对应数量如下:<br/>
1、特等奖:松下直发器(中奖后需前往物业管理处领取);<br/>
2、一等奖:韩国大宇多功能空气炸锅(中奖后需前往物业管理处领取);<br/>
3、二等奖:皮卡丘加湿器(中奖后需前往物业管理处领取);<br/>
4、三等奖:摩飞电蒸笼 或 B.Duck 儿童相机(中奖后需前往物业管理处领取);<br/>
5、四等奖:精选年货礼盒(中奖后需前往物业管理处领取);<br/>
6、五等奖:18.88元微信红包;<br/>
7、六等奖:8.88元微信红包;<br/>
8、七等奖:1.68元微信红包;<br/>
9、八等奖:0.68元微信红包;<br/>
七、奖品发放与领取<br/>
1、微信现金红包中奖消费者根据页面提示领取完成后红包将以转账的形式发送至您的微信账户。消费者成功领取后,现金红包金额将自动存入消费者的微信零钱中。逾期不领取的,视为消费者自愿放弃现金红包,系统将自动将该红包金额退回到活动方账户,且活动方不对此作任何形式的补偿。<br/>
2、若微信红包发放或领取过程中出现被微信平台系统自动拦截或因其他非活动方原因导致消费者无法领取微信红包的(包括但不限于因消费者微信账号活跃度低;朋友圈互动、好友关系较少;有过不正当手段刷奖记录;红包领取次数超过上限;未绑定或绑定的银行卡无法接收红包金额等),均不视为活动方的过错,且活动方将不作任何形式的补偿。如遇突发情况(如服务器异常等)导致红包的发放或领取失败,活动方将视具体情况为中奖的消费者安排补发,具体请留意并按照微信平台的提示进行操作领取。<br/>
八、注意事项<br/>
1、请在参加本活动前仔细阅读本规则的各项条款,如果消费者参加了本活动,则视为消费者已理解并同意本规则中的所有条款。<br/>
2、如消费者中奖后未按照活动提示操作或未在活动期间和/或兑奖期间内参与活动、进行奖品的抽取、领取、兑换的,均视为消费者自愿放弃参与活动和/或领取奖品,奖项自动失效,活动方不作任何形式的补偿。<br/>
3、本活动期间和/或兑奖期间内,如发现消费者存在违法违规行为(包括但不限于恶意套取资金、使用外挂或机器作弊、虚假交易,或其他违反诚实信用原则等行为),或在购买产品后的奖品抽取、领取、兑换中使用任何不正当的手段(包括但不限于软件作弊、通过系统漏洞、利用黑客工具等)获取中奖机会的,则活动方有权采取取消该消费者参加本活动的资格、取消该消费者领取奖品的资格、收回已发放的奖品、追究该消费者法律责任等一项或多项措施。如因消费者原因导致活动方或其他第三方遭受任何处罚或产生损失的,由消费者承担。<br/>
4、消费者需自行承担在参加本次促销活动中发生的费用,包括网络服务费、电话费、交通费及其他费用。<br/>
5、如遇不可抗力事件,包括但不限于地震、台风、洪水、火灾、战争、罢工、暴动、政府行为、疫情等,活动方有权取消、修改、暂停、提前终止本次活动且不作任何形式的补偿。<br/>
6、在法律允许的范围内,活动方有权对本活动规则进行调整,具体以调整后的活动规则为准。调整后的活动规则将公布在活动方的微信小程序上,公布后依法生效。如活动方调整活动规则后,消费者继续参与活动的,则视为消费者知悉并同意接受调整后的活动规则;如果消费者不接受上述活动规则的调整,可选择放弃参与变更规则后的活动。`
// 确保编辑器已初始化
this.$nextTick(() => {
this.$refs.textBox.setEdit(defaultText);
});
},
getExpressInfo(){
this.$apis.redenvelope.expressConfigList({}
).then(res => {
this.expressList = res.map(item => ({'describeMsg':item.describeMsg,'describeId':item.describeId}))
})
},
validateForm() {
return new Promise((resolve, reject) => {
this.formRef().validate((valid) => {
if (valid) {
resolve();
} else {
// reject(new Error('缺少必填内容'));
}
});
});
},
writeChange(val) {
this.configForm.ruleDescribe = val
},
change(id) {
this.configForm.merchantName = ''
if (id) {
this.configForm.merchantName = this.merchantObj.data.find(e => e.confId == id).confName
}
},
formRef() {
return this.$refs.formRef.$refs.formRef
},
handleCancel() {
this.$router.back()
},
handleSave() {
this.validateForm().then(() => {
const {describeId,pageTheme,ruleDescribe,...params} = this.configForm
// 页面主题判断
if (!params.theme1) return this.$message.error('请填写页面主题');
// 判断富文本编辑器是不是只有空格(不改变ruleDescribe的值)
const plainTextCheck = ruleDescribe.replace(/ |<[^>]+>/g, ' ').replace(/\s+/g, ' ');
if (plainTextCheck.trim() === '') {
this.$message.error('活动规则描述不能只输入空格');
return;
}
// 如果不是只有空格,使用原始的ruleDescribe
params.ruleDescribe = ruleDescribe;
params.writeInfoList = [...describeId];
this.$apis.redenvelope.newActivityTemplate(params).then(res => {
if (res.code == 0){
this.$message.success('新建活动模板成功');
this.handleCancel()
}else{
this.$message.error(res.message);
}
})
}).catch(error => {
this.$message.error(error.message);
});
}
},
}
</script>
<style scoped lang="scss">
.new-tmp{
background: #fff;
h2{
padding: 10px 0 0 16px;
}
.activity-wrap{
display: flex;
.cover-tips{
position: absolute;
color: #999999;
left: 90px;
top: 60px;
}
.activity-content {
width: 70%;
padding: 20px;
.page-theme{
.el-form-item{
display: flex;
width: 340px;
/deep/.el-form-item__label{
margin-right: 8px;
}
}
}
.physical-winning {
background: #F9F9F9;
width: 650px;
padding: 10px;
.el-form-item{
/deep/.el-form-item__label{
width: auto;
}
}
/deep/ .checkboxs-setting{
width:600px;
}
}
}
.redEnvelope-bg{
position: relative;
width: 500px;
height: 800px;
background-image: url("./../../../../assets/redEnvelope-bg.png");
background-repeat: no-repeat;
img{
position: absolute;
width: 98px;
height: 33px;
top: 55px;
left:28px;
}
p{
position: absolute;
font-family: SourceHanSansCN-Heavy;
font-weight: 900;
font-size: 35.5px;
letter-spacing: 0;
text-align: center;
background: linear-gradient(to bottom, #FFFFFF, #FFD58E); /* 设置背景渐变 */
-webkit-background-clip: text; /* Safari/Chrome */
-webkit-text-fill-color: transparent; /* Safari/Chrome */
color: transparent; /* Firefox/Opera */
text-shadow: 0 1px 3px #ffe9e9de;
top: 100px;
left: 45px;
}
.p2{
top: 150px;
}
}
}
}
</style>