index.vue
20.6 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
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
<template>
<div class="liveRoomPage">
<nav>
<el-form :inline="true" :model="listQuery" class="demo-form-inline">
<el-form-item label="状态:" label-width="100px">
<el-radio-group v-model="listQuery.state" @change="searchTypeChange">
<el-radio-button
v-for="item in searchType"
:key="item.value"
:label="item.value"
>
{{ item.label }}
</el-radio-button>
</el-radio-group>
</el-form-item>
<br>
<el-form-item label="关键字:" label-width="100px">
<el-input
v-model="listQuery.search"
placeholder="请输入商品名称/ID"
class="inputKeyWord"
style="width:400px;"
>
<el-button slot="append" icon="el-icon-search" @click="getList" />
</el-input>
</el-form-item>
<el-form-item>
<el-button style="margin-left: 20px" type="success" @click="addPro">添加直播商品</el-button>
</el-form-item>
</el-form>
</nav>
<section>
<el-table
ref="multipleTable"
:data="roomList"
border
:header-cell-style="{ background: '#EEF3FF', color: '#333333' }"
tooltip-effect="dark"
style="width: 100%"
>
<el-table-column prop="id" label="直播商品ID" />
<el-table-column prop="productName" label="商品名称" />
<el-table-column prop="productId" label="关联商品ID" />
<el-table-column prop="productImage" width="100" label="商品图片">
<template slot-scope="scope">
<img
style="width: 40px; height: 40px"
:src="scope.row.productImage"
alt=""
>
</template>
</el-table-column>
<el-table-column prop="startTime" label="商品小程序路径">
<template slot-scope="scope">
/pages_category_page1/goodsModule/goodsDetails?productId=
{{ scope.row.productId }}
</template>
</el-table-column>
<el-table-column label="价格类型" width="100">
<template slot-scope="scope">
<el-tag v-if="scope.row.priceType == 1">
一口价
</el-tag>
<el-tag v-if="scope.row.priceType == 2" type="success">
价格区间
</el-tag>
<el-tag v-if="scope.row.priceType == 3" type="danger">
折扣价
</el-tag>
</template>
</el-table-column>
<el-table-column label="审核状态" width="100">
<template slot-scope="scope">
<el-tag v-if="scope.row.state == 0" type="warning">
待审核
</el-tag>
<el-tag v-if="scope.row.state == 1" type="success">
已通过
</el-tag>
<el-tag v-if="scope.row.state == 2" type="danger">
未通过
</el-tag>
</template>
</el-table-column>
<el-table-column label="微信审核状态" width="120">
<template slot-scope="scope">
<el-tag v-if="scope.row.wxAuditStatus == 0" type="info">
未审核
</el-tag>
<el-tag v-if="scope.row.wxAuditStatus == 1" type="success">
审核中
</el-tag>
<el-tag v-if="scope.row.wxAuditStatus == 2" type="warning">
审核通过
</el-tag>
<el-tag v-if="scope.row.wxAuditStatus == 3" type="danger">
审核失败
</el-tag>
<el-tag v-if="scope.row.wxAuditStatus == -1">
未提交
</el-tag>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间">
<!-- 暂无 -->
</el-table-column>
<el-table-column
fixed="right"
label="操作"
width="200"
show-overflow-tooltip
>
<template slot-scope="scope">
<div class="btnList">
<el-button
v-if="scope.row.state != 1"
type="text"
@click="edit(scope.row)"
>编辑</el-button>
<el-button type="text" @click="seeMore(scope.row)">详情</el-button>
<el-button type="text" @click="del(scope.row)">删除</el-button>
<el-button
v-if="scope.row.state == 2"
type="text"
@click="reExamine(scope.row)"
>重新审核</el-button>
</div>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination
:current-page="listQuery.page"
:page-sizes="[10, 20, 50, 100]"
:page-size="10"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</section>
<el-dialog
:title="'直播间商品信息'"
:visible.sync="DetailsShow"
width="50%"
center
:close-on-click-modal="false"
>
<el-row>
<el-col :span="12">
<el-form :model="ProForm" size="mini" label-width="180px">
<el-form-item label="商品名称:">
{{ ProForm.productName }}
</el-form-item>
<el-form-item label="商品库存:">
{{ ProForm.stockNumber }}
</el-form-item>
<el-form-item label="商品图片:">
<img
style="width: 120px; height: 120px"
:src="ProForm.productImage"
alt=""
srcset=""
>
</el-form-item>
</el-form>
</el-col>
<el-col :span="12">
<el-form :model="ProForm" size="mini" label-width="180px">
<el-form-item label="商品价格:">
<span v-if="ProForm.priceType == 1">
一口价: {{ ProForm.fixedPrice }}
</span>
<span v-if="ProForm.priceType == 2">
最低价: {{ ProForm.minPrice }} - 最高价:{{ ProForm.maxPrice }}
</span>
<span v-if="ProForm.priceType == 3">
现价: {{ ProForm.marketPrice }}
</span>
</el-form-item>
</el-form>
</el-col>
</el-row>
<div v-if="ProForm.remark" style="text-align: center; margin-top: 20px">
<span style="color: red">备注:</span>
{{ ProForm.remark }}
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="DetailsShow = false">关 闭</el-button>
</span>
</el-dialog>
<!-- 添加直播间商品 -->
<el-dialog
:title="proShowState == 1 ? '新建直播间商品' : '编辑直播间商品'"
:visible.sync="addProShow"
width="50%"
center
:close-on-click-modal="false"
>
<div v-if="proShowState == 1">
<el-form :inline="true" :model="productForm" class="demo-form-inline">
<el-form-item class="inputWide" label="关键字:">
<el-input v-model="productForm.search" placeholder="请输入内容" />
</el-form-item>
<el-form-item>
<el-button
type="primary"
plai
@click="getClassifyGetAll"
>查询</el-button>
</el-form-item>
</el-form>
<el-table
ref="singleTable"
border
:data="proTableData"
highlight-current-row
style="width: 100%"
@current-change="selProduct"
>
<el-table-column property="productId" label="商品ID" />
<el-table-column property="productImage" label="商品主图">
<template slot-scope="scope">
<img
style="width: 40px; height: 40px"
:src="scope.row.productImage"
alt=""
>
</template>
</el-table-column>
<el-table-column property="productName" label="商品名称" />
<el-table-column property="stockNumber" label="库存" />
</el-table>
<el-pagination
style="margin-top: 20px"
:current-page="productForm.page"
:page-sizes="[5, 10, 20, 50, 100]"
:page-size="5"
layout="total, sizes, prev, pager, next, jumper"
:total="proTotal"
@size-change="handleSizeChange1"
@current-change="handleCurrentChange1"
/>
</div>
<el-form
ref="form"
style="margin-top: 20px"
:model="form"
:rules="rules"
size="small"
label-width="100px"
>
<el-form-item
v-if="proShowState == 1"
label="选中的商品"
prop="productImage"
>
<div class="uploadWidth">
<el-upload
class="avatar-uploader"
:headers="headers"
:action="uploadUrl"
:show-file-list="false"
:on-success="handlePictureCardPreview1"
disabled
>
<img v-if="selImage" :src="selImage" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</div>
<span style="color: red">* 请选择商品商品</span>
</el-form-item>
<!-- <el-form-item v-if="proShowState!=2 || form.wxAuditStatus == -1" label="商品封面图" prop="productImage"> -->
<el-form-item label="商品封面图" prop="productImage">
<div class="uploadWidth">
<el-upload
class="avatar-uploader"
:headers="headers"
:action="uploadUrl"
:show-file-list="false"
:before-upload="beforeAvatarUpload"
:on-success="handlePictureCardPreview1"
>
<img
v-if="form.productImage"
:src="form.productImage"
class="avatar"
>
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</div>
<span style="color: red">* 图片规则:图片尺寸最大300像素*300像素</span>
</el-form-item>
<!-- <el-form-item v-if="proShowState!=2 || form.wxAuditStatus == -1" label="商品库存" prop="stockNumber"> -->
<el-form-item label="商品库存" prop="stockNumber">
<el-input
v-model="form.stockNumber"
type="number"
style="width: 60%"
/>
</el-form-item>
<!-- <el-form-item v-if="proShowState!=2 || form.wxAuditStatus == -1" label="商品名称" prop="productName"> -->
<el-form-item label="商品名称" prop="productName">
<el-input v-model="form.productName" style="width: 60%" />
</el-form-item>
<el-form-item label="价格类型" prop="priceType">
<el-radio-group v-model="form.priceType">
<el-radio :label="1">一口价</el-radio>
<el-radio :label="2">价格区间</el-radio>
<el-radio :label="3">折扣价</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="价格" prop="title">
<el-input-number v-if="form.priceType == 1" v-model="form.fixedPrice" :min="0" :precision="2" :step="1" placeholder="一口价" style="width:250px" />
<el-input-number v-if="form.priceType == 2" v-model="form.minPrice" :min="0" :precision="2" :step="1" placeholder="最低价" style="width:250px" />
<el-input-number v-if="form.priceType == 2" v-model="form.maxPrice" :min="0" :precision="2" :step="1" placeholder="最高价" style="margin-left:20px;width:250px" />
<el-input-number v-if="form.priceType == 3" v-model="form.marketPrice" :min="0" :precision="2" :step="1" placeholder="折扣价" style="width:250px" />
<!-- <el-input
v-if="form.priceType == 1"
v-model="form.fixedPrice"
placeholder="一口价"
style="width: 160px"
/>
<el-input
v-if="form.priceType == 2"
v-model="form.minPrice"
placeholder="最低价"
style="width: 160px"
/>
<el-input
v-if="form.priceType == 2"
v-model="form.maxPrice"
style="margin-left: 20px; width: 160px"
placeholder="最高价"
/>
<el-input
v-if="form.priceType == 3"
v-model="form.marketPrice"
placeholder="折扣价"
style="width: 160px"
/> -->
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="addProShow = false">取 消</el-button>
<el-button
v-if="proShowState == 1"
type="success"
@click="addProSubmit"
>添 加</el-button>
<el-button
v-if="proShowState == 2"
type="primary"
@click="editProSubmit"
>保 存</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { getClassifyGetAll } from '@/api/commodity';
import {
liveProGetAll,
delLiveProduct,
addProductSave,
editProductSave,
ProReExamine,
} from '@/api/live';
import { WXuploadUrl } from '@/utils/request';
import { getToken } from '@/utils/auth';
export default {
data() {
return {
uploadUrl: WXuploadUrl,
headers: {
'Authorization-business': getToken()
},
searchType: [
{
label: '全部',
value: null,
},
{
label: '待审核',
value: 0,
},
{
label: '审核已通过',
value: 1,
},
{
label: '审核未通过',
value: 2,
},
],
listQuery: {
state: null,
search: '',
page: 0,
pageSize: 10,
shopId: null,
},
proListQuery: {
liveId: null,
page: 0,
pageSize: 10,
shopId: null,
},
roomList: [], // 直播间列表
roomProList: [], // 直播相关产品列表
total: 0,
DetailsShow: false,
auditShow: false,
activeName: 'first',
disabled: false,
ProForm: {}, // 添加直播间
liveRules: [], // 直播间添加验证
auditForm: {},
auditFormState: 1,
addProShow: false,
proShowState: 1,
productForm: {
search: '', // 搜索字段
shelveState: 1, // 上架状态 1-上架 0-不上架 null-全部
stock: 1, // 库存状态 1-有库存 0-无库存 null-全部
page: 1, // 当前页
pageSize: 5,
},
proTotal: 0,
proTableData: [],
form: {
productImage: null,
productMediaId: null,
stockNumber: null,
productName: null,
priceType: 1,
productId: null,
total: null,
},
rules: {
stockNumber: [
{ required: true, message: '商品库存不能为空', trigger: 'blur' },
],
productName: [
{ required: true, message: '商品名称不能为空', trigger: 'blur' },
],
},
selImage: '', // 选中的商品图片
};
},
created() {
this.getList();
},
methods: {
// 获取商品列表
async getList() {
const res = await liveProGetAll(this.listQuery);
this.total = res.data.total;
this.roomList = res.data.list;
},
seeMore(row) {
this.ProForm = row;
this.DetailsShow = true;
},
del(row) {
this.$confirm('是否确认删除该内容?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
delLiveProduct(row)
.then((res) => {
this.closeDialogVisible = false;
this.$message.success('删除成功');
this.getList();
})
.catch(err => {
this.$message.error(err.msg);
})
});
},
// 选择查询状态
searchTypeChange(e) {
this.listQuery.state = e;
this.getList();
},
// 分页
handleCurrentChange(e) {
this.listQuery.page = e;
this.getList();
},
handleSizeChange(e) {
this.listQuery.pageSize = e;
this.getList();
},
// 添加商品
addPro() {
this.proShowState = 1;
this.addProShow = true;
this.getClassifyGetAll();
this.selImage = ''
this.form = {
productImage: null,
stockNumber: null,
productName: null,
priceType: 1,
productId: null,
total: null,
};
},
edit(row) {
this.proShowState = 2;
this.addProShow = true;
const data = Object.assign({}, row)
this.form = data;
},
async getClassifyGetAll() {
const res = await getClassifyGetAll(this.productForm);
this.proTotal = res.data.total;
this.proTableData = res.data.list;
},
handleSizeChange1(e) {
this.productForm.pageSize = e;
this.getClassifyGetAll();
},
handleCurrentChange1(e) {
this.productForm.page = e;
this.getClassifyGetAll();
},
handlePictureCardPreview1(file) {
if (file.code === '200') {
this.form.productImage = file.data.url;
this.form.productMediaId = file.data.mediaId
} else {
this.$message.error('图片超出规定像素,上传失败!')
}
},
async beforeAvatarUpload(file) {
const istype = file.type === 'image/jpeg' || file.type === 'image/png'
const isLt2M = file.size / 1024 / 1024 < 2;
const isSize = await new Promise(function(resolve, reject) {
const width = 300
const height = 300
const _URL = window.URL || window.webkitURL
const image = new Image()
image.onload = function() {
const valid =
image.width <= width &&
image.height <= height
valid ? resolve() : reject()
}
image.src = _URL.createObjectURL(file)
}).then(
() => {
return file
},
() => {
this.$message.error(
'上传的图片最大分辨率不超过300*300'
)
return Promise.reject(false)
}
)
if (!istype) {
this.$message.error('上传图片只能是 JPG 或 PNG格式!')
}
if (!isLt2M) {
this.$message.error('上传图片大小不能超过 2MB!')
}
return isSize && istype && isLt2M
},
// 选中的商品
selProduct(e) {
console.log(e);
this.selImage = e.productImage;
this.form.productId = e.productId;
this.form.total = e.stockNumber;
this.form.stockNumber = e.stockNumber;
this.form.productImage = e.productImage;
this.form.productName = e.productName;
},
addProSubmit() {
addProductSave(this.form).then((res) => {
console.log(res);
if (res.code === '') {
this.addProShow = false;
this.getList();
this.$message.success('添加成功');
}
});
},
editProSubmit() {
editProductSave(this.form).then((res) => {
console.log(res);
if (res.code === '') {
this.addProShow = false;
this.getList();
this.$message.success('编辑成功');
}
});
},
// 重新审核
reExamine(row) {
ProReExamine({ id: row.id }).then((res) => {
if (res.code === '') {
this.$message.success('已重新提交');
this.getList();
}
});
},
},
};
</script>
<style lang="scss" scpoed>
.liveRoomPage {
padding: 32px 20px;
nav {
.search {
line-height: 40px;
margin: 10px 0;
display: flex;
.title {
min-width: 120px;
text-align: right;
}
.inputKeyWord {
max-width: 400px;
min-width: 200px;
}
}
}
section {
padding: 12px 8px;
background-color: #fff;
.pagination {
margin-top: 30px;
}
}
}
.search {
line-height: 40px;
margin: 10px 0;
display: flex;
.title {
min-width: 120px;
text-align: right;
}
.inputKeyWord {
max-width: 400px;
min-width: 200px;
}
}
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409eff;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 140px;
height: 140px;
line-height: 140px;
text-align: center;
}
.avatar {
width: 140px;
height: 140px;
display: block;
}
</style>