index.vue 2.18 KB
<!--
 * @Date: 2026-01-13 14:55:05
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2026-01-13 15:25:25
 * @FilePath: /xyxBooking-weapp/src/pages/offlineBookingList/index.vue
 * @Description: 离线预约记录页面
-->
<template>
  <view class="offline-booking-list-page">
    <view class="header-tip">
      <IconFont name="tips" size="15" color="#A67939" /> &nbsp;
      <text>您当前处于离线模式,仅展示本地缓存的预约记录</text>
    </view>

    <view class="list-wrapper">
      <view v-for="(item, index) in booking_list" :key="index">
        <reserveCard :data="item" detail_path="/offlineBookingDetail" is_offline />
      </view>

      <view v-if="!booking_list.length" class="empty">
        <text>本地无缓存预约记录</text>
      </view>
    </view>

    <view class="action-area">
      <button class="home-btn" @tap="toHome">返回首页</button>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'
import Taro, { useDidShow } from '@tarojs/taro'
import { IconFont } from '@nutui/icons-vue-taro'
import reserveCard from '@/components/reserveCard.vue'
import { get_offline_booking_cache } from '@/composables/useOfflineBookingCache'

const booking_list = ref([])

const toHome = () => {
  Taro.reLaunch({ url: '/pages/index/index' })
}

const load_cache = () => {
  booking_list.value = get_offline_booking_cache()
}

useDidShow(() => {
  load_cache()
})
</script>

<style lang="less">
.offline-booking-list-page {
  min-height: 100vh;
  background-color: #f6f6f6;

  .header-tip {
    display: flex;
    align-items: center;
    padding: 20rpx 32rpx;
    color: #a67939;
    font-size: 26rpx;
    background: #fff;
  }

  .list-wrapper {
    padding: 32rpx;
  }

  .empty {
    padding: 120rpx 0;
    text-align: center;
    color: #a67939;
    font-size: 32rpx;
  }

  .action-area {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 750rpx;
    padding: 24rpx 32rpx;
    background: #fff;
    box-sizing: border-box;
    box-shadow: 0 -10rpx 8rpx 0 rgba(0, 0, 0, 0.06);

    .home-btn {
      background-color: #a67939;
      color: #fff;
      border-radius: 16rpx;
      font-size: 32rpx;
      padding: 12rpx 0;
    }
  }
}
</style>