<template>
  <div class="app">
    <!-- 固定顶部导航 -->
    <header class="nav" :class="{ 'nav-light': current === 0 }">
      <div class="nav-inner">
        <div class="brand">
          <img v-if="current === 0" src="/img/logo.png" alt="">
          <img v-else src="/img/logo-w.png" alt="">
          <span class="brand-name">壹店无忧</span>
        </div>
        <nav class="nav-links">
          <a href="#" @click.prevent="goto(0)" :class="{ active: current < PAGES - 1 }">官网首页</a>
          <a href="#" @click.prevent="goto(PAGES - 1)" :class="{ active: current === PAGES - 1 }">关注下载</a>
        </nav>
      </div>
    </header>

    <!-- 右侧快捷导航 -->
    <aside class="dots" :class="{ 'dots-light': current === 0 || current === 6 }">
      <button v-for="n in PAGES" :key="n" class="dot" :class="{ active: current === n - 1 }" @click="goto(n - 1)"
        :aria-label="`跳到第 ${n} 屏`" />
    </aside>

    <!-- 首页：翻页容器 -->
    <main class="pager" ref="pager" @scroll="onScroll" @wheel.prevent="onWheel"> <!-- 首屏 -->
      <section id="s1" class="page hero">
        <div class="hero-inner">
          <img class="phone" src="/img/home_phone.png" alt="">
          <div class="hero-text">
            <div class="hero-logo">
              <img src="/img/logo.png" alt="">
            </div>
            <span>{{ firstPage.title }}</span>
            <p>{{ firstPage.desc }}</p>
          </div>
        </div>
        <svg class="wave wave-bottom" viewBox="0 0 1440 120" preserveAspectRatio="none">
          <path d="M0,50 C200,20 200,10 400,10 C600,10 700,70 900,70 C1100,70 1240,20 1440,20 L1440,120 L0,120 Z"
            fill="#f3f3f3" />
        </svg>
      </section>

      <!-- 功能页 -->
      <section v-for="(f, i) in features" :key="f.title" :id="`s${i + 2}`" class="page feature">
        <div class="feature-inner">
          <div class="feature-text">
            <h2>
              <span>{{ f.title[0] }}</span><br />
              <span class="indent">{{ f.title[1] }}</span>
            </h2>
            <p>{{ f.desc }}</p>
          </div>
          <img class="feature-illu" :src="f.img" alt="">
        </div>
        <div class="wave wave-bottom">
          <svg class="wave-layer wave-back" viewBox="0 0 2880 240" preserveAspectRatio="none">
            <path
              d="M0,100 C240,30 480,170 720,100 C960,30 1200,170 1440,100 C1680,30 1920,170 2160,100 C2400,30 2640,170 2880,100 L2880,240 L0,240 Z"
              fill="#fef2dc" />
          </svg>
          <svg class="wave-layer wave-front" viewBox="0 0 2880 240" preserveAspectRatio="none">
            <path
              d="M0,160 C240,220 480,80 720,140 C960,200 1200,60 1440,160 C1680,220 1920,80 2160,140 C2400,200 2640,60 2880,160 L2880,240 L0,240 Z"
              fill="#ffca28" />
          </svg>
        </div>
      </section>

      <!-- 首页最后：黑色二维码页 -->
      <section id="s7" class="page home-qr">
        <div class="home-qr-text">
          <h2>真实消费福利的生活平台</h2>
          <p class="home-qr-sub">全方位满足您吃喝玩乐游购的一站式综合性服务平台</p>
        </div>
        <div class="home-qr-row">
          <div class="dl-info">
            <p>邮箱：edaylife@163.com</p>
            <p>地址：四川省成都市武侯区长益路68号1栋6层6号</p>
            <p>Copyright &nbsp;&copy;&nbsp; 四川壹店网络科技有限公司 &nbsp;版权所有</p>
            <p>ICP备案号：<a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener">蜀ICP备2024067224号-1</a></p>
          </div>
          <div v-for="q in qrs" :key="q.label" class="home-qr-card">
            <span class="home-qr-title"><img class="icon" :src="q.tit_img" alt=""> {{ q.label }}</span>
            <div class="qr-img">
              <img :src="q.img" alt="">
            </div>
          </div>

        </div>

      </section>
    </main>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'

