<template>
  <div class="benefits-wrapper">
    <div class="carousel">
      <EffectFade :list="data?.fileList ?? []">
        <template v-slot="{ item }">
          <div class="banner-wrapper">
            <img class="banner" :src="config.sourceUrl + item" alt="" />
          </div>
        </template>
      </EffectFade>
    </div>
    <div class="right">
      <h1 class="title">{{ switchLanguage(data, 'title') }}</h1>
      <ScrollView class="intro-scroll" scrollbar>
        <p class="intro">
          {{ switchLanguage(data, 'content') }}
        </p>
      </ScrollView>
      <div class="qrcodeWrapper">
        <ThumbQRCode class="item" v-for="item of qr" :url="config.sourceUrl + item.fileUrl" :title="switchLanguage(item, 'name')" :key="item.name" />
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { storeToRefs } from 'pinia'
import { useStore } from '@/store/root'
import EffectFade from '@/components/EffectFade/EffectFade.vue'
import ScrollView from '@/base/ScrollView/ScrollView.vue'
import ThumbQRCode from '@/base/ThumbQRCode/ThumbQRCode.vue'

const props = defineProps({
  data: Object
})

const store = useStore()
const { config } = storeToRefs(store)
const qr = computed(() => props.data.qrFileList ?? [])
</script>

<style lang="scss" scoped>
.benefits-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  align-items: center;
  padding-top: 48px;

  .carousel {
    flex-shrink: 0;
    width: 944px;
    height: 548px;

    overflow: hidden;
    :deep(.swiper) {
      overflow: visible;
      .swiper-pagination {
        bottom: -16px;
        .swiper-pagination-bullet {
          width: 34px !important;
          height: 4px !important;
          background: rgba(0, 0, 0, 0.6);
          border-radius: 6px !important;
          opacity: inherit !important;
          margin: 0;
          &.swiper-pagination-bullet-active {
            background: #ffffff;
            border-radius: 6px !important;
          }
        }
      }
    }
    .banner {
      width: 944px;
      height: 532px;
      border-radius: var(--global-radius, 8px);
      object-fit: cover;
    }
  }
}
.qrcodeWrapper {
  display: flex;
  margin-left: 68px;
  .item {
    margin-right: 10px;
  }
}
.title {
  padding-top: 32px;
  padding-left: 68px;
  font-weight: 700;
  font-size: 28px;
  line-height: 150%;
  color: var(--carousel-titleColor);
}

.intro-scroll {
  position: relative;
  height: 250px;
  overflow: hidden;
  margin-left: 68px;
  margin-right: 31px;
  padding-right: 31px;
  margin-bottom: 33px;
  margin-top: 32px;
  .intro {
    font-weight: 400;
    font-size: 16px;
    line-height: 200%;
    text-align: justify;
    color: var(--carousel-introColor);
  }
}
@media (min-aspect-ratio: 1/1) {
  .benefits-wrapper {
    flex-direction: row;
    align-items: flex-start;
    padding-top: 100px;
    padding-left: 63px;
    .carousel {
      position: relative;
    }
  }
  .title {
    padding-top: 0;
  }
}
</style>
