张延森 4 years ago
parent
commit
b6d0601946

+ 13
- 0
src/compents/Divider/index.jsx View File

@@ -0,0 +1,13 @@
1
+import React from 'react'
2
+import { View } from '@tarojs/components'
3
+import './index.scss'
4
+
5
+export default props => {
6
+  return (
7
+    <View className="x-divider" style={props.style}>
8
+      <View className="x-divider__line">&nbsp;</View>
9
+      <View className="x-divider__text">{props.children}</View>
10
+      <View className="x-divider__line">&nbsp;</View>
11
+    </View>
12
+  )
13
+}

+ 16
- 0
src/compents/Divider/index.scss View File

@@ -0,0 +1,16 @@
1
+
2
+.x-divider {
3
+  display: flex;
4
+  align-items: center;
5
+
6
+  &__line {
7
+    flex: auto;
8
+    height: 1px;
9
+    background-color: #333;
10
+  }
11
+
12
+  &__text {
13
+    flex: none;
14
+    margin: 0 0.6em;
15
+  }
16
+}

+ 14
- 6
src/pages/addimg/index.jsx View File

@@ -37,7 +37,6 @@ const addimg = (props) => {
37 37
     }
38 38
 
39 39
     const choiceImg = (value) => {
40
-        console.log(value, '111')
41 40
         const t = choiceList.find(x => x.imageId == value.imageId)
42 41
         if (t) {
43 42
             setChoicelist(choiceList.filter(x => x.imageId != value.imageId))
@@ -50,9 +49,7 @@ const addimg = (props) => {
50 49
     }
51 50
 
52 51
     const onAddimg = (e) => {
53
-        console.log(e, '111')
54 52
         if (choiceList.length > 0) {
55
-
56 53
             const data = choiceList.map(x => {
57 54
                 return {
58 55
                     houseId,
@@ -90,14 +87,25 @@ const addimg = (props) => {
90 87
         })
91 88
     }
92 89
 
90
+    const handleSelectAll = () => {
91
+        if (choiceList && choiceList.length) {
92
+            setChoicelist([])
93
+        } else {
94
+            setChoicelist(list.slice())
95
+        }
96
+    }
93 97
 
94 98
     return <View className='addimg'>
95
-        <View>
96
-            <button className="weui-btn weui-btn_primary">全选</button>            
99
+        <View style="margin: 16px 0">
100
+            <button className="weui-btn weui-btn_primary" onClick={handleSelectAll}>
101
+            {
102
+                choiceList && choiceList.length ? '取消全选' : '全选'
103
+            }
104
+            </button>
97 105
         </View>
98 106
 
99 107
         <View >
100
-            <Layout>
108
+            <Layout type="custom">
101 109
             <View className='at-row at-row--wrap'>
102 110
                 {list.map((x) => {
103 111
                     return <View className='at-col at-col-3 addimg-view-card' key={x.imageId}>

+ 2
- 5
src/pages/customer/index.js View File

@@ -61,7 +61,7 @@ const index = (props) => {
61 61
     if(props.houseId && (!props.orderId || !regUnFinished)){
62 62
       request({url: `/taHouse/${props.houseId}`,}).then(res=>{
63 63
         const data = res.data.data
64
-        console.log(data,'data')
64
+        // console.log(data,'data')
65 65
         setHouseInfo(data)
66 66
         setPageState('2')
67 67
       })
@@ -74,9 +74,6 @@ const index = (props) => {
74 74
 
75 75
   }, [props.houseId, props.orderId, regUnFinished])
76 76
 
77
-  console.log('---------->', pageState)
78
-  // console.log('--------------->', houseId, orderId)
79
-
80 77
   return (
81 78
     <View className='index' >
82 79
 
@@ -91,7 +88,7 @@ const index = (props) => {
91 88
     {/* !!houseId&& */}
92 89
       {pageState!='1' && (
93 90
         <Tab
94
-        styleType='tab'
91
+          styleType='tab'
95 92
           value={['入住指引','房东推荐']}
96 93
           pageState={pageState}
97 94
           onClick={[(e) => setPageState('2'),(e) => setPageState('3')]} />

+ 12
- 2
src/pages/guide/index.jsx View File

@@ -8,6 +8,8 @@ import userRloe from "../../util/userRole";
8 8
 import { useSelector } from "react-redux";
9 9
 import request, { uploadFiles } from "@/util/request";
10 10
 import uploadicon from "../../assets/uploadicon.png";
11
+// import copy from '../../assets/copy.png'
12
+
11 13
 const guide = props => {
12 14
   const user = useSelector(state => state.user);
13 15
   // const guide = useSelector(state => state.guide)
@@ -32,6 +34,13 @@ const guide = props => {
32 34
     });
33 35
   };
34 36
 
37
+  const handleCopy = v => {
38
+    wx.setClipboardData({
39
+      data: v,
40
+      success(res) {}
41
+    });
42
+  }
43
+
35 44
   const onToMap = type => {
36 45
     if (user.role == userRloe.customer) return;
37 46
     switch (type) {
@@ -190,9 +199,10 @@ const guide = props => {
190 199
                     <Text>名称:</Text>
191 200
                     <Text>{detail.wifiName}</Text>
192 201
                   </View>
193
-                  <View>
202
+                  <View onClick={() => handleCopy(detail.wifiPassword)}>
194 203
                     <Text>密码:</Text>
195
-                    <Text>{detail.wifiPassword}</Text>
204
+                    <Text style="display: inline-block; margin-right: 6px">{detail.wifiPassword}</Text>
205
+                    <mp-icon icon="copy" size={12}></mp-icon>
196 206
                   </View>
197 207
                 </ContainerLayout>
198 208
               </View>

+ 3
- 0
src/pages/house/household/index.config.js View File

@@ -1,3 +1,6 @@
1 1
 export default {
2 2
     navigationBarTitleText: '查看入住人',
3
+    usingComponents: {
4
+      "mp-icon": "weui-miniprogram/icon/icon"
5
+    }
3 6
 }

+ 54
- 21
src/pages/house/household/index.jsx View File

@@ -8,15 +8,17 @@ import Layout from "../../../layout/index";
8 8
 import request from "../../../util/request";
9 9
 import groupby from "lodash.groupby";
10 10
 import copy from '../../../assets/copy.png'
11
+
11 12
 const house = props => {
12 13
   const router = useRouter();
14
+  const [queryParams, setQueryParams] = useState({})
13 15
   const { houseId } = router.params;
14 16
 
15 17
   const [list, setList] = useState({});
16 18
 
17 19
   useEffect(() => {
18 20
     getList();
19
-  }, []);
21
+  }, [queryParams]);
20 22
 
21 23
   const getList = () => {
22 24
     request({
@@ -33,18 +35,46 @@ const house = props => {
33 35
     });
34 36
   };
35 37
 
36
-  const getDate = value => {
37
-    const [date, time] = value.split("T");
38
-    console.log(time, "time");
39
-    return `${date} ${time.split(":")[0]}:${time.split(":")[1]}`;
40
-  };
41
-
42 38
   const onCopy = value => {
43 39
     wx.setClipboardData({
44 40
       data: value,
45 41
       success(res) {}
46 42
     });
47 43
   };
44
+
45
+
46
+  const handleDateChange = (e, item) => {
47
+    const dt = e.detail.value
48
+    if (!dt || dt == item.startDate) {
49
+      return
50
+    }
51
+
52
+    Taro.showModal({
53
+      title: '修改日期',
54
+      content: `确认日期修改为: ${dt}`,
55
+      success: e => {
56
+        if (e.confirm) {
57
+          request({
58
+            url: `/taHouseSetting/${item.settingId}`,
59
+            method: 'PUT',
60
+            data: {
61
+              startDate: dt
62
+            }
63
+          }).then(res => {
64
+            Taro.showToast({
65
+              title: '修改成功',
66
+              icon: 'success',
67
+            })
68
+
69
+            // 触发页面刷新
70
+            setQueryParams({})
71
+          })
72
+        }
73
+      }
74
+    })
75
+
76
+  }
77
+
48 78
   return (
49 79
     <View className="household">
50 80
       <Layout>
@@ -70,7 +100,23 @@ const house = props => {
70 100
                     </View>
71 101
                   );
72 102
                 })}
73
-                <View style="margin-top: 1em">{`入住时间:${getDate(list[item][0].createDate)}`}</View>
103
+                <View style="margin-top: 1em">
104
+                  <picker
105
+                    mode="date"
106
+                    start="2021-03-01"
107
+                    value={list[item][0].startDate}
108
+                    onChange={e => handleDateChange(e, list[item][0])}
109
+                  >
110
+                    <View>
111
+                      <Text>
112
+                      {`入住时间:${list[item][0].startDate}`}
113
+                      </Text>
114
+                      <View style="display: inline-block; margin-left: .5em">
115
+                        <mp-icon icon="pencil" size={16} color="#ffffff"></mp-icon>
116
+                      </View>
117
+                    </View>
118
+                  </picker>
119
+                </View>
74 120
                 {list[item].length == 0 && "暂无入住人信息"}
75 121
               </ContainerLayout>
76 122
             </View>
@@ -81,19 +127,6 @@ const house = props => {
81 127
             暂无入住信息
82 128
           </view>
83 129
         )}
84
-
85
-        {/* {list.map((x, index) => {
86
-      return <View className='household-view'>
87
-
88
-        <Text className='household-view-title'>入住日期:{index + 1}</Text>
89
-        <ContainerLayout className='household-view-card'>
90
-         
91
-         暂无入住人信息    
92
-        </ContainerLayout>
93
-
94
-      </View>
95
-
96
-    })} */}
97 130
       </Layout>
98 131
     </View>
99 132
   );

+ 38
- 55
src/pages/recommend/index.jsx View File

@@ -1,31 +1,25 @@
1 1
 import React, { useEffect, useState } from "react";
2 2
 import Taro from "@tarojs/taro";
3 3
 import { View, Text, Image, Button } from "@tarojs/components";
4
+import groupby from 'lodash.groupby'
4 5
 import ContainerLayout from "../../compents/container/index";
5
-import more from "../../assets/more.png";
6
+import Divider from '../../compents/Divider'
6 7
 import deleteicon from "../../assets/deleteicon.png";
7 8
 import userRloe from "../../util/userRole";
8 9
 import "./index.scss";
9 10
 import { useSelector } from "react-redux";
10
-import { AtFab } from "taro-ui";
11 11
 import request from "../../util/request";
12 12
 
13 13
 const ImageCard = props => {
14 14
   const { image, onDelete } = props;
15 15
   const user = useSelector(state => state.user);
16 16
   const [isopen, setIsOpen] = useState(false);
17
-// boxShadow:'0rpx 12rpx 0rpx 0rpx #8a8b8d'
17
+
18 18
   return (
19 19
     <View
20 20
       className="recommend-view-card"
21 21
       style={{ height: !isopen ? "330rpx" : undefined, overflow: "hidden" ,background:'#fff', boxShadow:'6rpx 12rpx 0rpx #898989' }}
22 22
     >
23
-      {/* <View onClick={() => setIsOpen(!isopen)}  style={{zIndex:99,boxShadow:'6rpx 12rpx 0rpx #898989',position: 'absolute',width:'100%',height:'330rpx',borderRadius: '30rpx',opacity:0}}>
24
-
25
-      </View>
26
-      <View onClick={() => setIsOpen(!isopen)}  style={{zIndex:-9, boxShadow:'0rpx 12rpx 0rpx -4rpx #898989',position: 'absolute',bottom:'0',width:'670rpx',background:'#fff', height:'100%',borderRadius: '30rpx',opacity:0}}>
27
-
28
-      </View> */}
29 23
       <Image
30 24
         className="recommend-view-img"
31 25
         mode="widthFix"
@@ -46,11 +40,6 @@ const ImageCard = props => {
46 40
       )}
47 41
     </View>
48 42
   );
49
-  //   : (
50
-  //     <View>
51
-  //       <Image className="recommend-view-img" mode="widthFix" src={image} onClick={() => setIsOpen(!isopen)}></Image>
52
-  //     </View>
53
-  //   );
54 43
 };
55 44
 
56 45
 const recommend = props => {
@@ -59,24 +48,15 @@ const recommend = props => {
59 48
   const { value, houseId, ...prop } = props;
60 49
 
61 50
   // const [state, setState] = useState(1)
62
-  const [list, setList] = useState([]);
51
+  const [list, setList] = useState({});
63 52
   const [id, setId] = useState();
64 53
 
65
-  // let list = props.dataSource || []
66
-
67 54
   useEffect(() => {
68
-    setList(props.dataSource || []);
55
+    const lst = groupby(props.dataSource || [], 'groupName')
56
+    // setList(props.dataSource || []);
57
+    setList(lst)
69 58
   }, [props.dataSource]);
70 59
 
71
-  // const getImageList=()=>{
72
-  //     request({url:'/taHouseSurround',params:{houseId:houseId}}).then((res)=>{
73
-  //         const {records,...page} =res.data.data
74
-  //         setList(records)
75
-  //     })
76
-  // }
77
-
78
-  //
79
-
80 60
   const onClick = item => {
81 61
     if (user.role == userRloe.customer) {
82 62
       setId(item.surroundId);
@@ -103,8 +83,10 @@ const recommend = props => {
103 83
     }
104 84
   };
105 85
 
86
+  const listGroupKeys = Object.keys(list) || []
87
+
106 88
   return (
107
-    <View className="recommend">
89
+    <View className="recommend page">
108 90
       {user.role == userRloe.landlord && (
109 91
         <Button
110 92
           onClick={() =>
@@ -114,34 +96,35 @@ const recommend = props => {
114 96
           添加图片
115 97
         </Button>
116 98
       )}
117
-      {true &&
118
-        list.map(x => {
119
-          return (
120
-            <View className="recommend-view">
121
-              <ContainerLayout className="recommend-view-layout">
122
-                <ImageCard image={x.image} onDelete={() => onClick(x)} />
123
-                {/* {id != x.surroundId ? <View className='recommend-view-card' style={userRloe.customer == user.role ? { height: "300rpx",overflow:'hidden' }:''}>
124
-
125
-                            <Image className='recommend-view-img' mode='widthFix' src={x.image} ></Image>
126
-
127
-
128
-                            {userRloe.customer == user.role ? <Image className='icon' src={more} onClick={() => onClick(x)}></Image>
129
-
130
-                                : <Image className='icon' src={deleteicon} mode='widthFix' style={{ width: '40rpx' }} onClick={() => onClick(x)}></Image>
131
-                            }
132
-
133
-                        </View> :
134
-                            <View  >
135
-                                <Image className='recommend-view-img' mode='widthFix' src={x.image}></Image>
136
-
137
-                            </View>
138
-                        } */}
139
-              </ContainerLayout>
140
-            </View>
141
-          );
142
-        })}
143 99
 
144
-      {list.length == 0 && <View className="nodata"> 暂无数据</View>}
100
+      { 
101
+        listGroupKeys.length == 0 ?
102
+          (<View className="nodata"> 暂无数据</View>) :
103
+          listGroupKeys.map(k => {
104
+            const lst = list[k] || []
105
+
106
+            return (
107
+              <View className="page__hd">
108
+                <View className="page__title" style="font-size: 1.6em">
109
+                  <Divider>{lst[0].groupName}</Divider>
110
+                </View>
111
+                <View className="page__bd">
112
+                {
113
+                  lst.map(x => {
114
+                    return (
115
+                      <View className="recommend-view">
116
+                        <ContainerLayout className="recommend-view-layout">
117
+                          <ImageCard image={x.image} onDelete={() => onClick(x)} />
118
+                        </ContainerLayout>
119
+                      </View>
120
+                    );
121
+                  })
122
+                }
123
+                </View>
124
+              </View>
125
+            )
126
+          })          
127
+      }
145 128
     </View>
146 129
   );
147 130
 };