merchant.js 782 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { getShopInfoApi } from "@/api/common/index";
  2. export default {
  3. state: {
  4. merchantInfo: null //商家信息
  5. },
  6. getters: {
  7. getMerchantInfo(state) {
  8. return state.merchantInfo;
  9. }
  10. },
  11. actions: {
  12. async initMerchantInfo({ commit }) {
  13. try {
  14. const { data } = await getShopInfoApi();
  15. commit("UPDATE_MERCHANT_INFO", data);
  16. return data;
  17. } catch (error) {
  18. throw new Error(error);
  19. }
  20. },
  21. /**
  22. * 设置不同类别选中商品列表信息
  23. */
  24. updateMerchantInfo({ commit }, info) {
  25. commit("UPDATE_MERCHANT_INFO", info);
  26. },
  27. /**
  28. * 清除商家信息
  29. */
  30. rmoveMerchantInfo({ commit }) {
  31. commit("UPDATE_MERCHANT_INFO", null);
  32. }
  33. },
  34. mutations: {
  35. ["UPDATE_MERCHANT_INFO"](state, info) {
  36. state.merchantInfo = info;
  37. }
  38. }
  39. };