messageShow.js 843 B

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