|
@@ -3,63 +3,56 @@ import { ScrollView } from '@tarojs/components'
|
3
|
3
|
import withLayout from '@/layout'
|
4
|
4
|
import { useSelector } from 'react-redux'
|
5
|
5
|
import { fetch } from '@/utils/request'
|
6
|
|
-import { API_LIVE_LIST } from '@/constants/api'
|
|
6
|
+import { API_LIVE_LIST, API_VIDEO_LIST } from '@/constants/api'
|
7
|
7
|
import './index.scss'
|
8
|
8
|
import '@/assets/css/iconfont.css'
|
9
|
9
|
import VideoListItem from './components/VideoListItem/index'
|
10
|
10
|
|
11
|
|
-export default withLayout(() => {
|
|
11
|
+export default withLayout((props) => {
|
|
12
|
+ const { city } = props
|
12
|
13
|
|
13
|
|
- const city = useSelector(state => state.city)
|
14
|
14
|
const [IsPull, setPull] = useState(false)
|
15
|
|
- const [CurrnetMenuId, setCurrnetMenuId] = useState(null)
|
|
15
|
+ const [CurrnetMenuId, setCurrnetMenuId] = useState('all')
|
16
|
16
|
const [MenuList] = useState([
|
17
|
17
|
{ name: '全部', id: 'all' },
|
18
|
18
|
{ name: '预告', id: 'notice' },
|
19
|
19
|
{ name: '直播中', id: 'live' },
|
20
|
|
- { name: '新房推荐', id: 'new' }
|
|
20
|
+ { name: '新房推荐', id: 'new' },
|
|
21
|
+ { name: '视频', id: 'video' }
|
21
|
22
|
])
|
22
|
23
|
const [PullTimer, setPullTimer] = useState(null)
|
23
|
|
- const [OriginList, setOriginList] = useState([])
|
24
|
|
- const [PageList, setPageList] = useState([])
|
|
24
|
+ // 全部或者新房的列表
|
|
25
|
+ const [activityList, setActivityList] = useState([])
|
|
26
|
+ // 预告与直播的列表
|
|
27
|
+ const [liveList, setLiveList] = useState([])
|
|
28
|
+ // 视频的列表
|
|
29
|
+ const [videoList, setVideoList] = useState([])
|
25
|
30
|
|
26
|
31
|
useEffect(() => {
|
27
|
|
- if (city.curCity.name) {
|
28
|
|
- setOriginList([])
|
|
32
|
+ if (city?.id) {
|
29
|
33
|
GetLiveList()
|
30
|
34
|
}
|
31
|
|
- }, [city])
|
|
35
|
+ }, [city?.id, CurrnetMenuId])
|
32
|
36
|
|
33
|
|
- useEffect(() => {
|
34
|
|
- if(OriginList.length && CurrnetMenuId === null) {
|
35
|
|
- setCurrnetMenuId('all')
|
36
|
|
- }
|
37
|
|
- }, [OriginList])
|
38
|
37
|
|
39
|
|
- useEffect(() => {
|
40
|
|
- if (CurrnetMenuId === 'all') {
|
41
|
|
- setPageList([...OriginList])
|
|
38
|
+ const GetLiveList = (params) => {
|
|
39
|
+ if (['all', 'new'].indexOf(CurrnetMenuId) > -1) {
|
|
40
|
+ // 全部与新房用的一个接口
|
|
41
|
+ fetch({ url: API_LIVE_LIST, payload: { ...params, cityId: city.id }, spin: true }).then((res) => {
|
|
42
|
+ setActivityList(res.records || [])
|
|
43
|
+ })
|
|
44
|
+ } else if (['notice', 'live'].indexOf(CurrnetMenuId) > -1) {
|
|
45
|
+ // 预告与直播是虽然是同一个接口, 但是返回值字段不一样
|
|
46
|
+ const process = 'notice' === CurrnetMenuId ? 1 : 2;
|
|
47
|
+ fetch({ url: API_LIVE_LIST, payload: { ...params, cityId: city.id, process }, spin: true}).then((res) => {
|
|
48
|
+ setLiveList(res.records || [])
|
|
49
|
+ })
|
42
|
50
|
} else {
|
43
|
|
- let Arr = []
|
44
|
|
- OriginList.map((item) => {
|
45
|
|
- if (CurrnetMenuId === 'new') {
|
46
|
|
- if(item.kind !== 'notice') {
|
47
|
|
- Arr.push({...item})
|
48
|
|
- }
|
49
|
|
- } else {
|
50
|
|
- if(item.kind === CurrnetMenuId) {
|
51
|
|
- Arr.push({...item})
|
52
|
|
- }
|
53
|
|
- }
|
|
51
|
+ // 视频另外一个接口
|
|
52
|
+ fetch({ url: API_VIDEO_LIST, payload: { ...params, cityId: city.id }, spin: true }).then((res) => {
|
|
53
|
+ setVideoList(res.records || [])
|
54
|
54
|
})
|
55
|
|
- setPageList([...Arr])
|
56
|
55
|
}
|
57
|
|
- }, [CurrnetMenuId])
|
58
|
|
-
|
59
|
|
- const GetLiveList = () => {
|
60
|
|
- fetch({ url: API_LIVE_LIST, method: 'get', payload: { cityId: city.curCity.id, pageNum: 1, pageSize: 10000 } }).then((res) => {
|
61
|
|
- setOriginList(res.records || [])
|
62
|
|
- })
|
63
|
56
|
}
|
64
|
57
|
|
65
|
58
|
const PageRefresh = () => { // 页面下拉刷新回调
|
|
@@ -110,7 +103,32 @@ export default withLayout(() => {
|
110
|
103
|
<ScrollView scroll-y refresher-enabled refresher-triggered={IsPull} onrefresherrefresh={PageRefresh} refresher-background='#f8f8f8'>
|
111
|
104
|
<view className='PageContent'>
|
112
|
105
|
{
|
113
|
|
- PageList.map((item, index) => (
|
|
106
|
+ /* 全部 与 新房 */
|
|
107
|
+ ['all', 'new'].indexOf(CurrnetMenuId) > -1 && activityList.map((item, index) => (
|
|
108
|
+ <view className='ListItem' key={`List-${index}`}>
|
|
109
|
+ <view>
|
|
110
|
+ <view>
|
|
111
|
+ <VideoListItem Data={item}></VideoListItem>
|
|
112
|
+ </view>
|
|
113
|
+ </view>
|
|
114
|
+ </view>
|
|
115
|
+ ))
|
|
116
|
+ }
|
|
117
|
+ {
|
|
118
|
+ /* 预告 与 直播 */
|
|
119
|
+ ['notice', 'live'].indexOf(CurrnetMenuId) > -1 && activityList.map((item, index) => (
|
|
120
|
+ <view className='ListItem' key={`List-${index}`}>
|
|
121
|
+ <view>
|
|
122
|
+ <view>
|
|
123
|
+ <VideoListItem Data={item}></VideoListItem>
|
|
124
|
+ </view>
|
|
125
|
+ </view>
|
|
126
|
+ </view>
|
|
127
|
+ ))
|
|
128
|
+ }
|
|
129
|
+ {
|
|
130
|
+ /* 视频 */
|
|
131
|
+ 'video' === CurrnetMenuId && activityList.map((item, index) => (
|
114
|
132
|
<view className='ListItem' key={`List-${index}`}>
|
115
|
133
|
<view>
|
116
|
134
|
<view>
|