<template>
  <div class="fix-height-subpage column no-wrap q-pa-md">
    <list-header></list-header>
    <div class="col q-mt-md" :class="{ 'light-shadow q-pa-md bg-white rounded-border': $q.platform.is.desktop }">
      <list-table></list-table>
    </div>
    <hotel-tips></hotel-tips>
  </div>
</template>

<script lang="ts">
import useMetaModule from '../../module/meta/metaModule'
import { useI18n } from 'vue-i18n'
import svgIcon from '../../components/global/svg-icon.vue'
import { defineComponent, inject, provide, reactive, ref, toRefs } from 'vue'
import { DirtionmaryHelper } from '../../config/dictionary'
import ListHeader from '../../components/hotel/list/ListHeader.vue'
import ListTable from '../../components/hotel/list/ListTable.vue'
import HotelTips from '../../components/hotel/list/HotelTips.vue'
import { date } from 'quasar'
export default defineComponent({
  components: { svgIcon, ListHeader, ListTable, HotelTips },
  setup() {
    const data = reactive({})
    let { setTitle } = useMetaModule()
    const { locale, t } = useI18n()
    const pageTitle = inject(DirtionmaryHelper.PAGE_TITLE_KEY) as any
    pageTitle.value = t('hotel.pageTitle')
    setTitle(pageTitle.value)
    const search = reactive({
      HotelChooseArray: [],
      StartDate: '',
      EndDate: '',
      Country: '651',
      Province: 0,
      City: 0,
      OutBranchId: -1,
      Star: 0,
      PriceLevel: 0,
      Supplier: 0,
      MaxPrice: '',
      MinPrice: ''
    })

    provide(DirtionmaryHelper.HOTEL_QUERY_PARAM, search)
    const HotelCarList = ref<Array<any>>([])

    const cacheCars = localStorage.getItem(DirtionmaryHelper.HOTEL_HOTELCARS_CACHE)
    if (cacheCars) {
      let cacheCarArray = JSON.parse(cacheCars).filter((x: any) => date.getDateDiff(new Date(x.Date), new Date(), 'days') >= 20)
      HotelCarList.value = cacheCarArray
    }
    provide(DirtionmaryHelper.HOTEL_CAR_LIST, HotelCarList)
    const updateObj = ref<any>({})
    provide(DirtionmaryHelper.HOTEL_UPDATEHOTEL_CAR, updateObj)
    const orderstatus = ref(false)
    provide(DirtionmaryHelper.HOTEL_CAR_ORDER_STATUS, orderstatus)
    const HotelLengths = ref(0)
    provide(DirtionmaryHelper.HOTEL_CAR_ORDER_LENGTH, HotelLengths)

    const menu = inject(DirtionmaryHelper.MENU_KEYS) as any
    menu.value = 2
    const methods = {}
    return {
      ...toRefs(data),
      ...methods
    }
  }
})
</script>

<style>

</style>
