config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import store from '@/utils/store';
  2. export default {
  3. state: {
  4. level: store.get('level') || {},
  5. category: store.get('category') || [],
  6. festival: store.get('festival') || []
  7. },
  8. actions: {
  9. // 等级
  10. getLevel({ commit }) {
  11. return this.$service.level.list().then(res => {
  12. commit('SET_LEVEL', res);
  13. return res;
  14. });
  15. },
  16. delLevel({ commit }) {
  17. commit('DEL_LEVEL');
  18. },
  19. // 分类
  20. getCategory({ commit }) {
  21. return this.$service.category.list().then(res => {
  22. commit('SET_CATEGORY', res);
  23. return res;
  24. });
  25. },
  26. delCategory({ commit }) {
  27. commit('DEL_CATEGORY');
  28. },
  29. // 节日
  30. getFestival({ commit }) {
  31. return this.$service.common.fest().then(res => {
  32. commit('SET_FESTIVAL', res);
  33. return res;
  34. });
  35. },
  36. delFestival({ commit }) {
  37. commit('DEL_FESTIVAL');
  38. }
  39. },
  40. mutations: {
  41. SET_LEVEL(state, val) {
  42. state.info = val;
  43. store.set('level', val);
  44. },
  45. DEL_LEVEL(state) {
  46. state.info = {};
  47. store.remove('level');
  48. },
  49. SET_CATEGORY(state, val) {
  50. state.info = val;
  51. store.set('category', val);
  52. },
  53. DEL_CATEGORY(state) {
  54. state.info = [];
  55. store.remove('category');
  56. },
  57. SET_FESTIVAL(state, val) {
  58. state.info = val;
  59. store.set('festival', val);
  60. },
  61. DEL_FESTIVAL(state) {
  62. state.info = [];
  63. store.remove('festival');
  64. }
  65. }
  66. };