1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // SLNearbyPeopleVc.m
- // SLAiELTS
- //
- // Created by Gusont on 2023/5/10.
- //
- #import "SLNearbyPeopleVc.h"
- #import "SLNearbyPeopleCell.h"
- #import "SLLocationManager.h"
- #import "SLFriensInfoVc.h"
- @interface SLNearbyPeopleVc ()<UITableViewDelegate, UITableViewDataSource>
- @property (weak, nonatomic) IBOutlet UITableView *tableView;
- @property (nonatomic, strong)NSMutableArray *nearbyPeoples;
- @end
- @implementation SLNearbyPeopleVc
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view from its nib.
- self.title = @"附近的人";
- [self.tableView registerNibCellWithReuseIdentifierClass:SLNearbyPeopleCell.class];
- UIImage *creatImage =[UIImage imageNamed:@"icon_pyq_more_back"];
- YMBarButtonItem *rightBarItem =[[YMBarButtonItem alloc]initWithImage:creatImage style:YMBarButtonItemPlain target:self action:@selector(moreBtnClick)];
- rightBarItem.titleInsets = UIEdgeInsetsMake(0, 0, 0, 20);
- self.navigationBar.rightBarButtonItem = rightBarItem;
- WS(weakSelf);
- [[SLLocationManager shareInstance] getLocationComplete:^(CLLocation * _Nullable currentLocation) {
- NSLog(@"%f--%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
- if (currentLocation) {
- NSDictionary *parameter = @{@"province" : [SLLocationManager shareInstance].province ,
- @"city" : [SLLocationManager shareInstance].city ,
- @"lon" : @(currentLocation.coordinate.longitude) ,
- @"lat" : @(currentLocation.coordinate.latitude)
- };
- [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Contacts/PeopleNearby" parameter:parameter success:^(id responseObject) {
- NSArray *datas = [responseObject objectForKey:@"data"];
- NSArray *friendsModel = [SLFriendsModel mj_objectArrayWithKeyValuesArray:datas];
- [weakSelf.nearbyPeoples addObjectsFromArray:friendsModel];
- [weakSelf.tableView reloadData];
- } failure:^(SPRequestError *error) {
- }];
- }
- }];
- }
- - (void)moreBtnClick {
- WS(weakSelf);
- [SLCustomizeAlert showBottomAletrWithTitles:@[@"只看男生", @"只看女生"] cancelTitle:@"取消" buttonIndex:^(NSInteger index) {
- if (index != 2) {
-
- }
- }];
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.nearbyPeoples.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- SLNearbyPeopleCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(SLNearbyPeopleCell.class)];
- SLFriendsModel *model = [self.nearbyPeoples objectAtIndex:indexPath.row];
- [cell confignCellWith:model];
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 74.0f;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- SLFriendsModel *model = [self.nearbyPeoples objectAtIndex:indexPath.row];
- SLFriensInfoVc *vc = [SLFriensInfoVc loadViewControllewWithNib];
- vc.friendModel = model;
- [self navPushViewController:vc animated:YES];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return 0.001f;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return 0.001f;
- }
- - (NSMutableArray *)nearbyPeoples {
- if (!_nearbyPeoples) {
- _nearbyPeoples = [NSMutableArray array];
- }
- return _nearbyPeoples;
- }
- @end
|