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); + }); + } +}