cdts/xdts-ios 3/TreeHole/Code/Features/Bottle/ViewController/BottleNerbyViewController.m

783 lines
34 KiB
Mathematica
Raw Normal View History

2023-07-27 09:20:00 +08:00
//
// BottleNerbyViewController.m
// TreeHole
//
// Created by on 2022/10/6.
//
#import "BottleNerbyViewController.h"
#import "userNearbyModel.h"
#import "BottleUserNearbyTableViewCell.h"
#import <SDCycleScrollView/SDCycleScrollView.h>
#import "UserService.h"
#import "BottleUserNearbyShaiXuanAlertView.h"
#import "PYAppService.h"
#import <CoreLocation/CoreLocation.h>
#import <MJRefresh.h>
#import "MTPickerView.h"
2023-07-27 18:25:18 +08:00
#import "THLVTipView.h"
2023-07-27 09:20:00 +08:00
#import "BRPickerView.h"
@interface BottleNerbyViewController ()<UITableViewDelegate,UITableViewDataSource,CLLocationManagerDelegate,SDCycleScrollViewDelegate,UITextFieldDelegate>
@property (nonatomic, assign) NSInteger nextPage;
@property (nonatomic, strong) UIView* topHeaderView;
@property (nonatomic, strong) NSMutableArray* tableMDataArray;
2023-07-27 18:25:18 +08:00
@property (nonatomic, strong) NSMutableArray* photosM;
2023-07-27 09:20:00 +08:00
@property (nonatomic, strong) SDCycleScrollView* cycleScrollView;
@property (nonatomic, strong) UIView* openVipAlertView;
2023-07-27 18:25:18 +08:00
@property (nonatomic, strong) THLVTipView* lvTipView;
2023-07-27 09:20:00 +08:00
@property (nonatomic, strong) NSMutableDictionary* nearbyParamDict;
@property (nonatomic, strong) CLLocationManager *cLLocationManager;
@property (nonatomic, strong) NSDictionary* shaiXuanDict;
@property (nonatomic,strong) UIButton *leftBtn;
@property (nonatomic,strong) NSString *city;
@property (nonatomic,copy) NSArray *bannerArr;
@property (nonatomic, copy) NSArray <NSNumber *> *linkage3SelectIndexs;
@end
@implementation BottleNerbyViewController
- (BOOL)mt_nagationBarTransparent{
return YES;
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
if ([UserService currentUser].isVIP) {
2023-07-27 18:25:18 +08:00
_contentTableView.mj_footer.hidden = NO;
[self loadPhotosData];
2023-07-27 09:20:00 +08:00
}else{
2023-07-27 18:25:18 +08:00
_contentTableView.mj_footer.hidden = YES;
self.lvTipView.descLbl.text = @"开通年VIP提升您的账号权重进而提升排名哦";
[self.lvTipView.tipBtn setTitle:@"开年VIP" forState:UIControlStateNormal];
2023-07-27 09:20:00 +08:00
}
[self loadBannerData];
}
- (void)loadBannerData {
[PYHTTPManager getWithPath:@"appconfig" params:nil callback:^(id _Nullable rsp, NSError * _Nullable error) {
if (rsp[@"banners"] != nil) {
NSArray *bannerArr = rsp[@"banners"];
self.bannerArr = bannerArr;
NSMutableArray *imgArr = [NSMutableArray array];
for (NSDictionary *info in bannerArr) {
[imgArr addObject:info[@"image"]];
}
self.cycleScrollView.imageURLStringsGroup = imgArr;
}
}];
}
2023-07-27 18:25:18 +08:00
- (void)loadPhotosData {
[UserService getUserPhotosWithUserID:[UserService currentUserID] completion:^(NSArray<ProfilePhoto *> * _Nonnull photos) {
self.photosM = [photos mutableCopy];
[self endLoading:nil];
if (self.photosM.count < 3) {
[self.lvTipView.tipBtn setTitle:@"更新形象照" forState:UIControlStateNormal];
self.lvTipView.descLbl.text = @"更新形象照完善您的个人形象进而提升排名哦~";
} else {
[self.lvTipView.tipBtn setTitle:@"查看瓶子" forState:UIControlStateNormal];
self.lvTipView.descLbl.text = @"多查看瓶子并回应增加互动值进而提升排名哦~";
}
}];
}
2023-07-27 09:20:00 +08:00
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"附近同好";
UIImageView *bgImgView = [UIImageView creatViewInSuperView:self.view];
bgImgView.frame = self.view.bounds;
bgImgView.image = UIImageMake(@"TH_BaseLocalBg");
// UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
// self.leftBtn = leftBtn;
// leftBtn.frame = CGRectMake(0, 0, FIX_SIZE(86), FIX_SIZE(24));
// [leftBtn setImage:ImageNamed(@"TH_TabBarNearSelected") forState:UIControlStateNormal];
// [leftBtn setTitle:@"全国" forState:UIControlStateNormal];
// leftBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
//
// leftBtn.titleLabel.font = [UIFont systemFontOfSize:14];
// [leftBtn addTarget:self action:@selector(locaClick) forControlEvents:UIControlEventTouchUpInside];
// [leftBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
// [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"nearCity"];
//
// [[NSUserDefaults standardUserDefaults] synchronize];
UIView *leftView = [[UIView alloc]init];
leftView.frame = CGRectMake(0, 0, FIX_SIZE(120), FIX_SIZE(44));
leftView.backgroundColor = [UIColor clearColor];
UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
leftBtn.backgroundColor = [UIColor clearColor];
self.leftBtn = leftBtn;
[leftView addSubview:leftBtn];
leftBtn.frame = CGRectMake(0, FIX_SIZE(12), FIX_SIZE(22), FIX_SIZE(20));
[leftBtn setImage:ImageNamed(@"TH_TabBarNearSelected") forState:UIControlStateNormal];
User *user = [UserService currentUser];
UITextField *locationTextField = [[UITextField alloc] init];
[leftView addSubview:locationTextField];
locationTextField.frame = CGRectMake(0, 0, FIX_SIZE(120), FIX_SIZE(44));
// locationTextField.backgroundColor = [UIColor clearColor];
locationTextField.delegate = self;
// locationTextField.backgroundColor = [UIColor w];
locationTextField.text = @" 全国(切换)";
locationTextField.inputView = [MTPickerView pickerViewWithType:MTPickerViewTypeLocation defaultValues:[@"全国-" componentsSeparatedByString:@"-"] valueDidChange:^(NSArray<NSString *> * _Nonnull values) {
NSLog(@"改成数据.%@",values);
} done:^(NSArray<NSString *> * _Nonnull selectedValues) {
NSLog(@"选择.");
if (selectedValues.count == 3) {
[UserService updateUserToRemoteWithParams:@{
@"province": selectedValues[0]?:@"",
@"city": selectedValues[1]?:@"",
@"district": selectedValues[2]?:@"",
} completion:^(id _Nullable rsp, NSError * _Nullable error) {
if (!error) {
user.province = selectedValues[0];
user.city = selectedValues[1];
user.district = selectedValues[2];
locationTextField.text = [NSString stringWithFormat:@" %@",user.city];
// [weakself reloadData];
NSLog(@"user.city===%@",user.city);
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[ud setObject:user.city forKey:@"nearCity"];
[ud synchronize];
self.city = user.city;
self.nextPage = 1;
[self reloadDataTableViewNT:self.nextPage withCity:user.city isRecommend:@""];
}else{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[SVProgressHUD showErrorWithStatus:[error.userInfo objectForKey:@"message"]];
});
}
}];
}
}];
self.leftView = leftView;
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftView];
UIButton *navBottleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
navBottleBtn.frame = CGRectMake(0, 0, FIX_SIZE(24), FIX_SIZE(24));
[navBottleBtn setImage:ImageNamed(@"TH_bottle_shaiXuan_icon") forState:UIControlStateNormal];
[navBottleBtn addTarget:self action:@selector(shaiXuanClick) forControlEvents:UIControlEventTouchUpInside];
self.navBottleBtn = navBottleBtn;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:navBottleBtn];
// Do any additional setup after loading the view.
_nextPage = 1;
_tableMDataArray = [NSMutableArray arrayWithArray:@[]];
_shaiXuanDict = [[NSUserDefaults standardUserDefaults]objectForKey:@"UserNearbyShaiXuanDict"];
// [[NSUserDefaults standardUserDefaults]setObject:weakself.nearbyParamDict forKey:@"UserNearbyShaiXuanParamDict"];
WeakSelf(self);
[self.view addSubview:self.contentTableView];
2023-07-27 18:25:18 +08:00
// [self.contentTableView addSubview:self.openVipAlertView];
2023-07-27 09:20:00 +08:00
//TabBarVC.
// _contentTableView.sd_layout.leftSpaceToView(self.view, 0).bottomSpaceToView(self.view, 0).rightSpaceToView(self.view, 0).topSpaceToView(self.view, 0);
_contentTableView.tableHeaderView = self.topHeaderView;
if(![PYAppService showAuthorizationWithTypeIfNeed:AuthorizationTypeLocation]){
//.
// [PYAppService sharedService].cLLocationManager
_cLLocationManager = [[CLLocationManager alloc] init];
[_cLLocationManager requestAlwaysAuthorization];
[_cLLocationManager requestWhenInUseAuthorization];
_cLLocationManager.delegate = self;
[_cLLocationManager startUpdatingLocation];
// [PYAppService sharedService].cLLocationManager.delegate = self;
// [[PYAppService sharedService].cLLocationManager startUpdatingLocation];
}else{
[self.contentTableView.mj_header beginRefreshing];
};
// NSString *usDefaultCity = [[NSUserDefaults standardUserDefaults]objectForKey:@"nearCity"];
_contentTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
weakself.nextPage = 1;
[self reloadDataTableViewNT:weakself.nextPage withCity:self.city isRecommend:@""];
});
}];
NSString *ud = [[NSUserDefaults standardUserDefaults] objectForKey:@"isRecommend"];
2023-07-27 18:25:18 +08:00
MJWeakSelf
2023-07-27 09:20:00 +08:00
_contentTableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
2023-07-27 18:25:18 +08:00
if ([UserService currentUser].isVIP) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
#pragma mark -- city
[self reloadDataTableViewNT:weakself.nextPage withCity:self.city isRecommend:ud];
});
} else {
// [weakself.contentTableView.mj_footer endRefreshing];
}
2023-07-27 09:20:00 +08:00
}];
[_contentTableView.mj_header beginRefreshing];
// [self reloadDataTableViewNT];
}
-(void)locaClick
{
///
BRStringPickerView *stringPickerView = [[BRStringPickerView alloc]init];
stringPickerView.pickerMode = BRStringPickerComponentLinkage;
stringPickerView.title = @"";
stringPickerView.dataSourceArr = [self getLinkag3DataSource];
// self.linkage3SelectIndexs = @[@2,@0,@0];
stringPickerView.selectIndexs = self.linkage3SelectIndexs;
// [stringPickerView.selectIndexs = @[@"2",@"0",@"0"];
stringPickerView.resultModelArrayBlock = ^(NSArray<BRResultModel *> *resultModelArr) {
// 1.
NSMutableArray *selectIndexs = [[NSMutableArray alloc]init];
// 2.
NSString *selectValue = @"";
// 广-广- 使 for 使
for (BRResultModel *model in resultModelArr) {
[selectIndexs addObject:@(model.index)];
selectValue = [NSString stringWithFormat:@"%@%@", selectValue, model.value];
if (selectValue.length>7) {
NSString *cityString = [selectValue substringWithRange:NSMakeRange(3, 3)];
NSLog(@"cityString%@",cityString);
[self.leftBtn setTitle:cityString forState:UIControlStateNormal];
self.nextPage = 1;
[self reloadDataTableViewNT:self.nextPage withCity:cityString isRecommend:@""];
}
}
if ([selectValue hasPrefix:@" "]) {
selectValue = [selectValue substringFromIndex:1];
}
self.linkage3SelectIndexs = selectIndexs;
// textField.text = selectValue;
};
//
BRPickerStyle *customStyle = [[BRPickerStyle alloc]init];
customStyle.selectRowTextFont = [UIFont boldSystemFontOfSize:20.0f];
customStyle.selectRowTextColor = [UIColor whiteColor];
stringPickerView.pickerStyle = customStyle;
[stringPickerView show];
return;
// WeakSelf(self);
// UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0,24, 24)];
// [self.view addSubview:view];
User *user = [UserService currentUser];
UITextField *locationTextField = [[UITextField alloc] init];
[self.view addSubview:locationTextField];
locationTextField.delegate = self;
locationTextField.text = user.location ?: @"选择城市-省市";
locationTextField.inputView = [MTPickerView pickerViewWithType:MTPickerViewTypeLocation defaultValues:[user.location ?: @"北京市-北京市-东城区" componentsSeparatedByString:@"-"] valueDidChange:^(NSArray<NSString *> * _Nonnull values) {
NSLog(@"改成数据.%@",values);
} done:^(NSArray<NSString *> * _Nonnull selectedValues) {
NSLog(@"选择.");
if (selectedValues.count == 3) {
[UserService updateUserToRemoteWithParams:@{
@"province": selectedValues[0]?:@"",
@"city": selectedValues[1]?:@"",
@"district": selectedValues[2]?:@"",
} completion:^(id _Nullable rsp, NSError * _Nullable error) {
if (!error) {
user.province = selectedValues[0];
user.city = selectedValues[1];
user.district = selectedValues[2];
// [weakself.contentTableView.mj_header beginRefreshing];
}else{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[SVProgressHUD showErrorWithStatus:[error.userInfo objectForKey:@"message"]];
});
}
}];
}
}];
// User *user = [UserService currentUser];
// UITextField *locationTextField = [[UITextField alloc] init];
// [self.contentTableView addSubview:locationTextField];
// locationTextField.frame = CGRectMake(0, 0, 24, 24);
// locationTextField.delegate = self;
// locationTextField.text = user.location ?: @"选择城市-省市";
// locationTextField.inputView =[MTPickerView pickerViewWithType:MTPickerViewTypeLocation defaultValues:[user.location ?: @"北京市-北京市-东城区" componentsSeparatedByString:@"-"] valueDidChange:^(NSArray<NSString *> * _Nonnull values) {
// NSLog(@"改成数据.%@",values);
// } done:^(NSArray<NSString *> * _Nonnull selectedValues) {
// NSLog(@"选择.");
// if (selectedValues.count == 3) {
// [UserService updateUserToRemoteWithParams:@{
// @"province": selectedValues[0]?:@"",
// @"city": selectedValues[1]?:@"",
// @"district": selectedValues[2]?:@"",
// } completion:^(id _Nullable rsp, NSError * _Nullable error) {
// if (!error) {
// user.province = selectedValues[0];
// user.city = selectedValues[1];
// user.district = selectedValues[2];
//// [weakself.contentTableView.mj_header beginRefreshing];
//
// }else{
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [SVProgressHUD showErrorWithStatus:[error.userInfo objectForKey:@"message"]];
// });
// }
// }];
// }
// }];
}
#pragma mark -
- (NSArray <BRResultModel *>*)getLinkag3DataSource {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"linkage3_data.json" ofType:nil];
NSData *data = [NSData dataWithContentsOfFile:filePath];
NSDictionary *responseObj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
NSMutableArray *allRegionModelArr = [[NSMutableArray alloc]init];
//
NSArray *provinceArr = responseObj[@"Result"][@"Province"];
for (NSInteger i = 0; i < provinceArr.count; i++) {
BRResultModel *model = [[BRResultModel alloc]init];
model.parentKey = @"-1";
model.parentValue = @"";
model.key = [NSString stringWithFormat:@"%@", provinceArr[i][@"ProvinceID"]];
model.value = provinceArr[i][@"Province"];
[allRegionModelArr addObject:model];
}
//
NSArray *cityArr = responseObj[@"Result"][@"City"];
for (NSInteger i = 0; i < cityArr.count; i++) {
BRResultModel *model = [[BRResultModel alloc]init];
model.parentKey = [NSString stringWithFormat:@"%@", cityArr[i][@"ProvinceID"]];
model.parentValue = @"";
model.key = [NSString stringWithFormat:@"%@", cityArr[i][@"CityID"]];
model.value = cityArr[i][@"City"];
[allRegionModelArr addObject:model];
}
//
NSArray *areaArr = responseObj[@"Result"][@"Area"];
for (NSInteger i = 0; i < areaArr.count; i++) {
BRResultModel *model = [[BRResultModel alloc]init];
model.parentKey = [NSString stringWithFormat:@"%@", areaArr[i][@"CityID"]];;
model.parentValue = @"";
model.key = [NSString stringWithFormat:@"%@", areaArr[i][@"AreaID"]];
model.value = areaArr[i][@"Area"];
[allRegionModelArr addObject:model];
}
return [allRegionModelArr copy];
}
-(void)reloadDataTableViewNT:(NSInteger)nextPage withCity:(NSString *)city isRecommend:(NSString *)isRecommend{
NSLog(@"nextPage===%zd",nextPage);
__weak typeof(self) _blockSelf = self;
NSDictionary* tempDict = [[NSUserDefaults standardUserDefaults]objectForKey:@"UserNearbyShaiXuanParamDict"];
if (!tempDict) {
_nearbyParamDict = [NSMutableDictionary dictionaryWithDictionary:@{}];
}else{
_nearbyParamDict = [NSMutableDictionary dictionaryWithDictionary:tempDict];
NSString* vipStr = _nearbyParamDict[@"vip"];
NSString* onlineStr = _nearbyParamDict[@"online"];
NSString* newStr = _nearbyParamDict[@"new"];
// NSString* city = _nearbyParamDict[@"city"];
_nearbyParamDict[@"vip"] = [NSNumber numberWithInteger:vipStr.integerValue];
_nearbyParamDict[@"online"] = [NSNumber numberWithInteger:onlineStr.integerValue];
_nearbyParamDict[@"new"] = [NSNumber numberWithInteger:newStr.integerValue];
_nearbyParamDict[@"version"] = @"1";
_nearbyParamDict[@"isRecommend"] = isRecommend;
//
// _nearbyParamDict[@"version"]
_nearbyParamDict[@"city"] = city ?: @"全国";
}
_nearbyParamDict[@"page"] = [NSNumber numberWithInteger:nextPage];
2023-07-27 18:25:18 +08:00
_nearbyParamDict[@"perpage"] = @(10);
2023-07-27 09:20:00 +08:00
NSLog(@"_nearbyParamDict : %@",_nearbyParamDict);
// NSData *data = [NSJSONSerialization dataWithJSONObject:_nearbyParamDict options:NSJSONWritingPrettyPrinted error:nil];
// [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"_nearbyParamDict : %@ \n data.length : %lu",_nearbyParamDict,(unsigned long)data.length]];
[PYHTTPManager postWithPath:@"usernearby1" params:_nearbyParamDict callback:^(id _Nullable rsp, NSError * _Nullable error) {
// NSLog(@"是的rsp : %@==%@",rsp[@"isRecommend"],error);
if (!error) {
[[NSUserDefaults standardUserDefaults]setObject:rsp[@"isRecommend"] forKey:@"isRecommend"];
[[NSUserDefaults standardUserDefaults] synchronize];
if (nextPage == 1) {
_blockSelf.tableMDataArray = [NSMutableArray arrayWithArray:@[]];
}
NSArray* listArray = rsp[@"list"];
if (![listArray isKindOfClass:[NSNull class]]) {
if(listArray.count == 0){
[SVProgressHUD showErrorWithStatus:@"暂时没有更多数据"];
return;
}
}else{
[SVProgressHUD showErrorWithStatus:@"暂时没有更多数据"];
return;
}
_blockSelf.nextPage ++;
[_blockSelf.tableMDataArray addObjectsFromArray:[userNearbyModel mj_objectArrayWithKeyValuesArray:listArray]];
NSMutableArray *newArray = [NSMutableArray array];
for (int i = 0; i < _blockSelf.tableMDataArray.count; i++) {
userNearbyModel *tempModel = _blockSelf.tableMDataArray[i];
if (![newArray containsObject:tempModel]) {
[newArray addObject:tempModel];
NSLog(@"user_local==%@",tempModel.user_local);
}else{
NSLog(@"有相同数据.");
}
}
_blockSelf.tableMDataArray = newArray;
}
[_blockSelf.contentTableView reloadData];
[_blockSelf.contentTableView.mj_header endRefreshing];
[_blockSelf.contentTableView.mj_footer endRefreshing];
}];
}
-(void)shaiXuanClick{
// NSLog(@"筛选.");
BottleUserNearbyShaiXuanAlertView* alertView = [[BottleUserNearbyShaiXuanAlertView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
WeakSelf(self);
alertView.sureClickBlock = ^(NSDictionary * _Nonnull dict) {
NSLog(@"dataDict SureClickBlock:%@",dict);
if ([dict[@"sx_gender"] isEqualToString:@"全部"]) {
weakself.nearbyParamDict[@"gender_str"] = @"";
}else{
weakself.nearbyParamDict[@"gender_str"] = dict[@"sx_gender"] ;
}
if ([dict[@"sx_age"] isEqualToString:@"全部"]) {
weakself.nearbyParamDict[@"age"] = @"";
}else{
weakself.nearbyParamDict[@"age"] = dict[@"sx_age"];
}
NSString *usDefaultCity = [[NSUserDefaults standardUserDefaults]objectForKey:@"nearCity"];
NSString *city;
if (usDefaultCity) {
city = usDefaultCity;
}else{
city = @"";
}
if ([dict[@"sx_gjsx"] isEqualToString:@"全部"]) {
weakself.nearbyParamDict[@"online"] = @"1";
weakself.nearbyParamDict[@"new"] = @"1";
weakself.nearbyParamDict[@"vip"] = @"1";
weakself.nearbyParamDict[@"city"] = city;
[weakself.nearbyParamDict removeObjectForKey:@"online"];
[weakself.nearbyParamDict removeObjectForKey:@"new"];
[weakself.nearbyParamDict removeObjectForKey:@"vip"];
}else if ([dict[@"sx_gjsx"] isEqualToString:@"VIP"]) {
weakself.nearbyParamDict[@"online"] = @"0";
weakself.nearbyParamDict[@"new"] = @"0";
weakself.nearbyParamDict[@"vip"] = @"1";
weakself.nearbyParamDict[@"city"] = city;
[weakself.nearbyParamDict removeObjectForKey:@"new"];
[weakself.nearbyParamDict removeObjectForKey:@"online"];
}else if ([dict[@"sx_gjsx"] isEqualToString:@"在线"]) {
weakself.nearbyParamDict[@"online"] = @"1";
weakself.nearbyParamDict[@"new"] = @"0";
weakself.nearbyParamDict[@"vip"] = @"0";
weakself.nearbyParamDict[@"city"] = city;
[weakself.nearbyParamDict removeObjectForKey:@"new"];
[weakself.nearbyParamDict removeObjectForKey:@"vip"];
}else if ([dict[@"sx_gjsx"] isEqualToString:@"新人"]) {
weakself.nearbyParamDict[@"online"] = @"0";
weakself.nearbyParamDict[@"new"] = @"1";
weakself.nearbyParamDict[@"vip"] = @"0";
weakself.nearbyParamDict[@"city"] = city;
[weakself.nearbyParamDict removeObjectForKey:@"online"];
[weakself.nearbyParamDict removeObjectForKey:@"vip"];
}
weakself.shaiXuanDict = dict;
[[NSUserDefaults standardUserDefaults]setObject:weakself.nearbyParamDict forKey:@"UserNearbyShaiXuanParamDict"];
[[NSUserDefaults standardUserDefaults] synchronize];
self.nextPage = 1;
[weakself reloadDataTableViewNT:self.nextPage withCity:city isRecommend:@""];
// [weakself.contentTableView.mj_header beginRefreshing];
};
[[ZcqVender theTopviewControler].view addSubview:alertView];
}
-(UITableView *)contentTableView{
if(!_contentTableView){
_contentTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.qmui_navigationBarMaxYInViewCoordinator, SCREEN_WIDTH, SCREEN_HEIGHT - self.qmui_navigationBarMaxYInViewCoordinator) style:UITableViewStyleGrouped];
_contentTableView.scrollEnabled = NO;
_contentTableView.backgroundColor = [UIColor clearColor];
_contentTableView.delegate = self;
_contentTableView.dataSource = self;
_contentTableView.scrollEnabled = YES;
_contentTableView.showsVerticalScrollIndicator = NO;
_contentTableView.showsHorizontalScrollIndicator = NO;
_contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_contentTableView.contentInset = UIEdgeInsetsZero;
2023-07-27 18:25:18 +08:00
// _contentTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
2023-07-27 09:20:00 +08:00
if (@available(iOS 11.0, *)) {
} else {
// Fallback on earlier versions
}//
[_contentTableView registerClass:[BottleUserNearbyTableViewCell class] forCellReuseIdentifier:@"BottleUserNearbyTableViewCell"];
}
return _contentTableView;
}
-(SDCycleScrollView *)cycleScrollView{
if (!_cycleScrollView) {
_cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(17, 10, SCREEN_WIDTH - 34, (SCREEN_WIDTH - 34)*0.45-5) imageNamesGroup:@[@"TH_nearbyBanner00", @"TH_nearbyBanner01", @"TH_nearbyBanner02", @"TH_nearbyBanner03"]];
_cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
2023-07-27 18:25:18 +08:00
_cycleScrollView.autoScrollTimeInterval = 6;
2023-07-27 09:20:00 +08:00
_cycleScrollView.currentPageDotColor = COLOR_WITH_RGB(0xFFFFFF);
_cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
_cycleScrollView.pageDotColor =COLOR_WITH_RGB_A(0x000000, 0.7);
// _cycleScrollView.showPageControl
// UIPageControlContentView
_cycleScrollView.delegate = self;
_cycleScrollView.backgroundColor = [UIColor whiteColor];
_cycleScrollView.layer.cornerRadius = 8;
_cycleScrollView.layer.masksToBounds = YES;
}
return _cycleScrollView;
}
-(UIView *)topHeaderView{
if (!_topHeaderView) {
_topHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.cycleScrollView.qmui_height + 20)];
_topHeaderView.contentMode = UIViewContentModeScaleAspectFill;
[_topHeaderView addSubview:self.cycleScrollView];
}
return _topHeaderView;
}
-(UIView *)openVipAlertView{
if (!_openVipAlertView) {
2023-07-27 18:25:18 +08:00
// float tabBarHeight = isIphoneX?83:48 + 44 - 44;
_openVipAlertView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200)];
2023-07-27 09:20:00 +08:00
_openVipAlertView.backgroundColor = COLOR_WITH_RGB_A(0x000000, 0.8);
UILabel* titleLab = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH, 28)];
titleLab.text = @"数十万同好等您查看";
titleLab.textAlignment = NSTextAlignmentCenter;
titleLab.font = MT_FONT_BOLD_NO_SCALE_SIZE(20);
titleLab.textColor = COLOR_WITH_RGB(0xFFFFFF);
[_openVipAlertView addSubview:titleLab];
UILabel* subTitleLab = [[UILabel alloc]initWithFrame:CGRectMake(0, titleLab.bottom + 20, SCREEN_WIDTH, 60)];
subTitleLab.text = @"开通VIP后才能查看更多附近的同好也可以根据您的喜好、年龄等筛选想要认识的人还可以获得其他九大会员特权拥有更多不一样的体验~";
subTitleLab.textAlignment = NSTextAlignmentCenter;
subTitleLab.numberOfLines = 0;
subTitleLab.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(14);
subTitleLab.textColor = COLOR_WITH_RGB(0xFFFFFF);
[_openVipAlertView addSubview:subTitleLab];
UIButton* openVipBtn = [[UIButton alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 132)/2.0, subTitleLab.bottom + 20, 132, 36)];
[openVipBtn setTitle:@"前往开通VIP" forState:UIControlStateNormal];
[openVipBtn setTitleColor:COLOR_WITH_RGB(0x000000) forState:UIControlStateNormal];
openVipBtn.titleLabel.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(14);
openVipBtn.backgroundColor = COLOR_WITH_RGB(0xFFB902);
openVipBtn.layer.cornerRadius = 18;
openVipBtn.layer.masksToBounds = YES;
[openVipBtn addTarget:self action:@selector(openVipBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[_openVipAlertView addSubview:openVipBtn];
}
return _openVipAlertView;
}
2023-07-27 18:25:18 +08:00
- (THLVTipView *)lvTipView {
if (_lvTipView == nil) {
NSArray * xibArray = [[NSBundle mainBundle]loadNibNamed:NSStringFromClass(THLVTipView.class) owner:nil options:nil] ;
_lvTipView = xibArray[0];
_lvTipView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 60);
}
return _lvTipView;
}
2023-07-27 09:20:00 +08:00
-(void)openVipBtnClick:(UIButton*)sender{
[PYAppService showVipVC:@"vip_page"];
}
#pragma mark -tableViewDelegate
//
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return _tableMDataArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
2023-07-27 18:25:18 +08:00
if (section == 0) {
return 60;
}
2023-07-27 09:20:00 +08:00
return 5;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
2023-07-27 18:25:18 +08:00
if (section == 0) {
return self.lvTipView;
}
2023-07-27 09:20:00 +08:00
return [UIView new];
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
2023-07-27 18:25:18 +08:00
if ([UserService currentUser].isVIP) {
return 0.01;
}
return 200;
2023-07-27 09:20:00 +08:00
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
2023-07-27 18:25:18 +08:00
if (![UserService currentUser].isVIP) {
return self.openVipAlertView;
}
2023-07-27 09:20:00 +08:00
return [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 20)];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
userNearbyModel* model = _tableMDataArray[indexPath.row];
if(model.user_photo.length > 0){
return 172 + 15 - 83 + FIX_SIZE(83);
}else{
return 75 + 15;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
userNearbyModel* model = _tableMDataArray[indexPath.row];
[PYAppService showUserCardVCWithUserID:[UserService userIDFromIMUserID:model.nearbyId].intValue];
}
//cell
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
BottleUserNearbyTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"BottleUserNearbyTableViewCell"];
if (!cell) {
cell = [[BottleUserNearbyTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BottleUserNearbyTableViewCell"];
}
cell.shaiXuanDict = _shaiXuanDict;
cell.dataModel = _tableMDataArray[indexPath.row];
return cell;
}
//.
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
CLLocation* location = [locations lastObject];
CLLocationDegrees lat = location.coordinate.latitude;
CLLocationDegrees lng = location.coordinate.longitude;
NSDictionary* tempDict = [[NSUserDefaults standardUserDefaults]objectForKey:@"UserNearbyShaiXuanParamDict"];
if (!tempDict) {
_nearbyParamDict = [NSMutableDictionary dictionaryWithDictionary:@{}];
}else{
_nearbyParamDict = [NSMutableDictionary dictionaryWithDictionary:tempDict];
}
_nearbyParamDict[@"lat"] = [NSNumber numberWithFloat:lat];
_nearbyParamDict[@"lng"] = [NSNumber numberWithFloat:lng];
[[NSUserDefaults standardUserDefaults]setObject:_nearbyParamDict forKey:@"UserNearbyShaiXuanParamDict"];
[self.contentTableView.mj_header beginRefreshing];
[_cLLocationManager stopUpdatingLocation];
}
//SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
if (self.bannerArr.count >= index) {
NSString *url = self.bannerArr[index][@"link"];
if ([url isEqualToString: @"https://ikuayou.com/"]) {
UIApplication *app = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:url];
if ([app canOpenURL:URL]) {
if (@available(iOS 10.0,*)) {
[app openURL:URL options:@{} completionHandler:nil];
} else {
[app openURL:URL];
}
}
} else {
[PYAppService openWebVCWithTitle:self.bannerArr[index][@"title"] url:url];
}
}
// NSArray* dataArray = @[
// @{@"title":@"产品介绍",@"urlStr":@"https://iquanpai.com/app-h5/4_141.html"},
// @{@"title":@"文明公约",@"urlStr":@"https://iquanpai.com/app-h5/4_142.html"},
// @{@"title":@"精选推荐",@"urlStr":@"https://iquanpai.com/app-h5/4_143.html"},
// @{@"title":@"谨防诈骗",@"urlStr":@"https://iquanpai.com/app-h5/4_152.html"},
// ];
// NSDictionary* dataDict = dataArray[index];
// [PYAppService openWebVCWithTitle:dataDict[@"title"] url:dataDict[@"urlStr"]];
}
@end