SLNearbyPeopleVc.m 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // SLNearbyPeopleVc.m
  3. // SLAiELTS
  4. //
  5. // Created by Gusont on 2023/5/10.
  6. //
  7. #import "SLNearbyPeopleVc.h"
  8. #import "SLNearbyPeopleCell.h"
  9. #import "SLLocationManager.h"
  10. #import "SLFriensInfoVc.h"
  11. @interface SLNearbyPeopleVc ()<UITableViewDelegate, UITableViewDataSource>
  12. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  13. @property (nonatomic, strong)NSMutableArray *nearbyPeoples;
  14. @end
  15. @implementation SLNearbyPeopleVc
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view from its nib.
  19. self.title = @"附近的人";
  20. [self.tableView registerNibCellWithReuseIdentifierClass:SLNearbyPeopleCell.class];
  21. UIImage *creatImage =[UIImage imageNamed:@"icon_pyq_more_back"];
  22. YMBarButtonItem *rightBarItem =[[YMBarButtonItem alloc]initWithImage:creatImage style:YMBarButtonItemPlain target:self action:@selector(moreBtnClick)];
  23. rightBarItem.titleInsets = UIEdgeInsetsMake(0, 0, 0, 20);
  24. self.navigationBar.rightBarButtonItem = rightBarItem;
  25. WS(weakSelf);
  26. [[SLLocationManager shareInstance] getLocationComplete:^(CLLocation * _Nullable currentLocation) {
  27. NSLog(@"%f--%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
  28. if (currentLocation) {
  29. NSDictionary *parameter = @{@"province" : [SLLocationManager shareInstance].province ,
  30. @"city" : [SLLocationManager shareInstance].city ,
  31. @"lon" : @(currentLocation.coordinate.longitude) ,
  32. @"lat" : @(currentLocation.coordinate.latitude)
  33. };
  34. [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Contacts/PeopleNearby" parameter:parameter success:^(id responseObject) {
  35. NSArray *datas = [responseObject objectForKey:@"data"];
  36. NSArray *friendsModel = [SLFriendsModel mj_objectArrayWithKeyValuesArray:datas];
  37. [weakSelf.nearbyPeoples addObjectsFromArray:friendsModel];
  38. [weakSelf.tableView reloadData];
  39. } failure:^(SPRequestError *error) {
  40. }];
  41. }
  42. }];
  43. }
  44. - (void)moreBtnClick {
  45. WS(weakSelf);
  46. [SLCustomizeAlert showBottomAletrWithTitles:@[@"只看男生", @"只看女生"] cancelTitle:@"取消" buttonIndex:^(NSInteger index) {
  47. if (index != 2) {
  48. }
  49. }];
  50. }
  51. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  52. return self.nearbyPeoples.count;
  53. }
  54. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  55. SLNearbyPeopleCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(SLNearbyPeopleCell.class)];
  56. SLFriendsModel *model = [self.nearbyPeoples objectAtIndex:indexPath.row];
  57. [cell confignCellWith:model];
  58. return cell;
  59. }
  60. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  61. return 74.0f;
  62. }
  63. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  64. SLFriendsModel *model = [self.nearbyPeoples objectAtIndex:indexPath.row];
  65. SLFriensInfoVc *vc = [SLFriensInfoVc loadViewControllewWithNib];
  66. vc.friendModel = model;
  67. [self navPushViewController:vc animated:YES];
  68. }
  69. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  70. return 0.001f;
  71. }
  72. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  73. return 0.001f;
  74. }
  75. - (NSMutableArray *)nearbyPeoples {
  76. if (!_nearbyPeoples) {
  77. _nearbyPeoples = [NSMutableArray array];
  78. }
  79. return _nearbyPeoples;
  80. }
  81. @end