Files
xinlong-shop-taro/src/pages/booking.tsx
赵忠林 f3886664f7 fix(api): 替换所有接口请求的域名为 guilixu-api.websoft.top
- 将获取 STS Token 的接口地址由 paopao-api 改为 guilixu-api
- 更新图片上传接口地址为新的 guilixu-api 域名
- 修改用户推广页面中邀请码链接和二维码接口的域名
- 更改注册页微信登录接口请求的域名为 guilixu-api
2026-06-16 17:15:59 +08:00

168 lines
5.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 (
<View className='min-h-screen bg-gray-50'>
<ScrollView scrollY style={{ height: scrollHeight }}>
{/* 选择日期 */}
<View className='bg-white mx-3 mt-3 p-3 rounded-lg'>
<Text className='text-sm font-medium text-gray-800 mb-2 block'></Text>
<Input
type='date'
value={date}
onInput={(e) => setDate(e.detail.value)}
className='bg-gray-50 rounded-lg p-2 text-sm'
/>
</View>
{/* 选择时间 */}
<View className='bg-white mx-3 mt-3 p-3 rounded-lg'>
<Text className='text-sm font-medium text-gray-800 mb-2 block'></Text>
<View className='grid grid-cols-3 gap-2'>
{timeSlots.map(slot => (
<View
key={slot}
className={`p-2 rounded-lg text-center text-sm ${
time === slot
? 'bg-green-500 text-white'
: 'bg-gray-50 text-gray-600'
}`}
onClick={() => setTime(slot)}
>
<Text>{slot}</Text>
</View>
))}
</View>
</View>
{/* 服务类型 */}
<View className='bg-white mx-3 mt-3 p-3 rounded-lg'>
<Text className='text-sm font-medium text-gray-800 mb-2 block'></Text>
<View className='flex flex-wrap gap-2'>
{serviceTypes.map(type => (
<View
key={type}
className={`px-3 py-1 rounded-full text-sm ${
serviceType === type
? 'bg-green-50 text-green-600 border border-green-500'
: 'bg-gray-50 text-gray-600 border border-gray-200'
}`}
onClick={() => setServiceType(type)}
>
<Text>{type}</Text>
</View>
))}
</View>
</View>
{/* 联系人信息 */}
<View className='bg-white mx-3 mt-3 p-3 rounded-lg'>
<Text className='text-sm font-medium text-gray-800 mb-2 block'></Text>
<View className='mb-2'>
<Text className='text-xs text-gray-500 mb-1 block'></Text>
<Input
value={contactName}
onInput={(e) => setContactName(e.detail.value)}
placeholder='请输入姓名'
className='bg-gray-50 rounded-lg p-2 text-sm w-full'
/>
</View>
<View>
<Text className='text-xs text-gray-500 mb-1 block'></Text>
<Input
type='number'
value={contactPhone}
onInput={(e) => setContactPhone(e.detail.value)}
placeholder='请输入手机号'
className='bg-gray-50 rounded-lg p-2 text-sm w-full'
/>
</View>
</View>
{/* 备注 */}
<View className='bg-white mx-3 mt-3 p-3 rounded-lg mb-4'>
<Text className='text-sm font-medium text-gray-800 mb-2 block'></Text>
<Input
value={remark}
onInput={(e) => setRemark(e.detail.value)}
placeholder='选填,如有特殊需求请注明'
className='bg-gray-50 rounded-lg p-2 text-sm w-full'
style={{ minHeight: '80px' }}
/>
</View>
</ScrollView>
{/* 提交按钮 */}
<View className='bg-white border-t border-gray-100 p-3' style={{ paddingBottom: '20px' }}>
<Button
type='primary'
className='w-full rounded-full'
style={{ backgroundColor: '#0e932e' }}
onClick={handleSubmit}
>
</Button>
</View>
</View>
)
}
export default BookingPage