index.vue 2.99 KB
<template>
    <view class="offline-booking-code-page">
        <view class="header-tip">
            <IconFont name="tips" size="15" color="#A67939" />
            <text>您当前处于离线模式,仅展示本地缓存的预约码</text>
        </view>

        <view style="padding: 32rpx;">
            <offlineQrCode :list="qrList"></offlineQrCode>
            <view class="warning">
                <view>
                    温馨提示
                </view>
                <view style="margin-top: 16rpx;">一人一码,扫码或识别身份证成功后进入</view>
            </view>
        </view>

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

<script setup>
import { ref, onMounted } from 'vue'
import Taro from '@tarojs/taro'
import offlineQrCode from '@/components/offlineQrCode';
import { IconFont } from '@nutui/icons-vue-taro'
import { useGo } from '@/hooks/useGo'

const go = useGo();
const qrList = ref([]);

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

// TODO: Mock Data as per requirement
const getMockData = () => {
    return [
        {
            name: '测试用户1',
            id_number: '110101199003078888',
            qr_code: 'OFFLINE_MOCK_QR_001',
            datetime: '2026-01-08 08:30-10:30',
            sort: 0
        },
        {
            name: '测试用户2',
            id_number: '110101199205126666',
            qr_code: 'OFFLINE_MOCK_QR_002',
            datetime: '2026-01-08 08:30-10:30',
            sort: 0
        }
    ];
}

onMounted(() => {
    try {
        const cachedData = Taro.getStorageSync('OFFLINE_QR_DATA');
        if (cachedData && cachedData.length > 0) {
            qrList.value = cachedData;
        } else {
            // Requirement 4: Mock data if no data
            console.log('No cached data found, using mock data');
            qrList.value = getMockData();
        }
    } catch (e) {
        console.error('Read storage failed', e);
        qrList.value = getMockData();
    }
});

</script>

<style lang="less">
.offline-booking-code-page {
    position: relative;
    min-height: 100vh;
    background-color: #F6F6F6;

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

        text {
            margin-left: 10rpx;
        }
    }

    .warning {
        text-align: center;
        color: #A67939;
        margin-top: 32rpx;
    }

    .action-area {
        position: fixed;
        bottom: 60rpx;
        left: 0;
        width: 100%;
        display: flex;
        justify-content: center;

        .home-btn {
            width: 600rpx;
            height: 88rpx;
            line-height: 88rpx;
            background: #fff;
            color: #A67939;
            border: 2rpx solid #A67939;
            border-radius: 44rpx;
            font-size: 32rpx;
        }
    }
}
</style>