<template>
  <div class="relic-search">
    <BtnClose
      @click="router.go(-1)"
    />
    <div class="search-bar">
      <input
        v-model="keyword"
        type="text"
        placeholder="请输入要搜索的内容..."
      >
      <img
        class="search"
        src="@/assets/images/icon_search_white.png"
        alt=""
        draggable="false"
      >
    </div>
    <menu class="tab-bar">
      <button
        v-for="(item, idx) in areaList"
        :key="idx"
        :class="{
          active: activeAreaIdx === idx
        }"
        @click="activeAreaIdx = idx"
      >
        {{ item }}
      </button>
    </menu>
    <ul class="relic-list">
      <li
        v-for="item in relicList"
        :key="item.id"
        class="relic-item"
      >
        <img
          :src="item.thumb"
          alt=""
          class="photo"
        >
        <div class="center">
          <div class="name">
            {{ item.name }}
          </div>
          <div class="desc">
            {{ item.description }}
          </div>
        </div>
        <button class="go">
          <img
            class=""
            src="@/assets/images/icon_arrow.png"
            alt=""
            draggable="false"
          >
        </button>
      </li>
    </ul>
  </div>
</template>

<script setup>
import { ref, computed, watch, onMounted, watchEffect } from "vue"
import { useRoute, useRouter } from "vue-router"
import { useStore } from "vuex"
import BtnClose from '@/components/BtnClose.vue'

const route = useRoute()
const router = useRouter()
const store = useStore()

const keyword = ref('')

const areaList = ref([
  '全部',
  '锡山区',
  '惠山区',
  '滨湖区',
  '梁溪区',
  '宜兴市',
  '江阴市',
  '新吴区',
])
const activeAreaIdx = ref(0)

// {
//   id: 1,
//   photo: 'icon_user-active.png',
//   name: '点位名称',
//   desc: '上看到附近可舒服都市妇科技术都是了解对方 时刻的风景 士大夫精神地方可是对方 ',
// },
const relicList = ref([])

watchEffect(() => {
  api.getRelicList(keyword.value, activeAreaIdx.value > 0 ? areaList.value[activeAreaIdx.value] : null).then((res) => {
    console.log('sdfsdf', res)
    relicList.value = res
  })
})


</script>

<style lang="less" scoped>
.relic-search{
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  >.search-bar{
    margin-top: 77px;
    flex: 0 0 auto;
    width: 874px;
    height: 74px;
    padding-left: 65px;
    padding-right: 32px;
    background: linear-gradient( 180deg, rgba(255,255,255,0.5) 100%, rgba(255,255,255,0.2) 0%);
    box-shadow: 0px 1px 4px 0px rgba(255,255,255,0.25);
    border-radius: 36px 36px 36px 36px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    margin-bottom: 58px;
    >input{
      flex: 1 0 1px;
      font-family: Source Han Sans CN, Source Han Sans CN;
      font-weight: 400;
      font-size: 24px;
      color: #FFFFFF;
      line-height: 28px;
      &::placeholder {
        font-size: 24px;
        color: rgba(200, 200, 200, 1);
        line-height: 28px;
      }
    }
    >img{
      flex: 0 0 auto;
      width: 32px;
      height: 32px;
    }
  }
  >menu.tab-bar{
    width: 100%;
    flex: 0 0 auto;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    margin-bottom: 89px;
    >button{
      font-family: Source Han Sans CN, Source Han Sans CN;
      font-weight: 400;
      font-size: 24px;
      color: rgba(255, 255, 255, 0.5);
      line-height: 28px;
      &.active{
        font-weight: bold;
        color: #fff;
        border-bottom: 1px solid #fff;
      }
    }
  }
  >ul.relic-list{
    flex: 1 0 1px;
    max-width: 1650px;
    overflow: auto;
    margin-bottom: 50px;
    >li.relic-item{
      height: 65px;
      display: inline-flex;
      align-items: center;
      margin-right: 97px;
      margin-bottom: 40px;
      cursor: pointer;
      >img{
        width: 65px;
        height: 65PX;
        margin-right: 26px;
        border-radius: 50%;
        border: 3px solid #FFFFFF;
      }
      >.center{
        width: 256px;
        margin-right: 77px;
        >.name{
          font-family: Source Han Sans CN, Source Han Sans CN;
          font-weight: bold;
          font-size: 24px;
          color: #FFFFFF;
          line-height: 28px;
          overflow: hidden;
          white-space: pre;
          text-overflow: ellipsis;
          margin-bottom: 4px;
        }
        >.desc{
          font-family: Source Han Sans CN, Source Han Sans CN;
          font-weight: 400;
          font-size: 16px;
          color: #FFFFFF;
          line-height: 19px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
      }
      >button.go{
        width: 26px;
        height: 22px;
        margin-right: 1px;
      }
    }
  }
}
</style>