Ver código fonte

Merge branch 'master' of http://git.ycjcjy.com/shigongli/client-miniapp into master

zlisen 4 anos atrás
pai
commit
2dd89677ce

+ 15
- 19
src/compents/getphone/index.jsx Ver arquivo

@@ -10,8 +10,6 @@ export default function GetUserPhone(props) {
10 10
 
11 11
     const user = useSelector(state => state.user)
12 12
     const dispatch = useDispatch()
13
-    const [showPannel, setShowPannel] = useState(true)
14
-    //   const { user, setUser } = useModel('user')
15 13
 
16 14
     const ToGetUserPhone = (e) => { // 授权手机号
17 15
         const { errMsg, ...data } = e.detail
@@ -32,13 +30,11 @@ export default function GetUserPhone(props) {
32 30
                     props.onOk(res)
33 31
                 }
34 32
             }).catch((er) => {
35
-                setShowPannel(true)
36 33
                 if (props.onError) {
37 34
                     props.onError(er.message || er.errMsg || er)
38 35
                 }
39 36
             })
40 37
         } else {
41
-            setShowPannel(true)
42 38
             if (props.onError) {
43 39
                 props.onError(errMsg)
44 40
             }
@@ -46,26 +42,26 @@ export default function GetUserPhone(props) {
46 42
     }
47 43
 
48 44
     const handleCancel = () => {
49
-        setShowPannel(false)
45
+        // setShowPannel(false)
50 46
         if (props.onCancel) {
51 47
             props.onCancel()
52 48
         }
53 49
     }
54 50
 
55
-
56
-
57
-    return (props.visible && <AtModal isOpened={showPannel}>
58
-        <AtModalHeader>您暂未授权手机号</AtModalHeader>
59
-        <AtModalAction>
60
-            <Button onClick={handleCancel}>取消</Button>
61
-            <Button
62
-                className='flex-item'
63
-                open-type='getPhoneNumber'
64
-                lang='zh_CN'
65
-                onGetphonenumber={ToGetUserPhone}
66
-                onClick={() => setShowPannel(false)}
67
-            >去授权</Button> </AtModalAction>
68
-    </AtModal>)
51
+    return (
52
+        <AtModal isOpened={props.visible} closeOnClickOverlay={false}>
53
+            <AtModalHeader>您暂未授权手机号</AtModalHeader>
54
+            <AtModalAction>
55
+                <Button onClick={handleCancel}>取消</Button>
56
+                <Button
57
+                    className='flex-item'
58
+                    open-type='getPhoneNumber'
59
+                    lang='zh_CN'
60
+                    onGetphonenumber={ToGetUserPhone}
61
+                >去授权</Button>
62
+            </AtModalAction>
63
+        </AtModal>
64
+    )
69 65
 
70 66
     // return props.visible && (
71 67
     //     <view style={{textAlign:'center'}}> 

+ 42
- 34
src/pages/customer/index.js Ver arquivo

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

+ 25
- 24
src/pages/guide/index.jsx Ver arquivo

@@ -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(',')

+ 7
- 13
src/pages/index/index.jsx Ver arquivo

@@ -24,32 +24,26 @@ const index = (props) => {
24 24
   // const [userRole, setUserRole] = useState('1')
25 25
   // const [pageState, SetPageState] = useState('1')
26 26
   // const [list, setList] = useState([])
27
-  const [visible, setVisible] = useState(false)
27
+  // const [visible, setVisible] = useState(false)
28
+  const [showAuthPhone, setShowAuthPhone] = useState(false)
28 29
 
29 30
   useEffect(() => {
30
-    if (user.personId && !user.phone) {
31
-      setVisible(true)
32
-    }
33
-    if (user.personId && user.phone) {
34
-      setVisible(false)
35
-    }
36
-  }, [user.phone, user.personId])
37
-
31
+    setShowAuthPhone(!user.phone)
32
+  }, [user.phone])
38 33
 
39 34
   const onOk = (res) => {
40
-
41 35
     dispatch({ type: 'LOGIN', user: res.data.data })
42
-    setVisible(false)
36
+    setShowAuthPhone(false)
43 37
   }
44 38
 
45 39
   const onCancel = (e) => {
46
-    setVisible(false)
40
+    setShowAuthPhone(false)
47 41
   }
48 42
 
49 43
   return <View className='index'>
50 44
 
51 45
     {user.personId && <View>
52
-      <GetPhone visible={visible} onOk={onOk} onCancel={onCancel} ></GetPhone>
46
+      <GetPhone visible={showAuthPhone} onOk={onOk} onCancel={onCancel} ></GetPhone>
53 47
       {user.role == roleList.customer && <Customer houseId={houseId} orderId={orderId}></Customer>}
54 48
       {user.role == roleList.landlord && <Landlord ></Landlord>}
55 49
     </View>}

+ 15
- 12
src/pages/recommend/index.jsx Ver arquivo

@@ -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
     //