import React, { useState, useEffect } from 'react' import { View, Text, ScrollView, Input } from '@tarojs/components' import Taro from '@tarojs/taro' import { Button } from '@nutui/nutui-react-taro' import { useUser } from '@/hooks/useUser' import { useScrollHeight } from '@/hooks/useScrollHeight' definePageConfig({ navigationBarTitleText: '穿线预约', }) const BookingPage: React.FC = () => { const { isLoggedIn } = useUser() const { storeId } = Taro.getCurrentInstance().router?.params || {} const [date, setDate] = useState('') const [time, setTime] = useState('') const [serviceType, setServiceType] = useState('') const [contactName, setContactName] = useState('') const [contactPhone, setContactPhone] = useState('') const [remark, setRemark] = useState('') const scrollHeight = useScrollHeight(100) useEffect(() => { if (!isLoggedIn) { Taro.navigateTo({ url: '/passport/login' }) } }, [isLoggedIn]) const timeSlots = [ '09:00-10:00', '10:00-11:00', '11:00-12:00', '14:00-15:00', '15:00-16:00', '16:00-17:00', '17:00-18:00', ] const serviceTypes = ['穿线服务', '穿线+手胶', '穿线+毛巾胶', '其他'] const handleSubmit = () => { if (!date || !time || !serviceType || !contactName || !contactPhone) { Taro.showToast({ title: '请填写完整信息', icon: 'none' }) return } Taro.showModal({ title: '确认预约', content: `预约时间:${date} ${time}\n服务类型:${serviceType}`, success: (res) => { if (res.confirm) { Taro.showToast({ title: '预约成功', icon: 'success' }) setTimeout(() => Taro.navigateBack(), 1500) } }, }) } return ( {/* 选择日期 */} 选择日期 setDate(e.detail.value)} className='bg-gray-50 rounded-lg p-2 text-sm' /> {/* 选择时间 */} 选择时间 {timeSlots.map(slot => ( setTime(slot)} > {slot} ))} {/* 服务类型 */} 服务类型 {serviceTypes.map(type => ( setServiceType(type)} > {type} ))} {/* 联系人信息 */} 联系人信息 姓名 setContactName(e.detail.value)} placeholder='请输入姓名' className='bg-gray-50 rounded-lg p-2 text-sm w-full' /> 手机号 setContactPhone(e.detail.value)} placeholder='请输入手机号' className='bg-gray-50 rounded-lg p-2 text-sm w-full' /> {/* 备注 */} 备注 setRemark(e.detail.value)} placeholder='选填,如有特殊需求请注明' className='bg-gray-50 rounded-lg p-2 text-sm w-full' style={{ minHeight: '80px' }} /> {/* 提交按钮 */} ) } export default BookingPage