<template>
  <view class="bg">
    <headerVue :type="'article'" />
    <view class="category-scroll">
      <video
        src="https://static.ticket.sz-trip.com/epicSoul/categorys.mp4"
        objectFit="cover"
      ></video>
    </view>
    <view class="title-box-about">
      关于阅读体
      <image
        src="https://des.js-dyyj.com/data/2025/08/29/a1bfbd3e-f63c-4dea-8aa6-9008bcf129c6.png"
        mode=""
      >
      </image>
    </view>
    <view
      class="start-swiper"
      v-show="isShow && startSwiper && startSwiper.length > 0"
      @click="this.isShow = false"
    >
      <swiper
        class="start-swiper"
        :indicator-dots="false"
        :autoplay="true"
        :interval="5000"
        :duration="500"
        @change="onSwiperChange"
      >
        <swiper-item v-for="(item, index) in startSwiper" :key="index">
          <image :src="showImg(item.head_img)" mode="aspectFill"></image>
        </swiper-item>
      </swiper>
    </view>
    <view class="desc-box">
      <view class="">
        Epic soul交响 |
        阅读体以数字文化资产IP为核心，以消费产品创新为导向，把“每个生命都有史诗般的灵魂”作为创作宗旨，通过文字、图像、音视频、交互式展览等多种技术工具创作完成的轻量化数字文化内容产品，邀您一起收藏这颗星球所有未被传唱的英雄史诗。
      </view>
      <view class="">
        Epic
        soul交响|阅读体将长期关注乡村振兴、城市更新、文化焕新等领域,践行探索未来文化信息的解构、分发和互动方式。
      </view>
    </view>
    <image
      style="width: 700rpx; height: 14rpx; margin: 80rpx auto; display: block"
      :src="showImg('/uploads/20250829/f7214bc2a4f4e236561de893ca7b9113.png')"
    ></image>
    <view class="title-box">
      阅读合集
      <image
        src="https://static.ticket.sz-trip.com/epicSoul/readingBody/titleSpan.png"
        mode=""
      ></image>
    </view>

    <image
      style="width: 700rpx; height: 23.5rpx; margin: 30rpx auto; display: block"
      src="https://des.js-dyyj.com/data/2025/08/29/ee445087-f64d-40a1-861b-586d1a9c7e31.png"
    ></image>
    <view
      class="new-book-body"
      @click="gotoUrlNew(readingList[0])"
      v-if="readingList.length"
    >
      <view
        class="newBookCard"
        style=""
        :style="{ backgroundImage: `url(${showImg(readingList[0].image)})` }"
      >
      </view>
      <!-- <image
        style="width: 583rpx; height: 706rpx"
        mode="aspectFill"
        :src="showImg(readingList[0].image)"
      ></image> -->
      <view class="new-book-body-title" style="">
        《今夜，我们都有一艘秘密飞船》
      </view>
      <view class="new-book-body-desc">
        本期由DAYUN远见文化工厂与吴文化博物馆联合推出，将其馆藏文物“元代朱碧山造银槎杯”活化为数字IP。这不仅是一次文物活化的深度实践，更是一份献给现代人的精神远航指南，邀你随时登船，自在漂浮。
      </view>
    </view>
    <!-- <view class="top-box">
			<swiper class="carousel-swiper" :indicator-dots="false" :autoplay="true" :interval="5000" :duration="500"
				@change="onSwiperChange">
				<swiper-item v-for="(item, index) in swiperList" :key="index">
					<image :src="showImg(item.head_img)" mode=""></image>
				</swiper-item>
			</swiper>
			<view class="exhibit-issue">issue/0{{ currentIndex + 1 }}</view>
			底部指示点
			<view class="custom-indicators">
				<view v-for="(_, index) in swiperList" :key="index"
					:class="['indicator-dot', {'active': index === currentIndex}]"></view>
			</view>
		</view> -->

    <!-- <uni-swiper-dot class="uni-swiper-dot-box" :info="swiperList" :current="current" :mode="mode"
			:dots-styles="dotsStyles" field="content">
			<swiper class="swiper-box" @change="change" :current="swiperDotIndex" :style="{height : swiperHeight + 'px'}">
				<swiper-item v-for="(item, index) in swiperList" :key="index" @click="gotoUrlNew(item)">
					<image :src="showImg(item.head_img)" mode="widthFix" :id="`swiper-item-${index}`"></image>
				</swiper-item>
			</swiper>
		</uni-swiper-dot> -->
    <image
      style="
        width: 700rpx;
        height: 23.5rpx;
        margin: 50rpx auto 30rpx;
        display: block;
      "
      src="https://des.js-dyyj.com/data/2025/08/29/d23d170b-9ae8-4306-a6f3-193327d844f8.png"
    ></image>
    <!-- <swiper class="category-scroll">
			<swiper-item v-for="(item, index) in categories" :key="index" @click="gotoUrlNew(item)">
				<image :src="showImg(item.head_img)" mode="aspectFill"></image>
			</swiper-item>
		</swiper> -->

    <!-- <view class="category-scroll" v-if="categories && categories.length > 0">
			<video src="https://static.ticket.sz-trip.com/epicSoul/category.mp4" :poster="showImg(categories[0].head_img)" objectFit="cover"></video>
		</view> -->

    <view class="reading-title flex-between" v-if="false">
      <!-- <view v-for="(item,index) in readingType" :key="index" @click="changeType(index)">{{item.title}}</view>
			<span :style="{left: readingIndex == 0 ? '32rpx' : (readingIndex == 1 ? '245rpx' : '448rpx')}"></span> -->
    </view>
    <view class="reading-box">
      <view
        class="reading-box-item"
        v-for="(item, index) in readingList.slice(1)"
        v-if="item.image && item.front_model && item.front_model.mini"
        :key="index"
        @click="gotoUrlNew(item)"
      >
        <view
          :style="{ backgroundImage: `url(${showImg(item.image)})` }"
          class="img-wrapper"
        >
        </view>
        <!--   <image
          mode="aspectFill"
          :src="showImg(item.image)"
          @click="gotoUrlNew(item)"
        ></image> -->
        <view class="reading-box-item-title">
          {{ item.title }}
        </view>
        <view class="reading-box-item-desc">
          {{ descList[index] }}
        </view>
      </view>
    </view>

    <CustomTabBar :currentTab="1" />
    <MusicControl />
  </view>
