import { getUserApi } from "@/api/common/index";
export default {
	state: {
		merchantInfo: null //商家信息
	},
	getters: {
		getMerchantInfo(state) {
			return state.merchantInfo;
		}
	},
	actions: {
		async initMerchantInfo({ commit }) {
			try {
				const { data } = await getUserApi();
				commit("UPDATE_MERCHANT_INFO", data);
				return data;
			} catch (error) {
				throw new Error(error);
			}
		},
		/**
		 * 设置不同类别选中商品列表信息
		 */
		updateMerchantInfo({ commit }, info) {
			commit("UPDATE_MERCHANT_INFO", info);
		},
		/**
		 * 清除商家信息
		 */
		rmoveMerchantInfo({ commit }) {
			commit("UPDATE_MERCHANT_INFO", null);
		}
	},
	mutations: {
		["UPDATE_MERCHANT_INFO"](state, info) {
			state.merchantInfo = info;
		}
	}
};
