mallConfig.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import Vue from 'vue';
  2. const state = {
  3. auth_page: {},
  4. bar_title: {},
  5. cat_style: {},
  6. copyright: {},
  7. mall: {
  8. setting: {
  9. theme_color: 'classic-red'
  10. }
  11. },
  12. navbar: {
  13. navs: []
  14. },
  15. plugin: {
  16. vip_card: {
  17. setting: {
  18. background: '#f7f7f7'
  19. }
  20. }
  21. },
  22. share_setting: [],
  23. share_setting_custom: {},
  24. user_center: {},
  25. __wxapp_img: {},
  26. theme: "classic-red",
  27. windowHeight: {
  28. height: 0,
  29. width: 0,
  30. boolean: false
  31. },
  32. };
  33. const getters = {
  34. getNavBar(state) {
  35. return state.navbar;
  36. },
  37. getNavBarNavs(state) {
  38. for (let i = 0, len = state.navbar.navs.length; i < len; i++) {
  39. }
  40. },
  41. getUserCenter(state) {
  42. return state.user_center;
  43. },
  44. getWxappImg(state) {
  45. return state.__wxapp_img;
  46. },
  47. getCatStyle(state) {
  48. return state.cat_style;
  49. },
  50. getVip(state) {
  51. return state.plugin.vip_card;
  52. },
  53. getVideo(state) {
  54. return state.mall.setting.is_goods_video;
  55. },
  56. getShowCart(state) {
  57. return state.mall.setting.is_show_cart;
  58. },
  59. getTheme(state) {
  60. return state.mall.setting.theme_color;
  61. },
  62. getSetting(state) {
  63. return state.mall.setting;
  64. }
  65. };
  66. const mutations = {
  67. mutSetConfig(state, data) {
  68. for (let item in data) {
  69. if (item === 'navbar') {
  70. for (let i = 0; i < data[item].navs.length; i++) {
  71. data[item].navs[i].id = i;
  72. }
  73. }
  74. state[item] = data[item];
  75. }
  76. },
  77. mutSetHeight(state, data) {
  78. state.windowHeight = data;
  79. }
  80. };
  81. const actions = {
  82. actionGetConfig(context) {
  83. Vue.prototype.$mallConfig.getConfig().then(response => {
  84. context.commit('mutSetConfig', response);
  85. }).catch(() => {
  86. });
  87. },
  88. actionHeight(context, data) {
  89. context.commit("mutSetHeight", data);
  90. },
  91. actionResetConfig(context) {
  92. Vue.prototype.$mallConfig.resetConfig();
  93. Vue.prototype.$mallConfig.getConfig().then(response => {
  94. context.commit('mutSetConfig', response);
  95. }).catch(() => {
  96. });
  97. }
  98. };
  99. export default {
  100. namespaced: true,
  101. state,
  102. getters,
  103. mutations,
  104. actions
  105. }