messageShow.js 783 B

123456789101112131415161718192021222324
  1. import axios from '~plugins/axios'
  2. export const actions = {
  3. // 获取未读消息数量
  4. loadMessageCount({ commit }, params = {}) {
  5. commit('messageCount/REQUEST_MESSAGE_COUNT')
  6. return axios.get('/messages/count', {params})
  7. .then(response => {
  8. commit('messageCount/REQUEST_MESSAGE_COUNT_SUCCESS', response.data)
  9. }, err => {
  10. commit('messageCount/REQUEST_MESSAGE_COUNT_FAILURE', err)
  11. })
  12. },
  13. // 获取全部消息
  14. getAllMessage({ commit }, params = {}) {
  15. commit('messageList/REQUEST_MESSAGE_LIST')
  16. return axios.get('/messages', {params})
  17. .then(response => {
  18. commit('messageList/GET_MESSAGE_LIST_SUCCESS', response.data)
  19. }, err => {
  20. commit('messageList/GET_MESSAGE_LIST_FAILURE', err)
  21. })
  22. }
  23. }