<template>
  <view class="d-flex flex-col h-100vh">
    <SimplePageContentLoader :loader="loader">
      <template v-if="loader.content.value">
        <view class="banner">
          <swiper class="swiper" circular :indicator-dots="true" :autoplay="true" :interval="2000" :duration="1000">
            <swiper-item v-for="(item, key) in loader.content.value.images" :key="key">
              <view class="item">
                <ImageWrapper :src="item" mode="aspectFill" width="750rpx" />
              </view>
            </swiper-item>
          </swiper>
        </view>
        <view class="d-flex flex-col p-3">
          <view class="intro-block artifact-info">
            <HomeTitle :title="loader.content.value.title" />
            <view class="desc no-indent">
              <view class="navigation">
                <view class="address">
                  <text class="iconfont icon-navigation"></text>
                  <text>{{ loader.content.value.address }}</text>
                </view>
                <view class="link">
                  去这里 <text class="iconfont icon-go"></text>
                </view>
              </view>
              <view class="entry">
                <view class="label">开放时间：</view>
                <view class="value">{{ loader.content.value.openStatusText }}</view>
              </view>
              <view class="entry">
                <view class="label">年代：</view>
                <view class="value">{{ loader.content.value.age }} 年）</view>
              </view>
              <view class="entry">
                <view class="label">文物类型：</view>
                <view class="value">{{ loader.content.value.crTypeText }}</view>
              </view>
              <view class="entry">
                <view class="label">所属区域：</view>
                <view class="value">{{ loader.content.value.regionText }}</view>
              </view>
              <view class="entry">
                <view class="label">级别：</view>
                <view class="value">{{ loader.content.value.levelText }}</view>
              </view>
              <view class="entry">
                <view class="label">保护范围：</view>
                <view class="value">
                </view>
              </view>
              <u-parse :content="loader.content.value.protectedArea" :tagStyle="commonParserStyle"></u-parse>
            </view>
          </view>
          <view class="intro-block">
            <view class="title">
              <view class="line"></view>
              <text class="sm">简介</text>
            </view>
            <view class="desc">
              <u-parse :content="loader.content.value.intro" :tagStyle="commonParserStyle"></u-parse>
            </view>
            <view class="sub-title">详情</view>
            <view class="desc">
              <u-parse :content="loader.content.value.value" :tagStyle="commonParserStyle"></u-parse>
            </view>
          </view>
          <HomeTitle title="更多人气好去处" showMore />
          <view class="rec-list">
            <swiper class="swiper" :autoplay="false" :circular="false" :duration="500"
                    :next-margin="'145rpx'">
              <swiper-item v-for="item in loader.content.value.associationMeList" :key="item.id" @click="goDetails(item)">
                <view class="item">
                  <image :src="item.image" mode="aspectFill"></image>
                  <view class="name">
                    <text>{{ item.title }}</text>
                  </view>
                </view>
              </swiper-item>
            </swiper>
          </view>
          <HomeTitle title="本地吃透透" showMore />
          <view class="food-list">
            <view class="item" v-for="item in foodList" :key="item.id">
              <image :src="item.image" mode="aspectFill"></image>
              <view class="info">
                <view class="name">{{ item.name }}</view>
              </view>
            </view>
          </view>
        </view>
      </template>
    </SimplePageContentLoader>
  </view>
</template>
<script setup lang="ts">
import type { GetContentDetailItem } from "@/api/CommonContent";
import { useSimplePageContentLoader } from "@/common/composeabe/SimplePageContentLoader";
import { onLoad } from "@dcloudio/uni-app";
import { navTo } from "@/common/utils/PageAction";
import UnmoveableContent from "@/api/inheritor/UnmoveableContent";
import SimplePageContentLoader from "@/common/components/SimplePageContentLoader.vue";
import ImageWrapper from "@/common/components/ImageWrapper.vue";
import HomeTitle from "@/pages/parts/HomeTitle.vue";
import commonParserStyle from "@/common/style/commonParserStyle";
import { useLoadQuerys } from "@/common/composeabe/LoadQuerys";

const loader = useSimplePageContentLoader<
  GetContentDetailItem, 
  { id: number }
>(async (params) => {
  if (!params)
    throw new Error("!params");
  return await UnmoveableContent.getContentDetail(params.id);
});

useLoadQuerys({ id : 0, }, (p) => loader.loadData(p));

function goDetails(item: any) {
  navTo('inherit_artifact_details', { id: item.id })
}

const foodList = [
  {
    id: 1,
    image: 'https://lucheng.app4lh.cn/static/tmp/static/tmp/food1.png',
    name: '沙茶面',
  },
  {
    id: 2,
    image: 'https://lucheng.app4lh.cn/static/tmp/static/tmp/food2.png',
    name: '碗糕',
  },
  {
    id: 3,
    image: 'https://lucheng.app4lh.cn/static/tmp/static/tmp/food1.png',
    name: '姜母鸭',
  },
  {
    id: 4,
    image: 'https://lucheng.app4lh.cn/static/tmp/static/tmp/food2.png',
    name: '炸枣',
  }
];
</script>

<style lang="scss" scoped>
page {
  background: #FFF3E1;
}

.food-list {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;

  .item {
    width: calc(50% - 15rpx);
    margin-bottom: 53rpx;

    image {
      width: 100%;
      height: 360rpx;
      display: block;
    }

    .info {
      text-align: center;
      padding-top: 20rpx;
      font-weight: bold;
      font-size: 30rpx;
      color: #312520;
    }
  }
}

.rec-list {
  swiper {
    height: 300rpx;
  }

  .item {
    width: 514rpx;
    height: 300rpx;
    position: relative;
    border-radius: 20rpx;
    overflow: hidden;
    background-color: #eaeaea;

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

    .name {
      position: absolute;
      bottom: 34rpx;
      right: 22rpx;
      color: #fff;
      font-weight: 600;
      font-size: 28rpx;
    }
  }
}

.intro-block {
  margin-bottom: 38rpx;
  .title{
    .sm{
      font-size: 30rpx;
    }
  }
  &.artifact-info{
    .desc{
      line-height: inherit;
      padding-bottom: 10rpx;
    }
  }
  .entry {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    margin-bottom: 10rpx;

    .label {
      color: #666666;
      font-weight: 400;
      font-size: 28rpx;
    }
    .value {
      font-size: 28rpx;
      color: #312520;
      font-weight: 400;
    }
  }
  .sub-title{
    margin-left: 20rpx;
    margin-top: 10rpx;
    font-size: 30rpx;
    font-weight: 600;
  }
  .desc{
    padding:30rpx;
  }
  .navigation{
    display: flex;
    align-items: center;
    margin-bottom: 28rpx;
    .address{
      flex:1;
      height: auto;
      background: #F9F6EB;
      border-radius: 28rpx;
      font-weight: 400;
      font-size: 24rpx;
      color: #000000;
      line-height: 48rpx;
      padding-left: 30rpx;
      display: flex;
      align-items: center;
      text.iconfont{
        display: inline-block;
        font-size: 36rpx;
        margin-right: 8rpx;
      }
    }
    .link{
      margin-left: 20rpx;
      color:#FF8719;
    }
  }
}
.banner {
  margin-top: 0;
  .swiper {
    border-radius: 0;
    height: 504rpx;
  }
}

</style>
