From e48475bba3024e4fdc03ce29dc3f43b9b97755b6 Mon Sep 17 00:00:00 2001 From: x ronger Date: Sun, 2 Aug 2020 19:21:51 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=B6=88=E6=81=AF=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/common/notification/list.vue | 91 +++++++++++++++++++++++++ pages/notification.vue | 44 ++++++++++++ store/notification.js | 52 ++++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 components/common/notification/list.vue create mode 100644 pages/notification.vue create mode 100644 store/notification.js diff --git a/components/common/notification/list.vue b/components/common/notification/list.vue new file mode 100644 index 0000000..c97a07a --- /dev/null +++ b/components/common/notification/list.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/pages/notification.vue b/pages/notification.vue new file mode 100644 index 0000000..67c794a --- /dev/null +++ b/pages/notification.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/store/notification.js b/store/notification.js new file mode 100644 index 0000000..3be3bbe --- /dev/null +++ b/store/notification.js @@ -0,0 +1,52 @@ +export const NOTIFICATION_API_PATH = '/api/notification' + +const getDefaultListData = () => { + return { + notifications: [], + pagination: {} + } +} + +export const state = () => { + return { + list: { + fetching: false, + data: getDefaultListData() + } + } +} + +export const mutations = { + // 消息列表 + updateListFetching(state, action) { + state.list.fetching = action + }, + updateListData(state, action) { + state.list.data = action + } +} + +export const actions = { + // 获取消息列表 + fetchList({commit}, params = {}) { + // 清空已有数据 + commit('updateListData', getDefaultListData()) + commit('updateListFetching', true) + let data = { + page: params.page || 1 + } + + return this.$axios + .$get(`${NOTIFICATION_API_PATH}/all`, { + params: data + }) + .then(response => { + commit('updateListFetching', false); + commit('updateListData', response); + }) + .catch(error => { + console.log(error); + commit('updateListFetching', false); + }); + } +}