|
@@ -0,0 +1,161 @@
|
|
1
|
+
|
|
2
|
+import Taro from '@tarojs/taro'
|
|
3
|
+import { View, Button, RadioGroup, Label, Radio, ScrollView } from '@tarojs/components'
|
|
4
|
+import { API_GET_AGENT_BUILDINGS, API_ITEMS_LIST } from '@/constants/api'
|
|
5
|
+import { ROLE_CODE } from '@/constants/user'
|
|
6
|
+import { useSelector } from 'react-redux'
|
|
7
|
+import { fetch } from '@/utils/request'
|
|
8
|
+
|
|
9
|
+import { useState, useEffect, useRef } from 'react'
|
|
10
|
+import './style.css'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+export default (props) => {
|
|
14
|
+ const { closeModal, setBuidName, onChange = () => { }, type = '', frameTitle, flag, } = props
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+ let wrapAnimate = 'wrap wrapAnimate'
|
|
18
|
+ let frameAnimate = 'frame-wrapper'
|
|
19
|
+ const [textNextSum, setTextNext] = useState(1)
|
|
20
|
+ const [recommendContent, setRecommendContent] = useState([])
|
|
21
|
+ const city = useSelector(state => state.city)
|
|
22
|
+
|
|
23
|
+ const [loading, setLoading] = useState(false)
|
|
24
|
+ const [dicts, setDicts] = useState([])
|
|
25
|
+
|
|
26
|
+ const hideFrame = (e) => {
|
|
27
|
+ console.log('关闭', e);
|
|
28
|
+ closeModal()//关闭
|
|
29
|
+
|
|
30
|
+ }
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+ useEffect(() => {
|
|
34
|
+ if (type !== ROLE_CODE.CUSTOMER && type !== ROLE_CODE.DRIFT && type !== ROLE_CODE.CONSULTANT) {
|
|
35
|
+ fetch({ url: API_GET_AGENT_BUILDINGS }).then((res) => {
|
|
36
|
+ setDicts(res || [])
|
|
37
|
+ })
|
|
38
|
+ } else {
|
|
39
|
+ fetch({ url: API_ITEMS_LIST, payload: { pageNumber: 1, pageSize: 1000, cityId: city.curCity.id } }).then((res) => {
|
|
40
|
+
|
|
41
|
+ setDicts(res.records)
|
|
42
|
+ })
|
|
43
|
+ }
|
|
44
|
+ }, [])
|
|
45
|
+
|
|
46
|
+ const [darkMode, setDarkMode] = useState('light')
|
|
47
|
+
|
|
48
|
+ useEffect(() => {
|
|
49
|
+ Taro.getSystemInfo({
|
|
50
|
+ success: function (res) {
|
|
51
|
+ console.log(res.theme)
|
|
52
|
+ setDarkMode(res.theme)
|
|
53
|
+
|
|
54
|
+ }
|
|
55
|
+ })
|
|
56
|
+
|
|
57
|
+ }, [darkMode])
|
|
58
|
+
|
|
59
|
+ const [conTent, setConTent] = useState()
|
|
60
|
+
|
|
61
|
+ const buildingConten = (e) => {
|
|
62
|
+ console.log(e, 'eeeeeeeeeeeeeeee');
|
|
63
|
+ setConTent(e.detail.value)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ const buliClick = (e) => {
|
|
71
|
+ e.stopPropagation()
|
|
72
|
+
|
|
73
|
+ if (conTent === '' || conTent === null || conTent === undefined) {
|
|
74
|
+ Taro.showToast({
|
|
75
|
+ title: '未正确选择楼盘',
|
|
76
|
+ icon: 'error',
|
|
77
|
+ duration: 2000
|
|
78
|
+ })
|
|
79
|
+
|
|
80
|
+ } else {
|
|
81
|
+ onChange(conTent)
|
|
82
|
+ return dicts.map((item, inx) => {
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+ if (item.buildingId === conTent) {
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+ const findIndex = inx
|
|
89
|
+ const name = dicts[findIndex].buildingName
|
|
90
|
+ // item.buildingName
|
|
91
|
+ setBuidName(name)
|
|
92
|
+ console.log(name);
|
|
93
|
+
|
|
94
|
+ closeModal()
|
|
95
|
+
|
|
96
|
+ console.log('选中', conTent);
|
|
97
|
+ // const newArr = dicts.filter(function (obj) {
|
|
98
|
+ // return obj.buildingId == e.detail.value;
|
|
99
|
+ // });
|
|
100
|
+ // console.log(newArr);
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+ }
|
|
105
|
+ return item
|
|
106
|
+
|
|
107
|
+ })
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+ return (
|
|
116
|
+ flag && <view >
|
|
117
|
+ <view className={wrapAnimate} style='background:rgba(0,0,0,0);'></view>
|
|
118
|
+ <view onClick={hideFrame} className={frameAnimate} catchMove>
|
|
119
|
+ <view className={darkMode == 'dark' ? 'frame-dark' : 'frame'}>
|
|
120
|
+ {/* 标题 */}
|
|
121
|
+ <view className={darkMode == 'dark' ? 'title-wrapper-dark' : 'title-wrapper'}>
|
|
122
|
+ <view>{frameTitle}</view>
|
|
123
|
+ </view>
|
|
124
|
+ {/* 内容 */}
|
|
125
|
+ <view style='overflow-x: hidden;'>
|
|
126
|
+ <View className='page-section'>
|
|
127
|
+ <View className='radio-list' >
|
|
128
|
+ <scroll-view
|
|
129
|
+ scrollY
|
|
130
|
+ style={{ height: '30vh', overflow: 'hidden' }}
|
|
131
|
+ catchMove
|
|
132
|
+ >
|
|
133
|
+ <RadioGroup className='radio-list__RadioGroup' onChange={buildingConten} onClick={e => e.stopPropagation()}>
|
|
134
|
+ {dicts.map((item, i) => {
|
|
135
|
+ return (
|
|
136
|
+ <Label catchMove className='radio-list__label' for={i} key={i}>
|
|
137
|
+ <view className={darkMode == 'dark' ? 'radio-list__text-dark' : 'radio-list__text'}>{item.buildingName}</view>
|
|
138
|
+
|
|
139
|
+ <Radio catchMove className='radio-list__radio' value={item.buildingId} checked={item.buildingId === conTent ? true : false}></Radio>
|
|
140
|
+
|
|
141
|
+ </Label>
|
|
142
|
+ )
|
|
143
|
+ })}
|
|
144
|
+ </RadioGroup>
|
|
145
|
+ </scroll-view>
|
|
146
|
+ </View>
|
|
147
|
+ </View>
|
|
148
|
+
|
|
149
|
+ {/* <view className='bottom-text' onClick={handleTextNext}> */}
|
|
150
|
+ <view style={{ display: 'flex', margin: '2em auto' }}>
|
|
151
|
+ <Button className='checkBtn' onClick={() => closeModal()} >取消</Button>
|
|
152
|
+ <Button className='okBtn' onClick={buliClick}> 确定</Button>
|
|
153
|
+ </view>
|
|
154
|
+
|
|
155
|
+ </view>
|
|
156
|
+ </view>
|
|
157
|
+ </view>
|
|
158
|
+ </view>
|
|
159
|
+
|
|
160
|
+ )
|
|
161
|
+}
|