zlisen 4 yıl önce
ebeveyn
işleme
8c6fee073a

+ 67
- 42
src/pages/house/household/index.jsx Dosyayı Görüntüle

@@ -1,58 +1,83 @@
1
-import React, { useEffect, useMemo, useState,useRef } from 'react'
2
-import Taro from '@tarojs/taro'
1
+import React, { useEffect, useMemo, useState } from 'react'
2
+import Taro, { useRouter } from '@tarojs/taro'
3 3
 import './index.scss'
4
-import { View, Text, Input,Image } from '@tarojs/components'
4
+import { View, Text, Input, Image } from '@tarojs/components'
5 5
 import ContainerLayout from '../../../compents/container/index'
6 6
 import radio from '../../../assets/radio.png'
7 7
 import Layout from '../../../layout/index'
8
+import request from '../../../util/request'
9
+import groupby from 'lodash.groupby';
10
+
8 11
 const house = (props) => {
9 12
 
10
-  const [list, setList] = useState([])
11
-  const [radioHouse, setRadioHouse] = useState()
12
-  
13
-    const ref = useRef();
14
-    useEffect(() => {
15
-      ref.current = 3;
16
-    });
17
-  
18
-  
19
-
20
-  const radioHouseState = useMemo(()=>props.radioHouseState,[props.radioHouseState])
21
-  wx.setNavigationBarTitle({
22
-    title: '民宿房源管理'
23
-  })
24
-console.log(props,radioHouseState)
13
+  const router = useRouter()
14
+  const { houseId } = router.params
15
+
16
+  const [list, setList] = useState({})
17
+
18
+
19
+
25 20
   useEffect(() => {
26
-    setList([
27
-      {
28
-        id:1,
29
-        name: 'zhou',
30
-        phone: '177'
31
-      },
32
-      {
33
-        id:2,
34
-        name: 'zhou',
35
-        phone: '177'
36
-      },
37
-      {
38
-        id:3,
39
-        name: 'zhou',
40
-        phone: '177'
41
-      }
42
-    ])
21
+    getList()
43 22
   }, [])
44 23
 
45
-  const onShare = () => {
46
-    Taro.navigateTo({ url: "/pages/share/index" })
24
+  const getList = () => {
25
+    request({ url: '/taHousePerson',params:{houseId:houseId,pageSize:9999} }).then((res) => {
26
+      const { records, ...page } = res.data.data
27
+      console.log(groupby(records, item => item.orderId))
28
+      setList(groupby(records, item => item.orderId))
29
+      //   {
30
+      //   const [date,_] = item.createDate.split('T')
31
+      //   return date
32
+      // }))
33
+    })
47 34
   }
48 35
 
36
+  // {
49 37
 
38
+  //   Object.keys(list).map((item) => {
39
+  //       console.log(list[item], item, 'list[item]11')
50 40
 
41
+  //       return <View className='imglist-card'>
42
+  //           <View className='imglist-card-tags' style={{ display: 'flex' }}>
43
+  //               {/* imageimageimageimage34 */}
44
+  //               {list[item].map((x) => {
45
+  //                   return <View className='tag' s>{x.tagName}</View>
46
+  //               })}
47
+  //           </View>
48
+  //           <Image src={list[item][0].image} style={{ width: '100%' }} onClick={() => { setData(list[item]); setIsOpened(true) }}></Image>
49
+  //       </View>
50
+  //   })
51
+  // }
51 52
   return <View className='household'>
52 53
 
53 54
     <Layout>
54
-      <View className='household-text'>vjoaphepionvodashvoia</View>
55
-    {list.map((x, index) => {
55
+      {/* <View className='household-text'>vjoaphepionvodashvoia</View> */}
56
+
57
+      {
58
+        Object.keys(list).map((item) => {
59
+          return <View className='household-view'>
60
+            {/* {index + 1} */}
61
+            <Text className='household-view-title'>订单编号:{item}</Text>
62
+            <ContainerLayout className='household-view-card'>
63
+              {list[item].map((x) => {
64
+                return <view>{x.name}: {x.phone}</view>  
65
+              })}
66
+              {list[item].length == 0 && '暂无入住人信息'}
67
+
68
+            </ContainerLayout>
69
+
70
+          </View>
71
+        })
72
+
73
+      }
74
+      {
75
+        Object.keys(list).length === 0 && <view style={{textAlign:'center',paddingTop:30}}>
76
+           暂无入住信息
77
+        </view>
78
+      }
79
+
80
+      {/* {list.map((x, index) => {
56 81
       return <View className='household-view'>
57 82
 
58 83
         <Text className='household-view-title'>入住日期:{index + 1}</Text>
@@ -63,10 +88,10 @@ console.log(props,radioHouseState)
63 88
 
64 89
       </View>
65 90
 
66
-    })}
91
+    })} */}
67 92
     </Layout>
68
-   
69
-   
93
+
94
+
70 95
   </View>
71 96
 }
72 97
 

+ 1
- 1
src/pages/house/household/index.scss Dosyayı Görüntüle

@@ -24,7 +24,7 @@
24 24
       margin-top: 26.67px;
25 25
       position: relative;
26 26
       min-height: 150px;
27
-
27
+line-height: 45px;
28 28
  text-align: center;
29 29
 background-color:#274291;
30 30
 

+ 1
- 10
src/pages/house/index.jsx Dosyayı Görüntüle

@@ -25,26 +25,17 @@ const house = (props) => {
25 25
     useDidShow(() => {
26 26
         if (houseId) {
27 27
             getDetail()
28
+            getImageList()
28 29
         }
29 30
     })
30 31
 
31
-    useEffect(() => {
32
-        getImageList()
33
-    }, [])
34
-
35 32
     const getImageList=()=>{
36 33
         request({url:'/taHouseSurround',params:{houseId:houseId}}).then((res)=>{
37 34
             const {records,...page} =res.data.data  
38 35
             setImgSource(records)
39 36
         })
40 37
     }
41
-    // useEffect(() => {
42
-    //     console.log(houseId, 'params33')
43
-    //     if (houseId) {
44
-    //         getDetail()
45
-    //     }
46 38
 
47
-    // }, [])
48 39
     const getDetail = () => {
49 40
         request({ url: `/taHouse/${houseId}` }).then((res) => {
50 41
             setDataSource(res.data.data)