config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. usage: store.get('usage') || []
  8. },
  9. actions: {
  10. // 等级
  11. getLevel({ commit }) {
  12. return this.$service.level.list().then(res => {
  13. commit('SET_LEVEL', res);
  14. return res;
  15. });
  16. },
  17. delLevel({ commit }) {
  18. commit('DEL_LEVEL');
  19. },
  20. // 分类
  21. getCategory({ commit }) {
  22. return this.$service.category.list().then(res => {
  23. commit(
  24. 'SET_CATEGORY',
  25. res.filter(e => e.status != '0')
  26. );
  27. return res;
  28. });
  29. },
  30. delCategory({ commit }) {
  31. commit('DEL_CATEGORY');
  32. },
  33. // 节日
  34. getFestival({ commit }) {
  35. return this.$service.common.fest().then(res => {
  36. commit('SET_FESTIVAL', res);
  37. return res;
  38. });
  39. },
  40. delFestival({ commit }) {
  41. commit('DEL_FESTIVAL');
  42. },
  43. // 用途
  44. getUsage({ commit }) {
  45. return this.$service.common.usage().then(res => {
  46. commit('SET_USAGE', res);
  47. return res;
  48. });
  49. },
  50. delUsage({ commit }) {
  51. commit('DEL_USAGE');
  52. }
  53. },
  54. mutations: {
  55. SET_LEVEL(state, val) {
  56. state.level = val;
  57. store.set('level', val);
  58. },
  59. DEL_LEVEL(state) {
  60. state.level = {};
  61. store.remove('level');
  62. },
  63. SET_CATEGORY(state, val) {
  64. state.category = val;
  65. store.set('category', val);
  66. },
  67. DEL_CATEGORY(state) {
  68. state.category = [];
  69. store.remove('category');
  70. },
  71. SET_FESTIVAL(state, val) {
  72. state.festival = val;
  73. store.set('festival', val);
  74. },
  75. DEL_FESTIVAL(state) {
  76. state.festival = [];
  77. store.remove('festival');
  78. },
  79. SET_USAGE(state, val) {
  80. state.usage = val;
  81. store.set('usage', val);
  82. },
  83. DEL_USAGE(state) {
  84. state.usage = [];
  85. store.remove('usage');
  86. }
  87. }
  88. };