JXNearVC.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. //
  2. // JXNearVC.h.m
  3. //
  4. // Created by flyeagleTang on 14-4-3.
  5. // Copyright (c) 2014年 Reese. All rights reserved.
  6. //
  7. #import "JXNearVC.h"
  8. #import "JXChatViewController.h"
  9. #import "AppDelegate.h"
  10. #import "JXLabel.h"
  11. #import "JXImageView.h"
  12. #import "JXRoomPool.h"
  13. #import "JXTableView.h"
  14. #import "JXNewFriendViewController.h"
  15. #import "JXTopMenuView.h"
  16. #import "QCheckBox.h"
  17. #import "JXConstant.h"
  18. #import "JXSearchUserVC.h"
  19. #import "selectProvinceVC.h"
  20. #import "JXUserInfoVC.h"
  21. #import "searchData.h"
  22. //#import "JXCell.h"
  23. #import "MJRefresh.h"
  24. #import "JXNearCell.h"
  25. #import "JXTopSiftJobView.h"
  26. #import "JXLocMapVC.h"
  27. #import "JXGooMapVC.h"
  28. @interface JXNearVC () <UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,JXActionSheetVCDelegate>
  29. {
  30. JXTopSiftJobView *_topSiftView; //表头筛选控件
  31. int _selMenu;
  32. BOOL _isLoading;
  33. BOOL _selected; //cell点击延时,防止多次快速点击
  34. BOOL _isNoMoreData;
  35. JXCollectionView *_collectionView;
  36. MJRefreshHeaderView *_refreshHeader;
  37. MJRefreshFooterView *_refreshFooter;
  38. int _oldRowCount;
  39. NSTimeInterval _lastScrollTime;
  40. }
  41. @property (nonatomic, strong) NSMutableArray *nearArray;
  42. //@property (nonatomic, strong) NSMutableArray *userArray;
  43. @property (nonatomic, assign) NSInteger selectNum;
  44. @end
  45. @implementation JXNearVC
  46. - (id)init
  47. {
  48. self = [super init];
  49. if (self) {
  50. self.heightHeader = JX_SCREEN_TOP;
  51. self.heightFooter = 0;
  52. //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  53. self.isFreeOnClose = YES;
  54. self.isGotoBack = YES;
  55. _array = [[NSMutableArray alloc] init];
  56. _nearArray = [NSMutableArray array];
  57. // _userArray = [NSMutableArray array];
  58. _selMenu = 1;
  59. _page=0;
  60. _isLoading=0;
  61. [g_notify addObserver:self selector:@selector(searchAddUser:) name:kSeachAddUserNotification object:nil];
  62. [g_notify addObserver:self selector:@selector(refreshCallPhone:) name:kNearRefreshCallPhone object:nil];
  63. }
  64. return self;
  65. }
  66. - (void)refreshCallPhone:(NSNotification *)notif {
  67. [_collectionView reloadItemsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:self.selectNum inSection:0], nil]];
  68. }
  69. - (void)viewWillAppear:(BOOL)animated{
  70. [super viewWillAppear:animated];
  71. // if (!self.isSearch) {
  72. // [self scrollToPageUp];
  73. // }
  74. }
  75. - (void)viewDidLoad
  76. {
  77. [super viewDidLoad];
  78. self.tableBody.backgroundColor = [UIColor whiteColor];
  79. [self createHeadAndFoot];
  80. CGRect frame = self.tableBody.frame;
  81. if (!_isSearch) {
  82. frame.origin.y += 40;
  83. frame.size.height -= 40;
  84. self.title = Localized(@"JXNearVC_NearHere");
  85. }else {
  86. self.title = Localized(@"JXNearVC_AddFriends");
  87. }
  88. self.tableBody.frame = frame;
  89. [self customView];
  90. UIButton* btn = [UIFactory createButtonWithImage:@"search" highlight:nil target:self selector:@selector(onSearch)];
  91. btn.custom_acceptEventInterval = 1.0f;
  92. // UIButton* btn = [UIFactory createButtonWithTitle:Localized(@"JXNearVC_AddFriends") titleFont:[UIFont systemFontOfSize:15] titleColor:[UIColor whiteColor] normal:nil highlight:nil];
  93. // [btn addTarget:self action:@selector(onSearch) forControlEvents:UIControlEventTouchUpInside];
  94. btn.frame = CGRectMake(JX_SCREEN_WIDTH-100, JX_SCREEN_TOP - 38, 30, 30);
  95. [self.tableHeader addSubview:btn];
  96. btn = [UIFactory createButtonWithRect:CGRectMake(JX_SCREEN_WIDTH-17-15, JX_SCREEN_TOP - 13-18, 17, 18) title:nil titleFont:nil titleColor:nil normal:@"near_screening" selected:nil selector:@selector(onScreening) target:self];
  97. btn.custom_acceptEventInterval = 1.0f;
  98. // UIButton* btn = [UIFactory createButtonWithTitle:Localized(@"JXNearVC_AddFriends") titleFont:[UIFont systemFontOfSize:15] titleColor:[UIColor whiteColor] normal:nil highlight:nil];
  99. // [btn addTarget:self action:@selector(onSearch) forControlEvents:UIControlEventTouchUpInside];
  100. [self.tableHeader addSubview:btn];
  101. _search = [[searchData alloc] init];
  102. _search.minAge = 0;
  103. _search.maxAge = 200;
  104. _search.sex = -1;
  105. [self scrollToPageUp];
  106. }
  107. - (void) customView {
  108. //顶部筛选控件
  109. _topSiftView = [[JXTopSiftJobView alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP, JX_SCREEN_WIDTH, 40)];
  110. _topSiftView.delegate = self;
  111. _topSiftView.isShowMoreParaBtn = NO;
  112. _topSiftView.preferred = _selMenu;
  113. _topSiftView.titleSelectedColor = THEMECOLOR;
  114. _topSiftView.titleNormalColor = HEXCOLOR(0x222222);
  115. _topSiftView.dataArray = [[NSArray alloc] initWithObjects:Localized(@"JXNearVC_NearPer"),Localized(@"JXNearVC_Map"), nil];
  116. //Localized(@"JXNearVC_NewPer")
  117. // _topSiftView.searchForType = SearchForPos;
  118. [self.view addSubview:_topSiftView];
  119. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  120. _collectionView = [[JXCollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.tableBody.frame.size.height)collectionViewLayout:layout];
  121. _collectionView.frame = self.tableBody.frame;
  122. _collectionView.backgroundColor = HEXCOLOR(0xF2F2F2);
  123. _collectionView.contentSize = CGSizeMake(0, self.tableBody.frame.size.height+10);
  124. _collectionView.delegate = self;
  125. _collectionView.dataSource = self;
  126. [_collectionView registerClass:[JXNearCell class] forCellWithReuseIdentifier:NSStringFromClass([JXNearCell class])];
  127. [self.view addSubview:_collectionView];
  128. _refreshHeader = [MJRefreshHeaderView header];
  129. _refreshFooter = [MJRefreshFooterView footer];
  130. [self addRefreshViewWith:_collectionView header:_refreshHeader footer:_refreshFooter];
  131. }
  132. - (void)onScreening {
  133. JXActionSheetVC *actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JX_OnlySeeFemale"),Localized(@"JX_OnlyLookAtMen"),Localized(@"JX_NoGender")]];
  134. actionVC.delegate = self;
  135. [self presentViewController:actionVC animated:NO completion:nil];
  136. }
  137. - (void)actionSheet:(JXActionSheetVC *)actionSheet didButtonWithIndex:(NSInteger)index {
  138. [_wait start];
  139. if (index == 2) {
  140. _search.sex = -1;
  141. }else {
  142. _search.sex = (int)index;
  143. }
  144. [self scrollToPageUp];
  145. }
  146. //添加刷新控件
  147. - (void)addRefreshViewWith:(UICollectionView *)collectionView header:(MJRefreshHeaderView *)header footer:(MJRefreshFooterView *)footer{
  148. header.scrollView = collectionView;
  149. footer.scrollView = collectionView;
  150. header.beginRefreshingBlock = ^(MJRefreshBaseView *baseView){
  151. [self scrollToPageUp];
  152. _page = 0;
  153. // [self getServerData];
  154. };
  155. footer.beginRefreshingBlock = ^(MJRefreshBaseView *baseView){
  156. [self scrollToPageDown];
  157. // [self getServerData];
  158. };
  159. }
  160. - (void)viewDidAppear:(BOOL)animated
  161. {
  162. [super viewDidAppear:animated];
  163. }
  164. - (void)didReceiveMemoryWarning
  165. {
  166. [super didReceiveMemoryWarning];
  167. // Dispose of any resources that can be recreated.
  168. }
  169. #pragma mark UICollectionView delegate
  170. #pragma mark-----多少组
  171. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  172. return 1;
  173. }
  174. #pragma mark-----多少个
  175. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  176. // return _array.count;
  177. if (_selMenu == 0) {
  178. return _nearArray.count;
  179. }
  180. // else if (_selMenu == 2) {
  181. // return _userArray.count;
  182. // }
  183. return 0;
  184. }
  185. #pragma mark-----每一个的大小
  186. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  187. {
  188. return CGSizeMake((JX_SCREEN_WIDTH - 38)/2, (JX_SCREEN_WIDTH - 38)/2+53);
  189. }
  190. #pragma mark-----每一个边缘留白
  191. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
  192. return UIEdgeInsetsMake(10, 15, 10, 15);
  193. }
  194. #pragma mark-----最小行间距
  195. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
  196. return 10.0;
  197. }
  198. #pragma mark-----最小竖间距
  199. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
  200. return 8.0;
  201. }
  202. #pragma mark-----返回每个单元格是否可以被选择
  203. - (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath{
  204. return YES;
  205. }
  206. #pragma mark-----创建单元格
  207. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  208. JXNearCell *cell;
  209. cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([JXNearCell class]) forIndexPath:indexPath];
  210. cell.backgroundColor = [UIColor whiteColor];
  211. // cell.delegate = self;
  212. // cell.didTouch = @selector(onHeadImage:);
  213. // if (_array.count)
  214. // [cell doRefreshNearExpert:[_array objectAtIndex:indexPath.row]];
  215. if (_selMenu == 0) {
  216. if (_nearArray.count) {
  217. [cell doRefreshNearExpert:[_nearArray objectAtIndex:indexPath.row]];
  218. }
  219. }
  220. // else if (_selMenu == 2) {
  221. // if (_userArray.count) {
  222. // [cell doRefreshNearExpert:[_userArray objectAtIndex:indexPath.row]];
  223. // }
  224. // }
  225. if(indexPath.row == [self collectionView:_collectionView numberOfItemsInSection:indexPath.section]-1){
  226. BOOL flag = YES;
  227. if(_oldRowCount == [self collectionView:_collectionView numberOfItemsInSection:indexPath.section])//说明翻页之后,数据没有增长,则不再自动翻页,但可手动翻页
  228. flag = NO;
  229. if([[NSDate date] timeIntervalSince1970]-_lastScrollTime<0.5)//避免刷新过快
  230. flag = NO;
  231. if (_nearArray.count < jx_page_size) { // 不足一页,不翻页
  232. flag = NO;
  233. }
  234. if (flag) {
  235. _oldRowCount = (int)[self collectionView:_collectionView numberOfItemsInSection:indexPath.section];
  236. [self scrollToPageDown];
  237. _lastScrollTime = [[NSDate date] timeIntervalSince1970];
  238. }
  239. }
  240. return cell;
  241. }
  242. #pragma mark-----点击单元格
  243. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  244. // [self stopAllPlayer];
  245. if (_selected == false) { //防多次快速点击cell
  246. _selected = true;
  247. //点击过一次之后。5秒再让cell点击可以响应
  248. [self performSelector:@selector(changeDidSelect) withObject:nil afterDelay:0.2];
  249. NSDictionary* d;
  250. if (_selMenu == 0) {
  251. d = [_nearArray objectAtIndex:indexPath.row];
  252. }
  253. self.selectNum = indexPath.row;
  254. // else if (_selMenu == 2) {
  255. // d = [_userArray objectAtIndex:indexPath.row];
  256. // }
  257. // [_array objectAtIndex:indexPath.row];
  258. // [g_server getUser:[d objectForKey:@"userId"] toView:self];
  259. JXUserInfoVC* vc = [JXUserInfoVC alloc];
  260. vc.userId = [d objectForKey:@"userId"];
  261. vc.fromAddType = 6;
  262. vc = [vc init];
  263. [g_navigation pushViewController:vc animated:YES];
  264. d = nil;
  265. }
  266. }
  267. -(void)changeDidSelect{
  268. _selected = false;
  269. }
  270. - (void)dealloc {
  271. // NSLog(@"JXNearVC.dealloc");
  272. // [_search release];
  273. // [_array removeAllObjects];
  274. // [_array release];
  275. // [super dealloc];
  276. }
  277. -(void)changeToMap{
  278. //创建地图视图
  279. [self createMap];
  280. }
  281. -(void)createMap{
  282. // NSString *countryCode = [[NSUserDefaults standardUserDefaults] objectForKey:kISOcountryCode];
  283. // if ([countryCode isEqualToString:@"CN"] || !countryCode) {
  284. // if (!_mapVC) {
  285. // _mapVC = [[JXLocMapVC alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, self.tableBody.frame.size.height) andType:2];
  286. // [self.view addSubview:_mapVC.view];
  287. // }
  288. // _mapVC.view.frame = self.tableBody.frame;
  289. // _mapVC.view.hidden = NO;
  290. // }else {
  291. // BOOL isShowGoo = [g_default boolForKey:kUseGoogleMap];
  292. if (g_config.isChina) {
  293. if (!_mapVC) {
  294. _mapVC = [[JXLocMapVC alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, self.tableBody.frame.size.height) andType:2];
  295. [self.view addSubview:_mapVC.view];
  296. }
  297. _mapVC.search = _search;
  298. _mapVC.view.frame = self.tableBody.frame;
  299. _mapVC.view.hidden = NO;
  300. [_mapVC getDataByCurrentLocation];
  301. } else {
  302. if (!_goomapVC) {
  303. _goomapVC = [[JXGooMapVC alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, self.tableBody.frame.size.height) andType:2];
  304. [self.view addSubview:_goomapVC.view];
  305. }
  306. _goomapVC.search = _search;
  307. _goomapVC.view.frame = self.tableBody.frame;
  308. _goomapVC.view.hidden = NO;
  309. [_goomapVC getDataByCurrentLocation];
  310. }
  311. //AppStore上线ipv6被拒,先隐藏google地图
  312. // [self checkAfterScroll:0];
  313. // [_topSiftView resetAllParaBtn];
  314. // }
  315. }
  316. // JXNearVc
  317. -(void)getServerData{
  318. [_wait start];
  319. // self.isShowFooterPull = _selMenu == 1;
  320. if (_selMenu == 0) {
  321. // [_refreshHeader beginRefreshing];
  322. //18938880001
  323. if ([g_myself.telephone rangeOfString:@"18938880001"].location != NSNotFound) {
  324. [g_server nearbyNewUser:_search nearOnly:_bNearOnly page:_page toView:self];
  325. }else {
  326. [g_server nearbyUser:_search nearOnly:_bNearOnly lat:g_server.latitude lng:g_server.longitude page:_page toView:self];
  327. }
  328. }else if(_selMenu == 1){
  329. //Map
  330. [_wait stop];
  331. [self changeToMap];
  332. }
  333. // else if(_selMenu == 2){
  334. // //新用户
  335. // [g_server nearbyNewUser:_search nearOnly:_bNearOnly page:_page toView:self];
  336. // }
  337. }
  338. //顶部刷新获取数据
  339. -(void)scrollToPageUp{
  340. if(_isLoading)
  341. return;
  342. _page = 0;
  343. // _search = nil;
  344. _bNearOnly = YES;
  345. [self getServerData];
  346. [self performSelector:@selector(stopLoading) withObject:nil afterDelay:1.0];
  347. }
  348. -(void)scrollToPageDown{
  349. if(_isLoading)
  350. return;
  351. if (!_isNoMoreData) {
  352. _page++;
  353. }
  354. [self getServerData];
  355. }
  356. - (void)stopLoading {
  357. _isLoading = NO;
  358. [_refreshHeader endRefreshing];
  359. [_refreshFooter endRefreshing];
  360. }
  361. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  362. [_wait stop];
  363. [self stopLoading];
  364. if([aDownload.action isEqualToString:act_nearbyUser] || [aDownload.action isEqualToString:act_nearNewUser]){
  365. BOOL scrollToTop = NO;
  366. if (_isNoMoreData) {
  367. _isNoMoreData = NO;
  368. scrollToTop = YES;
  369. }
  370. if(_page == 0){
  371. // [_array removeAllObjects];
  372. // [_array addObjectsFromArray:array1];
  373. [_nearArray removeAllObjects];
  374. [_nearArray addObjectsFromArray:array1];
  375. }else{
  376. if([array1 count]>0){
  377. [_nearArray addObjectsFromArray:array1];
  378. }else{//刷新到最后没有数据,重新配置参数,加载所有
  379. [g_App showAlert:Localized(@"JX_NotMoreData")];
  380. _isNoMoreData = YES;
  381. _bNearOnly = YES;
  382. _search = nil;
  383. _search = [[searchData alloc] init];
  384. _search.sex = -1;
  385. _page=0;
  386. }
  387. }
  388. // _refreshCount++;
  389. // [_table reloadData];
  390. _refreshFooter.hidden = [array1 count] < jx_page_size;
  391. [_collectionView reloadData];
  392. if (scrollToTop)
  393. [_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
  394. }else if([aDownload.action isEqualToString:act_UserGet]){
  395. JXUserObject* user = [[JXUserObject alloc]init];
  396. [user getDataFromDict:dict];
  397. JXUserInfoVC* vc = [JXUserInfoVC alloc];
  398. vc.user = user;
  399. vc.fromAddType = 6;
  400. vc = [vc init];
  401. // [g_window addSubview:vc.view];
  402. [g_navigation pushViewController:vc animated:YES];
  403. // [user release];
  404. }
  405. // else if ([aDownload.action isEqualToString:act_nearNewUser]) {
  406. // if (_page == 0) {
  407. //// [_array removeAllObjects];
  408. //// [_array addObjectsFromArray:array1];
  409. // [_userArray removeAllObjects];
  410. // [_userArray addObjectsFromArray:array1];
  411. // }else{
  412. // if ([_userArray count] > 0) {
  413. // [_userArray addObjectsFromArray:array1];
  414. // }else{
  415. // [g_App showAlert:Localized(@"JX_NotMoreData")];
  416. // _isNoMoreData = YES;
  417. // _search = nil;
  418. // _search = [[searchData alloc] init];
  419. // _search.minAge = 0;
  420. // _search.maxAge = 200;
  421. // _search.sex = -1;
  422. // _page=0;
  423. // }
  424. //
  425. // }
  426. // [_collectionView reloadData];
  427. // }
  428. }
  429. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  430. [_wait stop];
  431. [self stopLoading];
  432. return show_error;
  433. }
  434. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  435. [_wait stop];
  436. [self stopLoading];
  437. return show_error;
  438. }
  439. -(void) didServerConnectStart:(JXConnection*)aDownload{
  440. [_wait start];
  441. }
  442. //-(void)buildMenu{
  443. // _tb = [JXTopMenuView alloc];
  444. // _tb.items = [NSArray arrayWithObjects:@"最新",@"最热",@"附近",nil];
  445. // _tb.delegate = self;
  446. // _tb.onClick = @selector(actionSegment:);
  447. // [_tb initWithFrame:CGRectMake(0, JX_SCREEN_TOP, JX_SCREEN_WIDTH, 44)];
  448. // [_tb selectOne:0];
  449. // [self.tableHeader addSubview:_tb];
  450. //// [_tb release];
  451. //}
  452. //-(void)actionSegment:(UIButton*)sender{
  453. // [_array removeAllObjects];
  454. //// _refreshCount++;
  455. //// [_table reloadData];
  456. // [_collectionView reloadData];
  457. // [self scrollToPageUp];
  458. //}
  459. /**
  460. 消息列表添加好友的搜索
  461. */
  462. -(void)searchAddUser:(NSNotification *)notificition{
  463. [g_mainVC doSelected:2];
  464. searchData * searchData = notificition.object;
  465. [self doSearch:searchData];
  466. }
  467. -(void)onSearch{
  468. // [_topSiftView resetItemBtnWith:0];
  469. // [_topSiftView moveBottomSlideLine:0];
  470. // [_topSiftView resetBottomLineIndex:0];
  471. JXSearchUserVC* vc = [[JXSearchUserVC alloc]init];
  472. vc.delegate = self;
  473. vc.didSelect = @selector(doSearch:);
  474. // [g_window addSubview:vc.view];
  475. [g_navigation pushViewController:vc animated:YES];
  476. }
  477. -(void)doSearch:(searchData*)p{
  478. _search = p;
  479. _bNearOnly = NO;
  480. _isSearch = YES;
  481. _page = 0;
  482. _selMenu = 0;
  483. [_topSiftView resetBottomLineIndex:0];
  484. [self checkAfterScroll:0];
  485. [self getServerData];
  486. }
  487. -(void)onHeadImage:(UIView*)sender{
  488. }
  489. //筛选点击
  490. - (void)topItemBtnClick:(UIButton *)btn{
  491. [self checkAfterScroll:(btn.tag-100)];
  492. [_topSiftView resetAllParaBtn];
  493. }
  494. - (void)checkAfterScroll:(CGFloat)offsetX{
  495. if (offsetX == 0) {
  496. _selMenu = 0;
  497. if (_nearArray.count <= 0) {
  498. if (!_isSearch) {
  499. [self scrollToPageUp];
  500. }
  501. }else {
  502. [_collectionView reloadData];
  503. [_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:NO];
  504. }
  505. _mapVC.view.hidden = YES;
  506. _goomapVC.view.hidden = YES;
  507. }else if (offsetX == 1){
  508. _selMenu = 1;
  509. [self changeToMap];
  510. [_topSiftView resetBottomLineIndex:1];
  511. }
  512. // else if (offsetX == 2){
  513. // _selMenu = 2;
  514. //// _page=0;
  515. // _search = nil;
  516. // _search = [[searchData alloc] init];
  517. // _search.minAge = 0;
  518. // _search.maxAge = 200;
  519. // _search.sex = -1;
  520. // _bNearOnly = NO;
  521. //
  522. // if (_userArray.count <= 0) {
  523. // [self scrollToPageUp];
  524. // }else {
  525. // [_collectionView reloadData];
  526. // [_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:NO];
  527. // }
  528. //
  529. // _mapVC.view.hidden = YES;
  530. // _goomapVC.view.hidden = YES;
  531. // }
  532. }
  533. @end