center.vue
18.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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
<template>
<div class="live-room">
<div class="memberCardWrap" v-if="!(merchantModel==2 && accountLevel==1)">
<div class="cardBoxWrap">
<img src="@/assets/memberCard.png" alt="" />
<div class="masonry">
<img src="@/assets/masonry.png" alt="" />
</div>
<div class="memberCardName">{{ ruleForm.cardName }}</div>
</div>
<div class="cardDetail" v-if="!isShowEditWrap">
<div class="flex-1"> <p>{{ ruleForm.cardName }}</p>
<GLButton @click="openEditWrap" fn="编辑" mode="div"> <img src="@/assets/edit.png" class="editIcon" @click="openEditWrap" alt="" /></GLButton>
</div>
<!-- <img src="@/assets/edit.png" class="editIcon" @click="openEditWrap" alt="" /> -->
<div class="row">
<span>售价:</span>
<span class="price" v-if="ruleForm.price">¥{{ ruleForm.price }}</span>
</div>
<div class="row">
<span>市场价:</span>
<span class="price" v-if="ruleForm.marketPrice">¥{{ ruleForm.marketPrice }}</span>
</div>
<div class="row">
<span>会员权益使用地址:</span>
<span class="address ellipsis-1" :title="ruleForm.linkUrl">{{ ruleForm.linkUrl }}</span>
</div>
<el-button class="seeEquity" size="small" type="primary" @click="openDialog">查看权益</el-button>
</div>
<div class="cardDetail editForm" v-else>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="90px" class="demo-ruleForm" style="width: 500px">
<el-form-item label="会员卡名" prop="cardName" size="small">
<el-input v-model="ruleForm.cardName" size="small" class="cardNameInput" show-word-limit placeholder="请输入会员卡名" maxlength="15"></el-input>
</el-form-item>
<el-form-item label="售价" size="small" prop="price" style="width: 300px">
<el-input v-model="ruleForm.price" size="small" placeholder="请输入合理价格" @keyup.native="ruleForm.price = oninput(ruleForm.price)">
<!-- <template slot="append">元</template> -->
<span slot="suffix" class="suffix-label">元</span>
</el-input>
</el-form-item>
<el-form-item label="市场价" prop="marketPrice" size="small" style="width: 300px">
<!-- :onkeyup="(ruleForm.marketPrice = ruleForm.marketPrice.replace(/[^\-\d.]/g, ''))" -->
<el-input v-model="ruleForm.marketPrice" size="small" placeholder="请输入合理价格" @keyup.native="ruleForm.marketPrice = oninput(ruleForm.marketPrice)">
<!-- <template slot="append">元</template> -->
<span slot="suffix" class="suffix-label">元</span>
</el-input>
</el-form-item>
</el-form>
<el-button size="small" class="cancelBtn" @click="cancelEdit">取消</el-button>
<el-button size="small" class="saveBtn" type="primary" @click="submitRuleForm('ruleForm')">保存</el-button>
</div>
</div>
<p class="pageTitle" v-if="!(merchantModel==2 && accountLevel==1)">会员中心</p>
<div class="live-room container">
<el-form :inline="true" style="width: 100%" :model="searchForm" label-width="70px" label-position="right">
<el-row>
<el-form-item size="small" label="会员用户">
<el-input :size="size" v-model="searchForm.userInfo" placeholder="请输入会员用户或手机号" clearable></el-input>
</el-form-item>
<el-form-item size="small" label="门店" style="margin-left: -10px">
<el-input :size="size" v-model="searchForm.merchantName" placeholder="请输入门店" clearable></el-input>
</el-form-item>
<el-form-item size="small" label="状态" style="margin-left: -10px">
<el-select size="small" v-model="searchForm.status" placeholder="请选择">
<el-option v-for="item in memberCenterStatus" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue"></el-option>
</el-select>
</el-form-item>
</el-row>
<el-row>
<el-form-item size="small" label="会员类型">
<el-select size="small" v-model="searchForm.memberType" placeholder="请选择">
<el-option v-for="item in memberTypeLists" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue"></el-option>
</el-select>
</el-form-item>
<el-form-item size="small" label="开通日期" style="margin-left: -10px">
<el-date-picker :size="size" v-model="searchForm.daterange" type="daterange" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions || {}"></el-date-picker>
</el-form-item>
<el-form-item size="small" class="fr-mr0">
<el-button :size="size" type="primary" @click="handleSearch">查询</el-button>
<el-button :size="size" @click="handleReset">重置</el-button>
</el-form-item>
</el-row>
</el-form>
<GLTable ref="memberCenterRef" @setTableFinishFun="setTableFinishFun" :searchForm="searchFormTable" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
<span slot="accountName" slot-scope="scope">
<div>{{ scope.scope.accountName }}</div>
<div>{{ scope.scope.mobile }}</div>
</span>
</GLTable>
</div>
<glsx-dialog title="权益详情" width="712px" :noBtnOk="true" :noCancel="true" :noClose="false" typeName="primary" btnCancelLabel="关闭" btnSize="small" :isVisible="isDialogVisible" :showClose="false" @closeDialog="handleClose" @confirmDialog="handleClose">
<!-- <el-scrollbar> -->
<div class="modal-body">
<div class="equity-name">汽车权益</div>
<div class="equity-panel">
<div class="equity-item" v-for="(item, index) in merchantData.carServiceList" :key="index">
<div class="equity-item-icon"><img :src="item.equityIcon" /></div>
<div class="equity-item-name">{{ item.equityName }}</div>
<div class="equity-item-desc">{{ item.equityDesc }}</div>
</div>
</div>
<div v-for="(item, index) in merchantData.goodsServiceList" :key="index">
<div class="equity-name">{{ item.goodsCategory }}</div>
<div class="equity-panel">
<div class="equity-item" v-for="(v, xindex) in item.equityGoodsGroupDescDtos" :key="xindex">
<div class="equity-item-icon"><img :src="v.equityIcon" /></div>
<div class="equity-item-name">{{ v.equityName }}</div>
<div class="equity-item-desc">{{ v.equityDesc }}</div>
</div>
</div>
</div>
</div>
<!-- </el-scrollbar> -->
</glsx-dialog>
</div>
</template>
<script>
import glsxDialog from '@/components/glsx-dialog'
import { getCenterListApi, getMoreMerchant, getCardContent, updateCardContent } from '@/api/modules/center'
import { statusList, memberTypeList } from '@/common/constant'
export default {
components: {
glsxDialog
},
data() {
var checkPrice = (rule, value, callback) => {
// if (!value) {
// return callback(new Error('价格不能为空'))
// }
// setTimeout(() => {
// if (!Number.isInteger(value)) {
// callback(new Error('请输入数字值'))
// } else {
// if (value < 0) {
// callback(new Error('不能是负数'))
// } else {
// callback()
// }
// }
// }, 1000)
}
return {
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now() || time.getTime() < new Date('2017-12-31').getTime()
}
},
size: 'small',
getListApi: getCenterListApi,
searchForm: {
userInfo: '',
status: '',
merchantName: '',
memberType: ''
},
searchFormTable: {},
memberTypeLists: [
{
dictValue: '',
dictLabel: '全部'
},
{
dictValue: 1,
dictLabel: '正式会员'
},
{
dictValue: 2,
dictLabel: '试用会员'
}
],
memberCenterStatus: [
{
dictValue: '',
dictLabel: '全部'
},
{
dictValue: 1,
dictLabel: '生效中'
},
{
dictValue: 2,
dictLabel: '已失效'
}
],
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// 表格参数
tableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '会员用户',
prop: 'accountName',
width: '180',
addHtml: 'accountName'
// formatter: cellValue => {
// return cellValue.startTime + '-' + cellValue.endTime
// }
},
{
label: '会员类型',
prop: 'memberType',
formatter: cellValue => {
return this.baseDataList.memberTypeList.find(item => item.confId == cellValue.memberType).confName
}
},
{
label: '开通门店',
prop: 'merchantName'
},
{
label: '开通方式',
prop: 'activeTypeDesc'
},
{
label: '开通日期',
prop: 'activeTime'
// addHtml: 'activeTime'
},
{
label: '状态',
prop: 'status',
formatter: cellValue => {
return this.baseDataList.statusList.find(item => item.confId == cellValue.status).confName
}
}
]
},
baseDataList: {
statusList: statusList,
memberTypeList: memberTypeList
},
isShowEditWrap: false,
ruleForm: {
equityId: '',
cardName: '',
price: '',
marketPrice: '',
linkUrl: '',
tryAble: ''
},
copyRuleForm: {},
rules: {
cardName: [
{ required: true, message: '请输入会员卡名称', trigger: 'blur' },
{ min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }
],
price: [
{ required: true, message: '请输入价格', trigger: 'blur' }
// { validator: checkPrice, trigger: 'blur' }
]
// marketPrice: [{ validator: checkPrice, trigger: 'blur' }]
},
//权益 - 弹窗
isDialogVisible: false,
merchantData: {},
merchantId: 0,//记得改 glsxadmin:44184606
merchantModel: 1, //集团:1,门店:2
accountLevel: 0, //1,2,3,4工厂,省代,市代,门店
}
},
created() {
if (window.__POWERED_BY_QIANKUN__) {
//运行在qiankun容器中
this.merchantId = this.$globalState.session.merchantId
this.merchantModel = this.$globalState.session.merchantModel
this.accountLevel = this.$globalState.session.accountLevel
}
this.getCardContentFun()
},
mounted () {
},
methods: {
oninput(value) {
let str = value
let len1 = str.substr(0, 1)
let len2 = str.substr(1, 1) //如果第一位是0,第二位不是点,就用数字把点替换掉
if (str.length > 1 && len1 == 0 && len2 != '.') {
str = str.substr(1, 1)
} //第一位不能是.
if (len1 == '.') {
str = ''
}
if (len1 == '+') {
str = ''
}
if (len1 == '-') {
str = ''
} //限制只能输入一个小数点
if (Number(value) >= 99999) {
return (str = 99999)
}
if (str.indexOf('.') != -1) {
let str_ = str.substr(str.indexOf('.') + 1)
if (str_.indexOf('.') != -1) {
str = str.substr(0, str.indexOf('.') + str_.indexOf('.') + 1)
}
}
//正则替换
// (/[^\-\d.]/g, ''))"
str = str.replace(/[^\d.^]+/g, '') // 保留数字和小数点
str = str.replace(/^\D*([0-9]\d*\.?\d{0,2})?.*$/, '$1') // 小数点后只能输 2 位
return str
},
getCardContentFun() {
getCardContent({ merchantId: this.merchantId }).then(res => {
if(!res){
return
}
this.ruleForm.equityId = res.equityClassId
this.ruleForm.cardName = res.equityName
this.ruleForm.price = res.goodPrice
this.ruleForm.marketPrice = res.marketPrice
this.ruleForm.linkUrl = res.freeUrl
this.ruleForm.tryAble=res.tryAble
})
},
openEditWrap() {
this.copyRuleForm = JSON.parse(JSON.stringify(this.ruleForm))
this.isShowEditWrap = true
},
//点击取消编辑按钮
cancelEdit() {
this.ruleForm = this.copyRuleForm
this.isShowEditWrap = false
},
submitRuleForm(formName) {
this.$refs[formName].validate(valid => {
if (!valid) {
return
}
this.isShowEditWrap = false
let params = {}
params.id = this.ruleForm.equityId
params.cardClassName = this.ruleForm.cardName
params.price = this.ruleForm.price
params.marketPrice = this.ruleForm.marketPrice
params.tryAble = this.ruleForm.tryAble
updateCardContent(params).then(res => {
if (!res) {
return
}
this.$message.success('修改成功')
this.getCardContentFun()
})
})
},
beforeSearchFn() {
return new Promise((resolve, reject) => {
this.searchFormTable = JSON.parse(JSON.stringify(this.searchForm))
if (this.searchFormTable.daterange) {
this.searchFormTable.startTime = this.searchForm.daterange[0] + ' 00:00:00'
this.searchFormTable.endTime = this.searchForm.daterange[1] + ' 23:59:59'
} else {
if (this.searchFormTable.beginTime) delete this.searchFormTable.beginTime && delete this.searchFormTable.endTime
}
delete this.searchFormTable.daterange
resolve()
})
},
handleReset() {
this.searchForm = {}
this.handleSearch()
},
handleSearch() {
this.$refs.memberCenterRef.refreshTable()
},
setTableFinishFun() {
//接收到的数据为空
// if (!this.$refs.memberCenterRef.data.length) {
// this.$refs.memberCenterRef.setTableHeightFun()
// }
this.$refs.memberCenterRef.data.length ? (this.$refs.memberCenterRef.tableHeightValues = '') : this.$refs.memberCenterRef.setTableHeightFun()
},
handleClose() {
this.isDialogVisible = !this.isDialogVisible
},
openDialog() {
this.isDialogVisible = !this.isDialogVisible
getMoreMerchant({})
.then(res => {
this.merchantData = res
})
.catch(err => {
console.error('错误信息:', err)
})
}
}
}
</script>
<style lang="scss" scoped>
.memberCardWrap {
display: flex;
background-color: #fff;
height: 173px;
box-sizing: border-box;
margin: 20px 0px;
padding: 15px 20px;
box-shadow: 0 1px 5px 0 rgba(38, 38, 38, 0.1);
.cardBoxWrap {
position: relative;
.masonry {
position: absolute;
top: 40px;
left: 32px;
}
.memberCardName {
position: absolute;
font-size: 15px;
color: #8e5310;
font-weight: 700;
top: 54px;
left: 88px;
}
}
.cardDetail {
height: 129px;
width: calc(100% - 350px);
padding-top: 8px;
margin-left: 10px;
position: relative;
.seeEquity {
position: absolute;
right: 0;
bottom: 14px;
}
.cancelBtn {
position: absolute;
right: 100px;
bottom: 0;
padding: 8px 30px;
}
.saveBtn {
position: absolute;
right: 0;
bottom: 0;
padding: 8px 30px;
}
.editIcon {
margin-left: 10px;
vertical-align: middle;
cursor: pointer;
}
.flex-1{
display: flex;
p {
display: inline-block;
font-weight: 600;
color: #333333;
font-size: 16px;
margin: 0;
}
}
.row {
margin-top: 15px;
font-weight: 400;
font-size: 14px;
span:first-child {
color: #333;
}
.price {
color: #eb4e4e;
}
.address {
display: inline-block;
vertical-align: bottom;
max-width: calc(100% - 220px);
color: #989898;
}
}
}
.editForm {
padding-top: 0px;
.cardNameInput {
width: 423px;
}
}
}
.pageTitle {
position: relative;
padding: 0 0px;
height: 20px;
font-size: 20px;
font-weight: 700;
color: #333333;
line-height: 20px;
letter-spacing: 1px;
}
.el-form-item {
margin-bottom: 15px;
}
.el-range-editor.is-active,
.el-range-editor.is-active:hover {
border-color: #5850ff;
width: 215px;
}
.el-range-editor--small.el-input__inner {
width: 215px;
}
/deep/ .container .el-input--small .el-input__inner {
width: 215px;
}
/deep/ .el-dialog__header .el-dialog__title {
font-size: 16px;
color: #000;
font-weight: 700;
height: 24px;
line-height: 24px;
}
// ::v-deep .el-dialog__body {
// border-top: 1px solid #e6e6e6;
// border-bottom: 1px solid #e6e6e6;
// padding: 20px 25px;
// }
/deep/.el-dialog__body {
border-top: 1px solid #e6e6e6;
border-bottom: 1px solid #e6e6e6;
// padding: 20px 45px;
padding: 20px 20px 20px 45px;
.modal-body {
// overflow: auto;
max-height: 400px;
}
.equity-panel {
display: grid;
grid-template-columns: repeat(5, 1fr);
}
.equity-item {
display: flex;
flex-direction: column;
align-items: center;
color: #999;
margin-bottom: 15px;
}
.equity-name {
font-size: 15px;
font-weight: 700;
margin: 12px 0px;
color: #000;
height: 24px;
line-height: 24px;
}
.equity-item-icon {
width: 46px;
height: 46px;
margin-bottom: 10px;
}
.equity-item-icon img {
width: 46px;
height: 46px;
border-radius: 50%;
}
.equity-item-name {
font-size: 14px;
width: 80px;
text-align: center;
color: #282829;
font-weight: 400;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
margin-bottom: 10px;
}
.equity-item-desc {
font-size: 12px;
width: 80px;
text-align: center;
color: #fc5b32;
font-weight: 400;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
}
/deep/ .el-dialog__footer {
padding: 20px;
text-align: center;
}
</style>