<template>
  <!--圖片 - 6x1-->
  <div class="q-mt-xl">
    <section class="scence2 section-block">
      <div class="content">
        <h2 class="block-title">{{ plugData.Title.split('|')[0] }}</h2>
        <p class="title-teaser">{{ plugData.SubTitle }}</p>
      </div>
      <!-- <div class="scence-wrap">
        <ul class="scence-list">
          <template v-for="(item, index) in plugData.Details">
            <li :key="index" v-if="item.ImageUrl">
              <a
                @click="OpenNewUrl(item.LinkUrl)"
                target="_blank"
                class="img rounded-borders overflow-hidden"
                :style="{ backgroundImage: `url('${item.ImageUrl}')` }"
              >
                <h4 class="scence-title">
                  {{
                    item.TripTitle && item.TripTitle.length > 14
                      ? item.TripTitle.substring(0, 14)
                      : item.TripTitle
                  }}
                </h4>
              </a>
            </li>
          </template>
        </ul>
      </div> -->
      <div
        class="row items-center q-col-gutter-md q-mt-md no-wrap"
        style="margin-left: -16px"
        :class="{'overflow-auto full-width':$q.platform.is.mobile}"
      >
        <template v-for="(item, index) in plugData.Details">
          <div
            v-if="item.ImageUrl"
            :key="index"
            class="relative-position"
            style=" min-width: 200px;"
            :class="{ 'col': ((current != index && $q.platform.is.desktop) || realCount!=5), 'col-4': current == index && $q.platform.is.desktop && realCount==5 }"
            @mouseenter="hoverHandler(index)"
          >
            <q-img
              :src="item.ImageUrl"
              spinner-color="grey"
              spinner-size="20px"
              height="270px"
              class="rounded-borders overflow-hidden"
            />
            <div class="absolute-bottom-left absolute-bottom-right rounded-borders overflow-hidden q-pa-md" style="left:16px;background: linear-gradient(to bottom,rgba(0,0,0,0),rgba(0,0,0,.5));">
              <div class="subtitle" style="">
                <a :href="item.LinkUrl" target="_blank" rel="noopener noreferrer" style="color:inherit;">
                  {{
                  item.TripTitle.split('|')[0]}}
                </a>
                <div class="q-mt-sm row items-center no-wrap overflow-hidden" v-if="current==index && plugData.Title.indexOf('|tag')!=-1 && realCount==5">
                  <q-chip outline color="grey-2" class="f12 cursor-pointer" text-color="grey-2" clickable @click="goProductListHandler(0,item.TripTitle.split('|')[1])">觀光行程</q-chip>
                  <q-chip outline color="grey-2" class="f12 cursor-pointer"  text-color="grey-2" clickable @click="goProductListHandler(1,item.TripTitle.split('|')[1])">熱門票券</q-chip>
                  <q-chip style="background:rgba(255,255,255,.3)" clickable class="f12 cursor-pointer"  text-color="grey-2" @click="CommonJump(`/city/${item.TripTitle.split('|')[1]}`,{},'blank')">更多在地體驗</q-chip>
                </div>
              </div>
            </div>
          </div>
        </template>
      </div>
    </section>
  </div>
</template>

<script>
import {date} from 'quasar'
//圖片 - 6x1
export default {
  props: ["plugData"],
  data() {
    return {
      current: 0,
      realCount: 0
    };
  },
  created() {
    this.realCount = this.plugData.Details.filter(x=> x.ImageUrl!='').length
  },
  methods: {
    hoverHandler(i) {
      this.current = i;
    },
    getTagHandler(str){
      let arr = []
      let strs=str.split('|')
      if(strs.length>1){
        arr=strs[1].split(',')
      }
      return arr
    },
    goProductListHandler(t,id){
      let CategoryName=t==0?'观光行程':'景点门票'
      this.CommonJump('/search',{
        areaId:id,
        qsearchDate:date.formatDate(new Date(),'YYYY-MM-DD'),
        qsearchEndDate:date.formatDate(date.addToDate(new Date(),{month:2}),'YYYY-MM-DD'),
        CategoryName
      })
    }
  },
};
</script>

<style>
.scence2 {
}

.scence2 .block-title {
  font-size: 22px;
  font-weight: 600;
  padding: 0;
  margin: 0;
  line-height: unset;
}

.scence2 .title-teaser {
  margin-bottom: 10px;
  font-size: 16px;
  color: #999;
}

.scence2 .scence-wrap {
  margin-top: 15px;
}

.scence2 .scence-list {
  margin-left: -8px;
  margin-right: -8px;
  display: flex;
  flex-wrap: wrap;
  padding: 0;
}

.scence2 .scence-list > * {
  padding: 0;
  margin: 0;
  display: block;
  flex: 1;
  margin: 8px;
  transition: -webkit--webkit-transform 0.2s ease,
    -webkit--moz-transform 0.2s ease, -webkit--o-transform 0.2s ease,
    -webkit-transform 0.2s ease, -webkit-transform 0.2s ease,
    -moz-transform 0.2s ease, -o-transform 0.2s ease, transform 0.2s ease,
    box-shadow 0.2s ease;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.09);
}

.scence2 .scence-list > *:last-child {
  margin-right: 0px;
}

.scence2 .scence-list > * a {
  position: relative;
  display: block;
  width: 100%;
  height: 300px;
  background-size: cover;
  background-position: center;
}

.scence2 .scence-list > * a::before {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  height: 80px;
  content: "";
  background-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.02) 0,
    rgba(0, 0, 0, 0.8) 100%
  );
}

.scence2 .scence-list > * a .scence-title {
  position: absolute;
  display: block;
  padding: 0 16px 16px;
  white-space: pre-wrap;
  right: 0;
  bottom: 0;
  left: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 20px;
  color: #fff;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
  word-break: break-all;
  z-index: 2;
}

.scence2 .subtitle {
  /* white-space: pre-wrap; */
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
  word-break: break-all;
  z-index: 2;
}

.scence2 .scence-list > * {
  display: block;
  width: calc(25% - 16px);
  margin: 8px;
  transition: -webkit--webkit-transform 0.2s ease,
    -webkit--moz-transform 0.2s ease, -webkit--o-transform 0.2s ease,
    -webkit-transform 0.2s ease, -webkit-transform 0.2s ease,
    -moz-transform 0.2s ease, -o-transform 0.2s ease, transform 0.2s ease,
    box-shadow 0.2s ease;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.09);
}

@media only screen and (min-width: 1200px) {
  .scence2 .scence-list > * {
    display: inline-block !important;
    vertical-align: middle !important;
    width: 180px !important;
  }
}

@media only screen and (max-width: 800px) {
  .scence2 {
    margin-top: 40px;
  }

  .scence2 .scence-wrap {
    margin-top: -12px;
  }

  .scence2 .scence-wrap {
    height: 310px !important;
    overflow: hidden !important;
  }

  .scence2 .scence-list {
    padding-bottom: 30px !important;
    width: 100% !important;
    display: block !important;
    white-space: nowrap !important;
    overflow-y: scroll !important;
  }

  .scence2 .scence-list > * {
    display: inline-block !important;
    vertical-align: middle !important;
    width: 180px !important;
  }
}
</style>
