loading.js 1.0 KB

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