|
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'
|
2
|
2
|
import { useSelector } from 'react-redux'
|
3
|
3
|
import Taro from '@tarojs/taro'
|
4
|
4
|
import { queryActivityList } from '@/services/activity'
|
5
|
|
-import { Swiper, SwiperItem } from '@tarojs/components'
|
|
5
|
+import { Swiper, SwiperItem, Block } from '@tarojs/components'
|
6
|
6
|
import '@/assets/css/iconfont.css'
|
7
|
7
|
import './index.scss'
|
8
|
8
|
|
|
@@ -12,21 +12,23 @@ export default function HotRecommend (props) {
|
12
|
12
|
const city = useSelector(state => state.city)
|
13
|
13
|
const [MenuList] = useState([{ name: '热门活动', id: 'dymic' }, { name: '热门团房', id: 'house' }])
|
14
|
14
|
const [CurrentId, setCurrentId] = useState('dymic')
|
15
|
|
- const [list, setList] = useState([])
|
|
15
|
+ const [list, setList] = useState([[], []])
|
16
|
16
|
const [CurrentContentInfo, setCurrentContentInfo] = useState({})
|
17
|
17
|
|
18
|
18
|
useEffect(() => {
|
19
|
19
|
if (city.curCity.name) {
|
20
|
20
|
GetRecommendActivity()
|
21
|
21
|
}
|
22
|
|
- }, [city, CurrentId])
|
|
22
|
+ }, [city])
|
23
|
23
|
|
24
|
24
|
const GetRecommendActivity = () => {
|
25
|
|
-
|
26
|
|
- queryActivityList({ home: 1, cityId: city.curCity.id, type: CurrentId }).then((res) => {
|
|
25
|
+ queryActivityList({ home: 1, cityId: city.curCity.id, type: 'dymic' }).then((res) => {
|
27
|
26
|
const resArr = res.records || []
|
28
|
|
- setList(resArr)
|
29
|
|
- change(!!resArr.length)
|
|
27
|
+ queryActivityList({ home: 1, cityId: city.curCity.id, type: 'house' }).then((subRes) => {
|
|
28
|
+ const subResArr = subRes.records || []
|
|
29
|
+ setList([resArr || [], subResArr || []])
|
|
30
|
+ change(resArr.length || subResArr.length)
|
|
31
|
+ })
|
30
|
32
|
})
|
31
|
33
|
}
|
32
|
34
|
|
|
@@ -62,24 +64,42 @@ export default function HotRecommend (props) {
|
62
|
64
|
}
|
63
|
65
|
</view>
|
64
|
66
|
<view className='Content'>
|
65
|
|
- {/* <view className='flex-h'>
|
66
|
|
- <text className='flex-item'>{CurrentContentInfo.title || '暂无活动'}</text>
|
67
|
|
- <text onClick={ToMore}>{CurrentId === 'dymic' ? '更多活动' : '更多团房'}</text>
|
68
|
|
- </view>
|
69
|
|
- <text>{CurrentContentInfo.halfTitle}</text> */}
|
70
|
67
|
<Swiper autoplay interval={5000} vertical>
|
71
|
68
|
{
|
72
|
|
- list.map((item, index) => (
|
73
|
|
- <SwiperItem key={`Banner-${index}`}>
|
74
|
|
- <view className='swiper-item'>
|
75
|
|
- <view className='flex-h'>
|
76
|
|
- <text className='flex-item' onClick={toDetail}>{item.title || '暂无活动'}</text>
|
77
|
|
- <text onClick={() => {ToMore()}}>{CurrentId === 'dymic' ? '更多活动' : '更多团房'}</text>
|
78
|
|
- </view>
|
79
|
|
- <text onClick={toDetail}>{item.halfTitle}</text>
|
80
|
|
- </view>
|
81
|
|
- </SwiperItem>
|
82
|
|
- ))
|
|
69
|
+ CurrentId === 'dymic' &&
|
|
70
|
+ <Block>
|
|
71
|
+ {
|
|
72
|
+ list[0].map((item, index) => (
|
|
73
|
+ <SwiperItem key={`Banner-${index}`}>
|
|
74
|
+ <view className='swiper-item'>
|
|
75
|
+ <view className='flex-h'>
|
|
76
|
+ <text className='flex-item' onClick={toDetail}>{item.title || '暂无活动'}</text>
|
|
77
|
+ <text onClick={() => { ToMore() }}>更多活动</text>
|
|
78
|
+ </view>
|
|
79
|
+ <text onClick={toDetail}>{item.halfTitle}</text>
|
|
80
|
+ </view>
|
|
81
|
+ </SwiperItem>
|
|
82
|
+ ))
|
|
83
|
+ }
|
|
84
|
+ </Block>
|
|
85
|
+ }
|
|
86
|
+ {
|
|
87
|
+ CurrentId === 'house' &&
|
|
88
|
+ <Block>
|
|
89
|
+ {
|
|
90
|
+ list[1].map((item, index) => (
|
|
91
|
+ <SwiperItem key={`Banner-${index}`}>
|
|
92
|
+ <view className='swiper-item'>
|
|
93
|
+ <view className='flex-h'>
|
|
94
|
+ <text className='flex-item' onClick={toDetail}>{item.title || '暂无活动'}</text>
|
|
95
|
+ <text onClick={() => { ToMore() }}>更多团房</text>
|
|
96
|
+ </view>
|
|
97
|
+ <text onClick={toDetail}>{item.halfTitle}</text>
|
|
98
|
+ </view>
|
|
99
|
+ </SwiperItem>
|
|
100
|
+ ))
|
|
101
|
+ }
|
|
102
|
+ </Block>
|
83
|
103
|
}
|
84
|
104
|
</Swiper>
|
85
|
105
|
</view>
|