Procházet zdrojové kódy

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

张延森 před 4 roky
rodič
revize
ddb2489be2

+ 2
- 2
config/dev.js Zobrazit soubor

@@ -4,10 +4,10 @@ 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"',
10
+    HOST: '"http://192.168.211.181:7080"',
11 11
  
12 12
     // OSS_PATH: "https://njcj.oss-cn-shanghai.aliyuncs.com/",
13 13
     // OSS_FAST_PATH: "https://njcj.oss-accelerate.aliyuncs.com/",

+ 11
- 7
src/pages/customer/index.js Zobrazit soubor

@@ -27,11 +27,13 @@ const index = (props) => {
27 27
   }
28 28
 
29 29
   useEffect(() => {
30
+    
30 31
     if(props.orderId){
31
-      request({url: `/taHouseOrder/{props.orderId}`,}).then(res=>{
32
+      request({url: `/taHouseOrder/${props.orderId}`,}).then(res=>{
32 33
         const data = res.data.data
34
+        console.log(data,'props.orderId')
33 35
         setOrderInfo(data)
34
-        regUnFinished(data.status !== 1)
36
+        setRegUnFinished(data.status !== 1)
35 37
       })
36 38
     }
37 39
   }, [props.orderId])
@@ -43,9 +45,11 @@ const index = (props) => {
43 45
   }, [props.orderId, regUnFinished])
44 46
   
45 47
   useEffect(() => {
48
+    console.log(props.houseId && (!props.orderId || !regUnFinished),'data')
46 49
     if(props.houseId && (!props.orderId || !regUnFinished)){
47 50
       request({url: `/taHouse/${props.houseId}`,}).then(res=>{
48 51
         const data = res.data.data
52
+        console.log(data,'data')
49 53
         setHouseInfo(data)
50 54
         setPageState('2')
51 55
       })
@@ -59,15 +63,15 @@ const index = (props) => {
59 63
   }, [props.houseId, props.orderId, regUnFinished])
60 64
  
61 65
   return (
62
-    <View className='index'>
66
+    <View className='index' >
63 67
       {pageState=='1'&&<Register oderId={orderId} dataSource={orderInfo} onFinished={handleRegisterFinished}></Register>}
64 68
 
65
-      <Layout>
69
+      {pageState!='1'&&<Layout>
66 70
         {pageState=='2'&&<Guide houseId={houseId} dataSource={houseInfo}></Guide>  }
67 71
         {pageState=='3'&&<Recommend houseId={houseId} dataSource={surroundList}></Recommend>  }
68
-      </Layout>
69
-    
70
-      {!!houseId && (
72
+      </Layout>}
73
+    {/* !!houseId&& */}
74
+      {pageState!='1' && (
71 75
         <Tab
72 76
           value={['入住指引','房东推荐']}
73 77
           pageState={pageState}

+ 3
- 5
src/pages/customer/register/index.jsx Zobrazit soubor

@@ -2,7 +2,7 @@ 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 6
 import Tab from '../../../compents/tab'
7 7
 import Layout from '../../../layout'
8 8
 import request from '@/util/request'
@@ -55,7 +55,7 @@ const InputGroup = props => {
55 55
 
56 56
   return (
57 57
     <View className='register-user'>
58
-      <Text>入住人{props.index}</Text>
58
+      <Text>入住人{props.index+1}</Text>
59 59
       <ContainerLayout className='register-user-from'>
60 60
         {console.log(name,phone,'name,phone')}
61 61
         <Input name="name" className='register-user-from-input' value={name} onInput={handeNameChange} placeholder='姓名' type='text' />
@@ -67,8 +67,6 @@ const InputGroup = props => {
67 67
 
68 68
 const register = (props) => {
69 69
 
70
-  const { orderId } = props
71
-
72 70
   let [list, setList] = useState([])
73 71
   useEffect(() => {
74 72
     if (props.dataSource) {
@@ -116,7 +114,7 @@ const register = (props) => {
116 114
     setList([...list])
117 115
   }
118 116
 
119
-  return <View className='register'>
117
+  return <View className='register' >
120 118
     <Layout>
121 119
       {list.map((x, index) => {
122 120
         let inx = index

+ 67
- 42
src/pages/house/household/index.jsx Zobrazit soubor

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

+ 1
- 1
src/pages/house/household/index.scss Zobrazit soubor

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

+ 26
- 19
src/pages/house/index.jsx Zobrazit soubor

@@ -20,24 +20,31 @@ const house = (props) => {
20 20
     const [userRole, setUserRole] = useState('1')
21 21
     const [pageState, setPageState] = useState('2')
22 22
     const [list, setList] = useState([])
23
-    useEffect(() => {
24
-
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
-    }, [])
23
+    const [dataSource, setDataSource] = useState([])
24
+    const [imgSource, setImgSource] = useState([])
25
+    useDidShow(() => {
26
+        if (houseId) {
27
+            getDetail()
28
+            getImageList()
29
+        }
30
+    })
31
+
32
+    const getImageList=()=>{
33
+        request({url:'/taHouseSurround',params:{houseId:houseId}}).then((res)=>{
34
+            const {records,...page} =res.data.data  
35
+            setImgSource(records)
36
+        })
37
+    }
38
+
39
+    const getDetail = () => {
40
+        request({ url: `/taHouse/${houseId}` }).then((res) => {
41
+            setDataSource(res.data.data)
40 42
 
43
+            wx.setNavigationBarTitle({
44
+                title: res.data.data.title
45
+            })
46
+        })
47
+    }
41 48
     
42 49
 
43 50
     const onTabClick = (e) => {
@@ -56,8 +63,8 @@ const house = (props) => {
56 63
         <View >
57 64
 
58 65
             <Layout>
59
-                {pageState == '2' && <Guide houseId={houseId}></Guide>}
60
-                {pageState == '3' && <Recommend houseId={houseId}></Recommend>}
66
+                {pageState == '2' && <Guide houseId={houseId} dataSource={dataSource}></Guide>}
67
+                {pageState == '3' && <Recommend houseId={houseId} dataSource={imgSource}></Recommend>}
61 68
             </Layout>
62 69
             {pageState != '1' && <Tab value={['入住指引', '房东推荐']} pageState={pageState} onClick={[(e) => setPageState('2'), (e) => setPageState('3')]}></Tab>}
63 70
 

+ 52
- 40
src/pages/share/index.jsx Zobrazit soubor

@@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react'
2 2
 // import { useEffect, useLayoutEffect, useReducer, useState, useContext, useRef, useCallback, useMemo } from '@tarojs/taro'
3 3
 import Taro, { useShareAppMessage, useRouter } from "@tarojs/taro";
4 4
 import { useSelector, } from 'react-redux'
5
-import { View, Input, Text, Image ,Picker } 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'
@@ -30,9 +30,9 @@ const index = (props) => {
30 30
     const [userRole, setUserRole] = useState('1')
31 31
     const [pageState, setPageState] = useState('1')
32 32
     const [list, setList] = useState([])
33
-    const [number,setNumber] = useState()
34
-    const [startTime,setStartTime]=useState('')
35
-    const [endTime,setEndTime]=useState('')
33
+    const [personNum, setPersonNum] = useState()
34
+    const [startTime, setStartTime] = useState('')
35
+    const [endTime, setEndTime] = useState('')
36 36
     useEffect(() => {
37 37
 
38 38
         // console.log(page, 'page')
@@ -52,28 +52,57 @@ const index = (props) => {
52 52
         ])
53 53
     }, [])
54 54
     useShareAppMessage(res => {
55
-        console.log('3333')
55
+        Taro.showLoading({
56
+            title: '分享中',
57
+          })
56 58
         if (res.from === 'button') {
57 59
             // 来自页面内转发按钮
58 60
             console.log(res.target)
59 61
         }
60
-        const response =  syncAddOrder()
61
-        // /api/ma/taHouseSetting method:'post'
62
-        return {
63
-            title: '分享到微信',
64
-            path: `/pages/index/index?houseId=${houseId}&number=${number}&startTime=${startTime}&endTime=${endTime}`
62
+
63
+        const data = {
64
+            houseId,
65
+            personNum,
66
+            startDate: startTime,
67
+            endDate: endTime
65 68
         }
69
+        return request({ url: '/taHouseSetting', method: 'post', data }).then(res => {
70
+            const { data } = res.data
71
+            if (res.data.data) {
72
+                console.log(data.taHouseOrder.orderId)
73
+                const { orderId } = data.taHouseOrder
74
+                return request({ url: `/taHouse/${houseId}/share` }).then(res => {
75
+                    Taro.hideLoading()
76
+                    return {
77
+                        title: '分享到微信',
78
+                        path: `/pages/index/index?houseId=${houseId}&personNum=${personNum}&startTime=${startTime}&endTime=${endTime}&orderId=${orderId}`
79
+                    }
80
+                })
81
+            } else {
82
+                Taro.showModal({
83
+                    title: '输入信息有误',
84
+                    content: '请重新输入',
85
+                    showCancel: false,
86
+                    success: function (res) {
87
+                        if (res.confirm) {
88
+                            console.log('用户点击确定')
89
+                        } else if (res.cancel) {
90
+                            console.log('用户点击取消')
91
+                        }
92
+                    }
93
+                })
94
+            }
95
+
96
+        })
97
+
98
+
99
+
66 100
     })
67 101
 
68 102
     async function syncAddOrder() {
69
-        const data={
70
-            houseId,
71
-            number,
72
-            startTime,
73
-            endTime
74
-        }
75
-      return  request({url:'/taHouseSetting',method:'post',data})
76
-      }   
103
+
104
+
105
+    }
77 106
 
78 107
     const onTimeChange = (e) => {
79 108
         console.log(e, '111')
@@ -82,24 +111,11 @@ const index = (props) => {
82 111
 
83 112
 
84 113
     return <View className='share'>
85
-
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> */}
97
-
98 114
         <Layout>
99 115
             <View className='inputstyle-view'>
100 116
                 <Text className='title'>入住人数</Text>
101 117
                 <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
102
-                    <Input type='number' onInput={()=>setLngLat(e.detail.value)} placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
118
+                    <Input type='number' value={personNum} onInput={(e) => setPersonNum(e.detail.value)} placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
103 119
                 </Container>
104 120
             </View>
105 121
             <View className='inputstyle-view'>
@@ -107,7 +123,7 @@ const index = (props) => {
107 123
                 <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
108 124
 
109 125
                     <Picker mode='date' onChange={onTimeChange}>
110
-                        <View className='input' style={{height: '44rpx',lineHeight: '44rpx',fontsize: '28rpx'}}>
126
+                        <View className='input' style={{ height: '44rpx', lineHeight: '44rpx', fontsize: '28rpx' }}>
111 127
                             {startTime}
112 128
                         </View>
113 129
                     </Picker>
@@ -118,20 +134,16 @@ const index = (props) => {
118 134
             <View className='inputstyle-view'>
119 135
                 <Text className='title'>离店日期</Text>
120 136
                 <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
121
-                <Picker mode='date' onChange={(e)=>{setEndTime(e.detail.value)}}>
122
-                        <View className='input' style={{height: '44rpx',lineHeight: '44rpx',fontsize: '28rpx'}}>
137
+                    <Picker mode='date' onChange={(e) => { setEndTime(e.detail.value) }}>
138
+                        <View className='input' style={{ height: '44rpx', lineHeight: '44rpx', fontsize: '28rpx' }}>
123 139
                             {endTime}
124 140
                         </View>
125 141
                     </Picker>
126 142
                 </Container>
127 143
             </View>
128 144
         </Layout>
129
-        <Tab openType="share" className='addhousetab' color='#ffffff' pageState='3' onClick={(e) => console.log(33)} value={['分享到微信']} ></Tab> 
130
-
131
-
132
-        {/* onClick={[(e) => setPageState('2'),style={{ display: 'contents' }} (e) => setPageState('1')]} */}
145
+        <Tab openType="share" className='addhousetab' color='#ffffff' pageState='3' onClick={(e) => console.log(33)} value={['分享到微信']} ></Tab>
133 146
 
134
-        {/* <Tab className='addhousetab' color='#ffffff' pageState='3' value={['分享到微信']} ></Tab> */}
135 147
 
136 148
     </View>
137 149
 }