tab.js 645 B

1234567891011121314151617181920212223242526272829303132333435
  1. import Cache from '@/utils/cache'
  2. import Constant from '@/utils/constant'
  3. const val = Cache.get(Constant.CACHE_TAB_SELECTED)
  4. const getDefaultState = () => {
  5. return {
  6. index: val === undefined ? 1 : val,
  7. selectedHotelId: 0
  8. }
  9. }
  10. const state = getDefaultState()
  11. const mutations = {
  12. SET_INDEX: (state, index) => {
  13. Cache.set(Constant.CACHE_TAB_SELECTED, index)
  14. state.index = index
  15. },
  16. SET_SELECTEDHOTELId: (state, hotelId) => {
  17. state.selectedHotelId = hotelId
  18. }
  19. }
  20. const actions = {
  21. index({ commit }, index) {
  22. commit('SET_INDEX', index)
  23. }
  24. }
  25. export default {
  26. namespaced: true,
  27. state,
  28. mutations,
  29. actions
  30. }