import Cache from '@/utils/cache' import Constant from '@/utils/constant' const val = Cache.get(Constant.CACHE_TAB_SELECTED) const getDefaultState = () => { return { index: val === undefined ? 1 : val, selectedHotelId: 0 } } const state = getDefaultState() const mutations = { SET_INDEX: (state, index) => { Cache.set(Constant.CACHE_TAB_SELECTED, index) state.index = index }, SET_SELECTEDHOTELId: (state, hotelId) => { state.selectedHotelId = hotelId } } const actions = { index({ commit }, index) { commit('SET_INDEX', index) } } export default { namespaced: true, state, mutations, actions }