liveroom.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import _ from 'lodash';
  4. Vue.use(Vuex);
  5. const api = {
  6. liveroomInfo: `/api/train/liveroom`,
  7. personCount: `/api/train/liveroom/personcount`,
  8. notice: `/api/train/liveroom/sendmsg`,
  9. };
  10. const state = () => ({});
  11. const mutations = {};
  12. const actions = {
  13. async query({ commit }, { skip = 0, limit, ...info } = {}) {
  14. const res = await this.$axios.$get(`${api.liveroomInfo}`, { skip, limit, ...info });
  15. return res;
  16. },
  17. async create({ commit }, payload) {
  18. const res = await this.$axios.$post(`${api.liveroomInfo}`, payload);
  19. return res;
  20. },
  21. async fetch({ commit }, payload) {
  22. const res = await this.$axios.$get(`${api.liveroomInfo}/${payload}`);
  23. return res;
  24. },
  25. async update({ commit }, { id, ...data }) {
  26. const res = await this.$axios.$post(`${api.liveroomInfo}/update/${id}`, data);
  27. return res;
  28. },
  29. async delete({ commit }, payload) {
  30. const res = await this.$axios.$delete(`${api.liveroomInfo}/${payload}`);
  31. return res;
  32. },
  33. async personCount({ commit }, payload) {
  34. const res = await this.$axios.$post(`${api.personCount}`, payload);
  35. return res;
  36. },
  37. async notice({ commit }, payload) {
  38. const res = await this.$axios.$post(`${api.notice}`, payload);
  39. return res;
  40. },
  41. };
  42. export default {
  43. namespaced: true,
  44. state,
  45. mutations,
  46. actions,
  47. };