|
@@ -1,8 +1,6 @@
|
1
|
1
|
import React, { useState, useEffect, useRef } from 'react'
|
2
|
2
|
import Taro from '@tarojs/taro'
|
3
|
|
-import { API_SPECIAL_ROOM_LIST } from '@/constants/api'
|
4
|
3
|
import { ScrollView, Image } from '@tarojs/components'
|
5
|
|
-import { fetch } from '@/utils/request'
|
6
|
4
|
import '@/assets/css/iconfont.css'
|
7
|
5
|
import useTimer from './useTimer'
|
8
|
6
|
import './index.scss'
|
|
@@ -11,38 +9,21 @@ const toW = n => `${Number(n / 10000).toFixed(1)}万`
|
11
|
9
|
const itFmt = it => `${it.unitType} ${Number(it.currentPrice / it.area).toFixed(0)}元/㎡`
|
12
|
10
|
|
13
|
11
|
export default function SpecialPriceHouse (props) {
|
14
|
|
- const { Info } = props
|
15
|
|
- const { buildingId } = Info || {}
|
16
|
|
-
|
17
|
|
- const [list, setList] = useState([])
|
18
|
|
- const [leftTime] = useTimer(list)
|
|
12
|
+ const { dataSource } = props
|
|
13
|
+ const [leftTime] = useTimer(dataSource)
|
19
|
14
|
|
20
|
15
|
const handleMore = () => {
|
21
|
16
|
Taro.navigateTo({ url: '/pages/index/specialPriceHouse/index' })
|
22
|
17
|
}
|
23
|
18
|
|
24
|
|
- useEffect(() => {
|
25
|
|
- if (!buildingId) {
|
26
|
|
- setList([])
|
27
|
|
- return;
|
28
|
|
- }
|
29
|
|
-
|
30
|
|
- fetch({ url: API_SPECIAL_ROOM_LIST, method: 'get', params: { pageSize: 500, buildingId }, showToast: false}).then((res) => {
|
31
|
|
- const { records } = res || {}
|
32
|
|
- if (records && records.length) {
|
33
|
|
- setList(records)
|
34
|
|
- } else {
|
35
|
|
- setList([])
|
36
|
|
- }
|
37
|
|
- })
|
38
|
|
- }, [buildingId])
|
|
19
|
+ const len = dataSource ? dataSource.length : 0
|
39
|
20
|
|
40
|
|
- return list.length > 0 && (
|
|
21
|
+ return len > 0 && (
|
41
|
22
|
<view className='components SpecialPriceHouse'>
|
42
|
23
|
<view className='Title flex-h'>
|
43
|
24
|
<view className='flex-item'>
|
44
|
25
|
<text>特价房源</text>
|
45
|
|
- <text>{`(${list.length})`}</text>
|
|
26
|
+ <text>{`(${len})`}</text>
|
46
|
27
|
</view>
|
47
|
28
|
<text onClick={handleMore}>更多</text>
|
48
|
29
|
<text className='iconfont icon-jiantouright'></text>
|
|
@@ -51,7 +32,7 @@ export default function SpecialPriceHouse (props) {
|
51
|
32
|
<view className='List'>
|
52
|
33
|
<ScrollView scrollX>
|
53
|
34
|
{
|
54
|
|
- list.map((item, index) => (
|
|
35
|
+ dataSource.map((item, index) => (
|
55
|
36
|
<view className='ListItem' key={`List-${index}`}>
|
56
|
37
|
<text className='Tips'>{`${toW(item.thriftPrice)}`}</text>
|
57
|
38
|
<view className='Price'>
|