index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import $request from '../lib/request.js';
  4. Vue.use(Vuex);
  5. const baseurl = 'http://192.168.0.45:18090';
  6. const api = {
  7. imgQuery: '/api/cms/imgnews/query',
  8. contentQuery: '/api/cms/contents/query',
  9. intactQuery: '/api/journal/intact/query',
  10. marketQuery: '/api/market/wares/query',
  11. };
  12. const state = () => ({
  13. imgList: [],
  14. contentList: [],
  15. intactLiost: [],
  16. details: {},
  17. marketList: []
  18. });
  19. const actions = {
  20. async imgQuery({ commit }) {
  21. const res = await $request.get(`${baseurl}${api.imgQuery}`);
  22. commit('imgQuery', res[1]?.data);
  23. return res;
  24. },
  25. async contentQuery({ commit }, payload) {
  26. const res = await $request.get(`${baseurl}${api.contentQuery}`, payload);
  27. commit('contentQuery', res[1]?.data);
  28. return res;
  29. },
  30. async intactQuery({ commit }, payload) {
  31. const res = await $request.get(`${baseurl}${api.intactQuery}`, payload);
  32. commit('intactQuery', res[1]?.data);
  33. return res[1]?.data.data;
  34. },
  35. async marketQuery ({ commit }, payload) {
  36. const res = await $request.get(`${baseurl}${api.marketQuery}`, payload);
  37. commit('marketQuery', res[1]?.data);
  38. return res[1]?.data.data;
  39. },
  40. };
  41. const mutations = {
  42. imgQuery(state, payload) {
  43. state.imgList = payload?.data;
  44. },
  45. contentQuery(state, payload) {
  46. state.contentList = payload?.data;
  47. },
  48. intactQuery(state, payload) {
  49. state.intactLiost = payload?.data;
  50. },
  51. marketQuery(state, payload) {
  52. state.marketList = payload?.data;
  53. },
  54. };
  55. export default new Vuex.Store({
  56. state,
  57. mutations,
  58. actions,
  59. modules: {}
  60. });