<template>
  <div class="box">
    <!-- 遮罩层区域 -->
    <div class="mask" @click="handleClose"></div>
    <!-- 内容区域 -->
    <div class="container">
      <!-- 关闭按钮区域 -->
      <div class="close_icon" @click="handleClose"></div>

      <!-- 标题区域 -->
      <div class="title">
        <div class="title_text">{{ currentTown }}民宿列表</div>
        <img src="@/assets/images/33.png" />
      </div>

      <!-- 搜索框区域 -->
      <div class="serach">
        <el-input
          style="height: 100%"
          placeholder="请输入民宿名称"
          :suffix-icon="Search"
          v-model="serachValue"
        >
        </el-input>
      </div>

      <!-- 列表区域 -->
      <div class="list">
        <!-- 每一个民宿区域 -->
        <div class="list_item" v-for="item in hotelList" :key="item.id">
          <!-- 新闻信息区域 -->
          <div class="item_info">{{ item.title }}</div>
          <!-- 箭头图标区域 -->
          <div class="item_icon" @click="handleLookDetail(item)">
            <img src="@/assets/images/right.png" />
          </div>
          <!-- 底部边框区域 -->
          <div class="item_line"></div>
        </div>
      </div>

      <!-- 分页器区域 -->
      <div class="pagination">
        <el-pagination
          v-model:current-page="currentPage"
          v-model:page-size="pageSize"
          background
          layout="prev, pager, next, jumper"
          :total="total"
          :pager-count="5"
        />
      </div>

      <!-- 每一个民宿详情弹窗区域 -->
      <Transition name="fade">
        <HotelDetailDialog v-if="showDetailDialog" :detailObj="detailObj" />
      </Transition>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { Search } from "@element-plus/icons-vue";
import HotelDetailDialog from "./hotelDetailDialog.vue";

defineProps(["currentTown"]);
const $emit = defineEmits(["closeDialog"]);

// 搜索框绑定数据
const serachValue = ref("");
// 当前页
const currentPage = ref<number>(1);
// 每页多少条
const pageSize = ref<number>(6);
// 总条数
const total = ref<number>(100);
// 每一个民宿详情弹窗显示隐藏控制
const showDetailDialog = ref<boolean>(false);

// 民宿列表数据
const hotelList = ref([
  {
    id: 1,
    title: "靖安一日游",
    url: "	https://pic.rmb.bdstatic.com/daca09fd4974fe3361289d3306db4d63.jpeg",
  },
  {
    id: 2,
    title: "关于靖安县防火措施",
    url: "	https://pic.rmb.bdstatic.com/daca09fd4974fe3361289d3306db4d63.jpeg",
  },
  {
    id: 3,
    title: "靖安县大好河，非常漂亮",
    url: "	https://pic.rmb.bdstatic.com/daca09fd4974fe3361289d3306db4d63.jpeg",
  },
  {
    id: 4,
    title: "欢迎大家游玩靖安",
    url: "	https://pic.rmb.bdstatic.com/daca09fd4974fe3361289d3306db4d63.jpeg",
  },
  {
    id: 5,
    title: "欢迎各位领导莅临参观",
    url: "	https://pic.rmb.bdstatic.com/daca09fd4974fe3361289d3306db4d63.jpeg",
  },
  {
    id: 6,
    title: "三爪仑一日游攻略",
    url: "	https://pic.rmb.bdstatic.com/daca09fd4974fe3361289d3306db4d63.jpeg",
  },
]);

// 民宿详情数据
const detailObj = ref({});

// 点击关闭按钮回调
const handleClose = () => {
  $emit("closeDialog", false);
};

// 点击每一个新闻箭头图标的回调
const handleLookDetail = (item: any) => {
  detailObj.value = item;
  showDetailDialog.value = true;
};
</script>

<style lang="scss" scoped>
.box {
  z-index: 9999;
  position: absolute;
  top: -151px;
  left: 0;
  width: 7072px;
  height: 1872px;
  background-color: rgba($color: #000000, $alpha: 0.4);

  .mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 7072px;
    height: 1872px;
  }

  .container {
    position: absolute;
    top: 642px;
    left: 2620px;
    width: 779px;
    height: 853px;
    background-image: url(@/assets/images/53.png);
    background-size: 100% 100%;

    .close_icon {
      position: absolute;
      top: 17px;
      right: 8px;
      width: 42px;
      height: 42px;
      cursor: pointer;
      background-image: url(@/assets/images/12.png);
      background-size: 100% 100%;
    }

    .title {
      position: relative;
      margin-top: 64px;
      margin-left: 57px;
      width: 655px;
      height: 41px;
      line-height: 41px;

      .title_text {
        position: absolute;
        left: 15px;
        z-index: 1;
        font-size: 23.5px;
        font-weight: bold;
        color: #e0efff;
      }

      img {
        position: absolute;
        left: 0;
        bottom: 0;
        width: 655px;
        height: 16px;
      }
    }

    .serach {
      position: absolute;
      top: 152px;
      left: 319px;
      width: 393px;
      height: 61px;
      border-radius: 5px;
      border: 2px solid #cccccc;
      background-color: rgba(36, 98, 125, 0.2);

      ::v-deep(.el-input__wrapper) {
        padding: 0 22px;
        font-size: 24px;
        box-shadow: none;
        background-color: transparent;

        .el-input__inner {
          color: #fff;
        }
      }
    }

    .list {
      margin-top: 150px;
      margin-left: 57px;
      width: 657px;
      height: 480px;
      overflow-y: auto;

      .list_item {
        position: relative;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        height: 80px;

        .item_info {
          margin-left: 10px;
          font-size: 20px;
        }

        .item_icon {
          margin-right: 10px;
          width: 27px;
          height: 27px;
          cursor: pointer;

          img {
            width: 100%;
            height: 100%;
          }
        }

        .item_line {
          position: absolute;
          bottom: 0;
          width: 100%;
          height: 6px;
          background-image: url(@/assets/images/news-list-bottomLine.png);
          background-size: 100% 100%;
        }
      }
    }

    .pagination {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      margin-left: 57px;
      width: 657px;
      height: 100px;
    }
  }
}

::v-deep(.el-pagination.is-background .el-pager li),
::v-deep(.el-pagination.is-background .btn-next),
::v-deep(.el-pagination.is-background .btn-prev) {
  color: #b0b0b0;
  border: 1px solid #b0b0b0;
  background-color: transparent;
}

::v-deep(.el-pagination.is-background .el-pager li.is-active) {
  color: #70b7fa;
}

::v-deep(.el-pagination__goto),
::v-deep(.el-pagination__classifier),
::v-deep(.el-input__inner) {
  color: #b0b0b0;
}
</style>