const pager = ref(null)
const current = ref(0)

const firstPage = {
  title: '一个让您能享受到真实消费福利的生活平台',
  desc: '深入融合生活的丰富需求，全方位满足您吃喝玩乐游购的一站式综合性服务平台，让每一次消费都是价值创造。'
}

const features = [
  { title: ['大牌吃喝', '品质享受'], img: '/img/f1.png', desc: '精心筛选国民大牌餐饮，从连锁品牌到网红品牌，应有尽有，都是顶级味蕾体验，随时随处地放心享受。' },
  { title: ['本地团购', '便捷实惠'], img: '/img/f2.png', desc: '覆盖全国城市本地优质商家门店，丰富的团购活动，满足多样的消费需求，团购更实惠。' },
  { title: ['电商购物', '随心享购'], img: '/img/f3.png', desc: '丰富的购物商城，涵盖家用电器、珠宝箱包、家居百货、美妆个护等优质商品，让您足不出户，轻松选购到家。' },
  { title: ['生活服务', '无限精彩'], img: '/img/f4.png', desc: '聚合加油、话费、水电费、飞机票、高铁票、酒店、旅游等刚需服务，快捷到位。' },
  { title: ['红包补贴', '贴心回馈'], img: '/img/f5.png', desc: '让您每一次消费物有所值，红包补贴政策不断，无论是购物还是服务，都能让您真实享受到补贴快乐。' },
]

const qrs = [
  { label: '公众号关注', img: '/img/gzhewm.png', tit_img: '/img/wechat.png' },
  { label: 'App 下载', img: '/img/downloadewm.png', tit_img: '/img/cloud.png' },
]

const PAGES = 7 // hero + 5 features + qr
const LOCK_MS = 800
let locked = false

const goto = (idx) => {
  if (!pager.value) return
  const target = Math.max(0, Math.min(PAGES - 1, idx))
  if (target === current.value) return
  locked = true
  current.value = target
  pager.value.scrollTo({ top: target * pager.value.clientHeight, behavior: 'smooth' })
  setTimeout(() => { locked = false }, LOCK_MS)
}

const onScroll = () => {
  if (!pager.value || locked) return
  current.value = Math.round(pager.value.scrollTop / pager.value.clientHeight)
}

const onWheel = (e) => {
  e.preventDefault()
  if (locked) return
  goto(current.value + (e.deltaY > 0 ? 1 : -1))
}

const onKey = (e) => {
  if (!pager.value) return
  if (e.key === 'ArrowDown' || e.key === 'PageDown') {
    e.preventDefault()
    goto(current.value + 1)
  } else if (e.key === 'ArrowUp' || e.key === 'PageUp') {
    e.preventDefault()
    goto(current.value - 1)
  }
}

onMounted(() => window.addEventListener('keydown', onKey))
onUnmounted(() => window.removeEventListener('keydown', onKey))
</script>

<style scoped>
@font-face {
  font-family: 'AlimamaShuHeiTi-Bold';
  src: url('/ALIMAMASHUHEITI.TTF') format('truetype');
  font-display: swap;
}

* {
  box-sizing: border-box;
}

.app {
  height: 100vh;
  overflow: hidden;
  isolation: isolate;
}

/* 顶部导航 */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 100;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 30px;
}

.brand img {
  width: 54px;
  height: 47px;
}

.brand-name {
  font-size: 25px;
  color: #000;
}

.nav-links {
  display: flex;
  gap: 40px;
  align-items: center;
}

.nav-links a {
  color: #000;
  text-decoration: none;
  font-size: 18px;
  padding: 6px 0 12px;
  position: relative;
  transition: 0.2s;
  mix-blend-mode: difference;
}

.nav-links a::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  height: 6px;
  width: 70%;
  border-radius: 3px;
}

.nav-links a.active,
.nav-links a:hover {
  color: #000;
  font-size: 22px;
}

.nav-links a.active::after,
.nav-links a:hover::after {
  background: #000;
}

