index.vue 6.78 KB
<!--
 * @Date: 2023-06-21 10:23:09
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2026-01-13 15:47:00
 * @FilePath: /xyxBooking-weapp/src/pages/index/index.vue
 * @Description: 预约页首页
-->
<template>
  <view class="index-page">
    <view v-if="is_offline" class="offline-banner mx-6 mt-4 rounded-xl px-4 py-3">
      <view class="flex items-center">
        <IconFont name="tips" size="18" />
        <text class="ml-2 font-medium">离线模式</text>
      </view>
      <view class="mt-1 text-sm opacity-80">网络不佳,已启用本地显示</view>
    </view>
    <view class="index-content">
      <view style="height: 28vh;">
        <swiper class="my-swipe" :autoplay="true" :interval="3000" indicator-dots indicator-color="white" :circular="true">
          <swiper-item>
            <image style="height: 28vh; width: 100vw;" src="https://cdn.ipadbiz.cn/xys/booking/banner01.png?imageMogr2/thumbnail/500x/strip/quality/100" />
          </swiper-item>
        </swiper>
      </view>

      <view ref="root" class="index-circular">
        <view class="booking-wrapper">
          <view class="booking" @tap="toBooking">
            <view><image :src="icon_1" style="width: 96rpx; height: 96rpx;" /></view>
            <view style="color: #FFF;">开始预约</view>
          </view>
        </view>
      </view>
      <view class="logo"></view>
    </view>
    <view class="index-nav">
      <view class="nav-logo">
        <image :src="icon_3" style="width: 48rpx; height: 48rpx;" />
        首页
      </view>
      <view class="nav-logo" @tap="toCode">
        <image :src="icon_4" style="width: 140rpx; height: 140rpx; position: absolute; top: -100rpx;" />
        <view style="width: 48rpx; height: 48rpx;"></view>
        预约码
      </view>
      <view class="nav-logo" @tap="toMy">
        <image :src="icon_5" style="width: 48rpx; height: 48rpx;" />
        我的
      </view>
    </view>
  </view>
</template>

<script setup>
import Taro, { useDidShow, useShareAppMessage } from '@tarojs/taro'
import { IconFont } from '@nutui/icons-vue-taro'
// import { showSuccessToast, showFailToast } from 'vant'; // NutUI 或 Taro API
import { ref } from 'vue'
import { useGo } from '@/hooks/useGo'
import { get_network_type, is_usable_network } from '@/utils/network'
import icon_1 from '@/assets/images/立即预约@2x.png'
import icon_3 from '@/assets/images/首页02@2x.png'
import icon_4 from '@/assets/images/二维码icon.png'
import icon_5 from '@/assets/images/我的01@2x.png'

const go = useGo();
const is_offline = ref(false)

const refresh_offline_state = async () => {
  const network_type = await get_network_type()
  is_offline.value = !is_usable_network(network_type)
}

useDidShow(() => {
  refresh_offline_state()
})

const toBooking = () => { // 跳转到预约须知
  // 如果是离线模式,不跳转
  if (is_offline.value) {
    Taro.showToast({
      title: '当前为离线模式,无法预约',
      icon: 'none'
    })
    return
  }
  go('/notice');
}
const toCode = () => { // 跳转到预约码
  Taro.redirectTo({
    url: '/pages/bookingCode/index'
  })
}
const toMy = () => { // 跳转到我的
  Taro.redirectTo({
    url: '/pages/me/index'
  })
}

useShareAppMessage(() => {
  return {
    title: '西园寺预约',
    path: '/pages/index/index'
  }
})

</script>

<style lang="less">
.index-page {
  position: relative;
  min-height: 100vh;
  background-color: #F3EEE3;
  background-image:
    linear-gradient(180deg, rgba(166, 121, 57, 0.10) 0%, rgba(255, 255, 255, 0.90) 60%, rgba(243, 238, 227, 1) 100%),
    url('https://cdn.ipadbiz.cn/xys/booking/bg.jpg?imageMogr2/thumbnail/200x/strip/quality/50');
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover; /* 确保背景覆盖 */

  .offline-banner {
    position: absolute;
    top: 24rpx;
    left: 24rpx;
    right: 24rpx;
    z-index: 10;
    background: rgba(255, 255, 255, 0.88);
    color: #A67939;
    border: 2rpx solid rgba(166, 121, 57, 0.25);
    box-shadow: 0 12rpx 30rpx rgba(166, 121, 57, 0.12);
    backdrop-filter: blur(6px);
  }
  .index-content {
    height: calc(100vh - 134rpx);
    .index-control {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      margin-top: 130rpx;
      // font-weight: bold;
      font-size: 37rpx;
      .booking {
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #A67939;
        border-radius: 14rpx;
        color: #FFFFFF;
        padding: 22rpx 128rpx;
        border: 2rpx solid #A67939;
      }
      .record {
        display: flex;
        justify-content: center;
        align-items: center;
        color: #A67939;
        border-radius: 14rpx;
        padding: 22rpx 128rpx;
        border: 2rpx solid #A67939;
        margin-top: 48rpx;
      }
      .search {
        display: flex;
        justify-content: center;
        align-items: center;
        color: #A67939;
        border-radius: 14rpx;
        padding: 22rpx 128rpx;
        border: 2rpx solid #A67939;
        margin-top: 48rpx;
      }
    }
    .index-circular {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-top: 130rpx;
      // font-weight: bold;
      font-size: 35rpx;

      .booking-wrapper {
        height: 260rpx;
        width: 260rpx;
        border-radius: 50%;
        background-color: rgba(166, 121, 57, 0.26);
        display: flex;
        align-items: center;
        justify-content: center;
        .booking {
          height: 230rpx;
          width: 230rpx;
          border-radius: 50%;
          background-color: #A67939;
          display: flex;
          align-items: center;
          justify-content: center;
          flex-direction: column;
        }
      }
    }
    .logo {
      position: absolute;
      right: 0;
      bottom: 200rpx;
      height: 400rpx;
      width: 150rpx;
      background-image: url('https://cdn.ipadbiz.cn/xys/booking/logo.png?imageMogr2/thumbnail/50x/strip/quality/50');
      background-repeat: no-repeat;
      background-size: contain;
      background-position: center;
    }
  }
  .my-swipe {
    height: 400rpx;
    swiper-item { /* Taro swiper-item 编译后 */
      height: 400rpx;
      width: 750rpx;
      background-size: cover;
      background-repeat: no-repeat;
      background-position: center;
    }
  }
  .index-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 750rpx;
    height: 134rpx;
    background: #FFFFFF;
    box-shadow: 0 -10rpx 8rpx 0 rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: space-around;
    color: #A67939;
    .nav-logo {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
  }
}
</style>