1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#import "VankeMainBoard_iPhone.h"
#import "VankeFloorListBoard_iPhone.h"
#import "VankeFloorListBoardCell_iPhone.h"
#import "VankeServiceDashBoard_iPhone.h"
#import "VankeAppBoard_iPhone.h"
#import "VankeUtil.h"
#import "GEToast.h"
@interface VankeMainBoard_iPhone ()
@property (strong, nonatomic) VankeServiceDashBoard_iPhone *communityDashBoard;
@property (strong, nonatomic) VankeServiceDashBoard_iPhone *centerDashBoard;
@property (strong, nonatomic) VankeServiceDashBoard_iPhone *squreDashBoard;
@property (strong, nonatomic) VankeServiceDashBoard_iPhone *currDashBoard;
@end
#pragma mark -
@interface VankeMainBoard_iPhone ()
{
NSInteger _curTopMenuIndex;
}
@end
@implementation VankeMainBoard_iPhone
SUPPORT_AUTOMATIC_LAYOUT( YES )
SUPPORT_RESOURCE_LOADING( YES )
DEF_OUTLET( VankeWeatherCell_iPhone, weatherBoard );
DEF_OUTLET( VankeTopMenuBoardCell_iPhone, topMenu );
DEF_OUTLET( BeeUIView, serviceDashBoardView );
DEF_OUTLET( BeeUITextField, txtQuery);
DEF_MODEL( VankeProjectSummaryModel, summaryModel );
- (void)load
{
_curTopMenuIndex = 0;
self.summaryModel = [VankeProjectSummaryModel modelWithObserver:self];
}
- (void)unload
{
self.summaryModel = nil;
}
#pragma mark - Signal
ON_CREATE_VIEWS( signal )
{
self.view.backgroundColor = [UIColor whiteColor];
[self addLeftIconToTextField:_txtQuery icon:@"search"];
[_weatherBoard reloadLocationAndWeather];
}
ON_DELETE_VIEWS( signal )
{
}
ON_LAYOUT_VIEWS( signal )
{
// 如果没有设置当前tab,则默认为第一页
if (nil == _currDashBoard) {
[self showCommunityDashBoard];
}
}
ON_WILL_APPEAR( signal )
{
[BeeUIRouter sharedInstance].view.pannable = YES;
self.navigationBarShown = NO;
[[VankeAppBoard_iPhone sharedInstance] showMenu];
}
ON_DID_APPEAR( signal )
{
}
ON_WILL_DISAPPEAR( signal )
{
[BeeUIRouter sharedInstance].view.pannable = NO;
}
ON_DID_DISAPPEAR( signal )
{
}
ON_SIGNAL3( VankeMainBoard_iPhone, txtQuery, signal )
{
if ([signal is:BeeUITextField.RETURN]) {
[self showListView: CELL_TYPE_FLOOR];
}
}
#pragma VankeWeatherCell_iPhone
ON_SIGNAL3( VankeWeatherCell_iPhone, btnMask, signal )
{
[_weatherBoard reloadLocationAndWeather: YES];
}
#pragma VankeTopMenuBoardCell_iPhone
ON_SIGNAL3( VankeTopMenuBoardCell_iPhone, menuCommunity, signal ) {
[self.topMenu selectCommunity];
[self showCommunityDashBoard];
}
ON_SIGNAL3( VankeTopMenuBoardCell_iPhone, menuCenter, signal ) {
[self.topMenu selectCenter];
[self showCenterDashBoard];
}
ON_SIGNAL3( VankeTopMenuBoardCell_iPhone, menuSqure, signal ) {
[self.topMenu selectSqure];
[self showSqureDashBoard];
}
#pragma mark - VankeServiceSaleCell_iPhone
ON_SIGNAL3( VankeServiceSaleCell_iPhone, mask, signal ) {
[[VankeAppBoard_iPhone sharedInstance] hideMenu];
[self showListView: CELL_TYPE_FLOOR];
}
ON_SIGNAL3(VankeServiceBoardCell_iPhone, mask, signal) {
VankeServiceBoardCell_iPhone *cell = (VankeServiceBoardCell_iPhone *)signal.sourceCell;
if ([@"当前客流" eq:cell.lblTitle.data]) {
[[VankeAppBoard_iPhone sharedInstance] hideMenu];
[self showListView: CELL_TYPE_PASSENGER];
}
}
#pragma mark - VankeProjectSummaryModel
ON_SIGNAL3(VankeProjectSummaryModel, RELOADING, signal) {
}
ON_SIGNAL3(VankeProjectSummaryModel, RELOADED, signal) {
if (![_summaryModel isOk]) {
[GEToast showWithText:[_summaryModel getMessage] bottomOffset:20 duration:1.0f];
return;
}
if (nil != _currDashBoard) {
ProjectSummary *data = [[_summaryModel getServerResp] getSummary:_currDashBoard.name];
if (nil != data) {
[_currDashBoard setData:data];
}
}
}
-(void) addLeftIconToTextField: (BeeUITextField*) textField icon: (NSString*) icon {
UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:icon]];
img.frame = CGRectMake(0, 0, 30, 25);
img.contentMode = UIViewContentModeCenter;
textField.leftView = img;
textField.leftViewMode = UITextFieldViewModeAlways;
}
-(void) showCommunityDashBoard {
_curTopMenuIndex = 0;
if (self.currDashBoard != nil && self.currDashBoard == self.communityDashBoard) {
return;
}
CGRect frame = self.serviceDashBoardView.frame;
if (frame.size.width <= 0) {
return;
}
if (self.communityDashBoard == nil) {
self.communityDashBoard = [VankeServiceDashBoard_iPhone communityDashBarod];
}
if (self.currDashBoard != nil) {
self.currDashBoard.frame = CGRectMake(0, 0, 0, 0);
[self.currDashBoard removeFromSuperview];
}
[self.serviceDashBoardView addSubview:self.communityDashBoard];
[UIView animateWithDuration:0.25 animations:^{
self.communityDashBoard.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
self.currDashBoard = self.communityDashBoard;
[self RELAYOUT];
}];
// 刷新数据
[_summaryModel reload];
}
-(void) showCenterDashBoard {
_curTopMenuIndex = 1;
if (self.currDashBoard != nil && self.currDashBoard == self.centerDashBoard) {
return;
}
CGRect frame = self.serviceDashBoardView.frame;
if (frame.size.width <= 0) {
return;
}
if (self.centerDashBoard == nil) {
self.centerDashBoard = [VankeServiceDashBoard_iPhone centerDashBarod];
}
if (self.currDashBoard != nil) {
self.currDashBoard.frame = CGRectMake(0, 0, 0, 0);
[self.currDashBoard removeFromSuperview];
}
[self.serviceDashBoardView addSubview:self.centerDashBoard];
[UIView animateWithDuration:0.25 animations:^{
self.centerDashBoard.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
self.currDashBoard = self.centerDashBoard;
[self RELAYOUT];
}];
// 刷新数据
[_summaryModel reload];
}
-(void) showSqureDashBoard {
_curTopMenuIndex = 2;
if (self.currDashBoard != nil && self.currDashBoard == self.squreDashBoard) {
return;
}
CGRect frame = self.serviceDashBoardView.frame;
if (frame.size.width <= 0) {
return;
}
if (self.squreDashBoard == nil) {
self.squreDashBoard = [VankeServiceDashBoard_iPhone squreDashBarod];
}
if (self.currDashBoard != nil) {
self.currDashBoard.frame = CGRectMake(0, 0, 0, 0);
[self.currDashBoard removeFromSuperview];
}
[self.serviceDashBoardView addSubview:self.squreDashBoard];
[UIView animateWithDuration:0.25 animations:^{
self.squreDashBoard.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
self.currDashBoard = self.squreDashBoard;
[self RELAYOUT];
}];
// 刷新数据
[_summaryModel reload];
}
-(void) showListView: (CellType) type {
VankeFloorListBoard_iPhone * board = [VankeFloorListBoard_iPhone boardWithType:type];
if (nil != _currDashBoard) {
board.projectCategory = _currDashBoard.name;
board.salesDate = _summaryModel.salesDate;
board.theme = _currDashBoard.theme;
NSString *nameLike = [VankeUtil trim:$(self.txtQuery).data];
board.projectNameLike = nameLike;
}
[self.stack pushBoard:board animated:YES transition:bee.ui.transitionFade];
}
@end