</template>

<script>
import headerVue from "@/components/header.vue";
import CustomTabBar from "@/components/CustomTabBar.vue";
import MusicControl from "@/components/MusicControl.vue";
export default {
  components: {
    headerVue,
    CustomTabBar,
    MusicControl,
  },
  data() {
    return {
      swiperList: [],
      current: 0,
      swiperDotIndex: 0,
      swiperHeight: 524,
      mode: "round",
      dotsStyles: {
        selectedBackgroundColor: "rgb(133, 133, 133)",
        selectedBorder: "none",
        backgroundColor: "rgba(150, 150, 150, 0.5)",
        border: "none",
      },
      currentIndex: 0,
      categories: [],
      readingList: [],
      readingType: [
        {
          title: "2025",
          id: 3,
        },
        {
          title: "2026",
          id: 6,
        },
        {
          title: "全部",
          id: "",
        },
      ],
      readingIndex: 0,
      startSwiper: [],
      isShow: true,
      descList: [
        "颠覆“笨猪”的刻板印象，讲述一段关于文明、家国、美味与勇气的趣味进化史。为新中式烘焙品牌圣百合提供文化寻根的灵感，让最寻常的食物也能讲述不凡的故事。",
        "以一根不眠之“丝”为线索，展现其从天虫吐丝的生命史诗，到织就华夏文明经纬的惊人跨度。致力于让古老的丝绸非遗，重焕新生，成为可被穿戴的东方美学。",
        "以一缕千年柏香为引，探索人类被低估的“嗅觉指纹” 。通过对千年古柏背后人文风骨的挖掘，为新中式香氛产业提供深度文化叙事，将无形的意境转化为可被感知的灵魂香气。",
        "以“三个桃子”数字IP为核心，追溯一颗果实260万年的迁徙史与文化象征，赋能国家地理标志农产品，将一颗普通的果实，塑造成蕴含中国桃园江湖情义的味觉与美学信物 。",
      ],
    };
  },
  onReady() {
    this.sendRequest();
  },
  onShow() {
    const app = getApp();
    if (
      app.globalData.musicSrc !=
      "https://static.ticket.sz-trip.com/epicSoul/EpicSouls.mp3"
    ) {
      app.updateMusicSrc(
        "https://static.ticket.sz-trip.com/epicSoul/EpicSouls.mp3"
      );
      app.initBackgroundMusic(); // 初始化背景音乐
      uni.$bgMusic.play(); // 播放音乐
    }
  },
  methods: {
    sendRequest() {
      this.Post(
        {
          type_id: 3,
          position: 2,
        },
        "/api/adv/getAdv"
      ).then((res) => {
        if (res.data) {
          this.swiperList = res.data;

          setTimeout(() => {
            this.$nextTick(() => {
              this.change({
                detail: {
                  current: 0,
                },
              });
            });
          }, 500);
        }
      });

      this.Post(
        {
          type_id: 3,
          position: 1,
        },
        "/api/adv/getAdv"
      ).then((res) => {
        if (res.data) {
          this.categories = res.data;
        }
      });

      this.Post(
        {
          type_id: 3,
          position: 4,
        },
        "/api/adv/getAdv"
      ).then((res) => {
        if (res.data) {
          this.startSwiper = res.data;
        }
      });

      this.getList();
    },
    // 全部阅读 文章
    getList() {
      this.Post(
        {
          type_id: this.readingType[this.readingIndex].id,
          offset: 0,
          limit: 1,
        },
        "/api/article/getArticleByType"
      ).then((res) => {
        if (res.data) {
          this.readingList = res.data;
        }
      });
    },
    change(e) {
      this.current = e.detail.current;
      let element = "#swiper-item-" + e.detail.current;
      let query = uni.createSelectorQuery().in(this);
      query.select(element).boundingClientRect();
      query.exec((res) => {
        if (res && res[0]) {
          this.swiperHeight = res[0].height;
        }
      });
    },
    onSwiperChange(e) {
      this.currentIndex = e.detail.current;
    },
    changeType(index) {
      this.readingIndex = index;
      this.getList();
    },
    viewDetail(item) {
      if (item.url) {
        uni.navigateTo({
          url:
            "/subPackages/webPage/webPage?url=" + encodeURIComponent(item.url),
        });
        return;
      }
      uni.navigateTo({
        url: "/subPackages/letter/detail?id=" + item.id,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.bg {
  padding-bottom: 200rpx;
}

.swiper-box,
.top-box {
  margin: 10rpx 25rpx 0;
  height: 830rpx;
  box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
  border-radius: 20rpx;
  overflow: hidden;
  // padding-top: 10rpx;
  // background-color: #fff;

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

.carousel-swiper {
  width: 582.13rpx;
  height: 706.24rpx;
  margin: -40rpx auto 0;

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

.exhibit-issue {
  font-family: serif;
  font-size: 28rpx;
  color: #999;
  font-style: italic;
  padding: 40rpx 30rpx 0 0;
  text-align: right;
}

.custom-indicators {
  display: flex;
  justify-content: center;
  gap: 8rpx;
  margin-top: 40rpx;

  .indicator-dot {
    width: 8rpx;
    height: 8rpx;
    border-radius: 4rpx;
    background-color: rgba(150, 150, 150, 0.5);
    transition: all 0.3s;
  }

  .indicator-dot.active {
    width: 20rpx;
    background-color: rgb(133, 133, 133);
  }
}

.category-scroll {
  // padding: 40rpx 0 0 40rpx;
  // display: flex;
  height: 393rpx;
  margin: 50rpx 25rpx 0;

  image {
    width: 100%;
    height: 393rpx;
    flex-shrink: 0;
    // margin-right: 20rpx;
    border-radius: 20rpx;
  }

  video {
    width: 100%;
    height: 393rpx;
    border-radius: 20rpx;
  }
}

.title-box {
  font-size: 36rpx;
  font-weight: 500;
  margin-top: 40rpx;
  padding-left: 25rpx;

  image {
    width: 185.85rpx;
    height: 20.98rpx;
    margin-left: 21rpx;
  }
}

.title-box-about {
  font-size: 36rpx;
  font-weight: 500;
  margin-top: 50rpx;
  padding-left: 25rpx;

  image {
    width: 106.5rpx;
    height: 20.98rpx;
    margin-left: 21rpx;
  }
}

.reading-title {
  margin: 60rpx auto 0;
  width: 585rpx;
  height: 30rpx;
  border-radius: 15rpx;
  background-color: rgba(46, 220, 78, 0.8);
  font-weight: bold;
  font-size: 28rpx;
  color: #000000;
  padding: 0 40rpx;
  position: relative;

  view {
    position: absolute;
    z-index: 20;
    bottom: 15rpx;
  }

  & > view:nth-child(2) {
    left: 268rpx;
  }

  & > view:nth-child(3) {
    right: 55rpx;
  }

  span {
    width: 111rpx;
    height: 100%;
    background-color: rgb(9, 154, 60);
    border-radius: 15rpx;
    position: absolute;
    left: 32rpx;
  }
}

.reading-box {
  margin: 20rpx 25rpx 0;

  padding: 35rpx 0rpx 5rpx;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  position: relative;
  // top: -15rpx;
  gap: 16rpx;

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

  .reading-box-item {
    flex: 0 0 calc(50% - 20rpx);
    border-radius: 20rpx;
    box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
    background-color: #fff;
    padding: 20rpx;
    font-size: 30rpx;
  }

  .reading-box-item-title {
    margin: 15rpx 0;
    font-weight: bold;
  }

  .reading-box-item-desc {
    font-size: 20rpx;
    color: #808080;
  }
}

.start-swiper {
  width: 100vw;
  height: calc(100vh - 123rpx);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;

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

.desc-box {
  padding: 0 25rpx;
  color: #616161;
  margin: 30rpx 0;
  font-size: 24rpx;
  padding: 0 40rpx;

  view {
    margin-bottom: 20rpx;
  }
}

.new-book-body {
  margin: 20rpx 25rpx 0;
  border-radius: 20rpx;
  box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
  padding: 50rpx 0rpx 30rpx;
  background-color: #fff;
  text-align: left;

  image {
    margin: 0 auto;
    display: block;
  }

  .new-book-body-title {
    width: 583rpx;
    font-size: 37rpx;
    font-weight: bold;
    margin: 20rpx auto;
  }

  .new-book-body-desc {
    width: 583rpx;
    color: #808080;
    font-size: 24rpx;
    margin: 20rpx auto;
  }
}
.newBookCard {
  width: 583rpx;
  height: 706rpx;
  margin: 0 auto;
  background-size: 100% auto;
  background-repeat: no-repeat;
  background-position: top;
  background-color: #fff;
}
.img-wrapper {
  width: 100%;
  height: 346rpx;
  margin: 0 auto;
  background-size: 100% auto;
  background-repeat: no-repeat;
  background-position: top;
  background-color: #fff;
}
</style>
