|
@@ -1,170 +1,236 @@
|
1
|
|
-import React, { useEffect, useState } from 'react'
|
2
|
|
-import Taro, { useDidShow } from '@tarojs/taro'
|
3
|
|
-import { View, Text, Image } from '@tarojs/components'
|
4
|
|
-import ContainerLayout from '../../compents/container/index'
|
5
|
|
-import icon from '../../assets/icon.png'
|
6
|
|
-import './index.scss'
|
7
|
|
-import userRloe from '../../util/userRole'
|
8
|
|
-import { useSelector } from 'react-redux'
|
9
|
|
-import request,{uploadFiles } from '@/util/request'
|
10
|
|
-import uploadicon from '../../assets/uploadicon.png'
|
11
|
|
-const guide = (props) => {
|
12
|
|
-
|
13
|
|
- const user = useSelector(state => state.user)
|
14
|
|
- // const guide = useSelector(state => state.guide)
|
15
|
|
-
|
16
|
|
-
|
17
|
|
-
|
18
|
|
-
|
19
|
|
- const { value, houseId, ...prop } = props
|
20
|
|
- const [state, setState] = useState(1)
|
21
|
|
-
|
22
|
|
- const [imgurl, setImgurl] = useState('')
|
23
|
|
- // const [detail, setDetail] = useState({})
|
24
|
|
- const detail = props.dataSource || {}
|
25
|
|
-
|
26
|
|
- // useDidShow(() => {
|
27
|
|
- // if (houseId) {
|
28
|
|
- // getDetail()
|
29
|
|
- // }
|
30
|
|
- // })
|
31
|
|
-
|
32
|
|
- // useEffect(() => {
|
33
|
|
- // console.log(houseId, 'params33')
|
34
|
|
- // if (houseId) {
|
35
|
|
- // getDetail()
|
36
|
|
- // }
|
37
|
|
-
|
38
|
|
- // }, [])
|
39
|
|
- // const getDetail = () => {
|
40
|
|
- // request({ url: `/taHouse/${houseId}` }).then((res) => {
|
41
|
|
- // setDetail(res.data.data)
|
42
|
|
-
|
43
|
|
- // wx.setNavigationBarTitle({
|
44
|
|
- // title: res.data.data.title
|
45
|
|
- // })
|
46
|
|
- // })
|
47
|
|
- // }
|
48
|
|
-
|
49
|
|
- const onOpenLocation = (lngLat) => {
|
50
|
|
- const [latitude, longitude] = lngLat.split(',')
|
51
|
|
- console.log(lngLat, latitude, longitude)
|
52
|
|
- wx.openLocation({
|
53
|
|
- latitude: Number(latitude),
|
54
|
|
- longitude: Number(longitude),
|
55
|
|
- scale: 18,
|
56
|
|
- fail: (err) => {
|
57
|
|
- console.log(err)
|
58
|
|
- }
|
59
|
|
- })
|
|
1
|
+import React, { useEffect, useState } from "react";
|
|
2
|
+import Taro, { useDidShow } from "@tarojs/taro";
|
|
3
|
+import { View, Text, Image } from "@tarojs/components";
|
|
4
|
+import ContainerLayout from "../../compents/container/index";
|
|
5
|
+import icon from "../../assets/icon.png";
|
|
6
|
+import "./index.scss";
|
|
7
|
+import userRloe from "../../util/userRole";
|
|
8
|
+import { useSelector } from "react-redux";
|
|
9
|
+import request, { uploadFiles } from "@/util/request";
|
|
10
|
+import uploadicon from "../../assets/uploadicon.png";
|
|
11
|
+const guide = props => {
|
|
12
|
+ const user = useSelector(state => state.user);
|
|
13
|
+ // const guide = useSelector(state => state.guide)
|
|
14
|
+
|
|
15
|
+ const { value, houseId, ...prop } = props;
|
|
16
|
+ const [state, setState] = useState(1);
|
|
17
|
+
|
|
18
|
+ const [imgurl, setImgurl] = useState("");
|
|
19
|
+ // const [detail, setDetail] = useState({})
|
|
20
|
+ const detail = props.dataSource || {};
|
|
21
|
+
|
|
22
|
+ // useDidShow(() => {
|
|
23
|
+ // if (houseId) {
|
|
24
|
+ // getDetail()
|
|
25
|
+ // }
|
|
26
|
+ // })
|
|
27
|
+
|
|
28
|
+ // useEffect(() => {
|
|
29
|
+ // console.log(houseId, 'params33')
|
|
30
|
+ // if (houseId) {
|
|
31
|
+ // getDetail()
|
|
32
|
+ // }
|
|
33
|
+
|
|
34
|
+ // }, [])
|
|
35
|
+ // const getDetail = () => {
|
|
36
|
+ // request({ url: `/taHouse/${houseId}` }).then((res) => {
|
|
37
|
+ // setDetail(res.data.data)
|
|
38
|
+
|
|
39
|
+ // wx.setNavigationBarTitle({
|
|
40
|
+ // title: res.data.data.title
|
|
41
|
+ // })
|
|
42
|
+ // })
|
|
43
|
+ // }
|
|
44
|
+
|
|
45
|
+ const onOpenLocation = lngLat => {
|
|
46
|
+ const [latitude, longitude] = lngLat.split(",");
|
|
47
|
+ console.log(lngLat, latitude, longitude);
|
|
48
|
+ wx.openLocation({
|
|
49
|
+ latitude: Number(latitude),
|
|
50
|
+ longitude: Number(longitude),
|
|
51
|
+ scale: 18,
|
|
52
|
+ fail: err => {
|
|
53
|
+ console.log(err);
|
|
54
|
+ }
|
|
55
|
+ });
|
|
56
|
+ };
|
|
57
|
+
|
|
58
|
+ const onToMap = type => {
|
|
59
|
+ if (user.role == userRloe.customer) return;
|
|
60
|
+ switch (type) {
|
|
61
|
+ case "address":
|
|
62
|
+ Taro.navigateTo({
|
|
63
|
+ url: `/pages/map/index?houseId=${houseId}&type=${type}`
|
|
64
|
+ });
|
|
65
|
+ break;
|
|
66
|
+ case "park":
|
|
67
|
+ Taro.navigateTo({
|
|
68
|
+ url: `/pages/map/index?houseId=${houseId}&type=${type}`
|
|
69
|
+ });
|
|
70
|
+ break;
|
|
71
|
+ case "wifi":
|
|
72
|
+ Taro.navigateTo({ url: `/pages/wifi/index?houseId=${houseId}` });
|
|
73
|
+ break;
|
|
74
|
+ case "image": {
|
|
75
|
+ if (user.role == userRloe.customer) return;
|
|
76
|
+ wx.chooseImage({
|
|
77
|
+ count: 1,
|
|
78
|
+ sizeType: ["original", "compressed"],
|
|
79
|
+ sourceType: ["album"],
|
|
80
|
+ success: res => {
|
|
81
|
+ // tempFilePath可以作为img标签的src属性显示图片
|
|
82
|
+ const tempFilePaths = res.tempFilePaths;
|
|
83
|
+
|
|
84
|
+ uploadFiles(tempFilePaths)
|
|
85
|
+ .then(res => {
|
|
86
|
+ console.log(res, "uploadFiles");
|
|
87
|
+ // setImgUrl(res[0])
|
|
88
|
+ setImgurl(res[0]);
|
|
89
|
+ request({
|
|
90
|
+ url: `/taHouse/${houseId}`,
|
|
91
|
+ method: "put",
|
|
92
|
+ data: { ...detail, desc: res[0] }
|
|
93
|
+ }).then(res => {});
|
|
94
|
+ })
|
|
95
|
+ .catch(e => {
|
|
96
|
+ console.log(e, "err");
|
|
97
|
+ });
|
|
98
|
+
|
|
99
|
+ // setImgurl(tempFilePaths[0])
|
|
100
|
+ }
|
|
101
|
+ // success: (res) => {
|
|
102
|
+ // // tempFilePath可以作为img标签的src属性显示图片
|
|
103
|
+
|
|
104
|
+ // console.log(res)
|
|
105
|
+ // const tempFilePaths = res.tempFilePaths
|
|
106
|
+ // setImgurl(tempFilePaths[0])
|
|
107
|
+
|
|
108
|
+ // }
|
|
109
|
+ });
|
|
110
|
+ break;
|
|
111
|
+ }
|
60
|
112
|
}
|
61
|
|
-
|
62
|
|
- const onToMap = (type) => {
|
63
|
|
- if (user.role == userRloe.customer) return
|
64
|
|
- switch (type) {
|
65
|
|
- case 'address': Taro.navigateTo({ url: `/pages/map/index?houseId=${houseId}&type=${type}` }); break;
|
66
|
|
- case 'park': Taro.navigateTo({ url: `/pages/map/index?houseId=${houseId}&type=${type}` }); break;
|
67
|
|
- case 'wifi': Taro.navigateTo({ url: `/pages/wifi/index?houseId=${houseId}` }); break;
|
68
|
|
- case 'image': {
|
69
|
|
- if (user.role == userRloe.customer) return
|
70
|
|
- wx.chooseImage({
|
71
|
|
- count: 1,
|
72
|
|
- sizeType: ['original', 'compressed'],
|
73
|
|
- sourceType: ['album',],
|
74
|
|
- success: (res) => {
|
75
|
|
- // tempFilePath可以作为img标签的src属性显示图片
|
76
|
|
- const tempFilePaths = res.tempFilePaths
|
77
|
|
-
|
78
|
|
- uploadFiles(tempFilePaths).then((res) => {
|
79
|
|
- console.log(res, 'uploadFiles')
|
80
|
|
- // setImgUrl(res[0])
|
81
|
|
- setImgurl(res[0])
|
82
|
|
- request({ url: `/taHouse/${houseId}`, method: 'put', data: { ...detail, desc:res[0] } }).then((res) => {
|
83
|
|
-
|
84
|
|
- })
|
85
|
|
- }).catch((e) => {
|
86
|
|
- console.log(e, 'err')
|
87
|
|
- })
|
88
|
|
-
|
89
|
|
- // setImgurl(tempFilePaths[0])
|
90
|
|
- }
|
91
|
|
- // success: (res) => {
|
92
|
|
- // // tempFilePath可以作为img标签的src属性显示图片
|
93
|
|
-
|
94
|
|
- // console.log(res)
|
95
|
|
- // const tempFilePaths = res.tempFilePaths
|
96
|
|
- // setImgurl(tempFilePaths[0])
|
97
|
|
-
|
98
|
|
-
|
99
|
|
-
|
100
|
|
- // }
|
101
|
|
- }); break;
|
102
|
|
- }
|
103
|
|
- }
|
104
|
|
- // Taro.navigateTo({ url: `/pages/map/index?type=${type}` })
|
105
|
|
- }
|
106
|
|
- const [addressName,addressDetail] = (detail.address||'').split('____')
|
107
|
|
- const [parkingName,parkingDetail] = (detail.parking||'').split('____')
|
108
|
|
- return <View className='guide'>
|
109
|
|
- {!!houseId&&<View>
|
110
|
|
- <View className='guide-view'>
|
111
|
|
- <Text className='guide-view-info'>房屋位置</Text>
|
112
|
|
- <ContainerLayout className='guide-view-layout' style={{ display: 'flex', justifyContent: 'space-between' }} onClick={() => onToMap('address')}>
|
113
|
|
- <View >
|
114
|
|
- <View className='guide-view-layout-text1' >{addressName}</View>
|
115
|
|
- <View className='guide-view-layout-text2'>{addressDetail}</View>
|
116
|
|
- </View>
|
117
|
|
- {user.role == userRloe.customer && <View style={{ float: 'right' }} onClick={() => onOpenLocation(detail.lngLat)}>
|
118
|
|
- <Image className='icon' src={icon} />
|
119
|
|
- <View className='icontext' >去这里</View>
|
120
|
|
- </View>}
|
121
|
|
- </ContainerLayout>
|
122
|
|
- </View>
|
123
|
|
- <View className='guide-view'>
|
124
|
|
- <Text className='guide-view-info'>停车位置</Text>
|
125
|
|
- <ContainerLayout className='guide-view-layout' style={{ display: 'flex', justifyContent: 'space-between' }} onClick={() => onToMap('park')}>
|
126
|
|
- <View >
|
127
|
|
- <View className='guide-view-layout-text1' >{parkingName}</View>
|
128
|
|
- <View className='guide-view-layout-text2'>{parkingDetail}</View>
|
129
|
|
- </View>
|
130
|
|
- {user.role == userRloe.customer && <View style={{ float: 'right' }} onClick={() => onOpenLocation(detail.parkLngLat)}>
|
131
|
|
- <Image className='icon' src={icon} />
|
132
|
|
- <View className='icontext'>去这里</View>
|
133
|
|
- </View>}
|
134
|
|
- </ContainerLayout>
|
135
|
|
- </View>
|
136
|
|
- <View className='guide-view'>
|
137
|
|
- <Text className='guide-view-info'>wifi信息</Text>
|
138
|
|
- <ContainerLayout className='guide-view-layout guide-view-wifi' onClick={() => onToMap('wifi')}>
|
139
|
|
- <View>
|
140
|
|
- <Text>名称:</Text><Text>{detail.wifiName}</Text>
|
141
|
|
- </View>
|
142
|
|
- <View>
|
143
|
|
- <Text>密码:</Text><Text>{detail.wifiPassword}</Text>
|
144
|
|
- </View>
|
145
|
|
- </ContainerLayout>
|
146
|
|
- </View>
|
147
|
|
- <View className='guide-view'>
|
148
|
|
- <Text className='guide-view-info'>其他指引</Text>
|
149
|
|
- {/* <ContainerLayout className='guide-view-layout guide-view-img'> */}
|
150
|
|
- {(detail.desc || imgurl) && <Image className='guide-view-img' mode='widthFix' onClick={() => onToMap('image')} src={imgurl || detail.desc}></Image>}
|
151
|
|
- {!detail.desc && !imgurl && <View style={{ padding: "300rpx" }} >
|
152
|
|
-
|
153
|
|
- <Image className='guide-view-img' mode='widthFix' onClick={() => onToMap('image')} src={uploadicon}></Image>
|
|
113
|
+ // Taro.navigateTo({ url: `/pages/map/index?type=${type}` })
|
|
114
|
+ };
|
|
115
|
+ // const [addressName,addressDetail] = (detail.address||'').split('____')
|
|
116
|
+ // const [parkingName,parkingDetail] = (detail.parking||'').split('____')
|
|
117
|
+ return (
|
|
118
|
+ <View className="guide">
|
|
119
|
+ {!!houseId && (
|
|
120
|
+ <View>
|
|
121
|
+ <View className="guide-view">
|
|
122
|
+ <Text className="guide-view-info">房屋位置</Text>
|
|
123
|
+ <ContainerLayout
|
|
124
|
+ className="guide-view-layout"
|
|
125
|
+ style={{ display: "flex", justifyContent: "space-between" }}
|
|
126
|
+ onClick={() => onToMap("address")}
|
|
127
|
+ >
|
|
128
|
+ <View>
|
|
129
|
+ <View className="guide-view-layout-text1">
|
|
130
|
+ {detail.shortAddress}
|
154
|
131
|
</View>
|
155
|
|
- }
|
156
|
|
- </View>
|
157
|
|
- </View>}
|
158
|
|
- {
|
159
|
|
- !houseId && <View className='recommend-noorder' style={{ marginTop: 'calc(40vh)',textAlign:'center' }}>
|
160
|
|
- <Text>哎呀</Text>
|
161
|
|
- <Text>暂时没发现您的入住订单呢~</Text>
|
162
|
|
-
|
163
|
|
-
|
164
|
|
- </View>
|
165
|
|
- }
|
166
|
|
-
|
|
132
|
+ <View className="guide-view-layout-text2">
|
|
133
|
+ {detail.address}
|
|
134
|
+ </View>
|
|
135
|
+ </View>
|
|
136
|
+ {user.role == userRloe.customer && (
|
|
137
|
+ <View
|
|
138
|
+ style={{
|
|
139
|
+ float: "right",
|
|
140
|
+ display: "flex",
|
|
141
|
+ justifyContent: "center",
|
|
142
|
+ flexDirection: "column"
|
|
143
|
+ }}
|
|
144
|
+ onClick={() => onOpenLocation(detail.lngLat)}
|
|
145
|
+ >
|
|
146
|
+ <Image className="icon" src={icon} />
|
|
147
|
+ <View className="icontext">去这里</View>
|
|
148
|
+ </View>
|
|
149
|
+ )}
|
|
150
|
+ </ContainerLayout>
|
|
151
|
+ </View>
|
|
152
|
+ <View className="guide-view">
|
|
153
|
+ <Text className="guide-view-info">停车位置</Text>
|
|
154
|
+ <ContainerLayout
|
|
155
|
+ className="guide-view-layout"
|
|
156
|
+ style={{ display: "flex", justifyContent: "space-between" }}
|
|
157
|
+ onClick={() => onToMap("park")}
|
|
158
|
+ >
|
|
159
|
+ <View>
|
|
160
|
+ <View className="guide-view-layout-text1">
|
|
161
|
+ {detail.shortParking}
|
|
162
|
+ </View>
|
|
163
|
+ <View className="guide-view-layout-text2">
|
|
164
|
+ {detail.parking}
|
|
165
|
+ </View>
|
|
166
|
+ </View>
|
|
167
|
+ {user.role == userRloe.customer && (
|
|
168
|
+ <View
|
|
169
|
+ style={{
|
|
170
|
+ float: "right",
|
|
171
|
+ display: "flex",
|
|
172
|
+ justifyContent: "center",
|
|
173
|
+ flexDirection: "column"
|
|
174
|
+ }}
|
|
175
|
+ onClick={() => onOpenLocation(detail.parkLngLat)}
|
|
176
|
+ >
|
|
177
|
+ <Image className="icon" src={icon} />
|
|
178
|
+ <View className="icontext">去这里</View>
|
|
179
|
+ </View>
|
|
180
|
+ )}
|
|
181
|
+ </ContainerLayout>
|
|
182
|
+ </View>
|
|
183
|
+ <View className="guide-view">
|
|
184
|
+ <Text className="guide-view-info">wifi信息</Text>
|
|
185
|
+ <ContainerLayout
|
|
186
|
+ className="guide-view-layout guide-view-wifi"
|
|
187
|
+ onClick={() => onToMap("wifi")}
|
|
188
|
+ >
|
|
189
|
+ <View>
|
|
190
|
+ <Text>名称:</Text>
|
|
191
|
+ <Text>{detail.wifiName}</Text>
|
|
192
|
+ </View>
|
|
193
|
+ <View>
|
|
194
|
+ <Text>密码:</Text>
|
|
195
|
+ <Text>{detail.wifiPassword}</Text>
|
|
196
|
+ </View>
|
|
197
|
+ </ContainerLayout>
|
|
198
|
+ </View>
|
|
199
|
+ <View className="guide-view">
|
|
200
|
+ <Text className="guide-view-info">其他指引</Text>
|
|
201
|
+ {/* <ContainerLayout className='guide-view-layout guide-view-img'> */}
|
|
202
|
+ {(detail.desc || imgurl) && (
|
|
203
|
+ <Image
|
|
204
|
+ className="guide-view-img"
|
|
205
|
+ mode="widthFix"
|
|
206
|
+ onClick={() => onToMap("image")}
|
|
207
|
+ src={imgurl || detail.desc}
|
|
208
|
+ ></Image>
|
|
209
|
+ )}
|
|
210
|
+ {!detail.desc && !imgurl && (
|
|
211
|
+ <View style={{ padding: "300rpx" }}>
|
|
212
|
+ <Image
|
|
213
|
+ className="guide-view-img"
|
|
214
|
+ mode="widthFix"
|
|
215
|
+ onClick={() => onToMap("image")}
|
|
216
|
+ src={uploadicon}
|
|
217
|
+ ></Image>
|
|
218
|
+ </View>
|
|
219
|
+ )}
|
|
220
|
+ </View>
|
|
221
|
+ </View>
|
|
222
|
+ )}
|
|
223
|
+ {!houseId && (
|
|
224
|
+ <View
|
|
225
|
+ className="recommend-noorder"
|
|
226
|
+ style={{ marginTop: "calc(40vh)", textAlign: "center" }}
|
|
227
|
+ >
|
|
228
|
+ <Text>哎呀</Text>
|
|
229
|
+ <Text>暂时没发现您的入住订单呢~</Text>
|
|
230
|
+ </View>
|
|
231
|
+ )}
|
167
|
232
|
</View>
|
|
233
|
+ );
|
168
|
234
|
};
|
169
|
235
|
|
170
|
|
-export default guide
|
|
236
|
+export default guide;
|