|
@@ -1,5 +1,5 @@
|
|
|
import React from 'react'
|
|
import React from 'react'
|
|
|
-import { View, Text, Image, ScrollView } from '@tarojs/components'
|
|
|
|
|
|
|
+import { View, Text, ScrollView } from '@tarojs/components'
|
|
|
import { useRouter, navigateTo, navigateBack } from '@tarojs/taro'
|
|
import { useRouter, navigateTo, navigateBack } from '@tarojs/taro'
|
|
|
import { useQuery } from '@tanstack/react-query'
|
|
import { useQuery } from '@tanstack/react-query'
|
|
|
import { format } from 'date-fns'
|
|
import { format } from 'date-fns'
|
|
@@ -10,11 +10,9 @@ import { Navbar, NavbarPresets } from '@/components/ui/navbar'
|
|
|
interface Activity {
|
|
interface Activity {
|
|
|
id: number
|
|
id: number
|
|
|
name: string
|
|
name: string
|
|
|
- description?: string
|
|
|
|
|
- type: 'departure' | 'return'
|
|
|
|
|
|
|
+ description: string | null
|
|
|
startDate: string
|
|
startDate: string
|
|
|
endDate: string
|
|
endDate: string
|
|
|
- imageUrl?: string
|
|
|
|
|
venueLocationId: number
|
|
venueLocationId: number
|
|
|
venueLocation: {
|
|
venueLocation: {
|
|
|
id: number
|
|
id: number
|
|
@@ -30,50 +28,20 @@ interface Activity {
|
|
|
name: string
|
|
name: string
|
|
|
level: number
|
|
level: number
|
|
|
code: string
|
|
code: string
|
|
|
- isDisabled: number
|
|
|
|
|
- isDeleted: number
|
|
|
|
|
- createdBy?: any
|
|
|
|
|
- updatedBy?: any
|
|
|
|
|
- createdAt: string
|
|
|
|
|
- updatedAt: string
|
|
|
|
|
}
|
|
}
|
|
|
city: {
|
|
city: {
|
|
|
id: number
|
|
id: number
|
|
|
name: string
|
|
name: string
|
|
|
level: number
|
|
level: number
|
|
|
code: string
|
|
code: string
|
|
|
- isDisabled: number
|
|
|
|
|
- isDeleted: number
|
|
|
|
|
- createdBy?: any
|
|
|
|
|
- updatedBy?: any
|
|
|
|
|
- createdAt: string
|
|
|
|
|
- updatedAt: string
|
|
|
|
|
}
|
|
}
|
|
|
district: {
|
|
district: {
|
|
|
id: number
|
|
id: number
|
|
|
name: string
|
|
name: string
|
|
|
level: number
|
|
level: number
|
|
|
code: string
|
|
code: string
|
|
|
- isDisabled: number
|
|
|
|
|
- isDeleted: number
|
|
|
|
|
- createdBy?: any
|
|
|
|
|
- updatedBy?: any
|
|
|
|
|
- createdAt: string
|
|
|
|
|
- updatedAt: string
|
|
|
|
|
}
|
|
}
|
|
|
- isDisabled: number
|
|
|
|
|
- isDeleted: number
|
|
|
|
|
- createdBy?: any
|
|
|
|
|
- updatedBy?: any
|
|
|
|
|
- createdAt: string
|
|
|
|
|
- updatedAt: string
|
|
|
|
|
}
|
|
}
|
|
|
- isDisabled: number
|
|
|
|
|
- isDeleted: number
|
|
|
|
|
- createdBy?: any
|
|
|
|
|
- updatedBy?: any
|
|
|
|
|
- createdAt: string
|
|
|
|
|
- updatedAt: string
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -172,18 +140,21 @@ const ActivitySelectPage: React.FC = () => {
|
|
|
|
|
|
|
|
const areaNames = getAreaNames()
|
|
const areaNames = getAreaNames()
|
|
|
|
|
|
|
|
- // 分离去程和返程活动
|
|
|
|
|
- const departureActivities = (activities as Activity[])
|
|
|
|
|
- .filter((activity: Activity) => activity.type === 'departure')
|
|
|
|
|
- .filter((activity, index, self) =>
|
|
|
|
|
- index === self.findIndex(a => a.id === activity.id)
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ // 根据路线数据分离去程和返程活动
|
|
|
|
|
+ const getActivitiesByRouteType = (routeType: 'departure' | 'return') => {
|
|
|
|
|
+ const routeIds = routeData?.routes
|
|
|
|
|
+ ?.filter(route => route.routeType === routeType)
|
|
|
|
|
+ .map(route => route.activityId) || [];
|
|
|
|
|
|
|
|
- const returnActivities = (activities as Activity[])
|
|
|
|
|
- .filter((activity: Activity) => activity.type === 'return')
|
|
|
|
|
- .filter((activity, index, self) =>
|
|
|
|
|
|
|
+ return activities.filter(activity =>
|
|
|
|
|
+ routeIds.includes(activity.id)
|
|
|
|
|
+ ).filter((activity, index, self) =>
|
|
|
index === self.findIndex(a => a.id === activity.id)
|
|
index === self.findIndex(a => a.id === activity.id)
|
|
|
- )
|
|
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const departureActivities = getActivitiesByRouteType('departure')
|
|
|
|
|
+ const returnActivities = getActivitiesByRouteType('return')
|
|
|
|
|
|
|
|
// 选择活动
|
|
// 选择活动
|
|
|
const handleSelectActivity = (activity: Activity, routeType: 'departure' | 'return') => {
|
|
const handleSelectActivity = (activity: Activity, routeType: 'departure' | 'return') => {
|
|
@@ -204,6 +175,8 @@ const ActivitySelectPage: React.FC = () => {
|
|
|
const getActivityDisplayInfo = (activity: Activity) => {
|
|
const getActivityDisplayInfo = (activity: Activity) => {
|
|
|
const venue = activity.venueLocation
|
|
const venue = activity.venueLocation
|
|
|
const locationParts: string[] = []
|
|
const locationParts: string[] = []
|
|
|
|
|
+
|
|
|
|
|
+ // 使用完整的地区对象
|
|
|
if (venue.district?.name) locationParts.push(venue.district.name)
|
|
if (venue.district?.name) locationParts.push(venue.district.name)
|
|
|
if (venue.city?.name) locationParts.push(venue.city.name)
|
|
if (venue.city?.name) locationParts.push(venue.city.name)
|
|
|
if (venue.province?.name) locationParts.push(venue.province.name)
|
|
if (venue.province?.name) locationParts.push(venue.province.name)
|
|
@@ -285,13 +258,10 @@ const ActivitySelectPage: React.FC = () => {
|
|
|
onClick={() => handleSelectActivity(activity, 'departure')}
|
|
onClick={() => handleSelectActivity(activity, 'departure')}
|
|
|
>
|
|
>
|
|
|
<View className="flex">
|
|
<View className="flex">
|
|
|
- {activity.imageUrl && (
|
|
|
|
|
- <Image
|
|
|
|
|
- src={activity.imageUrl}
|
|
|
|
|
- className="w-16 h-16 rounded-medium mr-4"
|
|
|
|
|
- mode="aspectFill"
|
|
|
|
|
- />
|
|
|
|
|
- )}
|
|
|
|
|
|
|
+ {/* 活动图片占位 - 后续可添加图片功能 */}
|
|
|
|
|
+ <View className="w-16 h-16 rounded-medium mr-4 bg-gray-200 flex items-center justify-center">
|
|
|
|
|
+ <Text className="text-gray-500 text-xs">活动图片</Text>
|
|
|
|
|
+ </View>
|
|
|
<View className="flex-1">
|
|
<View className="flex-1">
|
|
|
<Text className="text-base font-medium text-gray-800 block">
|
|
<Text className="text-base font-medium text-gray-800 block">
|
|
|
{activity.name}
|
|
{activity.name}
|
|
@@ -349,13 +319,10 @@ const ActivitySelectPage: React.FC = () => {
|
|
|
onClick={() => handleSelectActivity(activity, 'return')}
|
|
onClick={() => handleSelectActivity(activity, 'return')}
|
|
|
>
|
|
>
|
|
|
<View className="flex">
|
|
<View className="flex">
|
|
|
- {activity.imageUrl && (
|
|
|
|
|
- <Image
|
|
|
|
|
- src={activity.imageUrl}
|
|
|
|
|
- className="w-16 h-16 rounded-medium mr-4"
|
|
|
|
|
- mode="aspectFill"
|
|
|
|
|
- />
|
|
|
|
|
- )}
|
|
|
|
|
|
|
+ {/* 活动图片占位 - 后续可添加图片功能 */}
|
|
|
|
|
+ <View className="w-16 h-16 rounded-medium mr-4 bg-gray-200 flex items-center justify-center">
|
|
|
|
|
+ <Text className="text-gray-500 text-xs">活动图片</Text>
|
|
|
|
|
+ </View>
|
|
|
<View className="flex-1">
|
|
<View className="flex-1">
|
|
|
<Text className="text-base font-medium text-gray-800 block">
|
|
<Text className="text-base font-medium text-gray-800 block">
|
|
|
{activity.name}
|
|
{activity.name}
|