userCenter.js 744 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Vue from 'vue';
  2. const state = {
  3. data: {
  4. }
  5. };
  6. const getters = {
  7. data(state) {
  8. return state.data;
  9. }
  10. };
  11. const mutations = {
  12. data(state, data) {
  13. state.data = data;
  14. },
  15. };
  16. const actions = {
  17. data(context) {
  18. Vue.prototype.$request({
  19. url: Vue.prototype.$api.user.config,
  20. }).then(res => {
  21. let { data, code } = res;
  22. if (code === 0) {
  23. let config = data.config;
  24. if (data && config && config.user_center) {
  25. context.commit('data', config.user_center);
  26. }
  27. }
  28. });
  29. },
  30. };
  31. export default {
  32. namespaced: true,
  33. state,
  34. getters,
  35. mutations,
  36. actions
  37. }