对接会员消息

master
pikachu 2021-06-29 08:25:02 +08:00
parent 75e302bc12
commit 995b0d65fb
2 changed files with 153 additions and 16 deletions

View File

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

View File

@ -1,6 +1,21 @@
<template> <template>
<div class="msg-list"> <div class="msg-list">
<card _Title="我的消息" :_Tabs="status" :_Size="16" /> <card _Title="我的消息" :_Tabs="status" :_Size="16" @_Change="statusChange"/>
<Table :columns="messageColumns" :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> </div>
</template> </template>
<script> <script>
@ -8,27 +23,151 @@ import {memberMsgList, readMemberMsg, delMemberMsg} from '@/api/member.js'
export default { export default {
data() { data() {
return { return {
list: [], // messageData: {}, //
status: ['未读', '已读', '回收站'], status: ['未读', '已读', '回收站'],
params: { // params: { //
pageNumber: 1, pageNumber: 1,
pageSize: 10, pageSize: 10,
status: '' status: 'UN_READY'
}, },
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: { 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 () { // getList () { //
memberMsgList(this.params).then(res => { memberMsgList(this.params).then(res => {
if (res.success) { if (res.success) {
this.list = res.result.records; this.messageData = res.result;
} }
}) })
}, },
setRead (id) { // //
setRead (id) {
readMemberMsg(id).then(res => { 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 () { mounted () {
@ -37,5 +176,5 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
</style> </style>