mallConfig.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import Vue from 'vue';
  2. const state = {
  3. auth_page: {
  4. pic_url: ''
  5. },
  6. bar_title: {},
  7. cat_style: {},
  8. copyright: {},
  9. mall: {
  10. setting: {
  11. theme_color: 'classic-red'
  12. }
  13. },
  14. navbar: {
  15. navs: []
  16. },
  17. plugin: {
  18. vip_card: {
  19. setting: {
  20. background: '#f7f7f7'
  21. }
  22. }
  23. },
  24. share_setting: [],
  25. share_setting_custom: {},
  26. user_center: {},
  27. __wxapp_img: {},
  28. theme_color: {
  29. key: 'a',
  30. color: '#ff4544',
  31. background: '#ff4544',
  32. border: '#ff4544',
  33. border_s: '#f39800',
  34. background_s: '#f39800',
  35. main_text: '#ffffff',
  36. secondary_text: '#ffffff',
  37. border_m: 'border-color: #ff4544;border-bottom-color: transparent;border-left-color: transparent;border-right-color: transparent;',
  38. background_o: "rgba(255,69,68, 0.1)",
  39. background_p: "rgba(255,69,68, 0.2)",
  40. background_l: "rgba(255,69,68, 0.35)",
  41. background_q: "rgba(255,69,68, 0.8)",
  42. background_gradient: "linear-gradient(140deg, #ff4544, #f39800)",
  43. background_gradient_l: "linear-gradient(to right, rgba(255,69,68, 1), rgba(255,69,68, 0.5))",
  44. background_gradient_o: "linear-gradient(to right, rgba(255,69,68, 1), rgba(255,69,68, 0.7))",
  45. background_s_gradient_o: "linear-gradient(to right, rgb(243,152,0),rgba(243,152,0, 0.7))",
  46. background_gradient_btn: "linear-gradient(to left, rgb(255,69,68),rgba(255,69,68, 0.7))",
  47. background_s_gradient_btn: "linear-gradient(to right, rgb(243,152,0),rgba(243,152,0, 0.7))"
  48. },
  49. theme: "classic-red",
  50. windowHeight: {
  51. height: 0,
  52. width: 0,
  53. boolean: false
  54. },
  55. };
  56. const getters = {
  57. getNavBar(state) {
  58. return state.navbar;
  59. },
  60. getNavBarNavs(state) {
  61. for (let i = 0, len = state.navbar.navs.length; i < len; i++) {
  62. }
  63. },
  64. getUserCenter(state) {
  65. return state.user_center;
  66. },
  67. getWxappImg(state) {
  68. return state.__wxapp_img;
  69. },
  70. getCatStyle(state) {
  71. return state.cat_style;
  72. },
  73. getVip(state) {
  74. return state.plugin.vip_card;
  75. },
  76. getVideo(state) {
  77. return state.mall.setting.is_goods_video;
  78. },
  79. getShowCart(state) {
  80. return state.mall.setting.is_show_cart;
  81. },
  82. getTheme(state) {
  83. return state.theme_color;
  84. },
  85. getSetting(state) {
  86. return state.mall.setting;
  87. }
  88. };
  89. const mutations = {
  90. mutSetConfig(state, data) {
  91. for (let item in data) {
  92. if (item === 'navbar') {
  93. for (let i = 0; i < data[item].navs.length; i++) {
  94. data[item].navs[i].id = i;
  95. }
  96. }
  97. state[item] = data[item];
  98. }
  99. },
  100. mutSetHeight(state, data) {
  101. state.windowHeight = data;
  102. }
  103. };
  104. const actions = {
  105. actionGetConfig(context) {
  106. Vue.prototype.$mallConfig.getConfig().then(response => {
  107. context.commit('mutSetConfig', response);
  108. }).catch(() => {
  109. });
  110. },
  111. actionHeight(context, data) {
  112. context.commit("mutSetHeight", data);
  113. },
  114. actionResetConfig(context) {
  115. Vue.prototype.$mallConfig.resetConfig();
  116. Vue.prototype.$mallConfig.getConfig().then(response => {
  117. context.commit('mutSetConfig', response);
  118. }).catch(() => {
  119. });
  120. }
  121. };
  122. export default {
  123. namespaced: true,
  124. state,
  125. getters,
  126. mutations,
  127. actions
  128. }