|
@@ -2,6 +2,8 @@ import Taro, { Component } from '@tarojs/taro'
|
2
|
2
|
import { View, ScrollView } from '@tarojs/components'
|
3
|
3
|
|
4
|
4
|
import './index.scss'
|
|
5
|
+import Blank from '../../components/Blank'
|
|
6
|
+import HouseGrid from '../../components/HouseGrid'
|
5
|
7
|
|
6
|
8
|
export default class extends Component {
|
7
|
9
|
config = {
|
|
@@ -10,6 +12,7 @@ export default class extends Component {
|
10
|
12
|
|
11
|
13
|
state = {
|
12
|
14
|
dataType: 1, // maybe need change 1 预选, 2 认筹
|
|
15
|
+ houseList: [ { name: '1期1栋1单元1楼101户' } ],
|
13
|
16
|
chooseList: [ { name: '1期1栋1单元1楼101户' }, { name: '1期1栋1单元1楼102户' } ], // 已经选择的房源列表
|
14
|
17
|
collapsed: true, // 已选列表默认关闭, true 关闭, false 开启
|
15
|
18
|
}
|
|
@@ -22,6 +25,12 @@ export default class extends Component {
|
22
|
25
|
this.setState({ dataType })
|
23
|
26
|
}
|
24
|
27
|
|
|
28
|
+ // 添加到选择列表
|
|
29
|
+ // 注意, 不是确认选择
|
|
30
|
+ add2Cart = (room) => {
|
|
31
|
+
|
|
32
|
+ }
|
|
33
|
+
|
25
|
34
|
// 确认选择
|
26
|
35
|
handleSubmit = () => {
|
27
|
36
|
|
|
@@ -47,61 +56,90 @@ export default class extends Component {
|
47
|
56
|
}
|
48
|
57
|
|
49
|
58
|
renderHead() {
|
50
|
|
- const { dataType } = this.state
|
|
59
|
+ const { dataType, houseList } = this.state
|
|
60
|
+ const hasData = houseList && houseList.length
|
51
|
61
|
|
52
|
62
|
return (
|
53
|
63
|
<View className="head">
|
54
|
64
|
<View className="tips">仅显示符合认筹条件的房源。点击房源卡片查看房源详情,不要在房源详情页做操作。请在当前页面选择提交认筹。</View>
|
55
|
|
- <View className="actions">
|
56
|
|
- <View className={`action ${dataType === 1 ? 'active' : ''}`} onClick={() => this.changeShowData(1)}>预选热度图</View>
|
57
|
|
- <View className={`action ${dataType === 2 ? 'active' : ''}`} onClick={() => this.changeShowData(2)}>认筹热度图</View>
|
58
|
|
- </View>
|
|
65
|
+ {
|
|
66
|
+ hasData && (
|
|
67
|
+ <View className="actions">
|
|
68
|
+ <View className={`action ${dataType === 1 ? 'active' : ''}`} onClick={() => this.changeShowData(1)}>预选热度图</View>
|
|
69
|
+ <View className={`action ${dataType === 2 ? 'active' : ''}`} onClick={() => this.changeShowData(2)}>认筹热度图</View>
|
|
70
|
+ </View>
|
|
71
|
+ )
|
|
72
|
+ }
|
59
|
73
|
</View>
|
60
|
74
|
);
|
61
|
75
|
}
|
62
|
76
|
|
63
|
77
|
renderHouses() {
|
64
|
|
- return (
|
65
|
|
- <ScrollView className="body" scrollY>
|
|
78
|
+ const { houseList } = this.state
|
|
79
|
+ const hasData = houseList && houseList.length
|
66
|
80
|
|
|
81
|
+ return hasData && (
|
|
82
|
+ <ScrollView className="body" scrollY>
|
|
83
|
+ {
|
|
84
|
+ houseList.map((item) => {
|
|
85
|
+ return <HouseGrid key={item.unitId} dataset={item} onRoomClick={this.handleRoomClick} onActionClick={this.add2Cart} />
|
|
86
|
+ })
|
|
87
|
+ }
|
67
|
88
|
</ScrollView>
|
68
|
89
|
)
|
69
|
90
|
}
|
70
|
91
|
|
71
|
92
|
renderAction() {
|
72
|
|
- const { chooseList, collapsed } = this.state;
|
|
93
|
+ const { chooseList, collapsed, houseList } = this.state;
|
73
|
94
|
const title = collapsed ? `已选择: ${chooseList[0].name} 等 ${chooseList.length} 个房源` : '已选列表'
|
74
|
95
|
const opened = collapsed ? 'off' : 'on'
|
|
96
|
+ const nodata = houseList && houseList.length ? '' : 'nodata'
|
|
97
|
+ const btnText = chooseList && chooseList.length ? '确认以上选择' : '未选择房源'
|
|
98
|
+ const choosed = chooseList && chooseList.length
|
75
|
99
|
|
76
|
100
|
return (
|
77
|
101
|
<View className="footer">
|
78
|
|
- <View className="shoping-cart collapse">
|
79
|
|
- <View className={`title ${opened}`} onClick={this.trigCartPannel}>
|
80
|
|
- <Text>{title}</Text>
|
81
|
|
- <Text className="at-icon at-icon-chevron-down"></Text>
|
82
|
|
- </View>
|
83
|
|
- <View className={`choose-list ${opened}`}>
|
84
|
|
- {chooseList.map((house, index) => {
|
85
|
|
- return (
|
86
|
|
- <View key={`cart-item-${index}`} className="choose-item" onClick={() => this.subChooseList(house)}>
|
87
|
|
- <View className="choose-item-body">{house.name}</View>
|
88
|
|
- <View className="choose-item-action">
|
89
|
|
- <Text className="at-icon at-icon-subtract-circle"></Text>
|
|
102
|
+ {
|
|
103
|
+ choosed && (
|
|
104
|
+ <View className="shoping-cart collapse">
|
|
105
|
+ <View className={`title ${opened}`} onClick={this.trigCartPannel}>
|
|
106
|
+ <Text>{title}</Text>
|
|
107
|
+ <Text className="at-icon at-icon-chevron-down"></Text>
|
|
108
|
+ </View>
|
|
109
|
+
|
|
110
|
+ <View className={`choose-list ${opened}`}>
|
|
111
|
+ {chooseList.map((house, index) => {
|
|
112
|
+ return (
|
|
113
|
+ <View key={`cart-item-${index}`} className="choose-item" onClick={() => this.subChooseList(house)}>
|
|
114
|
+ <View className="choose-item-body">{house.name}</View>
|
|
115
|
+ <View className="choose-item-action">
|
|
116
|
+ <Text className="at-icon at-icon-subtract-circle"></Text>
|
|
117
|
+ </View>
|
90
|
118
|
</View>
|
91
|
|
- </View>
|
92
|
|
- )
|
93
|
|
- })}
|
|
119
|
+ )
|
|
120
|
+ })}
|
|
121
|
+ </View>
|
94
|
122
|
</View>
|
95
|
|
- </View>
|
96
|
|
- <Button className="btn" onClick={this.handleSubmit}>确认以上选择</Button>
|
|
123
|
+ )
|
|
124
|
+ }
|
|
125
|
+ <Button className={`btn ${nodata}`} onClick={this.handleSubmit}>{btnText}</Button>
|
97
|
126
|
</View>
|
98
|
127
|
)
|
99
|
128
|
}
|
100
|
129
|
|
|
130
|
+ renderBlank() {
|
|
131
|
+ const { houseList } = this.state
|
|
132
|
+
|
|
133
|
+ return !(houseList && houseList.length) && (
|
|
134
|
+ <Blank tips="暂无符合条件的房源" />
|
|
135
|
+ )
|
|
136
|
+ }
|
|
137
|
+
|
101
|
138
|
render() {
|
102
|
139
|
return (
|
103
|
140
|
<View className="house-cart">
|
104
|
141
|
{this.renderHead()}
|
|
142
|
+ {this.renderBlank()}
|
105
|
143
|
{this.renderHouses()}
|
106
|
144
|
{this.renderAction()}
|
107
|
145
|
</View>
|