import store from '@/store'
import UTIL from '@/utils/util'
/** 字典配置 */
const state = {
	level: {},
	category: [],
	usage: [],
	fest: [],
	orderShop: {}
}

const getters = {
	// 等级数据
	getLevel: (state) => {
		return state.level || {}
	},
	// 分类数据
	getCategory: (state) => {
		return state.category || []
	},
	// 用途数据
	getUsage: (state) => {
		return state.usage || []
	},
	// 节日数据
	getFest: (state) => {
		return state.fest || []
	},
	// 下单-相关信息
	getOrderShop: (state) => {
		return state.orderShop || []
	}
}

const actions = {
	// 等级信息
	setLevel({
		commit
	}, data) {
		commit('SET_LEVEL', data)
	},
	delLevel({
		commit
	}) {
		commit('DEL_LEVEL')
	},
	// 分类数据
	setCategory({
		commit
	}, data) {
		commit('SET_CATEGORY', data)
	},
	delCategory({
		commit
	}) {
		commit('DEL_CATEGORY')
	},
	// 用途数据
	setUsage({
		commit
	}, data) {
		commit('SET_USAGE', data)
	},
	delUsage({
		commit
	}) {
		commit('DEL_USAGE')
	},
	// 节日数据
	setFest({
		commit
	}, data) {
		commit('SET_FEST', data)
	},
	delFest({
		commit
	}) {
		commit('DEL_FEST')
	},
	// 下单-商家数据
	setOrderShop({
		commit
	}, data) {
		commit('SET_ORDER_SHOP', data)
	},
	delOrderShop({
		commit
	}) {
		commit('DEL_ORDER_SHOP')
	}
}

const mutations = {
	// 等级信息
	SET_LEVEL(state, data = {}) {
		state.level = data
	},
	DEL_LEVEL(state) {
		state.level = ''
	},
	// 分类信息
	SET_CATEGORY(state, data = []) {
		state.category = data
	},
	DEL_CATEGORY(state) {
		state.category = ''
	},
	// 用途数据
	SET_USAGE(state, data = []) {
		state.usage = data
	},
	DEL_USAGE(state) {
		state.usage = ''
	},
	// 节日信息
	SET_FEST(state, data = []) {
		state.fest = data
	},
	DEL_FEST(state) {
		state.fest = ''
	},
	// 下单-商家数据
	SET_ORDER_SHOP(state, data = []) {
		state.orderShop = data
	},
	DEL_ORDER_SHOP(state) {
		state.orderShop = ''
	}
}

export default {
	state,
	getters,
	actions,
	mutations
}