/* 首屏白色样式 */
.nav-light .brand-name,
.nav-light .nav-links a,
.nav-light .nav-links a.active,
.nav-light .nav-links a:hover {
  color: #fff;
}

.nav-light .nav-links a.active::after,
.nav-light .nav-links a:hover::after {
  background: #fff;
}

/* 右侧快捷导航 */
.dots {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 90;
}

.dot {
  width: 12px;
  height: 12px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.4);
  background: transparent;
  cursor: pointer;
  transition: 0.2s;
}

.dot:hover {
  border-color: #000;
}

.dot.active {
  background: #ffc93a;
  border-color: #ffc93a;
  transform: scale(1.3);
}

.dots-light .dot {
  border-color: rgba(255, 255, 255, 0.6);
}

.dots-light .dot:hover {
  border-color: #fff;
}

.dots-light .dot.active {
  background: #fff;
  border-color: #fff;
}

/* 翻页容器 */
.pager {
  height: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

.pager::-webkit-scrollbar {
  display: none;
}

.page {
  height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 首屏 */
.hero {
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url(/img/home_bg.png);
  background-size: 100% auto;
}

.hero-inner {
  max-width: 1000px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 100px;
  position: relative;
  z-index: 2;
}

.phone {
  width: 300px;
  height: 597px;
}

.hero-text {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 60px;
  text-align: center;
  margin-top: -20px;
}

.hero-logo {
  width: 149px;
  height: 128px;
}

.hero-logo img {
  width: 100%;
  height: 100%;
  margin-bottom: 30px;
}

.hero-text span {
  font-size: 33px;
  line-height: 50px;
  letter-spacing: 2px;
  color: #ffffff;
  width: 384px;
}

.hero-text p {
  font-size: 20px;
  line-height: 42px;
  letter-spacing: 1px;
  color: #ffffff;
  margin: 0;
}

/* 波浪 */
.wave {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  height: 400px;
  overflow: hidden;
  pointer-events: none;
}

.wave-top {
  top: 0;
}

.wave-bottom {
  bottom: 0;
}

.wave-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 100%;
  animation: wave-slide 8s linear infinite;
}

.wave-back {
  animation-duration: 12s;
}

.wave-front {
  animation-duration: 7s;
  animation-direction: reverse;
}

@keyframes wave-slide {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-50%);
  }
}

/* 功能页 */
.feature {
  background: #fff;
}

.feature-inner {
  max-width: 1000px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 60px;
  margin-top: -100px;
}

.feature-text {
  flex: 1;
}

.feature-text h2 {
  font-size: 60px;
  font-weight: 700;
  color: #222;
  margin: 0 0 24px;
  line-height: 1.4;
}

.feature-text h2 .indent {
  padding-left: 60px;
}

.feature-text p {
  font-size: 20px;
  line-height: 33px;
}

.feature-illu {
  width: 450px;
}

/* 首页黑底二维码页 */
.home-qr {
  background: #fff;
  flex-direction: column;
  padding: 0 80px;
  position: relative;
}

.home-qr::before {
  content: '';
  position: absolute;
  bottom: -171px;
  left: 50%;
  transform: translateX(-50%);
  width: 1920px;
  height: 764px;
  background: url(/img/bottom_bg.png) no-repeat;
  background-size: 100% 78%;
}

.home-qr-text {
  display: flex;
  align-items: center;
  flex-direction: column;
}

.home-qr h2 {
  font-family: 'AlimamaShuHeiTi-Bold';
  font-size: 100px;
  letter-spacing: 0px;
  color: #000000;
  margin: 0;
}

.home-qr-sub {
  font-size: 28px;
  line-height: 36px;
  letter-spacing: 9px;
  color: #161616;
  margin-top: 70px;
}

.home-qr-row {
  display: flex;
  align-items: center;
  gap: 125px;
  margin-top: 180px;
  z-index: 2;
}

.home-qr-card {
  width: 250px;
  height: 290px;
  border-radius: 15px;
  border: solid 2px #ffffff;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: space-between;
  padding: 15px 0 25px;
}

