|
@@ -1,78 +1,117 @@
|
1
|
|
-import React, { useEffect, useState } from 'react'
|
2
|
|
-import Taro from '@tarojs/taro'
|
3
|
|
-import { View, Text, Image, Button } from '@tarojs/components'
|
4
|
|
-import ContainerLayout from '../../compents/container/index'
|
5
|
|
-import more from '../../assets/more.png'
|
6
|
|
-import deleteicon from '../../assets/deleteicon.png'
|
7
|
|
-import userRloe from '../../util/userRole'
|
8
|
|
-import './index.scss'
|
9
|
|
-import { useSelector } from 'react-redux'
|
10
|
|
-import { AtFab } from 'taro-ui'
|
11
|
|
-import request from '../../util/request'
|
12
|
|
-
|
13
|
|
-const recommend = (props) => {
|
14
|
|
-
|
15
|
|
- const user = useSelector(state => state.user)
|
16
|
|
-
|
17
|
|
- const { value, houseId,...prop } = props
|
18
|
|
-
|
19
|
|
- // const [state, setState] = useState(1)
|
20
|
|
- const [list, setList] = useState([])
|
21
|
|
- const [id, setId] = useState()
|
22
|
|
-
|
23
|
|
- // let list = props.dataSource || []
|
24
|
|
-
|
25
|
|
- useEffect(() => {
|
26
|
|
- setList(props.dataSource || [])
|
27
|
|
- }, [props.dataSource])
|
28
|
|
-
|
29
|
|
- // const getImageList=()=>{
|
30
|
|
- // request({url:'/taHouseSurround',params:{houseId:houseId}}).then((res)=>{
|
31
|
|
- // const {records,...page} =res.data.data
|
32
|
|
- // setList(records)
|
33
|
|
- // })
|
34
|
|
- // }
|
35
|
|
-
|
36
|
|
-
|
37
|
|
- //
|
|
1
|
+import React, { useEffect, useState } from "react";
|
|
2
|
+import Taro from "@tarojs/taro";
|
|
3
|
+import { View, Text, Image, Button } from "@tarojs/components";
|
|
4
|
+import ContainerLayout from "../../compents/container/index";
|
|
5
|
+import more from "../../assets/more.png";
|
|
6
|
+import deleteicon from "../../assets/deleteicon.png";
|
|
7
|
+import userRloe from "../../util/userRole";
|
|
8
|
+import "./index.scss";
|
|
9
|
+import { useSelector } from "react-redux";
|
|
10
|
+import { AtFab } from "taro-ui";
|
|
11
|
+import request from "../../util/request";
|
|
12
|
+
|
|
13
|
+const ImageCard = props => {
|
|
14
|
+ const { image,onDelete } = props;
|
|
15
|
+ const user = useSelector(state => state.user);
|
|
16
|
+ const [isopen, setIsOpen] = useState(false);
|
|
17
|
+
|
|
18
|
+ return (
|
|
19
|
+ <View
|
|
20
|
+ className="recommend-view-card"
|
|
21
|
+ style={
|
|
22
|
+
|
|
23
|
+ { height: !isopen?'330rpx':undefined, overflow: "hidden"}
|
|
24
|
+
|
|
25
|
+ }
|
|
26
|
+ >
|
|
27
|
+ <Image className="recommend-view-img" mode="widthFix" src={image} onClick={() => setIsOpen(!isopen)}></Image>
|
|
28
|
+
|
|
29
|
+ {userRloe.customer == user.role ? undefined : (
|
|
30
|
+ <Image
|
|
31
|
+ className="icon"
|
|
32
|
+ src={deleteicon}
|
|
33
|
+ mode="widthFix"
|
|
34
|
+ style={{ width: "40rpx" }}
|
|
35
|
+ onClick={() => onDelete()}
|
|
36
|
+ ></Image>
|
|
37
|
+ )}
|
|
38
|
+ </View>
|
|
39
|
+ )
|
|
40
|
+// : (
|
|
41
|
+// <View>
|
|
42
|
+// <Image className="recommend-view-img" mode="widthFix" src={image} onClick={() => setIsOpen(!isopen)}></Image>
|
|
43
|
+// </View>
|
|
44
|
+// );
|
|
45
|
+};
|
38
|
46
|
|
39
|
|
- const onClick = (item) => {
|
40
|
|
- if (user.role == userRloe.customer) {
|
41
|
|
- setId(item.surroundId)
|
42
|
|
- }
|
43
|
|
- else {
|
44
|
|
-
|
45
|
|
-
|
46
|
|
- Taro.showModal({
|
47
|
|
- title: '确定删除该图片吗?',
|
48
|
|
- content: '确定后,相关房东推荐会即时更新',
|
49
|
|
- cancelColor: '#d2d2d2',
|
50
|
|
- confirmColor: "#274191",
|
51
|
|
- success: function (res) {
|
52
|
|
- if (res.confirm) {
|
53
|
|
- console.log('用户点击确定')
|
54
|
|
- request({url: `/taHouseSurround/${item.surroundId}`, method: 'DELETE'}).then((res)=>{
|
55
|
|
- setList(list.filter((x)=>x.surroundId!=item.surroundId))
|
56
|
|
- })
|
57
|
|
-
|
58
|
|
-
|
59
|
|
- } else if (res.cancel) {
|
60
|
|
- console.log('用户点击取消')
|
61
|
|
- }
|
62
|
|
- }
|
63
|
|
- })
|
|
47
|
+const recommend = props => {
|
|
48
|
+ const user = useSelector(state => state.user);
|
|
49
|
+
|
|
50
|
+ const { value, houseId, ...prop } = props;
|
|
51
|
+
|
|
52
|
+ // const [state, setState] = useState(1)
|
|
53
|
+ const [list, setList] = useState([]);
|
|
54
|
+ const [id, setId] = useState();
|
|
55
|
+
|
|
56
|
+ // let list = props.dataSource || []
|
|
57
|
+
|
|
58
|
+ useEffect(() => {
|
|
59
|
+ setList(props.dataSource || []);
|
|
60
|
+ }, [props.dataSource]);
|
|
61
|
+
|
|
62
|
+ // const getImageList=()=>{
|
|
63
|
+ // request({url:'/taHouseSurround',params:{houseId:houseId}}).then((res)=>{
|
|
64
|
+ // const {records,...page} =res.data.data
|
|
65
|
+ // setList(records)
|
|
66
|
+ // })
|
|
67
|
+ // }
|
|
68
|
+
|
|
69
|
+ //
|
|
70
|
+
|
|
71
|
+ const onClick = item => {
|
|
72
|
+ if (user.role == userRloe.customer) {
|
|
73
|
+ setId(item.surroundId);
|
|
74
|
+ } else {
|
|
75
|
+ Taro.showModal({
|
|
76
|
+ title: "确定删除该图片吗?",
|
|
77
|
+ content: "确定后,相关房东推荐会即时更新",
|
|
78
|
+ cancelColor: "#d2d2d2",
|
|
79
|
+ confirmColor: "#274191",
|
|
80
|
+ success: function(res) {
|
|
81
|
+ if (res.confirm) {
|
|
82
|
+ console.log("用户点击确定");
|
|
83
|
+ request({
|
|
84
|
+ url: `/taHouseSurround/${item.surroundId}`,
|
|
85
|
+ method: "DELETE"
|
|
86
|
+ }).then(res => {
|
|
87
|
+ setList(list.filter(x => x.surroundId != item.surroundId));
|
|
88
|
+ });
|
|
89
|
+ } else if (res.cancel) {
|
|
90
|
+ console.log("用户点击取消");
|
|
91
|
+ }
|
64
|
92
|
}
|
65
|
|
-
|
|
93
|
+ });
|
66
|
94
|
}
|
67
|
|
-
|
68
|
|
-
|
69
|
|
- return <View className='recommend'>
|
70
|
|
- {user.role == userRloe.landlord && <Button onClick={()=>Taro.navigateTo({url:`/pages/material/index?houseId=${houseId}`})}>添加图片</Button>}
|
71
|
|
- {
|
72
|
|
- true && list.map((x) => {
|
73
|
|
- return <View className='recommend-view'>
|
74
|
|
- <ContainerLayout className='recommend-view-layout' >
|
75
|
|
- {id != x.surroundId ? <View className='recommend-view-card' style={userRloe.customer == user.role ? { height: "300rpx",overflow:'hidden' }:''}>
|
|
95
|
+ };
|
|
96
|
+
|
|
97
|
+ return (
|
|
98
|
+ <View className="recommend">
|
|
99
|
+ {user.role == userRloe.landlord && (
|
|
100
|
+ <Button
|
|
101
|
+ onClick={() =>
|
|
102
|
+ Taro.navigateTo({ url: `/pages/material/index?houseId=${houseId}` })
|
|
103
|
+ }
|
|
104
|
+ >
|
|
105
|
+ 添加图片
|
|
106
|
+ </Button>
|
|
107
|
+ )}
|
|
108
|
+ {true &&
|
|
109
|
+ list.map(x => {
|
|
110
|
+ return (
|
|
111
|
+ <View className="recommend-view">
|
|
112
|
+ <ContainerLayout className="recommend-view-layout">
|
|
113
|
+ <ImageCard image={x.image} onDelete={()=>onClick(x)}/>
|
|
114
|
+ {/* {id != x.surroundId ? <View className='recommend-view-card' style={userRloe.customer == user.role ? { height: "300rpx",overflow:'hidden' }:''}>
|
76
|
115
|
|
77
|
116
|
<Image className='recommend-view-img' mode='widthFix' src={x.image} ></Image>
|
78
|
117
|
|
|
@@ -87,16 +126,15 @@ const recommend = (props) => {
|
87
|
126
|
<Image className='recommend-view-img' mode='widthFix' src={x.image}></Image>
|
88
|
127
|
|
89
|
128
|
</View>
|
90
|
|
- }
|
91
|
|
- </ContainerLayout>
|
92
|
|
-
|
93
|
|
- </View>
|
94
|
|
- })
|
95
|
|
- }
|
96
|
|
-
|
97
|
|
- {list.length==0&& < View className='nodata'> 暂无数据</View>}
|
|
129
|
+ } */}
|
|
130
|
+ </ContainerLayout>
|
|
131
|
+ </View>
|
|
132
|
+ );
|
|
133
|
+ })}
|
98
|
134
|
|
|
135
|
+ {list.length == 0 && <View className="nodata"> 暂无数据</View>}
|
99
|
136
|
</View>
|
|
137
|
+ );
|
100
|
138
|
};
|
101
|
139
|
|
102
|
|
-export default recommend
|
|
140
|
+export default recommend;
|