!4 对接会员消息

Merge pull request !4 from chopper711/qiuqiu
master
chopper711 2021-06-29 01:05:55 +00:00 committed by Gitee
commit fe6ada46d7
2 changed files with 174 additions and 16 deletions

View File

@ -457,23 +457,21 @@ export function memberMsgList (params) {
* 设置消息为已读
* @param {String} messageId 消息id
*/
export function readMemberMsg (params) {
export function readMemberMsg (id) {
return request({
url: `/buyer/member/message`,
url: `/buyer/member/message/${id}`,
method: Method.PUT,
needToken: true,
params
needToken: true
});
}
/**
* 删除会员消息
* @param {String} messageId 消息id
*/
export function delMemberMsg (params) {
export function delMemberMsg (id) {
return request({
url: `/buyer/member/message`,
url: `/buyer/member/message/${id}`,
method: Method.DELETE,
needToken: true,
params
needToken: true
});
}

View File

@ -1,6 +1,22 @@
<template>
<div class="msg-list">
<card _Title="我的消息" :_Tabs="status" :_Size="16" />
<card _Title="我的消息" :_Tabs="status" :_Size="16" @_Change="statusChange"/>
<Table v-if="params.status != 'ALREADY_REMOVE' " :columns="messageColumns" :data="messageData.records"></Table>
<Table v-if="params.status == 'ALREADY_REMOVE' " :columns="messageDelColumns" :data="messageData.records"></Table>
<!-- 分页 -->
<Page
style="float:right;margin-top:10px"
:current="params.pageNumber"
:total="messageData.total"
:page-size="params.pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="[10, 20, 50]"
size="small"
show-total
show-elevator
></Page>
</div>
</template>
<script>
@ -8,27 +24,171 @@ import {memberMsgList, readMemberMsg, delMemberMsg} from '@/api/member.js'
export default {
data() {
return {
list: [], //
messageData: {}, //
status: ['未读', '已读', '回收站'],
params: { //
pageNumber: 1,
pageSize: 10,
status: ''
status: 'UN_READY'
},
messageDelColumns: [ // table
{
title: '消息标题',
key: 'title',
align: 'left',
tooltip: true,
},
{
title: '消息内容',
key: 'content',
align: 'left',
tooltip: true
},
{
title: '发送时间',
key: 'createTime',
align: 'left',
width: 240
},
],
messageColumns: [ // table
{
title: '消息标题',
key: 'title',
align: 'left',
tooltip: true,
},
{
title: '消息内容',
key: 'content',
align: 'left',
tooltip: true
},
{
title: '发送时间',
key: 'createTime',
align: 'left',
width: 240
},
{
title: '操作',
key: 'action',
align: 'center',
fixed: 'right',
width: 150,
render: (h, params) => {
if (params.row.status === 'UN_READY') {
return h('div', [
h(
'Button',
{
props: {
type: 'info',
size: 'small'
},
style: {
marginRight: '5px'
},
on: {
click: () => {
this.setRead(params.row.id);
}
}
},
'已读'
), h(
'Button',
{
props: {
size: 'small',
type: 'error'
},
on: {
click: () => {
this.removeMessage(params.row.id);
}
}
},
'删除'
)
]);
} else if (params.row.status === 'ALREADY_READY') {
return h('div', [
h(
'Button',
{
props: {
size: 'small',
type: 'error'
},
on: {
click: () => {
this.removeMessage(params.row.id);
}
}
},
'删除'
)
]);
} else {
}
}
}
]
}
},
methods: {
//
statusChange (index) {
if (index === 0) { this.params.status = 'UN_READY' }
if (index === 1) { this.params.status = 'ALREADY_READY' }
if (index === 2) { this.params.status = 'ALREADY_REMOVE' }
this.getList()
},
//
changePage (v) {
this.params.pageNumber = v;
this.getList();
},
//
changePageSize (v) {
this.params.pageSize = v;
this.getList();
},
getList () { //
memberMsgList(this.params).then(res => {
if (res.success) {
this.list = res.result.records;
this.messageData = res.result;
}
})
},
setRead (id) { //
//
setRead (id) {
readMemberMsg(id).then(res => {
if (res.success) {
this.getList()
}
})
},
//
removeMessage (id) {
this.$Modal.confirm({
title: '确认删除',
//
content: '确认要删除此消息?',
loading: true,
onOk: () => {
//
delMemberMsg(id).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success('消息已成功放入回收站');
this.getList();
}
});
},
});
}
},
mounted () {