.home-qr-title {
  display: flex;
  align-items: center;
  gap: 15px;
}

.home-qr-card span {
  font-size: 18px;
  line-height: 30px;
  color: #ffffff;
}

/* 首页黑底二维码页底部信息 */
.qr-img {
  width: 192px;
  height: 192px;
}

.qr-img img {
  width: 100%;
  height: 100%;
}

.dl-info {
  margin-top: 40px;
  text-align: left;
  color: #fff;
  font-size: 18px;
  line-height: 2;
  z-index: 2;
}

.dl-info p {
  margin: 0;
}

.dl-info a {
  color: inherit;
  text-decoration: none;
}

/* 响应式 */
@media (max-width: 1200px) {
  .nav-inner {
    padding: 0 20px;
  }

  .hero-inner {
    gap: 40px;
    padding: 0 20px;
  }

  .feature-inner {
    padding: 0 40px;
    gap: 30px;
  }

  .feature-text h2 {
    font-size: 44px;
  }

  .feature-illu {
    width: 350px;
  }

  .home-qr {
    padding: 0 40px;
  }

  .home-qr h2 {
    font-size: 72px;
  }

  .home-qr-row {
    gap: 60px;
  }
}

@media (max-width: 900px) {
  .dots {
    right: 12px;
    gap: 10px;
  }

  .dot {
    width: 10px;
    height: 10px;
  }

  .nav {
    height: 56px;
  }

  .brand {
    gap: 12px;
  }

  .brand img {
    width: 40px;
    height: auto;
  }

  .brand-name {
    font-size: 18px;
  }

  .nav-links {
    gap: 20px;
  }

  .nav-links a {
    font-size: 15px;
    padding: 4px 0 10px;
  }

  .nav-links a.active,
  .nav-links a:hover {
    font-size: 18px;
  }

  .hero-inner,
  .feature-inner {
    flex-direction: column;
    gap: 30px;
    padding: 80px 20px 60px;
  }

  .phone {
    width: 220px;
    height: 438px;
  }

  .hero-text {
    gap: 30px;
    margin-top: 0;
  }

  .hero-text span {
    font-size: 22px;
    line-height: 34px;
    width: auto;
    max-width: 90vw;
  }

  .hero-text p {
    font-size: 15px;
    line-height: 28px;
  }

  .feature-inner {
    margin-top: 0;
  }

  .feature-text h2 {
    font-size: 32px;
  }

  .feature-text p {
    font-size: 15px;
    line-height: 26px;
  }

  .feature-illu {
    width: 260px;
  }

  .home-qr {
    padding: 60px 20px 0;
    justify-content: flex-start;
  }

  .home-qr h2 {
    font-size: 40px;
    line-height: 1.2;
  }

  .home-qr-sub {
    font-size: 16px;
    letter-spacing: 4px;
    margin-top: 30px;
  }

  .home-qr-row {
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 40px;
  }

  .hero::before {
    background-size: cover;
    background-position: center;
  }

  .home-qr::before {
    width: 100%;
    height: auto;
    aspect-ratio: 1920 / 764;
    bottom: 0;
    background-size: cover;
  }
}

@media (max-width: 480px) {
  .hero-inner {
    padding-top: 0;
  }

  .feature-inner {
    padding-top: 0;
  }

  .phone {
    height: 350px;
    width: auto;
  }

  .wave {
    height: 200px;
  }

  .hero-logo {
    height: 80px;
    width: auto;
  }

  .brand-name {
    display: none;
  }

  .home-qr h2 {
    font-size: 30px;
  }

  .home-qr-row {
    flex-direction: column-reverse
  }

  .home-qr-sub {
    font-size: 13px;
    letter-spacing: 2px;
  }

  .home-qr-card {
    width: 220px;
    height: 260px;
    color: #000;
    border: #000 2px solid;
  }

  .home-qr-card .home-qr-title {
    color: #000;
  }

  .home-qr-card .icon {
    filter: brightness(0);
  }

  .qr-img {
    width: 170px;
    height: 170px;
  }

  .dl-info {
    font-size: 12px;
  }
}
</style>