张延森 4 years ago
parent
commit
b59aed94ca
3 changed files with 71 additions and 53 deletions
  1. 31
    17
      src/pages/customer/index.js
  2. 25
    24
      src/pages/guide/index.jsx
  3. 15
    12
      src/pages/recommend/index.jsx

+ 31
- 17
src/pages/customer/index.js View File

@@ -17,6 +17,8 @@ const index = (props) => {
17 17
   const user = useSelector(state => state.user)
18 18
 
19 19
   const [pageState, setPageState] = useState('3')
20
+  const [houseInfo, setHouseInfo] = useState()
21
+  const [surroundList, setSurroundList] = useState()
20 22
 
21 23
   useEffect(() => {
22 24
     if(props.orderId){
@@ -28,26 +30,38 @@ const index = (props) => {
28 30
       })
29 31
     }
30 32
   }, [props.orderId])
33
+  
34
+  useEffect(() => {
35
+    if(props.houseId){
36
+      request({url: `/taHouse/${props.houseId}`,}).then(res=>{
37
+        const data = res.data.data
38
+        setHouseInfo(data)
39
+        setPageState('2')
40
+      })
41
+    }
42
+
43
+    request({url:'/taHouseSurround', params:{houseId:houseId}}).then((res)=>{
44
+        const { records } = res.data.data  
45
+        setSurroundList(records)
46
+    })
47
+
48
+  }, [props.houseId])
31 49
  
32 50
   return (
33 51
     <View className='index'>
34
-        {pageState && (
35
-          <View>
36
-            {pageState=='1'&&<Register oderId={orderId}></Register>}
37
-
38
-            <Layout>
39
-              {pageState=='2'&&<Guide houseId={houseId}></Guide>  }
40
-              {pageState=='3'&&<Recommend houseId={houseId}></Recommend>  }
41
-            </Layout>
42
-          
43
-            {pageState!='1' && (
44
-              <Tab
45
-                value={['入住指引','房东推荐']}
46
-                pageState={pageState}
47
-                onClick={[(e) => setPageState('2'),(e) => setPageState('3')]} />
48
-            )}      
49
-          </View>
50
-        )}
52
+      {pageState=='1'&&<Register oderId={orderId}></Register>}
53
+
54
+      <Layout>
55
+        {pageState=='2'&&<Guide houseId={houseId} dataSource={houseInfo}></Guide>  }
56
+        {pageState=='3'&&<Recommend houseId={houseId} dataSource={surroundList}></Recommend>  }
57
+      </Layout>
58
+    
59
+      {!!houseId && (
60
+        <Tab
61
+          value={['入住指引','房东推荐']}
62
+          pageState={pageState}
63
+          onClick={[(e) => setPageState('2'),(e) => setPageState('3')]} />
64
+      )}
51 65
     </View>
52 66
   )
53 67
   

+ 25
- 24
src/pages/guide/index.jsx View File

@@ -20,30 +20,31 @@ const guide = (props) => {
20 20
     const [state, setState] = useState(1)
21 21
 
22 22
     const [imgurl, setImgurl] = useState('')
23
-    const [detail, setDetail] = useState({})
24
-
25
-    useDidShow(() => {
26
-        if (houseId) {
27
-            getDetail()
28
-        }
29
-    })
30
-
31
-    useEffect(() => {
32
-        console.log(houseId, 'params33')
33
-        if (houseId) {
34
-            getDetail()
35
-        }
36
-
37
-    }, [])
38
-    const getDetail = () => {
39
-        request({ url: `/taHouse/${houseId}` }).then((res) => {
40
-            setDetail(res.data.data)
41
-
42
-            wx.setNavigationBarTitle({
43
-                title: res.data.data.title
44
-            })
45
-        })
46
-    }
23
+    // const [detail, setDetail] = useState({})
24
+    const detail = props.dataSource || {}
25
+
26
+    // useDidShow(() => {
27
+    //     if (houseId) {
28
+    //         getDetail()
29
+    //     }
30
+    // })
31
+
32
+    // useEffect(() => {
33
+    //     console.log(houseId, 'params33')
34
+    //     if (houseId) {
35
+    //         getDetail()
36
+    //     }
37
+
38
+    // }, [])
39
+    // const getDetail = () => {
40
+    //     request({ url: `/taHouse/${houseId}` }).then((res) => {
41
+    //         setDetail(res.data.data)
42
+
43
+    //         wx.setNavigationBarTitle({
44
+    //             title: res.data.data.title
45
+    //         })
46
+    //     })
47
+    // }
47 48
 
48 49
     const onOpenLocation = (lngLat) => {
49 50
         const [latitude, longitude] = lngLat.split(',')

+ 15
- 12
src/pages/recommend/index.jsx View File

@@ -16,19 +16,22 @@ const recommend = (props) => {
16 16
 
17 17
     const { value, houseId,...prop } = props
18 18
 
19
-    const [state, setState] = useState(1)
20
-    const [list, setList] = useState([])
19
+    // const [state, setState] = useState(1)
20
+    // const [list, setList] = useState([])
21 21
     const [id, setId] = useState()
22
-    useEffect(() => {
23
-        getImageList()
24
-    }, [])
25
-
26
-    const getImageList=()=>{
27
-        request({url:'/taHouseSurround',params:{houseId:houseId}}).then((res)=>{
28
-            const {records,...page} =res.data.data  
29
-            setList(records)
30
-        })
31
-    }
22
+
23
+    const list = props.dataSource || []
24
+
25
+    // useEffect(() => {
26
+    //     getImageList()
27
+    // }, [])
28
+
29
+    // const getImageList=()=>{
30
+    //     request({url:'/taHouseSurround',params:{houseId:houseId}}).then((res)=>{
31
+    //         const {records,...page} =res.data.data  
32
+    //         setList(records)
33
+    //     })
34
+    // }
32 35
 
33 36
 
34 37
     //