feat(user): 新增收货地址管理及售后申请页面
- 新增地址类型定义,增强前端地址数据结构 - 新增地址编辑页面,支持地址智能识别和定位选点功能 - 地址编辑支持省市区选择及默认地址设置 - 新增地址列表页面,支持地址展示、删除、编辑和选择功能 - 实现售后申请页面,支持选择售后类型和退款原因 - 售后申请支持商品选择、退款金额计算和凭证上传 - 新增售后详情页面,支持售后状态展示及申请取消 - 优化页面加载和用户交互体验,增加错误提示和权限处理
This commit is contained in:
3
src_bak/pages/booking/detail/index.config.ts
Normal file
3
src_bak/pages/booking/detail/index.config.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '预约详情',
|
||||
}
|
||||
242
src_bak/pages/booking/detail/index.tsx
Normal file
242
src_bak/pages/booking/detail/index.tsx
Normal file
@@ -0,0 +1,242 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import { View, Text, ScrollView } from '@tarojs/components'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import { getShopBooking, cancelShopBooking } from '@/api/shop/shopBooking'
|
||||
import type { ShopBooking, BookingStatus } from '@/api/shop/shopBooking/model'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '预约详情',
|
||||
})
|
||||
|
||||
const BookingDetailPage: React.FC = () => {
|
||||
const router = useRouter()
|
||||
const [order, setOrder] = useState<ShopBooking | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [cancelling, setCancelling] = useState(false)
|
||||
|
||||
// 获取预约详情
|
||||
const loadBookingDetail = async () => {
|
||||
const id = router.params.id
|
||||
if (!id) {
|
||||
Taro.showToast({ title: '参数错误', icon: 'none' })
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await getShopBooking(id)
|
||||
setOrder(data)
|
||||
} catch (e: any) {
|
||||
console.error('获取预约详情失败:', e)
|
||||
Taro.showToast({ title: e.message || '获取详情失败', icon: 'none' })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadBookingDetail()
|
||||
}, [])
|
||||
|
||||
// 获取状态标签
|
||||
const getStatusInfo = (status: BookingStatus | undefined) => {
|
||||
const map: Record<BookingStatus, { label: string; color: string; bg: string }> = {
|
||||
'pending': { label: '待服务', color: 'text-orange-500', bg: 'bg-orange-50' },
|
||||
'confirmed': { label: '已确认', color: 'text-blue-500', bg: 'bg-blue-50' },
|
||||
'in_progress': { label: '进行中', color: 'text-blue-500', bg: 'bg-blue-50' },
|
||||
'completed': { label: '已完成', color: 'text-green-500', bg: 'bg-green-50' },
|
||||
'cancelled': { label: '已取消', color: 'text-gray-400', bg: 'bg-gray-100' },
|
||||
'rescheduled': { label: '已改签', color: 'text-purple-500', bg: 'bg-purple-50' },
|
||||
}
|
||||
return map[status as BookingStatus] || { label: '未知', color: 'text-gray-400', bg: 'bg-gray-100' }
|
||||
}
|
||||
|
||||
// 取消预约
|
||||
const handleCancel = () => {
|
||||
if (!order?.id) return
|
||||
|
||||
Taro.showModal({
|
||||
title: '确认取消',
|
||||
content: '确定取消该预约吗?\n\n取消后将无法恢复。',
|
||||
confirmColor: '#0e932e',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
setCancelling(true)
|
||||
await cancelShopBooking(order.id)
|
||||
Taro.showToast({ title: '已取消', icon: 'success' })
|
||||
// 重新加载详情
|
||||
setTimeout(() => loadBookingDetail(), 1500)
|
||||
} catch (e: any) {
|
||||
console.error('取消预约失败:', e)
|
||||
Taro.showToast({ title: e.message || '取消失败', icon: 'none' })
|
||||
} finally {
|
||||
setCancelling(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 改签预约
|
||||
const handleReschedule = () => {
|
||||
if (order?.id) {
|
||||
Taro.navigateTo({ url: `/pages/booking/reschedule/index?id=${order.id}` })
|
||||
}
|
||||
}
|
||||
|
||||
// 返回列表
|
||||
const handleBackToList = () => {
|
||||
Taro.navigateBack()
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<View className='min-h-screen bg-gray-50 flex items-center justify-center'>
|
||||
<Text className='text-gray-400'>加载中...</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
if (!order) {
|
||||
return (
|
||||
<View className='min-h-screen bg-gray-50 flex items-center justify-center'>
|
||||
<View className='text-center'>
|
||||
<Text className='text-gray-400 block mb-4'>暂无数据</Text>
|
||||
<View
|
||||
className='inline-block bg-orange-500 text-white px-4 py-2 rounded-full'
|
||||
onClick={handleBackToList}
|
||||
>
|
||||
<Text className='text-sm'>返回列表</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
const statusInfo = getStatusInfo(order.status)
|
||||
|
||||
return (
|
||||
<View className='min-h-screen bg-gray-50 flex flex-col'>
|
||||
<ScrollView scrollY className='flex-1'>
|
||||
{/* 状态卡片 */}
|
||||
<View className='p-4 text-white' style={{ background: 'linear-gradient(to right, #0e932e, #2eb872)' }}>
|
||||
<View className='flex items-center gap-2'>
|
||||
<Text className='text-2xl'>📅</Text>
|
||||
<View>
|
||||
<Text className='text-xl font-bold block mb-1'>{statusInfo.label}</Text>
|
||||
<Text className='text-xs opacity-80 block'>预约编号:{order.bookingNo}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 预约信息 */}
|
||||
<View className='bg-white mx-3 mt-3 rounded-xl p-4 shadow-sm'>
|
||||
<Text className='text-base font-medium text-gray-800 mb-3 block'>预约信息</Text>
|
||||
|
||||
<View className='flex justify-between py-2 border-b border-gray-50'>
|
||||
<Text className='text-sm text-gray-500'>服务名称</Text>
|
||||
<Text className='text-sm text-gray-800'>{order.serviceName || '预约服务'}</Text>
|
||||
</View>
|
||||
<View className='flex justify-between py-2 border-b border-gray-50'>
|
||||
<Text className='text-sm text-gray-500'>预约日期</Text>
|
||||
<Text className='text-sm text-gray-800'>{order.bookingDate || '-'}</Text>
|
||||
</View>
|
||||
<View className='flex justify-between py-2 border-b border-gray-50'>
|
||||
<Text className='text-sm text-gray-500'>预约时段</Text>
|
||||
<Text className='text-sm text-gray-800'>{order.bookingTime || '-'}</Text>
|
||||
</View>
|
||||
{order.price > 0 && (
|
||||
<View className='flex justify-between py-2 border-b border-gray-50'>
|
||||
<Text className='text-sm text-gray-500'>服务费用</Text>
|
||||
<Text className='text-sm text-red-500 font-bold'>¥{order.price}</Text>
|
||||
</View>
|
||||
)}
|
||||
<View className='flex justify-between py-2'>
|
||||
<Text className='text-sm text-gray-500'>预约备注</Text>
|
||||
<Text className='text-sm text-gray-800'>{order.remark || '无'}</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 联系人信息 */}
|
||||
{(order.contactName || order.contactPhone) && (
|
||||
<View className='bg-white mx-3 mt-3 rounded-xl p-4 shadow-sm'>
|
||||
<Text className='text-base font-medium text-gray-800 mb-3 block'>联系人</Text>
|
||||
{order.contactName && (
|
||||
<View className='flex justify-between py-2 border-b border-gray-50'>
|
||||
<Text className='text-sm text-gray-500'>姓名</Text>
|
||||
<Text className='text-sm text-gray-800'>{order.contactName}</Text>
|
||||
</View>
|
||||
)}
|
||||
{order.contactPhone && (
|
||||
<View className='flex justify-between py-2'>
|
||||
<Text className='text-sm text-gray-500'>电话</Text>
|
||||
<Text
|
||||
className='text-sm text-blue-500'
|
||||
onClick={() => Taro.makePhoneCall({ phoneNumber: order.contactPhone })}
|
||||
>
|
||||
{order.contactPhone} 📞</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 门店信息 */}
|
||||
<View className='bg-white mx-3 mt-3 rounded-xl p-4 shadow-sm'>
|
||||
<Text className='text-base font-medium text-gray-800 mb-3 block'>门店信息</Text>
|
||||
|
||||
<View className='flex items-center gap-2 mb-2'>
|
||||
<Text className='text-lg'>🏪</Text>
|
||||
<Text className='text-sm font-medium text-gray-800'>{order.storeName || '门店'}</Text>
|
||||
</View>
|
||||
{order.storePhone && (
|
||||
<View className='flex items-center gap-2 mb-2'>
|
||||
<Text className='text-sm text-gray-400'>📞</Text>
|
||||
<Text
|
||||
className='text-sm text-blue-500'
|
||||
onClick={() => Taro.makePhoneCall({ phoneNumber: order.storePhone })}
|
||||
>
|
||||
{order.storePhone}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
{order.address && (
|
||||
<View className='flex items-start gap-2 mb-2'>
|
||||
<Text className='text-sm text-gray-400'>📍</Text>
|
||||
<Text className='text-sm text-gray-600 flex-1'>{order.address}</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
{/* 创建时间 */}
|
||||
{order.createTime && (
|
||||
<View className='mx-3 mt-3 mb-4'>
|
||||
<Text className='text-xs text-gray-400'>预约时间:{order.createTime}</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 操作按钮 - 仅待服务状态显示 */}
|
||||
{order.status === 'pending' && (
|
||||
<View className='p-3 gap-3 mx-3'>
|
||||
<View
|
||||
className='text-center py-3 rounded-full border border-red-500 bg-white mb-3'
|
||||
onClick={handleCancel}
|
||||
>
|
||||
<Text className='text-red-500 font-medium'>{cancelling ? '取消中...' : '取消预约'}</Text>
|
||||
</View>
|
||||
<View
|
||||
className='text-center py-3 rounded-full bg-green-500'
|
||||
onClick={handleReschedule}
|
||||
>
|
||||
<Text className='text-white font-medium'>改签预约</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<View className='h-6' />
|
||||
</ScrollView>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default BookingDetailPage
|
||||
3
src_bak/pages/booking/list/index.config.ts
Normal file
3
src_bak/pages/booking/list/index.config.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '预约订单',
|
||||
}
|
||||
226
src_bak/pages/booking/list/index.tsx
Normal file
226
src_bak/pages/booking/list/index.tsx
Normal file
@@ -0,0 +1,226 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import { View, Text, ScrollView } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { pageShopBooking, cancelShopBooking } from '@/api/shop/shopBooking'
|
||||
import type { ShopBooking, BookingStatus } from '@/api/shop/shopBooking/model'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '预约订单',
|
||||
})
|
||||
|
||||
const BookingListPage: React.FC = () => {
|
||||
const [activeTab, setActiveTab] = useState(0)
|
||||
const [orders, setOrders] = useState<ShopBooking[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [finished, setFinished] = useState(false)
|
||||
const [page, setPage] = useState(1)
|
||||
|
||||
useEffect(() => {
|
||||
setOrders([])
|
||||
setPage(1)
|
||||
setFinished(false)
|
||||
loadList(1)
|
||||
}, [activeTab])
|
||||
|
||||
const loadList = async (p: number) => {
|
||||
if (loading) return
|
||||
setLoading(true)
|
||||
|
||||
try {
|
||||
// 根据 tab 筛选状态
|
||||
let status: BookingStatus | undefined
|
||||
if (activeTab === 1) status = 'pending'
|
||||
else if (activeTab === 2) status = 'in_progress'
|
||||
else if (activeTab === 3) status = 'completed'
|
||||
|
||||
const res = await pageShopBooking({
|
||||
page: p,
|
||||
limit: 10,
|
||||
status,
|
||||
})
|
||||
|
||||
if (res?.list) {
|
||||
const newList = res.list
|
||||
const total = res.count || 0
|
||||
if (p === 1) {
|
||||
setOrders(newList)
|
||||
} else {
|
||||
setOrders(prev => [...prev, ...newList])
|
||||
}
|
||||
// 判断是否已加载完所有数据
|
||||
setFinished(newList.length === 0 || orders.length + newList.length >= total)
|
||||
setPage(p)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('加载预约订单失败', err)
|
||||
Taro.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载更多
|
||||
const handleLoadMore = () => {
|
||||
if (!finished && !loading) {
|
||||
loadList(page + 1)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取状态标签
|
||||
const getStatusLabel = (status: BookingStatus) => {
|
||||
const map: Record<BookingStatus, { label: string; color: string }> = {
|
||||
'pending': { label: '待服务', color: 'text-orange-500' },
|
||||
'confirmed': { label: '已确认', color: 'text-blue-500' },
|
||||
'in_progress': { label: '进行中', color: 'text-blue-500' },
|
||||
'completed': { label: '已完成', color: 'text-green-500' },
|
||||
'cancelled': { label: '已取消', color: 'text-gray-400' },
|
||||
'rescheduled': { label: '已改签', color: 'text-purple-500' },
|
||||
}
|
||||
return map[status] || { label: '未知', color: 'text-gray-400' }
|
||||
}
|
||||
|
||||
// 取消预约
|
||||
const handleCancel = async (id: string) => {
|
||||
Taro.showModal({
|
||||
title: '确认取消',
|
||||
content: '确定取消该预约吗?\n\n取消后款项将退回您的余额。',
|
||||
confirmColor: '#0e932e',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
await cancelShopBooking(id)
|
||||
Taro.showToast({ title: '已取消,款项已退回余额', icon: 'success' })
|
||||
// 重新加载列表
|
||||
setOrders([])
|
||||
setPage(1)
|
||||
setFinished(false)
|
||||
loadList(1)
|
||||
} catch (err: any) {
|
||||
console.error('取消预约失败', err)
|
||||
Taro.showToast({ title: err?.message || '取消失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 改签预约
|
||||
const handleReschedule = (id: string) => {
|
||||
Taro.navigateTo({ url: `/pages/booking/reschedule/index?id=${id}` })
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const handleDetail = (id: string) => {
|
||||
Taro.navigateTo({ url: `/pages/booking/detail/index?id=${id}` })
|
||||
}
|
||||
|
||||
return (
|
||||
<View className='h-screen bg-gray-50 flex flex-col'>
|
||||
{/* Tab 栏 */}
|
||||
<View className='bg-white flex'>
|
||||
{['全部', '待服务', '进行中', '已完成'].map((tab, index) => (
|
||||
<View
|
||||
key={index}
|
||||
className={`flex-1 text-center py-3 relative ${
|
||||
activeTab === index ? 'text-orange-500 font-medium' : 'text-gray-600'
|
||||
}`}
|
||||
onClick={() => setActiveTab(index)}
|
||||
>
|
||||
<Text className='text-sm'>{tab}</Text>
|
||||
{activeTab === index && (
|
||||
<View className='absolute bottom-0 left-0 right-0 flex justify-center'>
|
||||
<View className='w-8 h-px bg-orange-500 rounded' />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
|
||||
{/* 订单列表 */}
|
||||
<ScrollView scrollY className='flex-1'>
|
||||
{orders.length === 0 ? (
|
||||
<View className='text-center py-16'>
|
||||
<Text className='text-4xl mb-3 block'>📅</Text>
|
||||
<Text className='text-sm text-gray-400 mb-3 block'>暂无预约订单</Text>
|
||||
<View
|
||||
className='inline-block bg-orange-500 text-white px-4 py-2 rounded-full'
|
||||
onClick={() => Taro.navigateTo({ url: '/pages/store/list/index' })}
|
||||
>
|
||||
<Text className='text-sm'>去预约</Text>
|
||||
</View>
|
||||
</View>
|
||||
) : (
|
||||
<View className='p-3'>
|
||||
{orders.map(order => {
|
||||
const statusInfo = getStatusLabel(order.status)
|
||||
return (
|
||||
<View key={order.id} className='bg-white rounded-xl p-4 mb-3 shadow-sm'>
|
||||
{/* 顶部状态 */}
|
||||
<View className='flex justify-between items-center mb-3'>
|
||||
<Text className='text-xs text-gray-500'>{order.bookingNo}</Text>
|
||||
<Text className={`text-sm font-medium ${statusInfo.color}`}>
|
||||
{statusInfo.label}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
{/* 预约信息 */}
|
||||
<View className='flex items-center gap-2 mb-3'>
|
||||
<View className='w-10 h-10 bg-blue-50 rounded-lg flex items-center justify-center flex-shrink-0'>
|
||||
<Text className='text-xl'>🏪</Text>
|
||||
</View>
|
||||
<View className='flex-1'>
|
||||
<Text className='text-sm text-gray-800 font-medium block'>{order.storeName}</Text>
|
||||
<Text className='text-xs text-gray-500 mt-0 block'>{order.serviceName}</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 预约时间 */}
|
||||
<View className='bg-gray-50 rounded-lg p-3 mb-3'>
|
||||
<View className='flex justify-between items-center mb-2'>
|
||||
<Text className='text-xs text-gray-500'>预约日期</Text>
|
||||
<Text className='text-sm text-gray-800'>{order.bookingDate}</Text>
|
||||
</View>
|
||||
<View className='flex justify-between items-center'>
|
||||
<Text className='text-xs text-gray-500'>预约时段</Text>
|
||||
<Text className='text-sm text-gray-800'>{order.bookingTime}</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 操作按钮 */}
|
||||
{order.status === 'pending' && (
|
||||
<View className='flex gap-2 pt-2 border-t border-gray-50'>
|
||||
<View
|
||||
className='flex-1 text-center py-2 rounded-full border border-red-500'
|
||||
onClick={() => handleCancel(order.id)}
|
||||
>
|
||||
<Text className='text-xs text-red-500'>取消预约</Text>
|
||||
</View>
|
||||
<View
|
||||
className='flex-1 text-center py-2 rounded-full bg-orange-500'
|
||||
onClick={() => handleDetail(order.id)}
|
||||
>
|
||||
<Text className='text-xs text-white'>查看详情</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
{order.status !== 'pending' && (
|
||||
<View className='flex justify-end pt-2 border-t border-gray-50'>
|
||||
<View
|
||||
className='text-center py-2 px-4 rounded-full bg-orange-500'
|
||||
onClick={() => handleDetail(order.id)}
|
||||
>
|
||||
<Text className='text-xs text-white'>查看详情</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default BookingListPage
|
||||
3
src_bak/pages/booking/reschedule/index.config.ts
Normal file
3
src_bak/pages/booking/reschedule/index.config.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '改签预约',
|
||||
}
|
||||
229
src_bak/pages/booking/reschedule/index.tsx
Normal file
229
src_bak/pages/booking/reschedule/index.tsx
Normal file
@@ -0,0 +1,229 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import { View, Text, ScrollView } from '@tarojs/components'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import { Button } from '@nutui/nutui-react-taro'
|
||||
import { getShopBooking, rescheduleShopBooking } from '@/api/shop/shopBooking'
|
||||
import type { ShopBooking } from '@/api/shop/shopBooking/model'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '改签预约',
|
||||
})
|
||||
|
||||
const BookingReschedulePage: React.FC = () => {
|
||||
const router = useRouter()
|
||||
const bookingId = router.params.id
|
||||
|
||||
const [originalBooking, setOriginalBooking] = useState<ShopBooking | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
|
||||
const [newDate, setNewDate] = useState('')
|
||||
const [newTime, setNewTime] = useState('')
|
||||
|
||||
const getDateRange = () => {
|
||||
const dates: { value: string; label: string }[] = []
|
||||
const today = dayjs()
|
||||
for (let i = 1; i <= 14; i++) {
|
||||
const d = today.add(i, 'day')
|
||||
const weekDays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
|
||||
dates.push({
|
||||
value: d.format('YYYY-MM-DD'),
|
||||
label: `${d.month() + 1}月${d.date()}日 ${weekDays[d.day()]}`,
|
||||
})
|
||||
}
|
||||
return dates
|
||||
}
|
||||
const dateRange = getDateRange()
|
||||
|
||||
const timeSlots = [
|
||||
{ label: '09:00-10:00', value: '09:00-10:00' },
|
||||
{ label: '10:00-11:00', value: '10:00-11:00' },
|
||||
{ label: '11:00-12:00', value: '11:00-12:00' },
|
||||
{ label: '14:00-15:00', value: '14:00-15:00' },
|
||||
{ label: '15:00-16:00', value: '15:00-16:00' },
|
||||
{ label: '16:00-17:00', value: '16:00-17:00' },
|
||||
{ label: '17:00-18:00', value: '17:00-18:00' },
|
||||
]
|
||||
|
||||
useEffect(() => {
|
||||
if (!bookingId) {
|
||||
Taro.showToast({ title: '参数错误', icon: 'none' })
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
fetchBookingDetail()
|
||||
}, [bookingId])
|
||||
|
||||
const fetchBookingDetail = async () => {
|
||||
try {
|
||||
const data = await getShopBooking(bookingId)
|
||||
setOriginalBooking(data)
|
||||
} catch (e: any) {
|
||||
console.error('获取预约详情失败:', e)
|
||||
Taro.showToast({ title: e.message || '获取详情失败', icon: 'none' })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!newDate) {
|
||||
Taro.showToast({ title: '请选择新日期', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!newTime) {
|
||||
Taro.showToast({ title: '请选择新时段', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
const oldDate = originalBooking?.bookingDate || '-'
|
||||
const oldTime = originalBooking?.bookingTime || '-'
|
||||
const confirmContent = `确定将预约从\n${oldDate} ${oldTime}\n改签至\n${newDate} ${newTime}吗?`
|
||||
|
||||
Taro.showModal({
|
||||
title: '确认改签',
|
||||
content: confirmContent,
|
||||
confirmText: '确认改签',
|
||||
confirmColor: '#0e932e',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
await submitReschedule()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const submitReschedule = async () => {
|
||||
try {
|
||||
setSubmitting(true)
|
||||
await rescheduleShopBooking({
|
||||
bookingId: bookingId,
|
||||
newDate: newDate,
|
||||
newTime: newTime,
|
||||
})
|
||||
Taro.showToast({ title: '改签成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
Taro.navigateBack()
|
||||
}, 1500)
|
||||
} catch (e: any) {
|
||||
console.error('改签失败:', e)
|
||||
Taro.showToast({ title: e.message || '改签失败', icon: 'none' })
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<View className='min-h-screen bg-gray-50 flex items-center justify-center'>
|
||||
<Text className='text-gray-400'>加载中...</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
if (!originalBooking) {
|
||||
return (
|
||||
<View className='min-h-screen bg-gray-50 flex items-center justify-center'>
|
||||
<Text className='text-gray-400'>预约信息不存在</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<View className='min-h-screen bg-gray-50 flex flex-col'>
|
||||
<ScrollView scrollY className='flex-1'>
|
||||
<View className='bg-white mx-3 mt-3 rounded-xl p-4'>
|
||||
<Text className='text-base font-medium text-gray-800 mb-3 block'>原预约信息</Text>
|
||||
|
||||
<View className='bg-gray-50 rounded-lg p-3'>
|
||||
<View className='flex justify-between items-center mb-2'>
|
||||
<Text className='text-sm text-gray-500'>预约编号</Text>
|
||||
<Text className='text-sm text-gray-800'>{originalBooking.id}</Text>
|
||||
</View>
|
||||
<View className='flex justify-between items-center mb-2'>
|
||||
<Text className='text-sm text-gray-500'>服务类型</Text>
|
||||
<Text className='text-sm text-gray-800'>{originalBooking.serviceName}</Text>
|
||||
</View>
|
||||
<View className='flex justify-between items-center mb-2'>
|
||||
<Text className='text-sm text-gray-500'>预约日期</Text>
|
||||
<Text className='text-sm text-gray-800'>{originalBooking.bookingDate}</Text>
|
||||
</View>
|
||||
<View className='flex justify-between items-center'>
|
||||
<Text className='text-sm text-gray-500'>预约时段</Text>
|
||||
<Text className='text-sm text-gray-800'>{originalBooking.bookingTime}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className='bg-white mx-3 mt-3 rounded-xl p-4'>
|
||||
<Text className='text-base font-medium text-gray-800 mb-3 block'>选择新日期</Text>
|
||||
|
||||
<ScrollView scrollX className='whitespace-nowrap'>
|
||||
<View className='flex gap-2'>
|
||||
{dateRange.map(date => (
|
||||
<View
|
||||
key={date.value}
|
||||
className={`inline-block px-3 py-2 rounded-lg text-center min-w-20 ${
|
||||
newDate === date.value
|
||||
? 'bg-green-500 text-white'
|
||||
: 'bg-gray-50 text-gray-600'
|
||||
}`}
|
||||
onClick={() => setNewDate(date.value)}
|
||||
>
|
||||
<Text className='text-xs block'>{date.label}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
|
||||
<View className='bg-white mx-3 mt-3 rounded-xl p-4'>
|
||||
<Text className='text-base font-medium text-gray-800 mb-3 block'>选择新时段</Text>
|
||||
|
||||
<View className='flex flex-wrap gap-2'>
|
||||
{timeSlots.map(slot => (
|
||||
<View
|
||||
key={slot.value}
|
||||
className={`px-4 py-2 rounded-lg text-center ${
|
||||
newTime === slot.value
|
||||
? 'bg-green-500 text-white'
|
||||
: 'bg-gray-50 text-gray-600'
|
||||
}`}
|
||||
onClick={() => setNewTime(slot.value)}
|
||||
>
|
||||
<Text className='text-sm'>{slot.label}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className='bg-white mx-3 mt-3 rounded-xl p-4 mb-4'>
|
||||
<Text className='text-base font-medium text-gray-800 mb-3 block'>改签说明</Text>
|
||||
<View className='text-xs text-gray-500 leading-6 space-y-1'>
|
||||
<Text className='block'>1. 每个订单只能改签一次,请谨慎选择</Text>
|
||||
<Text className='block'>2. 改签需提前2小时申请</Text>
|
||||
<Text className='block'>3. 改签不收取任何手续费</Text>
|
||||
<Text className='block'>4. 如有疑问,请联系客服咨询</Text>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
<View className='bg-white p-3 border-t border-gray-100' style={{ paddingBottom: '20px' }}>
|
||||
<Button
|
||||
type='primary'
|
||||
block
|
||||
loading={submitting}
|
||||
disabled={submitting || !newDate || !newTime}
|
||||
className='rounded-full'
|
||||
style={{ backgroundColor: '#0e932e', border: 'none' }}
|
||||
onClick={handleSubmit}
|
||||
>
|
||||
{submitting ? '提交中...' : '确认改签'}
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default BookingReschedulePage
|
||||
Reference in New Issue
Block a user