zlisen hace 4 años
padre
commit
2a3a433e96

+ 4
- 2
config/dev.js Ver fichero

@@ -4,9 +4,11 @@ module.exports = {
4 4
     NODE_ENV: '"development"'
5 5
   },
6 6
   defineConstants: {
7
-    HOST: '"http://localhost:7080"',
7
+    // HOST: '"http://localhost:7080"',
8 8
     // HOST: '"https://sgl.ycjcjy.com"',
9
-    
9
+    HOST: '"http://192.168.31.68:7080"',
10
+    // HOST: '"http://192.168.211.181:7080"',
11
+ 
10 12
     // OSS_PATH: "https://njcj.oss-cn-shanghai.aliyuncs.com/",
11 13
     // OSS_FAST_PATH: "https://njcj.oss-accelerate.aliyuncs.com/",
12 14
   },

+ 5
- 0
package-lock.json Ver fichero

@@ -11621,6 +11621,11 @@
11621 11621
       "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=",
11622 11622
       "dev": true
11623 11623
     },
11624
+    "lodash.groupby": {
11625
+      "version": "4.6.0",
11626
+      "resolved": "https://registry.npm.taobao.org/lodash.groupby/download/lodash.groupby-4.6.0.tgz",
11627
+      "integrity": "sha1-Cwih3PaDl8OXhVwyOXg4Mt90A9E="
11628
+    },
11624 11629
     "lodash.sortby": {
11625 11630
       "version": "4.7.0",
11626 11631
       "resolved": "https://registry.npm.taobao.org/lodash.sortby/download/lodash.sortby-4.7.0.tgz",

+ 1
- 0
package.json Ver fichero

@@ -42,6 +42,7 @@
42 42
     "@tarojs/runtime": "3.0.13",
43 43
     "@tarojs/taro": "3.0.13",
44 44
     "lodash": "4.17.15",
45
+    "lodash.groupby": "^4.6.0",
45 46
     "react": "^16.10.0",
46 47
     "react-dom": "^16.10.0",
47 48
     "react-redux": "^7.2.2",

+ 1
- 1
project.config.json Ver fichero

@@ -4,7 +4,7 @@
4 4
 	"description": "十公里小程序",
5 5
 	"appid": "wx06a7372d48d56843",
6 6
 	"setting": {
7
-		"urlCheck": true,
7
+		"urlCheck": false,
8 8
 		"es6": false,
9 9
 		"postcss": false,
10 10
 		"preloadBackgroundData": false,

+ 1
- 0
src/app.config.js Ver fichero

@@ -12,6 +12,7 @@ export default {
12 12
     'pages/material/index',
13 13
     'pages/label/index',
14 14
     'pages/label/edit/index',
15
+    'pages/addimg/index',
15 16
   ],
16 17
   window: {
17 18
     backgroundTextStyle: 'light',

+ 7
- 10
src/app.js Ver fichero

@@ -26,17 +26,14 @@ console.log(this.props,'this.props')
26 26
       success (res) {
27 27
         if (res.code) {
28 28
           //发起网络请求
29
-          // console.log(res.code,store.getState(),'code')
30
-          // asyncLogin().dispatch()
31
-          // store.dispatch(asyncLogin())
32
-          // asyncLogin()
29
+
33 30
           request({url:`/login?code=${res.code}`,method:"post"}).then((res)=>{
34
-            console.log(res.data.data.token,'res.data.data.token')
35
-            store.dispatch({type:'LOGIN',user:res.data.data})
36
-            Taro.setStorage({
37
-              key:"token",
38
-              data:res.data.data.token
39
-            })
31
+            try {
32
+              Taro.setStorageSync('token', res.data.data.token)
33
+              store.dispatch({type:'LOGIN',user:res.data.data})
34
+            } catch (e) { }
35
+            
36
+            
40 37
           })
41 38
         } else {
42 39
           console.log('登录失败!' + res.errMsg)

+ 7
- 0
src/app.scss Ver fichero

@@ -55,3 +55,10 @@ page {
55 55
    }
56 56
  
57 57
  }
58
+
59
+
60
+ .nodata{
61
+   text-align: center;
62
+   margin: auto;
63
+   margin-top: 90px;
64
+ }

+ 12
- 0
src/compents/NoData/index.jsx Ver fichero

@@ -0,0 +1,12 @@
1
+import React, { useEffect, useState } from 'react'
2
+import './index.scss'
3
+
4
+export default props => {
5
+  return (
6
+    <view className={`no-data-wrapper ${props.className}`} style={props.style}>
7
+      {
8
+        props.nodata ? <view className="no-data-view">{props.tips || '暂无数据'}</view> : props.children
9
+      }
10
+    </view>
11
+  )
12
+}

+ 17
- 0
src/compents/NoData/index.scss Ver fichero

@@ -0,0 +1,17 @@
1
+.no-data-wrapper {
2
+  position: relative;
3
+  height: 100%;
4
+  min-height: 200px;
5
+
6
+  .no-data-view {
7
+    width: 100%;
8
+    text-align: center;
9
+    font-size: 0.8em;
10
+    color: #aaa;
11
+    position: absolute;
12
+    left: 0;
13
+    top: 50%;
14
+    transform: translateY(-50%);
15
+    line-height: 2em;
16
+  }
17
+}

+ 87
- 0
src/compents/getphone/index.jsx Ver fichero

@@ -0,0 +1,87 @@
1
+import React, { useState } from 'react'
2
+import Taro from '@tarojs/taro'
3
+import { AtModal, AtModalHeader, AtModalContent, AtModalAction } from "taro-ui"
4
+import { Button } from '@tarojs/components'
5
+import { useSelector,useDispatch } from 'react-redux'
6
+import request from '@/util/request'
7
+import './index.scss'
8
+
9
+export default function GetUserPhone(props) {
10
+
11
+    const user = useSelector(state => state.user)
12
+    const dispatch = useDispatch()
13
+    const [showPannel, setShowPannel] = useState(true)
14
+    //   const { user, setUser } = useModel('user')
15
+
16
+    const ToGetUserPhone = (e) => { // 授权手机号
17
+        const { errMsg, ...data } = e.detail
18
+        console.log(e, 'e')
19
+        if (errMsg === 'getPhoneNumber:ok') {
20
+            request({
21
+                url: "/taPerson/phone",
22
+                method: 'post',
23
+                data: {
24
+                    sessionKey: user.sessionKey || '',
25
+                    encryptedData: data.encryptedData,
26
+                    iv: data.iv,
27
+                }
28
+            }).then((res) => {
29
+                // setUser({ ...user, phone: res.phoneNumber })
30
+
31
+                if (props.onOk) {
32
+                    props.onOk(res)
33
+                }
34
+            }).catch((er) => {
35
+                setShowPannel(true)
36
+                if (props.onError) {
37
+                    props.onError(er.message || er.errMsg || er)
38
+                }
39
+            })
40
+        } else {
41
+            setShowPannel(true)
42
+            if (props.onError) {
43
+                props.onError(errMsg)
44
+            }
45
+        }
46
+    }
47
+
48
+    const handleCancel = () => {
49
+        setShowPannel(false)
50
+        if (props.onCancel) {
51
+            props.onCancel()
52
+        }
53
+    }
54
+
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>)
69
+
70
+    // return props.visible && (
71
+    //     <view style={{textAlign:'center'}}> 
72
+    //         <view className='GetUserPhone'>
73
+    //             {
74
+    //                 showPannel && (
75
+    //                     <view className='centerLabel'>
76
+    //                         <text>您暂未授权手机号</text>
77
+    //                         <view className='flex-h'>
78
+    //                             <text className='flex-item' onClick={handleCancel}>取消</text>
79
+    //                             
80
+    //                         </view>
81
+    //                     </view>
82
+    //                 )
83
+    //             }
84
+    //         </view>
85
+    //     </view>
86
+    // )
87
+}

+ 49
- 0
src/compents/getphone/index.scss Ver fichero

@@ -0,0 +1,49 @@
1
+.GetUserPhone {
2
+    width: 100%;
3
+    position: fixed !important;
4
+    left: 0;
5
+    top: 0;
6
+    bottom: 0;
7
+    z-index: 1000;
8
+    background: rgba(0, 0, 0, 0.7);
9
+  
10
+    view {
11
+      width: 60%;
12
+      background: #fff;
13
+      border-radius: 10px;
14
+  
15
+      text {
16
+        display: block;
17
+        text-align: center;
18
+        font-size: 32px;
19
+        line-height: 40px;
20
+        padding: 40px 0;
21
+      }
22
+  
23
+      .flex-h {
24
+        position: relative;
25
+        overflow: hidden;
26
+        border-top: 2px solid rgba(0, 0, 0, 0.08);
27
+//   display: flex;
28
+        text {
29
+          font-size: 36px;
30
+          font-weight: bold;
31
+          line-height: 80px;
32
+          text-align: center;
33
+          border-right: 2px solid rgba(0, 0, 0, 0.08);
34
+          color: #999;
35
+        }
36
+        button {
37
+          font-size: 36px;
38
+          font-weight: bold;
39
+          line-height: 80px;
40
+          background: none;
41
+          border: none;
42
+          padding: 0 !important;
43
+          &::after {
44
+            display: none;
45
+          }
46
+        }
47
+      }
48
+    }
49
+  }

+ 60
- 21
src/compents/tab/index.jsx Ver fichero

@@ -1,11 +1,12 @@
1 1
 import React, { useEffect, useState } from 'react'
2 2
 import Taro from "@tarojs/taro";
3 3
 import { useSelector } from 'react-redux'
4
-import { View, Image } from '@tarojs/components'
4
+import { View, Button, Image } from '@tarojs/components'
5 5
 import uploadicon from '../../assets/uploadicon.png'
6 6
 import roleList from '../../util/userRole'
7 7
 import './index.scss'
8 8
 
9
+
9 10
 const getColor = (role) => {
10 11
     switch (role) {
11 12
         case roleList.landlord: return '#274291'
@@ -20,10 +21,10 @@ const tab = (props) => {
20 21
 
21 22
     const user = useSelector(state => state.user)
22 23
 
23
-    const { value, pageState, color, ...prop } = props
24
+    const { value, openType, pageState, formType, color, ...prop } = props
24 25
 
25 26
     const [state, setState] = useState(1)
26
-    console.log(props)
27
+    console.log(props, openType, 'formType')
27 28
     useEffect(() => {
28 29
 
29 30
     }, [])
@@ -31,27 +32,65 @@ const tab = (props) => {
31 32
     //     color: #fed12f;
32 33
     // }${props.className}
33 34
     return <View className='tab'>
34
-        {value.length == 1 && <View className={`tab,tab1,${props.className}`} style={{ backgroundColor: getColor(user.role) ,color}}   onClick={() => props.onClick('2')}>{value[0]}
35
-        </View>}
35
+        {value.length == 1 && 
36
+        <>
37
+        {openType &&  <button openType="share" className={`tab,tab1,${props.className}`} style={{ backgroundColor: getColor(user.role), color }} onClick={() => props.onClick('2')}>{value[0]}</button>}
38
+        {!openType && <View className={`tab,tab1,${props.className}`} style={{ backgroundColor: getColor(user.role), color }} onClick={() => props.onClick('2')}>{value[0]}</View>}
39
+        </>
40
+        }
36 41
         {value.length == 2 && <View className={`tab,tab2,${props.className}`} style={{ display: 'flex', }}>
37 42
             <View style={{ width: '50%' }} style={pageState == '2' ? { color: getColor(user.role), width: '50%' } : { width: '50%' }} onClick={props.onClick[0]}>{value[0]}</View>
38
-            <View style={{ width: '50%' }} style={pageState == '3' ? { color: getColor(user.role), width: '50%' } : { width: '50%' }} onClick={props.onClick[1]}>{value[1]}</View>
39
-        </View>}
40
-        {/* {value==1&&<View className={`tab,tab1,${props.className}`} onClick={()=>props.onClick(2)}>onClick={props.onClick[0]('2')}
41
-            开启旅程
42
-        </View>}
43
-        {value!=1&&<View className={`tab,tab2,${props.className}`}  style={{display: 'flex',}}>
44
-            <View style={{width:'50%'}} style={value=='guide'||value==2 ?{color: getColor(user.role),width:'50%'}:{width:'50%'}}  onClick={()=>props.onClick('guide')}>入住指引</View>
45
-            <View style={{width:'50%'}} style={value=='recommend' ?{color: getColor(user.role),width:'50%'}:{width:'50%'}} c onClick={()=>props.onClick('recommend')}>房东推荐</View>
46
-        </View>} */}
47
-        {/* {value==1&&<View className={`tab,tab1,${props.className}`} style={{background:getColor(user.role),color:'#ffffff'} } onClick={()=>Taro.navigateTo({ url: "/pages/house/add/index" })}>
48
-           +新增房源
43
+            {formType && <Button className='tab-btn' formType="submit" plain={true} style={pageState == '3' ? { color: getColor(user.role), width: '50%', border: 'none' } : { width: '50%', border: 'none' }}>{value[1]}</Button>}
44
+            {openType && <button className='tab-btn' openType="share" plain={true} style={pageState == '3' ? { color: getColor(user.role), width: '50%', border: 'none' } : { width: '50%', border: 'none' }}>{value[1]}</button>}
45
+            {!formType&&!openType &&
46
+                <View style={{ width: '50%' }} style={pageState == '3' ? { color: getColor(user.role), width: '50%' } : { width: '50%' }} onClick={props.onClick[1]}>{value[1]}</View>
47
+            }
49 48
         </View>}
50
-        {value!=1&&<View className={`tab,tab2,${props.className}`}  style={{display: 'flex',}}>
51
-            <View style={{width:'50%'}} style={value=='guide'||value==2 ?{color: getColor(user.role),width:'50%'}:{width:'50%'}}  onClick={()=>props.onClick('guide')}>入住指引</View>
52
-            <View style={{width:'50%'}} style={value=='recommend' ?{color: getColor(user.role),width:'50%'}:{width:'50%'}} c onClick={()=>props.onClick('recommend')}>房东推荐</View>
53
-        </View>} */}
49
+
54 50
     </View>
55 51
 };
56 52
 
57
-export default tab
53
+export default tab
54
+
55
+// import React, { useEffect, useState } from 'react'
56
+// import Taro from "@tarojs/taro";
57
+// import { Button, View } from '@tarojs/components'
58
+
59
+// import './index.scss'
60
+
61
+// const getColor = (role) => {
62
+//     switch (role) {
63
+//         case roleList.landlord: return '#274291'
64
+//         case roleList.adminuser: return '#274291'
65
+//         // landlord: 'landlord',
66
+//         case roleList.customer: return '#fed12f'
67
+//     }
68
+// }
69
+
70
+
71
+// const tab = (props) => {
72
+//     // formType="submit"
73
+
74
+//     const { value, pageState, formType, color, ...prop } = props
75
+
76
+//     const [state, setState] = useState(1)
77
+//     // console.log(props)
78
+//     useEffect(() => {
79
+
80
+//     }, [])
81
+//     //  &-on{
82
+//     //     color: #fed12f; style={{ backgroundColor:'#274291' ,color}}
83
+//     // }${props.className}
84
+//     return <View className='tab'>
85
+//         {value.length == 1 && <View className={`tab tab1 ${props.className}`} onClick={() => props.onClick('2')}>{value[0]}
86
+//         </View>}
87
+//         {value.length == 2 && <View className={`tab tab2 ${props.className}`} style={{ display: 'flex', }}>
88
+//             <View style={{ width: '50%' }} style={pageState == '2' ? { color: '#274291', width: '50%' } : { width: '50%' }} onClick={props.onClick[0]}>{value[0]}</View>
89
+//            { !formType? 
90
+//             <View formType={formType} style={{ width: '50%' }} style={pageState == '3' ? { color: '#274291', width: '50%' } : { width: '50%' }} onClick={props.onClick[1]}>{value[1]}</View>
91
+//             :<Button className='tab-btn' formType={formType} plain={true} style={{ width: '50%' }} style={pageState == '3' ? { color: '#274291', width: '50%',border:'none' } : { width: '50%',border:'none' }} onClick={props.onClick[1]}>{value[1]}</Button>}
92
+//         </View>}
93
+//     </View>
94
+// };
95
+
96
+// export default tab

+ 3
- 1
src/compents/tab/index.scss Ver fichero

@@ -8,7 +8,9 @@
8 8
     text-align: center;
9 9
     line-height: 173px;
10 10
     z-index:999;
11
-
11
+    &-btn{
12
+        line-height: unset;
13
+    }
12 14
 
13 15
     .tab1 {
14 16
         background-color: #274291;

+ 22
- 24
src/compents/tags/index.jsx Ver fichero

@@ -2,44 +2,42 @@ import React, { useEffect, useState } from 'react'
2 2
 import Taro from "@tarojs/taro";
3 3
 import { useSelector } from 'react-redux'
4 4
 import { View, Text } from '@tarojs/components'
5
-import roleList from '../../util/userRole'
6 5
 import './index.scss'
7
-import { set } from 'lodash';
8
-
9
-const getColor = (role) => {
10
-    switch (role) {
11
-        case roleList.landlord: return '#274291'
12
-        case roleList.adminuser: return '#274291'
13
-        // landlord: 'landlord',
14
-        case roleList.customer: return '#fed12f'
15
-    }
16
-}
17
-
18 6
 
19 7
 const tags = (props) => {
20 8
 
21
-    const user = useSelector(state => state.user)
22 9
 
23 10
     const { value, list, onChange, ...prop } = props
24 11
 
25 12
     const [state, setState] = useState(1)
26
-    const [key,setKey] = useState(value)
13
+    const [key, setKey] = useState(value)
14
+    const [keyList, setKeyList] = useState([])
27 15
     console.log(props)
28 16
     useEffect(() => {
29 17
 
30 18
     }, [])
31
-   const onClick = (item) =>{
32
-
33
-       setKey(item.id)
34
-       onChange(item)
35
-   }
19
+    const onClick = (item) => {
20
+       
21
+        
22
+        let  newkeyList= keyList
23
+        console.log(newkeyList.find(x => x.tagId === item.tagId),'333')
24
+        if (newkeyList.find(x => x.tagId === item.tagId)) {
25
+            newkeyList =  newkeyList.filter((x) => x.tagId != item.tagId )
26
+        } else {
27
+            newkeyList.push(item)
28
+        }
29
+
30
+console.log(newkeyList,keyList)
31
+        setKeyList([...newkeyList])
32
+        onChange([...newkeyList])
33
+    }
36 34
     return <View className='tags'>
37
-        <View className='at-row at-row--wrap' style={{marginTop:'10rpx'}}>
35
+        <View className='at-row at-row--wrap' style={{ marginTop: '10rpx' }}>
38 36
             {
39
-                list.map((item)=>{
40
-                   return <View className='at-col at-col-4 ' >
41
-                       <View className={`tags-btn tags-btn${item.id===key?'-on':''}`} onClick={()=>onClick(item)} >{item.name}</View>
42
-                       </View>
37
+                list.map((item, index) => {
38
+                    return <View className='at-col at-col-4 ' key={index}>
39
+                        <View className={`tags-btn tags-btn${keyList.find(x => x.tagId === item.tagId) ? '-on' : ''}`} onClick={() => onClick(item)} >{item.name}</View>
40
+                    </View>
43 41
                 })
44 42
             }
45 43
 

+ 8
- 0
src/pages/addimg/index.config.js Ver fichero

@@ -0,0 +1,8 @@
1
+// onShareAppMessage: function () {
2
+// return custom share data when user share.
3
+//     console.log('44444444')
4
+//   },
5
+
6
+export default {
7
+    enableShareAppMessage: true
8
+}

+ 115
- 0
src/pages/addimg/index.jsx Ver fichero

@@ -0,0 +1,115 @@
1
+import React, { useEffect, useMemo, useState } from 'react'
2
+import Taro, { useDidShow, useRouter } from '@tarojs/taro'
3
+import { useSelector } from 'react-redux'
4
+import { View, ScrollView, Image } from '@tarojs/components'
5
+import Layout from '../../layout/index'
6
+import Tab from '../../compents/tab/index'
7
+
8
+import radio from '../../assets/radio.png'
9
+import './index.scss'
10
+import request from '../../util/request'
11
+
12
+const addimg = (props) => {
13
+    const router = useRouter()
14
+    const { houseId, tagIds } = router.params
15
+    const user = useSelector(state => state.user)
16
+
17
+    const [pageState, setPageState] = useState('2')
18
+    const [list, setList] = useState([])
19
+
20
+    const [choiceList, setChoicelist] = useState([])
21
+
22
+
23
+    useEffect(() => {
24
+        getImageList()
25
+    }, [])
26
+
27
+    const getImageList = () => {
28
+
29
+
30
+        request({ url: '/taMetaImageTag', params: { tagIds: tagIds } }).then((res) => {
31
+            const { records, ...page } = res.data.data
32
+
33
+            const r = records.reduce((all, next) => all.some((atom) => atom.imageId == next.imageId) ? all : [...all, next], []);
34
+            setList(r)
35
+        })
36
+
37
+    }
38
+
39
+    const choiceImg = (value) => {
40
+        console.log(value, '111')
41
+        const t = choiceList.find(x => x.imageId == value.imageId)
42
+        if (t) {
43
+            setChoicelist(choiceList.filter(x => x.imageId != value.imageId))
44
+        } else {
45
+            setChoicelist([
46
+                ...choiceList,
47
+                value
48
+            ])
49
+        }
50
+    }
51
+
52
+    const onAddimg = (e) => {
53
+        console.log(e, '111')
54
+        if (choiceList.length > 0) {
55
+
56
+            const data = choiceList.map(x => {
57
+                return {
58
+                    houseId,
59
+                    image: x.image,
60
+                    imageId:x.imageId,
61
+                }
62
+            })
63
+            request({ url: '/taHouseSurround', method: 'post', data }).then((res)=>{
64
+                Taro.showModal({
65
+                    title: '添加成功',
66
+                    content: '点击确认按钮,返回上级菜单',
67
+                    showCancel: false,
68
+                    success: function (res) {
69
+                        if (res.confirm) {
70
+                            console.log('用户点击确定')
71
+        
72
+                            Taro.navigateBack({
73
+                                delta: 2
74
+                            })
75
+                        } else if (res.cancel) {
76
+                            console.log('用户点击取消')
77
+                        }
78
+                    }
79
+                })
80
+               
81
+            })
82
+        }
83
+
84
+    }
85
+
86
+
87
+    return <View className='addimg'>
88
+
89
+
90
+        <View >
91
+
92
+            <View className='at-row at-row--wrap'>
93
+                {list.map((x) => {
94
+                    return <View className='at-col at-col-3 addimg-view-card' key={x.imageId}>
95
+                        <View className='addimg-view-card-radio' onClick={() => choiceImg(x)}>
96
+                            {choiceList.find(y => y.imageId == x.imageId) && <Image src={radio} style={{ width: '30rpx', height: '20rpx' }}></Image>}
97
+                        </View>
98
+                        <Image src={x.image} mode='aspectFit' style={{ width: '100%', height: '200rpx' }} ></Image>
99
+                    </View>
100
+                })}
101
+                {/* {list.map((x) => {
102
+                    return <View className='at-col at-col-4'>A</View>
103
+                })} */}
104
+            </View>
105
+            <Tab value={['取消', `选择${choiceList.length}`]} pageState="3" onClick={[(e) => Taro.navigateBack({
106
+                delta: 1
107
+            }), (e) => onAddimg()]}></Tab>
108
+
109
+        </View>
110
+
111
+
112
+    </View>
113
+}
114
+
115
+export default addimg

+ 32
- 0
src/pages/addimg/index.scss Ver fichero

@@ -0,0 +1,32 @@
1
+.addimg {
2
+
3
+  
4
+  // padding: 13.33px 0;
5
+  &-view {
6
+
7
+    &-card {
8
+      padding: 0;
9
+      color: #181818;
10
+      font-size: 24px;
11
+      font-weight: 600;
12
+      margin-top: 26.67px;
13
+      position: relative;
14
+
15
+      &-radio {
16
+          width: 50px;
17
+          height: 50px;
18
+        background-color: #274291;
19
+        text-align: center;
20
+        line-height: 50px;
21
+        position: absolute;
22
+        border-radius: 25px;
23
+        top: 0px;
24
+        right: 0px;
25
+      }
26
+
27
+
28
+
29
+    }
30
+  }
31
+
32
+}

+ 21
- 50
src/pages/customer/index.js Ver fichero

@@ -9,39 +9,31 @@ import Recommend from '../recommend/index'
9 9
 // import HouseLIst from '../house/list'
10 10
 
11 11
 import './index.scss'
12
+import request from '../../util/request'
12 13
 
13 14
 const index = (props) => {
14
-
15
-  const page = useSelector(state => state.page)
16
-
15
+  const {houseId,orderId} = props
16
+ 
17 17
   const user = useSelector(state => state.user)
18 18
 
19
-  const [userRole, setUserRole] = useState('1')
20
-  const [pageState, setPageState] = useState('2')
21
-  const [list, setList] = useState([])
19
+  const [pageState, setPageState] = useState(false)
22 20
   useEffect(() => {
21
+    
22
+
23
+    if(orderId){
24
+      request({url:'',}).then(res=>{
25
+        setPageState('1')
26
+      })
27
+    }else{
28
+      setPageState('1')
29
+    }
23 30
 
24
-    console.log(page,'page')
25
-    setList([
26
-      {
27
-        name: 'zhou',
28
-        phone: '177'
29
-      },
30
-      {
31
-        name: 'zhou',
32
-        phone: '177'
33
-      },
34
-      {
35
-        name: 'zhou',
36
-        phone: '177'
37
-      }
38
-    ])
39 31
   }, [])
40 32
 
41 33
 
42 34
   const onTabClick = (e) => {
43 35
     console.log(e, '111')
44
-    setUserRole(e)
36
+    
45 37
   }
46 38
 
47 39
   const onRegisterChange = (e) => {
@@ -52,39 +44,18 @@ const index = (props) => {
52 44
   return <View className='index'>
53 45
 
54 46
 
55
-     <View>
56
-
47
+     {pageState&&<View>
48
+{pageState=='1'&&<Register oderId={orderId}></Register>  }
57 49
     <Layout>
58
-    {pageState=='1'&&<Register></Register>  }
59
-    {pageState=='2'&&<Guide></Guide>  }
60
-    {pageState=='3'&&<Recommend></Recommend>  }
50
+    
51
+    {pageState=='2'&&<Guide houseId={houseId}></Guide>  }
52
+    {pageState=='3'&&<Recommend houseId={houseId}></Recommend>  }
61 53
     </Layout>
62
-    {pageState=='1' &&<Tab value={['开启旅程']} onClick={(e)=>setPageState(e)}></Tab>}
54
+    
63 55
     {pageState!='1' &&<Tab value={['入住指引','房东推荐']} pageState={pageState} onClick={[(e) => setPageState('2'),(e) => setPageState('3')]}></Tab>}
64 56
 
65
-    </View>
66
-
67
-
68
-
69
-      {/* userRole={userRole} list={list} onChange={(e) => onRegisterChange(e)} */}
57
+    </View>}
70 58
 
71
-        {/* {userRole == 1 ? <Register userRole={userRole} list={list} onChange={(e) => onRegisterChange(e)}></Register> :
72
-          <View>
73
-            {(userRole == 'guide' || userRole == 2) && <Guide userRole={userRole}/>}
74
-            {userRole == 'recommend' && <Recommend userRole={userRole}/>}
75
-          </View>
76
-        }
77
-        {userRole == 2 ? <Register userRole={userRole} list={list} onChange={(e) => onRegisterChange(e)}></Register> :
78
-          <View>
79
-            {(userRole == 'guide' || userRole == 2) && <Guide userRole={userRole}/>}
80
-            {userRole == 'recommend' && <Recommend userRole={userRole}/>}
81
-          </View>
82
-        }
83
-     <HouseLIst userRole={userRole} list={list} onChange={(e) => onRegisterChange(e)}></HouseLIst>  */}
84
-       
85
-        
86
-      
87
-      {/* value={userRole} onClick={(e) => onTabClick(e)*/}
88 59
     
89 60
   </View>
90 61
 }

+ 98
- 40
src/pages/customer/register/index.jsx Ver fichero

@@ -2,52 +2,110 @@ import React, { useEffect, useState } from 'react'
2 2
 import './register.scss'
3 3
 import { View, Text, Input } from '@tarojs/components'
4 4
 import ContainerLayout from '../../../compents/container/index'
5
-import { AtInput }  from 'taro-ui'
5
+import { AtInput } from 'taro-ui'
6
+import Tab from '../../../compents/tab'
7
+import Layout from '../../../layout'
6 8
 
7
-const register = (props) => {
8 9
 
9
-    // const {list,onChange}= props
10
+const InputGroup = props => {
11
+  console.log('---------', JSON.stringify(props.dataSource))
12
+  const [name, setName] = useState(props.dataSource.name)
13
+  const [phone, setPhone] = useState(props.dataSource.phone)
10 14
 
11
-    const [list, setList] = useState([])
12
-    useEffect(() => {
15
+  useEffect(() => {
16
+    if (name !== props.dataSource.name) {
17
+      setName(props.dataSource.name)
18
+    }
19
+  }, [props.dataSource.name])
13 20
   
14
-    //   console.log(page,'page')
15
-      setList([
16
-        {
17
-          name: 'zhou',
18
-          phone: '177'
19
-        },
20
-        {
21
-          name: 'zhou',
22
-          phone: '177'
23
-        },
24
-        {
25
-          name: 'zhou',
26
-          phone: '177'
27
-        },
28
-        {
29
-            name: 'zhou',
30
-            phone: '177'
31
-          }
32
-      ])
33
-    }, [])
34
-    // const onChange =
35
-//  onChange={onChange}
36
-//  onChange={onChange}
37
-    return <View className='register'>
38
-        {list.map((x, index) => {
39
-            return <View className='register-user'>
40
-                <Text>入住人{index + 1}</Text>
41
-                <ContainerLayout className='register-user-from'>
42
-                    <AtInput className='register-user-from-input' title='姓名' type='text'   />
43
-                    <AtInput className='register-user-from-input'  title='电话' type='text'   />
44
-                </ContainerLayout>
45
-
46
-            </View>
47
-
48
-        })}
21
+  useEffect(() => {
22
+    if (phone !== props.dataSource.phone) {
23
+      setPhone(props.dataSource.phone)
24
+    }
25
+  }, [props.dataSource.phone])
26
+
27
+  const handeNameChange = e => {
28
+    console.log('333333333333333333')
29
+    const v = e.detail.value
30
+    setName(v)
31
+    if (props.onChange) {
32
+      props.onChange({
33
+        name: v,
34
+        phone
35
+      })
36
+    }
37
+    return v
38
+  }
39
+  
40
+  const handePhoneChange = e => {
41
+    const v = e.detail.value
42
+    setPhone(v)
43
+    if (props.onChange) {
44
+      props.onChange({
45
+        name,
46
+        phone: v
47
+      })
48
+    }
49
+    return v
50
+  }
51
+
52
+  const handleFocues = (_, e) => {
53
+    e.stopPropagation()
54
+    e.preventDefault()
55
+  }
49 56
 
57
+  return (
58
+    <View className='register-user'>
59
+      <Text>入住人{props.index}</Text>
60
+      <ContainerLayout className='register-user-from'>
61
+        {console.log(name,phone,'name,phone')}
62
+        <Input name="name" className='register-user-from-input' value={name} onInput={handeNameChange} placeholder='姓名' type='text' />
63
+        <Input name="phone" className='register-user-from-input' value={phone} onInput={handePhoneChange} placeholder='电话' type='text' />
64
+      </ContainerLayout>
50 65
     </View>
66
+  )
67
+}
68
+
69
+const register = (props) => {
70
+
71
+  const { orderId } = props
72
+
73
+  let [list, setList] = useState([])
74
+  useEffect(() => {
75
+    //   console.log(page,'page')
76
+    const arr = []
77
+    for (let i = 0; i < 4; i++) {
78
+      arr.push({
79
+        name:'',
80
+        phone:'',
81
+      })
82
+    }
83
+    setList(arr)
84
+  }, [])
85
+
86
+  const onClick = () => {
87
+    console.log(list)
88
+  }
89
+
90
+  const onChangeList = index => value =>  {
91
+    console.log(111111111, value, index)
92
+ 
93
+    list[index] = value
94
+
95
+    setList([...list])
96
+
97
+  }
98
+
99
+  return <View className='register'>
100
+    <Layout>
101
+      {list.map((x, index) => {
102
+        let inx = index
103
+        return <InputGroup key={inx} index={index} dataSource={x} onChange={onChangeList(inx)} />
104
+      })}
105
+    </Layout>
106
+
107
+    <Tab value={['开启旅程']} onClick={(e) => onClick(e)}></Tab>
108
+  </View>
51 109
 }
52 110
 
53 111
 export default register

+ 119
- 64
src/pages/guide/index.jsx Ver fichero

@@ -1,91 +1,146 @@
1
-import React, { useState } from 'react'
2
-import Taro from '@tarojs/taro'
1
+import React, { useEffect, useState } from 'react'
2
+import Taro, { useDidShow } from '@tarojs/taro'
3 3
 import { View, Text, Image } from '@tarojs/components'
4 4
 import ContainerLayout from '../../compents/container/index'
5 5
 import icon from '../../assets/icon.png'
6 6
 import './index.scss'
7 7
 import userRloe from '../../util/userRole'
8 8
 import { useSelector } from 'react-redux'
9
-
9
+import request from '@/util/request'
10
+import uploadicon from '../../assets/uploadicon.png'
10 11
 const guide = (props) => {
11 12
 
12 13
     const user = useSelector(state => state.user)
13 14
     // const guide = useSelector(state => state.guide)
14 15
 
15
-    const { value, ...prop } = props
16
-    console.log(guide,'guide')
16
+
17
+
18
+
19
+    const { value, houseId, ...prop } = props
17 20
     const [state, setState] = useState(1)
18 21
 
19 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
+    }
47
+
48
+    const onOpenLocation = (lngLat) => {
49
+        const [latitude, longitude] = lngLat.split(',')
50
+        console.log(lngLat, latitude, longitude)
51
+        wx.openLocation({
52
+            latitude: Number(latitude),
53
+            longitude: Number(longitude),
54
+            scale: 18,
55
+            fail: (err) => {
56
+                console.log(err)
57
+            }
58
+        })
59
+    }
20 60
 
21 61
     const onToMap = (type) => {
22 62
         if (user.role == userRloe.customer) return
23
-        console.log(type)
24
-        switch (type){
25
-            case 'house':Taro.navigateTo({ url: `/pages/map/index?type=${type}` }); break;
26
-            case 'park':Taro.navigateTo({ url: `/pages/map/index?type=${type}` }); break;
27
-            case 'wifi':Taro.navigateTo({ url: `/pages/wifi/index?type=${type}` }); break;
28
-            case 'image':{
63
+        switch (type) {
64
+            case 'address': Taro.navigateTo({ url: `/pages/map/index?houseId=${houseId}&type=${type}` }); break;
65
+            case 'park': Taro.navigateTo({ url: `/pages/map/index?houseId=${houseId}&type=${type}` }); break;
66
+            case 'wifi': Taro.navigateTo({ url: `/pages/wifi/index?houseId=${houseId}` }); break;
67
+            case 'image': {
68
+                if (user.role == userRloe.customer) return
29 69
                 wx.chooseImage({
30
-                count: 1,
31
-                sizeType: ['original', 'compressed'],
32
-                sourceType: ['album',],
33
-                success: (res)=> {
34
-                  // tempFilePath可以作为img标签的src属性显示图片
35
-                
36
-                  console.log(res)
37
-                  const tempFilePaths = res.tempFilePaths
38
-                    setImgurl(tempFilePaths[0])
39
-                }
40
-              }); break;}
70
+                    count: 1,
71
+                    sizeType: ['original', 'compressed'],
72
+                    sourceType: ['album',],
73
+                    success: (res) => {
74
+                        // tempFilePath可以作为img标签的src属性显示图片
75
+
76
+                        console.log(res)
77
+                        const tempFilePaths = res.tempFilePaths
78
+                        setImgurl(tempFilePaths[0])
79
+                    }
80
+                }); break;
81
+            }
41 82
         }
42 83
         // Taro.navigateTo({ url: `/pages/map/index?type=${type}` })
43 84
     }
44 85
     // 
45 86
     return <View className='guide'>
46
-        <View className='guide-view'>
47
-            <Text className='guide-view-info'>房屋位置</Text>
48
-            <ContainerLayout className='guide-view-layout' style={{ display: 'flex', justifyContent: 'space-between' }} onClick={() => onToMap('house')}>
49
-                <View  >
50
-                    <View className='guide-view-layout-text1' >南京市 浦口</View>
51
-                    <View className='guide-view-layout-text2'>秦淮区仙鹤街</View>
52
-                </View>
53
-                {user.role == userRloe.customer && <View style={{ float: 'right' }}>
54
-                    <Image className='icon' src={icon} />
55
-                    <View className='icontext'>去这里</View>
56
-                </View>}
57
-            </ContainerLayout>
58
-        </View>
59
-        <View className='guide-view'>
60
-            <Text className='guide-view-info'>停车位置</Text>
61
-            <ContainerLayout className='guide-view-layout' style={{ display: 'flex', justifyContent: 'space-between' }} onClick={() => onToMap('park')}>
62
-                <View  >
63
-                    <View className='guide-view-layout-text1' >南京市 浦口</View>
64
-                    <View className='guide-view-layout-text2'>秦淮区仙鹤街</View>
65
-                </View>
66
-                {user.role == userRloe.customer && <View style={{ float: 'right' }}>
67
-                    <Image className='icon' src={icon} />
68
-                    <View className='icontext'>去这里</View>
69
-                </View>}
70
-            </ContainerLayout>
71
-        </View>
72
-        <View className='guide-view'>
73
-            <Text className='guide-view-info'>wifi信息</Text>
74
-            <ContainerLayout className='guide-view-layout guide-view-wifi' onClick={() => onToMap('wifi')}>
75
-                <View>
76
-                    <Text>名称:</Text><Text>{4324}</Text>
77
-                </View>
78
-                <View>
79
-                    <Text>密码:</Text><Text>{23423}</Text>
87
+        {!!houseId&&<View>
88
+            <View className='guide-view'>
89
+                <Text className='guide-view-info'>房屋位置</Text>
90
+                <ContainerLayout className='guide-view-layout' style={{ display: 'flex', justifyContent: 'space-between' }} onClick={() => onToMap('address')}>
91
+                    <View  >
92
+                        <View className='guide-view-layout-text1' >{detail.address}</View>
93
+                        {/* <View className='guide-view-layout-text2'>{detail.lngLat}</View> */}
94
+                    </View>
95
+                    {user.role == userRloe.customer && <View style={{ float: 'right' }} onClick={() => onOpenLocation(detail.lngLat)}>
96
+                        <Image className='icon' src={icon} />
97
+                        <View className='icontext' >去这里</View>
98
+                    </View>}
99
+                </ContainerLayout>
100
+            </View>
101
+            <View className='guide-view'>
102
+                <Text className='guide-view-info'>停车位置</Text>
103
+                <ContainerLayout className='guide-view-layout' style={{ display: 'flex', justifyContent: 'space-between' }} onClick={() => onToMap('park')}>
104
+                    <View  >
105
+                        <View className='guide-view-layout-text1' >{detail.parking}</View>
106
+                        {/* <View className='guide-view-layout-text2'>{detail.parkLngLat}</View> */}
107
+                    </View>
108
+                    {user.role == userRloe.customer && <View style={{ float: 'right' }} onClick={() => onOpenLocation(detail.parkLngLat)}>
109
+                        <Image className='icon' src={icon} />
110
+                        <View className='icontext'>去这里</View>
111
+                    </View>}
112
+                </ContainerLayout>
113
+            </View>
114
+            <View className='guide-view'>
115
+                <Text className='guide-view-info'>wifi信息</Text>
116
+                <ContainerLayout className='guide-view-layout guide-view-wifi' onClick={() => onToMap('wifi')}>
117
+                    <View>
118
+                        <Text>名称:</Text><Text>{detail.wifiName}</Text>
119
+                    </View>
120
+                    <View>
121
+                        <Text>密码:</Text><Text>{detail.wifiPassword}</Text>
122
+                    </View>
123
+                </ContainerLayout>
124
+            </View>
125
+            <View className='guide-view'>
126
+                <Text className='guide-view-info'>其他指引</Text>
127
+                {/* <ContainerLayout className='guide-view-layout guide-view-img'> */}
128
+                {(detail.desc || imgurl) && <Image className='guide-view-img' mode='widthFix' onClick={() => onToMap('image')} src={imgurl || detail.desc}></Image>}
129
+                {!detail.desc && !imgurl && <View style={{ padding: "300rpx" }} >
130
+
131
+                    <Image className='guide-view-img' mode='widthFix' onClick={() => onToMap('image')} src={uploadicon}></Image>
80 132
                 </View>
81
-            </ContainerLayout>
82
-        </View>
83
-        <View className='guide-view'>
84
-            <Text className='guide-view-info'>其他指引</Text>
85
-            {/* <ContainerLayout className='guide-view-layout guide-view-img'> */}
86
-            <Image className='guide-view-img' mode='widthFix' onClick={() => onToMap('image')} src={imgurl||"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1657471424,2319316184&fm=26&gp=0.jpg"}></Image>
87
-            {/* </ContainerLayout> */}
88
-        </View>
133
+                }
134
+            </View>
135
+        </View>}
136
+        {
137
+            !houseId && <View className='recommend-noorder' style={{ marginTop: 'calc(40vh)',textAlign:'center' }}>
138
+                <Text>哎呀</Text>
139
+                <Text>暂时没发现您的入住订单呢~</Text>
140
+
141
+
142
+            </View>
143
+        }
89 144
 
90 145
     </View>
91 146
 };

+ 114
- 73
src/pages/house/addnewhouse/index.jsx Ver fichero

@@ -7,76 +7,84 @@ import Tab from '../../../compents/tab/index'
7 7
 import Container from '../../../compents/container/index'
8 8
 import locationicon from '../../../assets/locationicon.png'
9 9
 import uploadicon from '../../../assets/uploadicon.png'
10
+import request, { uploadFiles } from '../../../util/request'
10 11
 import './index.scss'
11 12
 
12
-const index = (props) => {
13 13
 
14
-    const page = useSelector(state => state.page)
14
+const index = (props) => {
15 15
 
16 16
     const user = useSelector(state => state.user)
17
-
17
+    const { shopKeeperList = [] } = user
18
+    const shopId = shopKeeperList[0].shopId || ''
18 19
     const [userRole, setUserRole] = useState('1')
19 20
     const [pageState, setPageState] = useState('1')
20 21
     const [list, setList] = useState([])
21
-    useEffect(() => {
22
+    const [imgUrl, setImgUrl] = useState('')
23
+    const [address, setAddress] = useState({})
24
+    const [parking, setParking] = useState({})
22 25
 
23
-        console.log(page, 'page')
24
-        setList([
25
-            {
26
-                name: 'zhou',
27
-                phone: '177'
28
-            },
29
-            {
30
-                name: 'zhou',
31
-                phone: '177'
32
-            },
33
-            {
34
-                name: 'zhou',
35
-                phone: '177'
36
-            }
37
-        ])
38
-    }, [])
39 26
 
27
+    useEffect(() => {
40 28
 
41
-    const onTabClick = (e) => {
42
-        console.log(e, '111')
43
-        setUserRole(e)
44
-    }
45 29
 
46
-    const onRegisterChange = (e) => {
47
-        console.log(e, '111')
48
-    }
49
-    const onSave = () => {
50
-        console.log(333)
30
+    }, [])
51 31
 
52
-        Taro.showModal({
53
-            title: '修改成功',
54
-            content: '点击确认按钮,返回上级菜单',
55
-            showCancel: false,
56
-            success: function (res) {
57
-                if (res.confirm) {
58
-                    console.log('用户点击确定')
59
-
60
-                    Taro.navigateBack({
61
-                        delta: 1
62
-                    })
63
-                } else if (res.cancel) {
64
-                    console.log('用户点击取消')
65
-                }
66
-            }
67
-        })
68
-    }
69 32
 
70
-    const onChooseLocation = () => {
33
+    const onChooseLocation = (type) => {
71 34
         console.log(333)
72 35
         wx.chooseLocation({
73 36
             success: (res) => {
74 37
                 console.log(res)
38
+                if (type == 'address') {
39
+                    setAddress(res)
40
+                } else {
41
+                    setParking(res)
42
+                }
43
+
44
+
75 45
             }
76 46
         })
77 47
     }
78 48
     const formSubmit = (e) => {
79
-        console.log(e, 'formSubmit')
49
+        console.log(e.detail, 'formSubmit')
50
+        const data = {
51
+            ...e.detail.value,
52
+            lngLat: `${address.latitude},${address.longitude}`,
53
+            parkLngLat: `${address.latitude},${address.longitude}`,
54
+            desc:imgUrl,
55
+        }
56
+        // latitude
57
+        // longitude
58
+        request({ url: '/taHouse', method: 'post', data }).then((res) => {
59
+            if (res.data.code == 1000)
60
+                Taro.navigateBack({
61
+                    delta: 1
62
+                })
63
+        })
64
+
65
+        // {shopId,
66
+
67
+        //     "address": "string",
68
+
69
+        //     "lngLat": "string",
70
+        //     "parkLngLat": "string",
71
+        //     "parking": "string",
72
+
73
+        //     "surroundList": [
74
+        //       {
75
+        //         "createDate": "2020-12-29T15:38:53.177Z",
76
+        //         "houseId": "string",
77
+        //         "image": "string",
78
+        //         "imageId": "string",
79
+        //         "sortNo": 0,
80
+        //         "status": 0,
81
+        //         "surroundId": "string"
82
+        //       }
83
+        //     ],
84
+        //     "title": "string",
85
+        //     "wifiName": "string",
86
+        //     "wifiPassword": "string"
87
+        //   }
80 88
     }
81 89
 
82 90
     const formReset = () => {
@@ -85,41 +93,54 @@ const index = (props) => {
85 93
 
86 94
     return <View className='addnewhouse'>
87 95
 
88
-
89
-        {/* <Form onSubmit={this.formSubmit} onReset={this.formReset} >
96
+        <Form onSubmit={formSubmit} onReset={formReset}>
97
+            {/* <Form onSubmit={this.formSubmit} onReset={this.formReset} >
90 98
         <View className='example-body'>
91 99
           <Switch name='switch' className='form-switch'></Switch>
92 100
         </View>
93 101
       </Form> */}
94 102
 
95
-        <Layout>
96
-            <Form onSubmit={formSubmit} onReset={formReset}>
103
+            <Layout>
104
+
97 105
                 <View className='inputstyle-view'>
98 106
                     <Text className='title'>民宿名称</Text>
99 107
                     <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
100
-                        <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
108
+                        <Input name='title' placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
101 109
                     </Container>
102 110
                 </View>
103
-                <View className='inputstyle-view'>
111
+                {/* <View className='inputstyle-view'>
104 112
                     <Text className='title'>房屋名称</Text>
105 113
                     <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
106
-                        <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
114
+                        <Input name='title' placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
107 115
                     </Container>
116
+                </View> */}
117
+                <View className='inputstyle-view'>
118
+                    <Text className='title'>位置信息</Text>
119
+                    <View style={{ display: 'flex' }}>
120
+                        <Container className='inputstyle-view-card' style={{ width: '100%', borderRadius: '20rpx', padding: '0 40rpx' }}>
121
+                            <Input name='address' value={address.address} disabled placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
122
+
123
+                        </Container>
124
+                        <Container className='map-view-icon' onClick={() => onChooseLocation('address')}>
125
+                            <Image className='icon' mode='widthFix' style={{ width: '100%' }} style={{ width: '40rpx' }} src={locationicon} />
126
+
127
+                        </Container>
128
+                    </View>
108 129
                 </View>
109 130
                 <View className='inputstyle-view'>
110
-                    <Text className='title'>位置形象</Text>
131
+                    <Text className='title'>具体地址</Text>
111 132
                     <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
112
-                        <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
133
+                        <Input name='lngLat' placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
113 134
                     </Container>
114 135
                 </View>
115 136
                 <View className='inputstyle-view'>
116
-                    <Text className='title'>当前地址</Text>
137
+                    <Text className='title'>停车场地址</Text>
117 138
                     <View style={{ display: 'flex' }}>
118 139
                         <Container className='inputstyle-view-card' style={{ width: '100%', borderRadius: '20rpx', padding: '0 40rpx' }}>
119
-                            <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
140
+                            <Input name='parking' value={parking.address} disabled placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
120 141
 
121 142
                         </Container>
122
-                        <Container className='map-view-icon' onClick={onChooseLocation}>
143
+                        <Container className='map-view-icon' onClick={() => onChooseLocation('parking')}>
123 144
                             <Image className='icon' mode='widthFix' style={{ width: '100%' }} style={{ width: '40rpx' }} src={locationicon} />
124 145
 
125 146
                         </Container>
@@ -128,46 +149,66 @@ const index = (props) => {
128 149
                 <View className='inputstyle-view'>
129 150
                     <Text className='title'>具体地址</Text>
130 151
                     <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
131
-                        <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
152
+                        <Input name='parkLngLat' placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
132 153
                     </Container>
133 154
                 </View>
134 155
                 <View className='inputstyle-view'>
135 156
                     <Text className='title'>WiFi名称</Text>
136 157
                     <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
137
-                        <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
158
+                        <Input name='wifiName' placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
138 159
                     </Container>
139 160
                 </View>
161
+
140 162
                 <View className='inputstyle-view'>
141 163
                     <Text className='title'>WiFi密码</Text>
142 164
                     <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
143
-                        <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
165
+                        <Input name='wifiPassword' placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
144 166
                     </Container>
145 167
                 </View>
146 168
                 <View className='inputstyle-view'>
147 169
                     <Text className='title'>其他指引</Text>
148 170
                     <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
149
-                        <Image className='guide-view-img' mode='widthFix' onClick={() => wx.chooseImage({
171
+                        <Image className='guide-view-img' mode='widthFix' onClick={() => Taro.chooseImage({
150 172
                             count: 1,
151
-                            sizeType: ['original', 'compressed'],
152
-                            sourceType: ['album',],
173
+                            // sizeType: ['original', 'compressed'],
174
+                            sourceType: ['album'],
153 175
                             success: (res) => {
154 176
                                 // tempFilePath可以作为img标签的src属性显示图片
177
+                                const tempFilePaths = res.tempFilePaths
178
+
179
+                                uploadFiles(tempFilePaths).then((res) => {
180
+                                    console.log(res, 'uploadFiles')
181
+                                    setImgUrl(res[0])
182
+                                }).catch((e) => {
183
+                                    console.log(e, 'err')
184
+                                })
155 185
 
156
-                                console.log(res)
157
-                                // const tempFilePaths = res.tempFilePaths
158 186
                                 // setImgurl(tempFilePaths[0])
159 187
                             }
160
-                        })} src={uploadicon || "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1657471424,2319316184&fm=26&gp=0.jpg"}></Image>
188
+                        })} src={imgUrl || uploadicon}></Image>
161 189
                         {/* <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' /> */}
162 190
                     </Container>
163 191
                 </View>
164
-            </Form>
165
-
166
-        </Layout>
167
-        <Tab className='addhousetab' pageState='3' value={['取消', '确认新增']} onClick={[(e) => setPageState('2'), () => formSubmit()]}></Tab>
168 192
 
169 193
 
194
+            </Layout>
195
+            <Tab formType="submit" className='addhousetab' pageState='3' value={['取消', '确认新增']} onClick={[(e) => {
196
+                Taro.navigateBack({
197
+                    delta: 1
198
+                })
199
+            }, () => { console.log('33') }]}></Tab>
200
+        </Form>
170 201
 
202
+        {/* Taro.chooseImage({
203
+            sourceType: ['album'],
204
+            success: (res) => {
205
+                const tempFilePaths = res.tempFilePaths
206
+                uploadFiles(tempFilePaths).then((res) => {
207
+                    console.log(res, 'uploadFiles')
208
+                    setImgUrl(res[0])
209
+                })
210
+            }
211
+        }) */}
171 212
 
172 213
 
173 214
     </View>

+ 9
- 8
src/pages/house/index.jsx Ver fichero

@@ -1,4 +1,5 @@
1 1
 import React, { useEffect, useMemo, useState } from 'react'
2
+import Taro, { useDidShow,useRouter } from '@tarojs/taro'
2 3
 import { useSelector } from 'react-redux'
3 4
 import { View, ScrollView } from '@tarojs/components'
4 5
 import Layout from '../../layout/index'
@@ -9,19 +10,18 @@ import Recommend from '../recommend/index'
9 10
 // import HouseLIst from '../house/list'
10 11
 
11 12
 import './index.scss'
13
+import request from '../../util/request'
12 14
 
13 15
 const house = (props) => {
14
-
15
-    const page = useSelector(state => state.page)
16
-
16
+    const router = useRouter()
17
+    const { houseId } = router.params
17 18
     const user = useSelector(state => state.user)
18
-
19
+   
19 20
     const [userRole, setUserRole] = useState('1')
20 21
     const [pageState, setPageState] = useState('2')
21 22
     const [list, setList] = useState([])
22 23
     useEffect(() => {
23 24
 
24
-        console.log(page, 'page')
25 25
         setList([
26 26
             {
27 27
                 name: 'zhou',
@@ -38,6 +38,7 @@ const house = (props) => {
38 38
         ])
39 39
     }, [])
40 40
 
41
+    
41 42
 
42 43
     const onTabClick = (e) => {
43 44
         console.log(e, '111')
@@ -55,10 +56,10 @@ const house = (props) => {
55 56
         <View >
56 57
 
57 58
             <Layout>
58
-                {pageState == '2' && <Guide></Guide>}
59
-                {pageState == '3' && <Recommend></Recommend>}
59
+                {pageState == '2' && <Guide houseId={houseId}></Guide>}
60
+                {pageState == '3' && <Recommend houseId={houseId}></Recommend>}
60 61
             </Layout>
61
-            {pageState != '1' && <Tab value={['入住指引', '房东推荐']} pageState={pageState} onClick={[(e) => setPageState('2'),(e) => setPageState('3')]}></Tab>}
62
+            {pageState != '1' && <Tab value={['入住指引', '房东推荐']} pageState={pageState} onClick={[(e) => setPageState('2'), (e) => setPageState('3')]}></Tab>}
62 63
 
63 64
         </View>
64 65
 

+ 53
- 44
src/pages/house/list/index.jsx Ver fichero

@@ -1,49 +1,52 @@
1
-import React, { useEffect, useMemo, useState,useRef } from 'react'
2
-import Taro from '@tarojs/taro'
1
+import React, { useEffect, useMemo, useState, forwardRef, useImperativeHandle } from 'react'
2
+import Taro, { useDidShow } 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
-
8
-const house = (props) => {
7
+import request from '@/util/request'
8
+let house = (props, ref) => {
9 9
 
10 10
   const [list, setList] = useState([])
11 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])
12
+
13
+
14
+  useImperativeHandle(ref, () => ({
15
+    // changeVal 就是暴露给父组件的方法
16
+    getRefHouseList: () => {
17
+      getHouseList()
18
+    }
19
+  }));
20
+
21
+
22
+
23
+  const radioHouseState = useMemo(() => props.radioHouseState, [props.radioHouseState])
21 24
   wx.setNavigationBarTitle({
22 25
     title: '民宿房源管理'
23 26
   })
24
-console.log(props,radioHouseState)
27
+  console.log(props, radioHouseState)
25 28
   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
-    ])
29
+    console.log(props, ref,'props, ref')
30
+    getHouseList()
43 31
   }, [])
32
+  useDidShow(() => {
33
+
34
+    getHouseList()
35
+  })
44 36
 
45
-  const onShare = () => {
46
-    Taro.navigateTo({ url: "/pages/share/index" })
37
+  const getHouseList = () => {
38
+    request({
39
+      url: '/taHouse',
40
+      // method: 'get',
41
+      params: { pageSize: 1, pageSize: 9999 }
42
+    }).then((res) => {
43
+      const { records, ...page } = res.data.data
44
+      setList(records)
45
+    })
46
+  }
47
+
48
+  const onShare = (x) => {
49
+    Taro.navigateTo({ url: `/pages/share/index?houseId=${x.houseId}` })
47 50
   }
48 51
 
49 52
 
@@ -51,23 +54,29 @@ console.log(props,radioHouseState)
51 54
   return <View className='houselist'>
52 55
     {list.map((x, index) => {
53 56
       return <View className='houselist-view'>
54
-        <Text className='houselist-view-title'>房源编号:{index + 1}</Text>
57
+        {/* <Text className='houselist-view-title'>房源编号:{x.houseId}</Text> */}
55 58
         <ContainerLayout className='houselist-view-card'>
56
-          {radioHouseState&&<View className='houselist-view-card-radio' onClick={()=>{ props.onChange(x),setRadioHouse(x.id)}}>
57
-            {radioHouse==x.id&&<Image src={radio} style={{width:'30rpx',height:'20rpx'}}></Image>}
59
+          {radioHouseState && <View className='houselist-view-card-radio' onClick={() => { props.onChange(x), setRadioHouse(x) }}>
60
+            {radioHouse?.houseId == x?.houseId && <Image src={radio} style={{ width: '30rpx', height: '20rpx' }}></Image>}
58 61
           </View>}
59
-          <View className='top' onClick={() => {if(!radioHouseState) Taro.navigateTo({ url: `/pages/house/index?=${x.id}`  })}}>福娃给v阿萨v不会让发到付</View>
62
+          <View className='top' onClick={() => { if (!radioHouseState) Taro.navigateTo({ url: `/pages/house/index?houseId=${x.houseId}` }) }}>{x.title}</View>
60 63
           <View className='bottom'>
61
-            <Text onClick={() => {if(!radioHouseState) Taro.navigateTo({ url: `/pages/house/household/index?id=${x.id}` })}}>查看入住人</Text>
62
-            <Text onClick={onShare}>分享链接</Text>
64
+            <Text onClick={() => { if (!radioHouseState) Taro.navigateTo({ url: `/pages/house/household/index?houseId=${x.houseId}` }) }}>查看入住人</Text>
65
+            <Text onClick={()=>onShare(x)}>分享链接</Text>
63 66
           </View>
64 67
         </ContainerLayout>
65
-        
68
+
66 69
       </View>
67 70
 
68 71
     })}
69
-   
70
-  </View>
71
-}
72 72
 
73
+
74
+    {
75
+      list.length == 0 &&
76
+      < View className='nodata'> 暂无数据</View>
77
+
78
+    }
79
+  </View >
80
+}
81
+house = forwardRef(house)
73 82
 export default house

+ 37
- 42
src/pages/index/index.jsx Ver fichero

@@ -1,69 +1,64 @@
1 1
 import React, { useEffect, useMemo, useState } from 'react'
2
-import { useSelector } from 'react-redux'
2
+import Taro,{useRouter} from '@tarojs/taro'
3
+import { useSelector, useDispatch } from 'react-redux'
3 4
 import { View, ScrollView } from '@tarojs/components'
4 5
 import Tab from '../../compents/tab/index'
5 6
 import Customer from '../customer/index'
6 7
 import Landlord from '../landlord/index'
7
-import AdminUser from '../adminUser/index'
8
-import Guide from '../guide/index'
9
-import Recommend from '../recommend/index'
10
-import HouseLIst from '../house/list'
11 8
 import roleList from '../../util/userRole'
12 9
 import './index.scss'
13 10
 import request from '../../util/request'
11
+import GetPhone from '@/compents/getPhone'
14 12
 const index = (props) => {
15 13
 
16 14
 
15
+  const router = useRouter()
16
+
17
+  const { houseId ,orderId} = router.params
17 18
   const user = useSelector(state => state.user)
18 19
 
20
+  const dispatch = useDispatch()
21
+
19 22
   const [userRole, setUserRole] = useState('1')
20 23
   const [pageState, SetPageState] = useState('1')
21 24
   const [list, setList] = useState([])
22
-  useEffect(() => {
23
-    setList([
24
-      {
25
-        name: 'zhou',
26
-        phone: '177'
27
-      },
28
-      {
29
-        name: 'zhou',
30
-        phone: '177'
31
-      },
32
-      {
33
-        name: 'zhou',
34
-        phone: '177'
35
-      }
36
-    ])
37
-
38
-    // fetch({ url: API_CARDS_LIST, payload })
39
-
40
-  
25
+  const [visible, setVisible] = useState(false)
41 26
 
27
+  useEffect(() => {
28
+    console.log(user,houseId, 'indexuser')
29
+    if (user.personId && !user.phone) {
30
+      setVisible(true)
31
+    }
32
+    if (user.personId && user.phone) {
33
+      setVisible(false)
34
+    }
35
+  }, [user.phone])
42 36
 
43
-  }, [])
44 37
 
38
+  const onOk = (res) => {
45 39
 
46
-  const onTabClick = (e) => {
47
-    console.log(e, '111')
48
-    setUserRole(e)
40
+    dispatch({ type: 'LOGIN', user: res.data.data })
41
+    setVisible(false)
49 42
   }
50 43
 
51
-  const onRegisterChange = (e) => {
52
-    console.log(e, '111')
44
+  const onCancel = (e) => {
45
+    setVisible(false)
53 46
   }
47
+  console.log(user.role == roleList.landlord, 'indexuser')
48
+
49
+  return <View className='index'>
50
+
51
+    {user.personId && <View>
52
+      {visible && <GetPhone visible={true} onOk={onOk} onCancel={onCancel} ></GetPhone>}
53
+      {!visible && user.role == roleList.customer && <Customer houseId={houseId} orderId={orderId}></Customer>}
54
+      {!visible && user.role == roleList.landlord && <Landlord ></Landlord>}
55
+    </View>}
54 56
 
55 57
 
56 58
 
57
- 
58
-  return <View className='index'>
59
-    {/* <ScrollView scrollY style={{ height: 'calc(100vh - 180rpx)' }} >
60 59
 
61
-   
62
-      <View className='page-container' > */}
63 60
 
64
-      {user.role==roleList.customer&&<Customer></Customer>  }
65
-      {user.role==roleList.landlord&&<Landlord></Landlord>  }
66
-        {/* {userRole == 1 ? <Register userRole={userRole} list={list} onChange={(e) => onRegisterChange(e)}></Register> :
61
+    {/* {userRole == 1 ? <Register userRole={userRole} list={list} onChange={(e) => onRegisterChange(e)}></Register> :
67 62
           <View>userRole={userRole} list={list} onChange={(e) => onRegisterChange(e)}
68 63
             {(userRole == 'guide' || userRole == 2) && <Guide userRole={userRole}/>}
69 64
             {userRole == 'recommend' && <Recommend userRole={userRole}/>}
@@ -76,10 +71,10 @@ const index = (props) => {
76 71
           </View>
77 72
         }
78 73
      <HouseLIst userRole={userRole} list={list} onChange={(e) => onRegisterChange(e)}></HouseLIst>  */}
79
-       
80
-        
81
-      
82
-      {/* </View>
74
+
75
+
76
+
77
+    {/* </View>
83 78
     </ScrollView>
84 79
     <Tab value={userRole} onClick={(e) => onTabClick(e)}></Tab> */}
85 80
   </View>

+ 39
- 46
src/pages/landlord/index.jsx Ver fichero

@@ -1,4 +1,4 @@
1
-import React, { useEffect, useMemo, useState } from 'react'
1
+import React, { useEffect, useRef, useState } from 'react'
2 2
 import Taro, { useDidShow } from "@tarojs/taro";
3 3
 import { useSelector } from 'react-redux'
4 4
 import { View, ScrollView, Button } from '@tarojs/components'
@@ -22,39 +22,12 @@ const index = (props) => {
22 22
   const [list, setList] = useState([])
23 23
   const [radioHouseData, setRadioHouseData] = useState()
24 24
   const [radioHouseState, setRadioHouseState] = useState(false)
25
-  console.log(user,'99999999')
26
-  useEffect(() => {
27
-
28
-   
29
-
30
-    setList([
31
-      {
32
-        name: 'zhou',
33
-        phone: '177'
34
-      },
35
-      {
36
-        name: 'zhou',
37
-        phone: '177'
38
-      },
39
-      {
40
-        name: 'zhou',
41
-        phone: '177'
42
-      }
43
-    ])
44
-
45
-    getHouseList()
46
-  }, [])
47
-
48
-  // useDidShow(()=>{
49
-  //   getHouseList()
50
-  // })
51
-
52
-  const getHouseList=()=>{
53
-    request({
54
-      url:'/taHouse',
55
-      method: 'get',
56
-    })
57
-  }
25
+
26
+
27
+  const childRef = useRef();
28
+
29
+
30
+
58 31
 
59 32
 
60 33
 
@@ -64,17 +37,37 @@ const index = (props) => {
64 37
   const onTabClick = (e) => {
65 38
     console.log(e, '111')
66 39
     setUserRole(e)
67
-    
40
+
68 41
   }
69 42
 
70 43
   const onRegisterChange = (e) => {
71 44
     console.log(e, '111')
72 45
   }
73 46
   const onCopy = (e) => {
74
-    
75
-    console.log(radioHouseData, '111')
76
-    if(radioHouseData.id){
77
-      Taro.navigateTo({ url: '/pages/house/addnewhouse/index?id=radioHouseData.id'})
47
+
48
+    console.log(childRef, '111')
49
+    if (radioHouseData.houseId) {
50
+
51
+      const {houseId,...data} = radioHouseData
52
+
53
+      request({ url: '/taHouse', method: 'post', data: { ...data } }).then((res) => {
54
+        Taro.showModal({
55
+          title: '复制成功',
56
+          content: '点击确认按钮,返回上级菜单',
57
+          showCancel: false,
58
+          success: function (res) {
59
+            if (res.confirm) {
60
+              console.log('用户点击确定')
61
+            
62
+              childRef.current.getRefHouseList();
63
+              setRadioHouseState(false)
64
+            } else if (res.cancel) {
65
+              console.log('用户点击取消')
66
+            }
67
+          }
68
+        })
69
+      })
70
+      // Taro.navigateTo({ url: '/pages/house/addnewhouse/index?id=radioHouseData.id'})
78 71
       // Taro.showModal({
79 72
       //   title: '修改成功',
80 73
       //   content: '点击确认按钮,返回上级菜单',
@@ -89,23 +82,23 @@ const index = (props) => {
89 82
       //     }
90 83
       //   }
91 84
       // })
92
-     
93
-    } 
94
- 
85
+
86
+    }
87
+
95 88
   }
96 89
 
97
-  
90
+
98 91
   return <View className='index'>
99 92
 
100 93
 
101 94
     <View>
102 95
 
103 96
       <Layout>
104
-        {pageState == '1' && <HouseLIst  radioHouseState={radioHouseState} onChange={(e) => setRadioHouseData(e)}></HouseLIst>}
97
+        {pageState == '1' && <HouseLIst ref={childRef} radioHouseState={radioHouseState} onChange={(e) => setRadioHouseData(e)}></HouseLIst>}
105 98
       </Layout>
106 99
       {!isOpened && <Tab className='addhousetab' value={['+添加房源']} onClick={(e) => setIsOpened(true)}></Tab>}
107 100
       {/* {pageState!='1' &&<Tab value={['入住指引','房东推荐']} pageState={pageState} onClick={(e)=>setPageState(e)}></Tab>} */}
108
-      {radioHouseState && <Tab pageState='3' value={['取消', '确认复制']} onClick={[(e) => { setRadioHouseState(false), setIsOpened(false) },()=>onCopy()]}></Tab>}
101
+      {radioHouseState && <Tab pageState='3' value={['取消', '确认复制']} onClick={[(e) => { setRadioHouseState(false), setIsOpened(false) }, () => onCopy()]}></Tab>}
109 102
     </View>
110 103
 
111 104
 
@@ -114,7 +107,7 @@ const index = (props) => {
114 107
       <View className='floatmodel' >
115 108
         <View onClick={() => Taro.navigateTo({ url: '/pages/house/addnewhouse/index' })}>新增房源</View>
116 109
         <View onClick={() => { setIsOpened(false); setRadioHouseState(true) }}>复制房源</View>
117
-        <View style={{ color: '#d2d2d2' }} onClick={()=>setIsOpened(false)}>取消</View>
110
+        <View style={{ color: '#d2d2d2' }} onClick={() => setIsOpened(false)}>取消</View>
118 111
       </View>
119 112
 
120 113
     </AtFloatLayout>

+ 69
- 37
src/pages/map/index.jsx Ver fichero

@@ -1,5 +1,5 @@
1 1
 import React, { useEffect, useMemo, useState } from 'react'
2
-import Taro from "@tarojs/taro";
2
+import Taro, { useDidShow, useRouter } from "@tarojs/taro";
3 3
 import { useSelector } from 'react-redux'
4 4
 import { View, Input, Text, Image } from '@tarojs/components'
5 5
 import Layout from '../../layout/index'
@@ -7,53 +7,83 @@ import Tab from '../../compents/tab/index'
7 7
 import Container from '../../compents/container/index'
8 8
 import locationicon from '../../assets/locationicon.png'
9 9
 import './index.scss'
10
+import request from '../../util/request';
10 11
 
11 12
 const index = (props) => {
12 13
 
13
-    const page = useSelector(state => state.page)
14
+    const router = useRouter()
14 15
 
15
-    const user = useSelector(state => state.user)
16
+    const { houseId, type } = router.params
16 17
 
17 18
     const [userRole, setUserRole] = useState('1')
18 19
     const [pageState, setPageState] = useState('1')
19
-    const [list, setList] = useState([])
20
+    const [address, setAddress] = useState({})
21
+    // const [lngLat, setLngLat] = useState('')
22
+
23
+    useDidShow(() => {
24
+
25
+    })
26
+
20 27
     useEffect(() => {
28
+        
29
+        if (houseId) {
30
+            getDetail()
31
+        }
21 32
 
22
-        console.log(page, 'page')
23
-        setList([
24
-            {
25
-                name: 'zhou',
26
-                phone: '177'
27
-            },
28
-            {
29
-                name: 'zhou',
30
-                phone: '177'
31
-            },
32
-            {
33
-                name: 'zhou',
34
-                phone: '177'
35
-            }
36
-        ])
37 33
     }, [])
34
+    const getDetail = () => {
35
+        request({ url: `/taHouse/${houseId}` }).then((res) => {
36
+            console.log(res.data.data,type, 'getDetail')
37
+            if (type == "address") {
38
+                setAddress(res.data.data.address)
39
+                setLngLat(res.data.data.lngLat)
40
+            }else if (type == 'park'){
41
+                setAddress(res.data.data.parking)
42
+                setLngLat(res.data.data.parkLngLat)
43
+            }
44
+
45
+        })
46
+    }
38 47
 
39 48
 
40
-    const onTabClick = (e) => {
49
+    const onClick = (e) => {
41 50
         console.log(e, '111')
42
-        setUserRole(e)
51
+        let data = {}
52
+        if (type == 'address') {
53
+            data = {
54
+                address: address.address,
55
+                lngLat:`${address.latitude},${address.longitude}`
56
+            }
57
+        } else if (type == 'park') {
58
+            data = {
59
+                parking: address.address,
60
+                parkLngLat:`${address.latitude},${address.longitude}`
61
+            }
62
+        }
63
+        console.log(data, '111')
64
+
65
+        request({ url: `/taHouse/${houseId}`, method: 'put', data: { ...data, houseId } }).then((res) => {
66
+            Taro.navigateBack({
67
+                delta: 1
68
+            })
69
+        })
43 70
     }
44 71
 
45
-    const onRegisterChange = (e) => {
72
+    const onChange = (e) => {
46 73
         console.log(e, '111')
74
+        // setLngLat(e.detail.value)
47 75
     }
48 76
     const onChooseLocation = () => {
49
-        console.log(333)
77
+        // console.log(333)
50 78
         wx.chooseLocation({
51
-            success:(res)=>{
79
+            success: (res) => {
52 80
                 console.log(res)
81
+
82
+                setAddress(res)
53 83
             }
54 84
         })
55 85
     }
56
-    
86
+
57 87
 
58 88
     return <View className='map'>
59 89
 
@@ -61,33 +91,35 @@ const index = (props) => {
61 91
 
62 92
 
63 93
         <Layout>
64
-            <View className='map-view'>
65
-                <Text className='title'>位置信息</Text>
94
+            {/* <View className='map-view'>
95
+                <Text className='title'></Text>
66 96
                 <Container className='map-view-card'>
67 97
                 <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
68 98
                 </Container>
69
-            </View>
99
+            </View> */}
70 100
             <View className='map-view' >
71
-                <Text className='title'>当前地址</Text>
101
+                <Text className='title'>位置信息</Text>
72 102
                 <View style={{ display: 'flex' }}>
73
-                <Container className='map-view-card' style={{ width: '100%' }}>
74
-                    <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
103
+                    <Container className='map-view-card' style={{ width: '100%' }}>
104
+                        {address.address&&<Input value={address.address} disabled placeholderClass='placeholderinput' className='input' type='text' placeholder='' />}
75 105
 
76
-                </Container>
77
-                <Container className='map-view-icon' onClick={onChooseLocation}>
78
-                    <Image className='icon' mode='widthFix' style={{ width: '100%' }} style={{width: '40rpx'}} src={locationicon} />
106
+                    </Container>
107
+                    <Container className='map-view-icon' onClick={() => onChooseLocation()}>
108
+                        <Image className='icon' mode='widthFix' style={{ width: '100%' }} style={{ width: '40rpx' }} src={locationicon} />
79 109
 
80
-                </Container>
110
+                    </Container>
81 111
                 </View>
82 112
             </View>
83 113
             <View className='map-view'>
84 114
                 <Text className='title'>具体地址</Text>
85 115
                 <Container className='map-view-card'>
86
-                <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
116
+                    <Input value={address.lngLat} onInput={onChange} placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
87 117
                 </Container>
88 118
             </View>
89 119
         </Layout>
90
-        {pageState == '1' && <Tab className='addhousetab' pageState='3' value={['取消', '保存修改']} onClick={[(e) => setPageState('2'), (e) => setPageState('3')]}></Tab>}
120
+        {pageState == '1' && <Tab className='addhousetab' pageState='3' value={['取消', '保存修改']} onClick={[(e) => Taro.navigateBack({
121
+            delta: 1
122
+        }), () => onClick()]}></Tab>}
91 123
 
92 124
 
93 125
 

+ 59
- 150
src/pages/material/index.jsx Ver fichero

@@ -1,6 +1,6 @@
1
- import React, { useEffect, useMemo, useState } from 'react'
1
+import React, { useEffect, useState } from 'react'
2 2
 // import { useEffect, useLayoutEffect, useReducer, useState, useContext, useRef, useCallback, useMemo } from '@tarojs/taro'
3
-import Taro, { useShareAppMessage } from "@tarojs/taro";
3
+import Taro, { useDidShow,useRouter } from "@tarojs/taro";
4 4
 import { useSelector, } from 'react-redux'
5 5
 import { View, Input, Text, Image } from '@tarojs/components'
6 6
 import Layout from '../../layout/index'
@@ -9,7 +9,8 @@ import Container from '../../compents/container/index'
9 9
 import locationicon from '../../assets/locationicon.png'
10 10
 import Tags from '../../compents/tags/index'
11 11
 import './index.scss'
12
-
12
+import request from '../../util/request'
13
+import groupby from 'lodash.groupby';
13 14
 // Page({
14 15
 //     data: {
15 16
 //         text: 'init data',
@@ -18,174 +19,82 @@ import './index.scss'
18 19
 // })
19 20
 
20 21
 const index = (props) => {
22
+    const router = useRouter()
21 23
 
22
-
23
-
24
-    const page = useSelector(state => state.page)
25
-
24
+    const { houseId } = router.params
26 25
     const user = useSelector(state => state.user)
27 26
 
28 27
     const [userRole, setUserRole] = useState('1')
29
-    const [pageState, setPageState] = useState('1')
28
+    const [pageState, setPageState] = useState('0')
30 29
     const [list, setList] = useState([])
30
+    const [labelList, setLabelList] = useState([])
31
+    const [arrList, setArrList] = useState({})
32
+    
31 33
     useEffect(() => {
32 34
 
33
-        // console.log(page, 'page')
34
-        setList([
35
-            {
36
-                typename: '行政区域',
37
-                list: [
38
-                    {
39
-                        id: 1,
40
-                        name: '建邺区'
41
-                    },
42
-                    {
43
-                        id: 2,
44
-                        name: '建邺区'
45
-                    },
46
-                    {
47
-                        id: 3,
48
-                        name: '建邺区'
49
-                    },
50
-                    {
51
-                        id: 4,
52
-                        name: '建邺区'
53
-                    },
54
-                    {
55
-                        id: 5,
56
-                        name: '建邺区'
57
-                    },
58
-                    {
59
-                        id: 6,
60
-                        name: '建邺区'
61
-                    },{
62
-                        id: 7,
63
-                        name: '建邺区'
64
-                    },
65
-                    {
66
-                        id: 8,
67
-                        name: '建邺区'
68
-                    },
69
-                    
70
-
71
-                ]
72
-            },
73
-            {
74
-                typename: '行政区域',
75
-                list: [
76
-                    {
77
-                        id: 1,
78
-                        name: '建邺区'
79
-                    },
80
-                    {
81
-                        id: 2,
82
-                        name: '建邺区'
83
-                    },
84
-                    {
85
-                        id: 3,
86
-                        name: '建邺区'
87
-                    },
88
-
89
-                ]
90
-            },
91
-            {
92
-                typename: '行政区域',
93
-                list: [
94
-                    {
95
-                        id: 1,
96
-                        name: '建邺区'
97
-                    },
98
-                    {
99
-                        id: 2,
100
-                        name: '建邺区'
101
-                    },
102
-                    {
103
-                        id: 3,
104
-                        name: '建邺区'
105
-                    },
106
-
107
-                ]
108
-            },
109
-        ])
35
+
36
+
110 37
     }, [])
111
-    useShareAppMessage(res => {
112
-        console.log('3333')
113
-        if (res.from === 'button') {
114
-            // 来自页面内转发按钮
115
-            console.log(res.target)
116
-        }
117
-        return {
118
-            title: '自定义转发标题',
119
-            path: '/page/share/index'
120
-        }
38
+
39
+    useDidShow(() => {
40
+        getMateTagGroupList()
121 41
     })
122 42
 
123
-    const onTabClick = (e) => {
124
-        console.log(e, '111')
125
-        setUserRole(e)
126
-    }
127 43
 
128
-    const onRegisterChange = (e) => {
129
-        console.log(e, '111')
44
+    const getMateTagGroupList = () => {
45
+        request({ url: '/taMateTagGroup', params: { pageSize: 1, pageSize: 9999 } }).then((res) => {
46
+            const { records, ...page } = res.data.data
47
+            setList(records)
48
+        })
130 49
     }
131
-    const onSave = () => {
132
-        console.log(333)
133 50
 
134
-        Taro.showModal({
135
-            title: '修改成功',
136
-            content: '点击确认按钮,返回上级菜单',
137
-            showCancel: false,
138
-            success: function (res) {
139
-                if (res.confirm) {
140
-                    console.log('用户点击确定')
51
+    const onSearch = () => {
52
+        console.log(333)
53
+        // getImageList()
141 54
 
142
-                    Taro.navigateBack({
143
-                        delta: 1
144
-                    })
145
-                } else if (res.cancel) {
146
-                    console.log('用户点击取消')
147
-                }
148
-            }
149
-        })
55
+        Taro.navigateTo({url:`/pages/addimg/index?tagIds=${labelList.map(x => x.tagId).join(',')}&houseId=${houseId}`})
150 56
     }
151 57
 
152
-    return <View className='material'>
58
+    const onLabelChange = (e, index) => {
59
+
60
+        
61
+        let newArrArrList={
62
+            ...arrList,
63
+            [index]: e
64
+        }
65
+        setArrList(newArrArrList)
66
+        console.log(newArrArrList, 'arrList')
67
+        let newArr = Object.values(newArrArrList).reduce((pre, cur) => {
68
+
69
+            return pre.concat(cur)
153 70
 
71
+        }, [])
72
+        setLabelList(newArr)
73
+        console.log(newArr, 'newArr')
74
+    }
154 75
 
76
+    return <View className='material'>
77
+        <View style={{ display: pageState == 1 ? 'none' : 'block' }}>
78
+            <Layout>
79
+                {
80
+                    list.map((item, index) => {
81
+                        return <View className='material-card' key={index}>
82
+                            <Text>{item.name}</Text>
83
+                            <Tags list={item.taMateTagList} onChange={(e) => onLabelChange(e, index)} > </Tags>
84
+                        </View>
85
+                    })
86
+                }
87
+            </Layout>
88
+            <Tab pageState='3' value={['取消', '开始查询']} onClick={[(e) => Taro.navigateBack({
89
+                delta: 1
90
+            }), (e) => onSearch()]}></Tab>
91
+        </View>
155 92
 
156 93
 
157
-        <Layout>
158
-            {
159
-                list.map((item) => {
160
-                    return <View className='material-card'>
161
-                        <Text>{item.typename}</Text>
162
-                        <Tags list={item.list}  onChange={(e)=>{console.log(e)}} style={{marginTop:'90rpx'}}> </Tags>
163
-                    </View>
164
-                })
165
-            }
166
-
167
-            {/* <View className='inputstyle-view'>
168
-                <Text className='title'>入住人数</Text>
169
-                <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
170
-                    <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
171
-                </Container>
172
-            </View>
173
-            <View className='inputstyle-view'>
174
-                <Text className='title'>入住日期</Text>
175
-                <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
176
-                    <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
177
-                </Container>
178
-            </View>
179
-
180
-            <View className='inputstyle-view'>
181
-                <Text className='title'>离店日期</Text>
182
-                <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
183
-                    <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
184
-                </Container>
185
-            </View> */}
94
+        {pageState == '1' && <><Layout>
95
+            12222222
186 96
         </Layout>
187
-{/* className='addhousetab' */}
188
-        <Tab  pageState='3' value={['取消', '开始查询']} onClick={[(e) => setPageState('2'), (e) => setPageState('3')]}></Tab>
97
+            <Tab pageState='3' value={['取消', '确认']} onClick={[(e) => setPageState('2'), (e) => setPageState('3')]}></Tab></>}
189 98
     </View>
190 99
 }
191 100
 

+ 47
- 62
src/pages/recommend/index.jsx Ver fichero

@@ -1,6 +1,6 @@
1 1
 import React, { useEffect, useState } from 'react'
2 2
 import Taro from '@tarojs/taro'
3
-import { View, Text, Image } from '@tarojs/components'
3
+import { View, Text, Image, Button } from '@tarojs/components'
4 4
 import ContainerLayout from '../../compents/container/index'
5 5
 import more from '../../assets/more.png'
6 6
 import deleteicon from '../../assets/deleteicon.png'
@@ -8,108 +8,93 @@ import userRloe from '../../util/userRole'
8 8
 import './index.scss'
9 9
 import { useSelector } from 'react-redux'
10 10
 import { AtFab } from 'taro-ui'
11
+import request from '../../util/request'
11 12
 
12 13
 const recommend = (props) => {
13 14
 
14 15
     const user = useSelector(state => state.user)
15 16
 
16
-    const { value, ...prop } = props
17
+    const { value, houseId,...prop } = props
17 18
 
18 19
     const [state, setState] = useState(1)
19 20
     const [list, setList] = useState([])
20 21
     const [id, setId] = useState()
21 22
     useEffect(() => {
22
-        setList([{
23
-            id: 1,
24
-            src: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1657471424,2319316184&fm=26&gp=0.jpg',
25
-            title: '八八餐厅1',
26
-            srcdetail: '',
27
-        }, {
28
-            id: 2,
29
-            src: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1657471424,2319316184&fm=26&gp=0.jpg',
30
-            title: '八八餐厅2',
31
-            srcdetail: '',
32
-        }, {
33
-            id: 3,
34
-            src: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1657471424,2319316184&fm=26&gp=0.jpg',
35
-            title: '八八餐厅3',
36
-            srcdetail: '',
37
-        }, {
38
-            id: 4,
39
-            src: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1657471424,2319316184&fm=26&gp=0.jpg',
40
-            title: '八八餐厅4',
41
-            srcdetail: '',
42
-        }])
23
+        getImageList()
43 24
     }, [])
44 25
 
45
-    
26
+    const getImageList=()=>{
27
+        request({url:'/taHouseSurround',params:{houseId:houseId}}).then((res)=>{
28
+            const {records,...page} =res.data.data  
29
+            setList(records)
30
+        })
31
+    }
32
+
33
+
46 34
     // 
47 35
 
48 36
     const onClick = (item) => {
49
-        if(user.role == userRloe.customer){
50
-            setId(item.id)
37
+        if (user.role == userRloe.customer) {
38
+            setId(item.surroundId)
51 39
         }
52
-        else{
40
+        else {
41
+
42
+           
53 43
             Taro.showModal({
54 44
                 title: '确定删除该图片吗?',
55 45
                 content: '确定后,相关房东推荐会即时更新',
56
-                cancelColor:'#d2d2d2',
57
-                confirmColor:"#274191",
46
+                cancelColor: '#d2d2d2',
47
+                confirmColor: "#274191",
58 48
                 success: function (res) {
59 49
                     if (res.confirm) {
60 50
                         console.log('用户点击确定')
61
-        
62
-                     
51
+                        request({url: `/taHouseSurround/${item.surroundId}`, method: 'DELETE'}).then((res)=>{
52
+                            getImageList()
53
+                        })
54
+                       
55
+
63 56
                     } else if (res.cancel) {
64 57
                         console.log('用户点击取消')
65 58
                     }
66 59
                 }
67 60
             })
68 61
         }
69
-        
62
+
70 63
     }
64
+   
65
+
71 66
     return <View className='recommend'>
67
+      {user.role == userRloe.landlord && <Button onClick={()=>Taro.navigateTo({url:`/pages/material/index?houseId=${houseId}`})}>添加图片</Button>}
72 68
         {
73 69
             true && list.map((x) => {
74 70
                 return <View className='recommend-view'>
75 71
                     <ContainerLayout className='recommend-view-layout' >
76
-                        {id != x.id ? <View><Image className='recommend-view-img' src={x.src} style={{ height: '280rpx' }}></Image>
77
-                            <View style={{ display: 'flex', justifyContent: 'space-between' }}>
78
-                                <View className='recommend-view-info'>
79
-                                    <Text className='recommend-view-info-title'>{x.title}</Text>
80
-                                    <Text className='introduction'>水煮鱼</Text>
81
-                                </View>
82
-                               { userRloe.customer==user.role ?  <Image className='icon' src={more  } onClick={() => onClick(x)}></Image>
83
-
84
-                              :  <Image className='icon' src={ deleteicon } style ={{width:'40rpx'}} onClick={() => onClick(x)}></Image>
85
-                              }
86
-                            </View>
72
+                        {id != x.surroundId ? <View className='recommend-view-card'>
73
+
74
+                            <Image className='recommend-view-img' src={x.image} ></Image>
75
+
76
+
77
+                            {userRloe.customer == user.role ? <Image className='icon' src={more} onClick={() => onClick(x)}></Image>
78
+
79
+                                : <Image className='icon' src={deleteicon} style={{ width: '40rpx' }} onClick={() => onClick(x)}></Image>
80
+                            }
81
+
82
+
83
+
87 84
                         </View> :
88
-                            <View><Image className='recommend-view-img' mode='widthFix' src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3184265929,203096592&fm=26&gp=0.jpg"></Image>
89
-                                <View style={{ display: 'flex', justifyContent: 'space-between' }}>
90
-                                    <View className='recommend-view-info'>
91
-                                        <Text className='text'>地址:{x.title}</Text>
92
-                                        <Text className='text'>推荐:水煮鱼</Text>
93
-                                    </View>
94
-                                </View>
85
+                            <View style={{ height: "700rpx" }}>
86
+                                <Image className='recommend-view-img'
87
+                                    src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3184265929,203096592&fm=26&gp=0.jpg"></Image>
88
+
95 89
                             </View>
96 90
                         }
97 91
                     </ContainerLayout>
92
+
98 93
                 </View>
99 94
             })
100 95
         }
101
-<AtFab>
102
-  <Text className='at-fab__icon at-icon at-icon-menu'></Text>
103
-</AtFab>
104
-        {
105
-            false && <View className='recommend-noorder' style={{ marginTop: 'calc(40vh)' }}>
106
-                <Text>哎呀</Text>
107
-                <Text>暂时没发现您的入住订单呢~</Text>
108
-
109
-
110
-            </View>
111
-        }
112
-
96
+        
97
+        {list.length==0&& < View className='nodata'> 暂无数据</View>}
113 98
 
114 99
     </View>
115 100
 };

+ 12
- 20
src/pages/recommend/index.scss Ver fichero

@@ -2,32 +2,21 @@
2 2
   padding: 13.3px 0;
3 3
   &-view {
4 4
     margin: 40px 0 0;
5
-
6
-    &-img{
5
+    position: relative;
6
+    &-card{
7 7
       width: 100%;
8 8
       height: 420px;
9
-      border-radius: 40px 40px 0 0;
10 9
     }
10
+    &-img{
11
+      width: 100%;
12
+      height:  100%;
13
+      border-radius: 40px;
14
+      
11 15
 
12
-    &-info{
13
-      padding: 10px 40px 22px;
14
-      display: grid;
15
-      &-title{
16
-        font-size: 28px;
17
-        color: #181818;
18
-        
19
-      }
20
-      .introduction{
21
-        font-size: 24px;
22
-        color: #7b7b7b;
23
-        font-weight: 500;
24
-      }
25
-      .text{
26
-        font-size: 24px;
27
-        font-weight: 550;
28
-      }
16
+    
29 17
     }
30 18
 
19
+
31 20
     &-layout {
32 21
       padding: 0;
33 22
 
@@ -41,6 +30,9 @@
41 30
       width: 10px;
42 31
       height: 40px;
43 32
       padding:20px 30px;
33
+      position: absolute;
34
+      right: 30px;
35
+      bottom: 30px;
44 36
   }
45 37
 
46 38
   &-noorder{

+ 53
- 39
src/pages/share/index.jsx Ver fichero

@@ -1,13 +1,14 @@
1 1
 import React, { useEffect, useMemo, useState } from 'react'
2 2
 // import { useEffect, useLayoutEffect, useReducer, useState, useContext, useRef, useCallback, useMemo } from '@tarojs/taro'
3
-import Taro, { useShareAppMessage } from "@tarojs/taro";
3
+import Taro, { useShareAppMessage, useRouter } from "@tarojs/taro";
4 4
 import { useSelector, } from 'react-redux'
5
-import { View, Input, Text, Image } from '@tarojs/components'
5
+import { View, Input, Text, Image ,Picker } from '@tarojs/components'
6 6
 import Layout from '../../layout/index'
7 7
 import Tab from '../../compents/tab/index'
8 8
 import Container from '../../compents/container/index'
9 9
 import locationicon from '../../assets/locationicon.png'
10 10
 import './index.scss'
11
+import request from '../../util/request';
11 12
 
12 13
 // Page({
13 14
 //     data: {
@@ -18,15 +19,20 @@ import './index.scss'
18 19
 
19 20
 const index = (props) => {
20 21
 
21
-  
22 22
 
23
-    const page = useSelector(state => state.page)
23
+
24
+    const router = useRouter()
25
+
26
+    const { houseId } = router.params
24 27
 
25 28
     const user = useSelector(state => state.user)
26 29
 
27 30
     const [userRole, setUserRole] = useState('1')
28 31
     const [pageState, setPageState] = useState('1')
29 32
     const [list, setList] = useState([])
33
+    const [number,setNumber] = useState()
34
+    const [startTime,setStartTime]=useState('')
35
+    const [endTime,setEndTime]=useState('')
30 36
     useEffect(() => {
31 37
 
32 38
         // console.log(page, 'page')
@@ -49,75 +55,83 @@ const index = (props) => {
49 55
         console.log('3333')
50 56
         if (res.from === 'button') {
51 57
             // 来自页面内转发按钮
52
-              console.log(res.target)
58
+            console.log(res.target)
53 59
         }
60
+        const response =  syncAddOrder()
61
+        // /api/ma/taHouseSetting method:'post'
54 62
         return {
55
-            title: '自定义转发标题',
56
-            path: '/page/share/index'
63
+            title: '分享到微信',
64
+            path: `/pages/index/index?houseId=${houseId}&number=${number}&startTime=${startTime}&endTime=${endTime}`
57 65
         }
58 66
     })
59 67
 
60
-    const onTabClick = (e) => {
61
-        console.log(e, '111')
62
-        setUserRole(e)
63
-    }
68
+    async function syncAddOrder() {
69
+        const data={
70
+            houseId,
71
+            number,
72
+            startTime,
73
+            endTime
74
+        }
75
+      return  request({url:'/taHouseSetting',method:'post',data})
76
+      }   
64 77
 
65
-    const onRegisterChange = (e) => {
78
+    const onTimeChange = (e) => {
66 79
         console.log(e, '111')
67
-    }
68
-    const onSave = () => {
69
-        console.log(333)
70
-
71
-        Taro.showModal({
72
-            title: '修改成功',
73
-            content: '点击确认按钮,返回上级菜单',
74
-            showCancel: false,
75
-            success: function (res) {
76
-                if (res.confirm) {
77
-                    console.log('用户点击确定')
78
-
79
-                    Taro.navigateBack({
80
-                        delta: 1
81
-                    })
82
-                } else if (res.cancel) {
83
-                    console.log('用户点击取消')
84
-                }
85
-            }
86
-        })
80
+        setStartTime(e.detail.value)
87 81
     }
88 82
 
89
-    return <View className='share'>
90 83
 
84
+    return <View className='share'>
91 85
 
92 86
 
87
+        {/* <View className='page-section'>
88
+            <Text>时间选择器</Text>
89
+            <View>
90
+              <Picker mode='time' onChange={this.onTimeChange}>
91
+                <View className='picker'>
92
+                  当前选择:{this.state.timeSel}
93
+                </View>
94
+              </Picker>
95
+            </View>
96
+          </View> */}
93 97
 
94 98
         <Layout>
95 99
             <View className='inputstyle-view'>
96 100
                 <Text className='title'>入住人数</Text>
97 101
                 <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
98
-                    <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
102
+                    <Input type='number' onInput={()=>setLngLat(e.detail.value)} placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
99 103
                 </Container>
100 104
             </View>
101 105
             <View className='inputstyle-view'>
102 106
                 <Text className='title'>入住日期</Text>
103 107
                 <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
104
-                    <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
108
+
109
+                    <Picker mode='date' onChange={onTimeChange}>
110
+                        <View className='input' style={{height: '44rpx',lineHeight: '44rpx',fontsize: '28rpx'}}>
111
+                            {startTime}
112
+                        </View>
113
+                    </Picker>
114
+                    {/* <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='' /> */}
105 115
                 </Container>
106 116
             </View>
107 117
 
108 118
             <View className='inputstyle-view'>
109 119
                 <Text className='title'>离店日期</Text>
110 120
                 <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
111
-                    <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
121
+                <Picker mode='date' onChange={(e)=>{setEndTime(e.detail.value)}}>
122
+                        <View className='input' style={{height: '44rpx',lineHeight: '44rpx',fontsize: '28rpx'}}>
123
+                            {endTime}
124
+                        </View>
125
+                    </Picker>
112 126
                 </Container>
113 127
             </View>
114 128
         </Layout>
115
-        <button open-type="share" style={{display:'contents'}}><Tab className='addhousetab' color='#ffffff' pageState='3' onClick={(e) => console.log(33)} value={['分享到微信']} ></Tab> </button>
129
+        <Tab openType="share" className='addhousetab' color='#ffffff' pageState='3' onClick={(e) => console.log(33)} value={['分享到微信']} ></Tab> 
116 130
 
117 131
 
118
-{/* onClick={[(e) => setPageState('2'),style={{ display: 'contents' }} (e) => setPageState('1')]} */}
132
+        {/* onClick={[(e) => setPageState('2'),style={{ display: 'contents' }} (e) => setPageState('1')]} */}
119 133
 
120
-{/* <Tab className='addhousetab' color='#ffffff' pageState='3' value={['分享到微信']} ></Tab> */}
134
+        {/* <Tab className='addhousetab' color='#ffffff' pageState='3' value={['分享到微信']} ></Tab> */}
121 135
 
122 136
     </View>
123 137
 }

+ 54
- 39
src/pages/wifi/index.jsx Ver fichero

@@ -1,15 +1,18 @@
1 1
 import React, { useEffect, useMemo, useState } from 'react'
2
-import Taro from "@tarojs/taro";
2
+import Taro,{useRouter } from "@tarojs/taro";
3 3
 import { useSelector } from 'react-redux'
4 4
 import { View, Input, Text, Image } from '@tarojs/components'
5 5
 import Layout from '../../layout/index'
6 6
 import Tab from '../../compents/tab/index'
7 7
 import Container from '../../compents/container/index'
8 8
 import locationicon from '../../assets/locationicon.png'
9
+import request from '../../util/request'
9 10
 import './index.scss'
10 11
 
11 12
 const index = (props) => {
13
+    const router = useRouter()
12 14
 
15
+    const { houseId } = router.params
13 16
     const page = useSelector(state => state.page)
14 17
 
15 18
     const user = useSelector(state => state.user)
@@ -17,24 +20,23 @@ const index = (props) => {
17 20
     const [userRole, setUserRole] = useState('1')
18 21
     const [pageState, setPageState] = useState('1')
19 22
     const [list, setList] = useState([])
20
-    useEffect(() => {
21
-
22
-        console.log(page, 'page')
23
-        setList([
24
-            {
25
-                name: 'zhou',
26
-                phone: '177'
27
-            },
28
-            {
29
-                name: 'zhou',
30
-                phone: '177'
31
-            },
32
-            {
33
-                name: 'zhou',
34
-                phone: '177'
35
-            }
36
-        ])
23
+    const [wifiName,setWifiName] = useState('')
24
+    const [wifiPassword,setWifiPassword] = useState('')
25
+
26
+   useEffect(() => {
27
+        
28
+        if (houseId) {
29
+            getDetail()
30
+        }
31
+
37 32
     }, [])
33
+    const getDetail = () => {
34
+        request({ url: `/taHouse/${houseId}` }).then((res) => {
35
+            console.log(res.data.data, 'getDetail')
36
+            setWifiName(res.data.data.wifiName)
37
+            setWifiPassword(res.data.data.wifiPassword)
38
+        })
39
+    }
38 40
 
39 41
 
40 42
     const onTabClick = (e) => {
@@ -47,25 +49,35 @@ const index = (props) => {
47 49
     }
48 50
     const onSave = () => {
49 51
         console.log(333)
52
+        const data= {
53
+            wifiName,
54
+            wifiPassword
55
+        }
56
+
57
+        request({ url: `/taHouse/${houseId}`, method: 'put', data: { ...data, houseId } }).then((res) => {
58
+            Taro.navigateBack({
59
+                delta: 1
60
+            })
61
+        })
50 62
         
51
-        Taro.showModal({
52
-            title: '修改成功',
53
-            content: '点击确认按钮,返回上级菜单',
54
-            showCancel:false,
55
-            success: function (res) {
56
-              if (res.confirm) {
57
-                console.log('用户点击确定')
58
-
59
-                Taro.navigateBack({
60
-                    delta: 1
61
-                  })
62
-              } else if (res.cancel) {
63
-                console.log('用户点击取消')
64
-              }
65
-            }
66
-          })
63
+        // Taro.showModal({
64
+        //     title: '修改成功',
65
+        //     content: '点击确认按钮,返回上级菜单',
66
+        //     showCancel:false,
67
+        //     success: function (res) {
68
+        //       if (res.confirm) {
69
+        //         console.log('用户点击确定')
70
+
71
+        //         Taro.navigateBack({
72
+        //             delta: 1
73
+        //           })
74
+        //       } else if (res.cancel) {
75
+        //         console.log('用户点击取消')
76
+        //       }
77
+        //     }
78
+        //   })
67 79
     }
68
-    onSave
80
+
69 81
 
70 82
     return <View className='map'>
71 83
 
@@ -76,18 +88,21 @@ const index = (props) => {
76 88
             <View className='map-view'>
77 89
                 <Text className='title'>WiFi名称</Text>
78 90
                 <Container className='map-view-card'>
79
-                <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
91
+                <Input value={wifiName} onInput={(e)=>setWifiName(e.detail.value)}  placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
80 92
                 </Container>
81 93
             </View>
82
-          
94
+         
95
+
83 96
             <View className='map-view'>
84 97
                 <Text className='title'>密码</Text>
85 98
                 <Container className='map-view-card'>
86
-                <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
99
+                <Input value={wifiPassword} onInput={(e)=>setWifiPassword(e.detail.value)} placeholderClass='placeholderinput' className='input' type='text' placeholder='小区/写字楼/大厦等' />
87 100
                 </Container>
88 101
             </View>
89 102
         </Layout>
90
-         <Tab className='addhousetab' pageState='3' value={['取消', '保存修改']} onClick={[(e) => setPageState('2'), () => onSave()]}></Tab>
103
+         <Tab className='addhousetab' pageState='3' value={['取消', '保存修改']} onClick={[(e) =>Taro.navigateBack({
104
+                delta: 1
105
+            }), () => onSave()]}></Tab>
91 106
 
92 107
 
93 108
 

+ 26
- 5
src/reducers/user.js Ver fichero

@@ -7,7 +7,10 @@ import {
7 7
 //     customer:'customer'
8 8
 // adminuser
9 9
 const INITIAL_STATE = {
10
+
11
+  phone:false
10 12
   // role: 'adminuser',
13
+  // role: 'landlord',
11 14
   // role:''
12 15
   // role: 'customer'
13 16
 }
@@ -34,12 +37,30 @@ export default function user(state = INITIAL_STATE, action) {
34 37
   console.log(state, 'state33')
35 38
   switch (action.type) {
36 39
     case 'LOGIN': {
37
-      console.log(state,action, 'state')
38
-      return {
39
-        ...state,
40
-        ...action.user,
41
-        role: 'landlord',
40
+
41
+      if (action.user.shopKeeperList.length > 0) {
42
+        return {
43
+          ...state,
44
+          ...action.user,
45
+          // role: 'landlord',
46
+          role: 'customer',
47
+        }
48
+      } else {
49
+        return {
50
+          ...state,
51
+          ...action.user,
52
+          role: 'customer',
53
+      
54
+          
55
+          
56
+        }
42 57
       }
58
+
59
+
60
+
61
+    }
62
+    case 'phone': {
63
+      return state
43 64
     }
44 65
 
45 66
     default:

+ 55
- 1
src/util/request.js Ver fichero

@@ -1,4 +1,6 @@
1 1
 import Taro from '@tarojs/taro'
2
+import { useSelector } from 'react-redux'
3
+import user from '../reducers/user'
2 4
 
3 5
 const baseURL = HOST
4 6
 
@@ -30,10 +32,12 @@ export function optionBuilder(options) {
30 32
   //   const showMessage = Object.prototype.hasOwnProperty.call(payload, 'showToast') ? payload.showToast : showToast
31 33
   //   const consultant = Taro.getStorageSync('consultantId') || ''
32 34
   //   const recommender = Taro.getStorageSync('recommender') || ''
35
+  // const token = useSelector(state => state.user)
33 36
   let api = `/api/ma${url}`
34 37
   if (method == 'GET' && JSON.stringify(params) != "{}") {
35 38
     api = `${api}?${paramsToString(params)}`
36 39
   }
40
+  // user.user?.token||
37 41
   const token = Taro.getStorageSync('token')||''
38 42
   console.log(token,'token')
39 43
   return [{
@@ -42,7 +46,7 @@ export function optionBuilder(options) {
42 46
       data,
43 47
       header: {
44 48
         'content-type': 'application/json',
45
-        'authorization': `X-Authorization-JWT ${token}`,
49
+      'X-Authorization-JWT': `${token}`,
46 50
         // 'appId': appId,
47 51
         // 'x-action': 'miniapp',
48 52
         // 'x-version': Version,
@@ -57,3 +61,53 @@ export function optionBuilder(options) {
57 61
     // }
58 62
   ]
59 63
 }
64
+
65
+
66
+export const uploadFiles = async (files,url) => {
67
+  const uploads = []
68
+  const token = Taro.getStorageSync('token')||''
69
+  for (var i = 0; i < files.length; i++) {
70
+    uploads[i] = new Promise((resolve, reject) => {
71
+      Taro.uploadFile({
72
+        url:  url||`${baseURL}/api/ma/image`,
73
+        filePath: files[i],
74
+        header: {
75
+          'authorization': `X-Authorization-JWT ${token}`,
76
+
77
+          // 'x-action': 'miniapp'
78
+        },
79
+        name: 'file',
80
+        success: function (res) {
81
+          // debugger
82
+          const _data = JSON.parse(res.data)
83
+          // if (_data.code !== CODE_SUCCESS) {
84
+          //   reject(new Error(_data.message))
85
+          // }
86
+
87
+          resolve(_data.data)
88
+        },
89
+        fail(err) {
90
+          reject(err)
91
+        }
92
+      })
93
+    })
94
+  }
95
+
96
+  return Promise.all(uploads)
97
+}
98
+
99
+
100
+function paramsToString(params) {
101
+  return Object.keys(params).map((key) => {
102
+    const val = params[key]
103
+    return Array.isArray(val) ? val.map((x) => {
104
+      return composeKeyValue(key, x)
105
+    }).join('&') : composeKeyValue(key, val)
106
+
107
+  }).join('&')
108
+}
109
+
110
+function composeKeyValue(k, v, encode) {
111
+
112
+  return encode === false ? `${k}=${v}` : `${encodeURIComponent(k)}=${encodeURIComponent(v)}`
113
+}