loading.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import mallConfig from '../../core/mallConfig.js';
  2. import User from "../../core/user";
  3. const state = {
  4. type: 'global',
  5. text: '加载中',
  6. color: '#ffffff',
  7. backgroundImage: '',
  8. isShow: false
  9. };
  10. const getters = {
  11. getType(state) {
  12. return state.type;
  13. },
  14. getText(state) {
  15. return state.text;
  16. },
  17. getColor(state) {
  18. return state.color;
  19. },
  20. getBackgroundImage: async function(state) {
  21. return state.backgroundImage;
  22. },
  23. getIsShow(state) {
  24. return state.isShow;
  25. }
  26. };
  27. const mutations = {
  28. mutSetLoading(state, data) {
  29. for (let item in data) {
  30. state[item] = data[item];
  31. }
  32. if (!state.backgroundImage) {
  33. mallConfig.getConfig().then(config => {
  34. state.backgroundImage = config.__wxapp_img.mall.loading;
  35. });
  36. }
  37. },
  38. };
  39. const actions = {
  40. actionGetLoading(context, data) {
  41. context.commit('mutSetLoading', data);
  42. },
  43. };
  44. export default {
  45. namespaced: true,
  46. state,
  47. getters,
  48. mutations,
  49. actions
  50. }