发现新朋友接口接入
This commit is contained in:
@@ -129,6 +129,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/// @param completion 完成
|
/// @param completion 完成
|
||||||
+ (void)homeGiftRecordList:(HttpRequestHelperCompletion)completion;
|
+ (void)homeGiftRecordList:(HttpRequestHelperCompletion)completion;
|
||||||
|
|
||||||
|
/// 发现新朋友列表
|
||||||
|
/// @param complection 完成
|
||||||
|
/// @param gender 性别. 1:男性 2:女性 null:不限定
|
||||||
|
+ (void)getNewFriendListcomplection:(HttpRequestHelperCompletion)complection gender:(NSString *)gender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -165,4 +165,11 @@
|
|||||||
[self makeRequest:@"home/service/gift/record" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
|
[self makeRequest:@"home/service/gift/record" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 发现新朋友列表
|
||||||
|
/// @param complection 完成
|
||||||
|
/// @param gender 性别. 1:男性 2:女性 null:不限定
|
||||||
|
+ (void)getNewFriendListcomplection:(HttpRequestHelperCompletion)complection gender:(NSString *)gender {
|
||||||
|
[self makeRequest:@"home/newFriend" method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, gender, nil];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -25,6 +25,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@property (nonatomic, copy) NSString *giftNum;
|
@property (nonatomic, copy) NSString *giftNum;
|
||||||
@property (nonatomic, copy) NSString *giftPicUrl;
|
@property (nonatomic, copy) NSString *giftPicUrl;
|
||||||
|
|
||||||
|
/// 自定义字段
|
||||||
|
/// 是否是空占位模型
|
||||||
|
@property (nonatomic, assign) BOOL isEmpty;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -24,6 +24,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/// 获取派对推荐列表
|
/// 获取派对推荐列表
|
||||||
- (void)getPartyRecommendRoomList;
|
- (void)getPartyRecommendRoomList;
|
||||||
|
|
||||||
|
/// 请求发现新朋友
|
||||||
|
/// @param gender 性别
|
||||||
|
- (void)getNewFriendListWithGender:(nullable NSString *)gender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#import "AccountInfoStorage.h"
|
#import "AccountInfoStorage.h"
|
||||||
///Model
|
///Model
|
||||||
#import "HomeRecommendRoomModel.h"
|
#import "HomeRecommendRoomModel.h"
|
||||||
|
#import "UserInfoModel.h"
|
||||||
///P
|
///P
|
||||||
#import "XPHomeProtocol.h"
|
#import "XPHomeProtocol.h"
|
||||||
@implementation XPHomePresenter
|
@implementation XPHomePresenter
|
||||||
@@ -78,4 +79,14 @@
|
|||||||
}] uid:uid];
|
}] uid:uid];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 发现新朋友
|
||||||
|
- (void)getNewFriendListWithGender:(nullable NSString *)gender {
|
||||||
|
[Api getNewFriendListcomplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||||
|
NSArray * array = [UserInfoModel modelsWithArray:data.data];
|
||||||
|
[[self getView] getNewFriendListSuccess:array];
|
||||||
|
}fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||||
|
[[self getView] getNewFriendListFail];
|
||||||
|
}] gender:gender];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -22,6 +22,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
- (void)getPartyRecommendRoomListSuccess:(NSArray *)list;
|
- (void)getPartyRecommendRoomListSuccess:(NSArray *)list;
|
||||||
///获取派对数据失败
|
///获取派对数据失败
|
||||||
- (void)getPartyRecommendDataFail;
|
- (void)getPartyRecommendDataFail;
|
||||||
|
///获取发现新朋友列表成功
|
||||||
|
- (void)getNewFriendListSuccess:(NSArray *)list;
|
||||||
|
///获取发现新朋友列表失败
|
||||||
|
- (void)getNewFriendListFail;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#import "XPCycleVerticalView.h"
|
#import "XPCycleVerticalView.h"
|
||||||
#import "XPCycleView.h"
|
#import "XPCycleView.h"
|
||||||
|
#import "XPHomeGiftRecordModel.h"
|
||||||
|
|
||||||
@interface XPCycleVerticalView () {
|
@interface XPCycleVerticalView () {
|
||||||
CGRect _topRect; //上View
|
CGRect _topRect; //上View
|
||||||
@@ -107,7 +108,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDataArray:(NSArray<XPHomeGiftRecordModel*> *)dataArray {
|
- (void)setDataArray:(NSArray<XPHomeGiftRecordModel*> *)dataArray {
|
||||||
_dataArray = dataArray;
|
if (dataArray.count == 0) {
|
||||||
|
XPHomeGiftRecordModel *model = [[XPHomeGiftRecordModel alloc] init];
|
||||||
|
model.isEmpty = YES;
|
||||||
|
_dataArray = @[model];
|
||||||
|
}else{
|
||||||
|
_dataArray = dataArray;
|
||||||
|
}
|
||||||
if (![_timer isValid]) {
|
if (![_timer isValid]) {
|
||||||
_indexNow = 0;
|
_indexNow = 0;
|
||||||
[self startAnimation];
|
[self startAnimation];
|
||||||
|
@@ -74,6 +74,7 @@
|
|||||||
|
|
||||||
- (void)setInfoModel:(XPHomeGiftRecordModel *)infoModel {
|
- (void)setInfoModel:(XPHomeGiftRecordModel *)infoModel {
|
||||||
_infoModel = infoModel;
|
_infoModel = infoModel;
|
||||||
|
self.stackView.hidden = _infoModel.isEmpty;
|
||||||
self.senderAvatarImageView.imageUrl = infoModel.senderAvatar;
|
self.senderAvatarImageView.imageUrl = infoModel.senderAvatar;
|
||||||
self.senderNameLabel.text = infoModel.senderNick;
|
self.senderNameLabel.text = infoModel.senderNick;
|
||||||
self.receiverAvatarImageView.imageUrl = infoModel.receiverAvatar;
|
self.receiverAvatarImageView.imageUrl = infoModel.receiverAvatar;
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@class HomeRecommendRoomModel;
|
@class UserInfoModel;
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@protocol XPFindNewFriendTableViewCellDelegate <NSObject>
|
@protocol XPFindNewFriendTableViewCellDelegate <NSObject>
|
||||||
@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@interface XPFindNewFriendTableViewCell : UITableViewCell
|
@interface XPFindNewFriendTableViewCell : UITableViewCell
|
||||||
|
|
||||||
@property (nonatomic, strong) HomeRecommendRoomModel *roomInfo;
|
@property (nonatomic, strong) UserInfoModel *roomInfo;
|
||||||
|
|
||||||
@property (nonatomic, weak) id<XPFindNewFriendTableViewCellDelegate> delegate;
|
@property (nonatomic, weak) id<XPFindNewFriendTableViewCellDelegate> delegate;
|
||||||
|
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
#import "NetImageView.h"
|
#import "NetImageView.h"
|
||||||
#import "ThemeColor.h"
|
#import "ThemeColor.h"
|
||||||
#import "XPButton.h"
|
#import "XPButton.h"
|
||||||
|
/// Model
|
||||||
|
#import "UserInfoModel.h"
|
||||||
|
|
||||||
@interface XPFindNewFriendTableViewCell()
|
@interface XPFindNewFriendTableViewCell()
|
||||||
/// 背景
|
/// 背景
|
||||||
@@ -24,7 +26,7 @@
|
|||||||
@property (nonatomic, strong) UIImageView *onlineImageView;
|
@property (nonatomic, strong) UIImageView *onlineImageView;
|
||||||
@property (nonatomic, strong) UIStackView *nameStackView;
|
@property (nonatomic, strong) UIStackView *nameStackView;
|
||||||
/// 贵族图标
|
/// 贵族图标
|
||||||
@property (nonatomic, strong) UIImageView *nobleImageView;
|
@property (nonatomic, strong) NetImageView *nobleImageView;
|
||||||
/// 昵称
|
/// 昵称
|
||||||
@property (nonatomic, strong) UILabel *nickLabel;
|
@property (nonatomic, strong) UILabel *nickLabel;
|
||||||
@property (nonatomic, strong) UIStackView *constellationStackView;
|
@property (nonatomic, strong) UIStackView *constellationStackView;
|
||||||
@@ -140,6 +142,7 @@
|
|||||||
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.left.mas_equalTo(self.nameStackView);
|
make.left.mas_equalTo(self.nameStackView);
|
||||||
make.bottom.mas_equalTo(self.avatarImageView.mas_bottom).offset(-4);
|
make.bottom.mas_equalTo(self.avatarImageView.mas_bottom).offset(-4);
|
||||||
|
make.right.mas_equalTo(self.livingView.mas_left).offset(-10);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self.livingView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.livingView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
@@ -158,19 +161,118 @@
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - 计算星座
|
||||||
|
-(NSInteger) getMonth:(long )time
|
||||||
|
{
|
||||||
|
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
|
||||||
|
NSCalendar* calendar = [NSCalendar currentCalendar];
|
||||||
|
NSDateComponents* components = [calendar components:NSCalendarUnitMonth fromDate:date];
|
||||||
|
NSInteger month = components.month;
|
||||||
|
return month;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSInteger) getDay:(long) time
|
||||||
|
{
|
||||||
|
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
|
||||||
|
NSCalendar* calendar = [NSCalendar currentCalendar];
|
||||||
|
NSDateComponents* components = [calendar components:NSCalendarUnitDay fromDate:date];
|
||||||
|
NSInteger day = components.day;
|
||||||
|
return day;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)calculateConstellationWithMonth:(long)time
|
||||||
|
{
|
||||||
|
NSString *astroString = @"魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
|
||||||
|
NSString *astroFormat = @"102123444543";
|
||||||
|
NSString *result;
|
||||||
|
|
||||||
|
NSInteger month = [self getMonth:time];
|
||||||
|
NSInteger day = [self getDay:time];
|
||||||
|
|
||||||
|
if (month<1 || month>12 || day<1 || day>31){
|
||||||
|
return @"错误日期格式!";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(month==2 && day>29)
|
||||||
|
{
|
||||||
|
return @"错误日期格式!!";
|
||||||
|
}else if(month==4 || month==6 || month==9 || month==11) {
|
||||||
|
if (day>30) {
|
||||||
|
return @"错误日期格式!!!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result=[NSString stringWithFormat:@"%@",[astroString substringWithRange:NSMakeRange(month*2-(day < [[astroFormat substringWithRange:NSMakeRange((month-1), 1)] intValue] - (-19))*2,2)]];
|
||||||
|
|
||||||
|
return [NSString stringWithFormat:@"%@座",result];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)calculateAge:(long)time {
|
||||||
|
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
|
||||||
|
NSCalendar *birthCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierISO8601];
|
||||||
|
NSDateComponents *birthCompomemts = [birthCalendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitWeekday | NSCalendarUnitDay fromDate:date];
|
||||||
|
NSInteger year = birthCompomemts.year;
|
||||||
|
NSInteger month = birthCompomemts.month;
|
||||||
|
NSInteger day = birthCompomemts.day;
|
||||||
|
NSLog(@"出生于%ld年%ld月%ld日", year, month, day);
|
||||||
|
|
||||||
|
NSDate *nowDate = [NSDate date];
|
||||||
|
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierISO8601];
|
||||||
|
NSDateComponents *compomemts = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitWeekday | NSCalendarUnitDay fromDate:nowDate];
|
||||||
|
NSInteger nowYear = compomemts.year;
|
||||||
|
NSInteger nowMonth = compomemts.month;
|
||||||
|
NSInteger nowDay = compomemts.day;
|
||||||
|
NSLog(@"今天是%ld年%ld月%ld日", nowYear, nowMonth, nowDay);
|
||||||
|
|
||||||
|
// 计算年龄
|
||||||
|
NSInteger userAge = nowYear - year - 1;
|
||||||
|
if ((nowMonth > month) || (nowMonth == month && nowDay >= day)) {
|
||||||
|
userAge++;
|
||||||
|
}
|
||||||
|
NSLog(@"用户年龄是%ld",userAge);
|
||||||
|
return [NSString stringWithFormat:@"%ld", userAge];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Getters And Setters
|
#pragma mark - Getters And Setters
|
||||||
|
|
||||||
- (void)setRoomInfo:(HomeRecommendRoomModel *)roomInfo {
|
- (void)setRoomInfo:(UserInfoModel *)roomInfo {
|
||||||
self.nobleImageView.hidden = YES;
|
self.nickLabel.text = roomInfo.nick;
|
||||||
self.nickLabel.text = @"用户昵称";
|
if (roomInfo.gender == GenderType_Female) {
|
||||||
[self.sexBtn setImage:[UIImage imageNamed:@"home_sex_female"] forState:UIControlStateNormal];
|
[self.sexBtn setImage:[UIImage imageNamed:@"home_sex_female"] forState:UIControlStateNormal];
|
||||||
self.sexBtn.backgroundColor = [ThemeColor colorWithHexString:@"#FF9CCE"];
|
self.sexBtn.backgroundColor = [ThemeColor colorWithHexString:@"#FF9CCE"];
|
||||||
[self.sexBtn setTitle:@"22" forState:UIControlStateNormal];
|
}else{
|
||||||
self.constellationLabel.text = @"巨蟹座";
|
[self.sexBtn setImage: [UIImage imageNamed:@"home_sex_man"] forState:UIControlStateNormal];
|
||||||
self.signLabel.text = @"我是个默认的个性签名";
|
self.sexBtn.backgroundColor = [ThemeColor colorWithHexString:@"#65D3F7"];
|
||||||
self.livingView.hidden = NO;
|
}
|
||||||
self.statusLabel.text = @"直播中";
|
if (roomInfo.birth) {
|
||||||
// self.statusLabel.text = @"和TA聊";
|
self.constellationLabel.text = [self calculateConstellationWithMonth:roomInfo.birth];
|
||||||
|
[self.sexBtn setTitle:[self calculateAge:roomInfo.birth] forState:UIControlStateNormal];
|
||||||
|
}else{
|
||||||
|
self.constellationLabel.text = @"";
|
||||||
|
[self.sexBtn setTitle:@"0" forState:UIControlStateNormal];
|
||||||
|
}
|
||||||
|
self.signLabel.text = roomInfo.userDesc;
|
||||||
|
if (roomInfo.roomUid.length <= 0) {
|
||||||
|
self.livingView.hidden = YES;
|
||||||
|
self.statusLabel.text = @"和TA聊";
|
||||||
|
self.chatImageView.hidden = NO;
|
||||||
|
}else{
|
||||||
|
self.livingView.hidden = NO;
|
||||||
|
self.statusLabel.text = @"直播中";
|
||||||
|
self.chatImageView.hidden = YES;
|
||||||
|
}
|
||||||
|
if (roomInfo.userVipInfoVO) {
|
||||||
|
self.nobleImageView.hidden = NO;
|
||||||
|
self.nobleImageView.imageUrl = roomInfo.userVipInfoVO.vipIcon;
|
||||||
|
if (roomInfo.userVipInfoVO.friendNickColour) {
|
||||||
|
self.nickLabel.textColor = [ThemeColor colorWithHexString:roomInfo.userVipInfoVO.friendNickColour];
|
||||||
|
}else{
|
||||||
|
self.nickLabel.textColor = [ThemeColor mainTextColor];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.nobleImageView.hidden = YES;
|
||||||
|
self.nickLabel.textColor = [ThemeColor mainTextColor];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIView *)bgView {
|
- (UIView *)bgView {
|
||||||
@@ -221,9 +323,9 @@
|
|||||||
return _nameStackView;
|
return _nameStackView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIImageView *)nobleImageView {
|
- (NetImageView *)nobleImageView {
|
||||||
if (!_nobleImageView) {
|
if (!_nobleImageView) {
|
||||||
_nobleImageView = [[UIImageView alloc] init];
|
_nobleImageView = [[NetImageView alloc] init];
|
||||||
_nobleImageView.contentMode = UIViewContentModeScaleAspectFit;
|
_nobleImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||||
}
|
}
|
||||||
return _nobleImageView;
|
return _nobleImageView;
|
||||||
|
@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@interface XPFindNewFriendViewController : MvpViewController<JXPagerViewListViewDelegate>
|
@interface XPFindNewFriendViewController : MvpViewController<JXPagerViewListViewDelegate>
|
||||||
|
|
||||||
/// 给首页调用定时刷新数据
|
/// 给首页调用定时刷新数据
|
||||||
- (void)refreshData;
|
- (void)refreshData:(nullable NSString *)gender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
#import "XPRoomViewController.h"
|
#import "XPRoomViewController.h"
|
||||||
#import "SessionViewController.h"
|
#import "SessionViewController.h"
|
||||||
///Model
|
///Model
|
||||||
#import "HomeRecommendRoomModel.h"
|
#import "UserInfoModel.h"
|
||||||
///P
|
///P
|
||||||
#import "XPHomePresenter.h"
|
#import "XPHomePresenter.h"
|
||||||
#import "XPHomeProtocol.h"
|
#import "XPHomeProtocol.h"
|
||||||
@@ -38,7 +38,6 @@
|
|||||||
@property (nonatomic,assign) int page;
|
@property (nonatomic,assign) int page;
|
||||||
/// 没有新的数据了
|
/// 没有新的数据了
|
||||||
@property (nonatomic,assign) BOOL hasNoMoreData;
|
@property (nonatomic,assign) BOOL hasNoMoreData;
|
||||||
@property (nonatomic,assign) NSString *tabId;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -56,49 +55,22 @@
|
|||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
[self initSubViews];
|
[self initSubViews];
|
||||||
[self initSubViewConstraints];
|
[self initSubViewConstraints];
|
||||||
self.tabId = @"3";
|
[self refreshData:nil];
|
||||||
[self initHeaderAndFooterRrfresh];
|
}
|
||||||
|
|
||||||
|
#pragma mark - InitHttp
|
||||||
|
|
||||||
|
- (void)requestData:(nullable NSString *)gender {
|
||||||
|
[self.presenter getNewFriendListWithGender:gender];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 刷新数据,可见时才调用
|
/// 刷新数据,可见时才调用
|
||||||
- (void)refreshData {
|
- (void)refreshData:(nullable NSString *)gender {
|
||||||
if (self.isViewLoaded && self.view.window) {
|
if (self.isViewLoaded && self.view.window) {
|
||||||
[self headerRefresh];
|
[self requestData:gender];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)initHeaderAndFooterRrfresh {
|
|
||||||
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
|
|
||||||
header.stateLabel.font = [UIFont systemFontOfSize:10.0];
|
|
||||||
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0];
|
|
||||||
header.stateLabel.textColor = [ThemeColor secondTextColor];
|
|
||||||
header.lastUpdatedTimeLabel.textColor = [ThemeColor secondTextColor];
|
|
||||||
self.tableView.mj_header = header;
|
|
||||||
|
|
||||||
MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
|
|
||||||
footer.stateLabel.textColor = [ThemeColor secondTextColor];
|
|
||||||
footer.stateLabel.font = [UIFont systemFontOfSize:10.0];
|
|
||||||
self.tableView.mj_footer = footer;
|
|
||||||
|
|
||||||
[self headerRefresh];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - 刷新的fangfa
|
|
||||||
- (void)headerRefresh {
|
|
||||||
self.page = 1;
|
|
||||||
[self.presenter getRecommendRoomList:self.tabId page:self.page pageSize:20 state:0];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)footerRefresh {
|
|
||||||
if (self.hasNoMoreData) {
|
|
||||||
[self showErrorToast:@"没有更多房间了"];
|
|
||||||
[self.tableView.mj_footer endRefreshing];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.page++;
|
|
||||||
[self.presenter getRecommendRoomList:self.tabId page:self.page pageSize:20 state:1];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Private Method
|
#pragma mark - Private Method
|
||||||
- (void)initSubViews {
|
- (void)initSubViews {
|
||||||
self.view.backgroundColor = [UIColor clearColor];
|
self.view.backgroundColor = [UIColor clearColor];
|
||||||
@@ -116,29 +88,15 @@
|
|||||||
|
|
||||||
|
|
||||||
#pragma mark - XPHomeProtocol
|
#pragma mark - XPHomeProtocol
|
||||||
- (void)getHomeRecommendRoomListSuccess:(NSArray *)list state:(BOOL)state {
|
|
||||||
if (state == 0) {
|
- (void)getNewFriendListSuccess:(NSArray *)list {
|
||||||
self.hasNoMoreData = NO;
|
[self.dataSource removeAllObjects];
|
||||||
[self.dataSource removeAllObjects];
|
[self.dataSource addObjectsFromArray:list];
|
||||||
[self.tableView.mj_header endRefreshing];
|
|
||||||
} else {
|
|
||||||
[self.tableView.mj_footer endRefreshing];
|
|
||||||
}
|
|
||||||
if (list.count > 0) {
|
|
||||||
self.hasNoMoreData = NO;
|
|
||||||
[self.dataSource addObjectsFromArray:list];
|
|
||||||
} else {
|
|
||||||
self.hasNoMoreData = YES;
|
|
||||||
}
|
|
||||||
[self.tableView reloadData];
|
[self.tableView reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)getHomeRecommendRoomListFail:(NSString *)message state:(BOOL)state {
|
- (void)getNewFriendListFail {
|
||||||
if (state == 0) {
|
|
||||||
[self.tableView.mj_header endRefreshing];
|
|
||||||
} else {
|
|
||||||
[self.tableView.mj_footer endRefreshing];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||||||
@@ -156,7 +114,7 @@
|
|||||||
|
|
||||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
if (self.dataSource.count > 0) {
|
if (self.dataSource.count > 0) {
|
||||||
HomeRecommendRoomModel * model = [self.dataSource safeObjectAtIndex1:indexPath.row];
|
UserInfoModel * model = [self.dataSource safeObjectAtIndex1:indexPath.row];
|
||||||
XPFindNewFriendTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPFindNewFriendTableViewCell class])];
|
XPFindNewFriendTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPFindNewFriendTableViewCell class])];
|
||||||
cell.roomInfo = model;
|
cell.roomInfo = model;
|
||||||
cell.delegate = self;
|
cell.delegate = self;
|
||||||
@@ -172,10 +130,10 @@
|
|||||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||||
if (self.dataSource.count > 0) {
|
if (self.dataSource.count > 0) {
|
||||||
HomeRecommendRoomModel * model = [self.dataSource safeObjectAtIndex1:indexPath.row];
|
UserInfoModel *model = [self.dataSource safeObjectAtIndex1:indexPath.row];
|
||||||
if (model.roomUid.integerValue > 0) {
|
// if (model.roomUid.integerValue > 0) {
|
||||||
[XPRoomViewController openRoom:model.uid fromNick:model.title fromType:UserEnterRoomFromType_Home_Recommend fromUid:nil viewController:self];
|
// [XPRoomViewController openRoom:model.uid fromNick:model.title fromType:UserEnterRoomFromType_Home_Recommend fromUid:nil viewController:self];
|
||||||
}
|
// }
|
||||||
/// 跳聊天
|
/// 跳聊天
|
||||||
// NSString * sessionId = [NSString stringWithFormat:@"%@",model.uid];
|
// NSString * sessionId = [NSString stringWithFormat:@"%@",model.uid];
|
||||||
// NIMSession * session = [NIMSession session:sessionId type:NIMSessionTypeP2P];
|
// NIMSession * session = [NIMSession session:sessionId type:NIMSessionTypeP2P];
|
||||||
|
@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@interface XPNewHomeFilterView : UIView
|
@interface XPNewHomeFilterView : UIView
|
||||||
|
|
||||||
/// 选择的下标
|
/// 选择的下标
|
||||||
@property (nonatomic, copy) void (^ selectBlock)(NSUInteger index, NSString *title);
|
@property (nonatomic, copy) void (^selectBlock)(NSString *gender, NSString *title);
|
||||||
|
|
||||||
/// 添加筛选视图
|
/// 添加筛选视图
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
|
@@ -81,7 +81,13 @@
|
|||||||
|
|
||||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
if (self.selectBlock) {
|
if (self.selectBlock) {
|
||||||
self.selectBlock(indexPath.row, self.dataSource[indexPath.row]);
|
NSString *gender = nil;
|
||||||
|
if (indexPath.row == 1) {
|
||||||
|
gender = @"2";
|
||||||
|
}else if (indexPath.row == 2) {
|
||||||
|
gender = @"1";
|
||||||
|
}
|
||||||
|
self.selectBlock(gender, self.dataSource[indexPath.row]);
|
||||||
}
|
}
|
||||||
[self dismiss];
|
[self dismiss];
|
||||||
}
|
}
|
||||||
|
@@ -86,6 +86,8 @@
|
|||||||
@property (nonatomic,strong) XPHomeHotRoomViewController *hotRoomVC;
|
@property (nonatomic,strong) XPHomeHotRoomViewController *hotRoomVC;
|
||||||
///发现新朋友
|
///发现新朋友
|
||||||
@property (nonatomic,strong) XPFindNewFriendViewController *friendVC;
|
@property (nonatomic,strong) XPFindNewFriendViewController *friendVC;
|
||||||
|
///性别
|
||||||
|
@property (nonatomic,strong) NSString *gender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -137,10 +139,10 @@
|
|||||||
|
|
||||||
- (void)headerRefresh {
|
- (void)headerRefresh {
|
||||||
[self.presenter getHomeTopBannerList];
|
[self.presenter getHomeTopBannerList];
|
||||||
// [self.presenter getHomeGiftRecord];
|
[self.presenter getHomeGiftRecord];
|
||||||
[_personalRoomVC refreshData];
|
[_personalRoomVC refreshData];
|
||||||
[_hotRoomVC refreshData];
|
[_hotRoomVC refreshData];
|
||||||
[_friendVC refreshData];
|
[_friendVC refreshData:self.gender];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)initHeaderAndFooterRrfresh {
|
- (void)initHeaderAndFooterRrfresh {
|
||||||
@@ -209,18 +211,19 @@
|
|||||||
- (void)filterBtnAction {
|
- (void)filterBtnAction {
|
||||||
XPNewHomeFilterView *filterView = [[XPNewHomeFilterView alloc] init];
|
XPNewHomeFilterView *filterView = [[XPNewHomeFilterView alloc] init];
|
||||||
@weakify(self);
|
@weakify(self);
|
||||||
filterView.selectBlock = ^(NSUInteger index, NSString *title) {
|
filterView.selectBlock = ^(NSString *gender, NSString *title) {
|
||||||
@strongify(self);
|
@strongify(self);
|
||||||
[self.filterBtn setTitle:title forState:UIControlStateNormal];
|
[self.filterBtn setTitle:title forState:UIControlStateNormal];
|
||||||
//TODO: 刷新列表
|
// 刷新列表
|
||||||
|
self.gender = gender;
|
||||||
|
[self.friendVC refreshData:self.gender];
|
||||||
};
|
};
|
||||||
[filterView addToVCView:self.view targetView:self.filterBtn];
|
[filterView addToVCView:self.view targetView:self.filterBtn];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 点击换一换
|
/// 点击换一换
|
||||||
- (void)refreshBtnAction {
|
- (void)refreshBtnAction {
|
||||||
[_friendVC refreshData];
|
[_friendVC refreshData:self.gender];
|
||||||
self.refreshBtn.userInteractionEnabled = NO;
|
self.refreshBtn.userInteractionEnabled = NO;
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
self.refreshBtn.userInteractionEnabled = YES;
|
self.refreshBtn.userInteractionEnabled = YES;
|
||||||
@@ -231,28 +234,6 @@
|
|||||||
- (void)getHomeTopBannerListSuccess:(NSArray *)list menuList:(NSArray *)list1{
|
- (void)getHomeTopBannerListSuccess:(NSArray *)list menuList:(NSArray *)list1{
|
||||||
[self.pagingView.mainTableView.mj_header endRefreshing];
|
[self.pagingView.mainTableView.mj_header endRefreshing];
|
||||||
self.headerView.menuList = list1;
|
self.headerView.menuList = list1;
|
||||||
|
|
||||||
// 模拟数据
|
|
||||||
XPHomeGiftRecordModel *model1 = [[XPHomeGiftRecordModel alloc] init];
|
|
||||||
model1.senderNick = @"小半";
|
|
||||||
model1.receiverNick = @"大半";
|
|
||||||
model1.giftName = @"星语星愿";
|
|
||||||
model1.giftNum = @"1";
|
|
||||||
|
|
||||||
XPHomeGiftRecordModel *model2 = [[XPHomeGiftRecordModel alloc] init];
|
|
||||||
model2.senderNick = @"小老弟";
|
|
||||||
model2.receiverNick = @"大老弟";
|
|
||||||
model2.giftName = @"宇宙飞船";
|
|
||||||
model2.giftNum = @"1";
|
|
||||||
|
|
||||||
XPHomeGiftRecordModel *model3 = [[XPHomeGiftRecordModel alloc] init];
|
|
||||||
model3.senderNick = @"心心念念";
|
|
||||||
model3.receiverNick = @"乔碧萝";
|
|
||||||
model3.giftName = @"大火箭";
|
|
||||||
model3.giftNum = @"1";
|
|
||||||
NSArray *array = @[model1, model2, model3];
|
|
||||||
self.headerView.messageList = array;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)getHomeGiftRecordSuccess:(NSArray *)list {
|
- (void)getHomeGiftRecordSuccess:(NSArray *)list {
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#import <SDCycleScrollView/SDCycleScrollView.h>
|
#import <SDCycleScrollView/SDCycleScrollView.h>
|
||||||
#import "SDPhotoBrowser.h"
|
#import "SDPhotoBrowser.h"
|
||||||
#import <ReactiveObjC/ReactiveObjC.h>
|
#import <ReactiveObjC/ReactiveObjC.h>
|
||||||
|
#import <YYText/YYText.h>
|
||||||
///Tool
|
///Tool
|
||||||
#import "ThemeColor.h"
|
#import "ThemeColor.h"
|
||||||
#import "XPMacro.h"
|
#import "XPMacro.h"
|
||||||
@@ -347,14 +348,62 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - 计算星座
|
||||||
|
-(NSInteger) getMonth:(long )time
|
||||||
|
{
|
||||||
|
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
|
||||||
|
NSCalendar* calendar = [NSCalendar currentCalendar];
|
||||||
|
NSDateComponents* components = [calendar components:NSCalendarUnitMonth fromDate:date];
|
||||||
|
NSInteger month = components.month;
|
||||||
|
return month;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSInteger) getDay:(long) time
|
||||||
|
{
|
||||||
|
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
|
||||||
|
NSCalendar* calendar = [NSCalendar currentCalendar];
|
||||||
|
NSDateComponents* components = [calendar components:NSCalendarUnitDay fromDate:date];
|
||||||
|
NSInteger day = components.day;
|
||||||
|
return day;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)calculateConstellationWithMonth:(long)time
|
||||||
|
{
|
||||||
|
NSString *astroString = @"魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
|
||||||
|
NSString *astroFormat = @"102123444543";
|
||||||
|
NSString *result;
|
||||||
|
|
||||||
|
NSInteger month = [self getMonth:time];
|
||||||
|
NSInteger day = [self getDay:time];
|
||||||
|
|
||||||
|
if (month<1 || month>12 || day<1 || day>31){
|
||||||
|
return @"错误日期格式!";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(month==2 && day>29)
|
||||||
|
{
|
||||||
|
return @"错误日期格式!!";
|
||||||
|
}else if(month==4 || month==6 || month==9 || month==11) {
|
||||||
|
if (day>30) {
|
||||||
|
return @"错误日期格式!!!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result=[NSString stringWithFormat:@"%@",[astroString substringWithRange:NSMakeRange(month*2-(day < [[astroFormat substringWithRange:NSMakeRange((month-1), 1)] intValue] - (-19))*2,2)]];
|
||||||
|
|
||||||
|
return [NSString stringWithFormat:@"%@座",result];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Getters And Setters
|
#pragma mark - Getters And Setters
|
||||||
- (void)setUserInfo:(UserInfoModel *)userInfo {
|
- (void)setUserInfo:(UserInfoModel *)userInfo {
|
||||||
_userInfo = userInfo;
|
_userInfo = userInfo;
|
||||||
if (_userInfo) {
|
if (_userInfo) {
|
||||||
self.avatarImageView.imageUrl = _userInfo.avatar;
|
self.avatarImageView.imageUrl = _userInfo.avatar;
|
||||||
self.nameLabel.text = _userInfo.nick;
|
self.nameLabel.text = _userInfo.nick;
|
||||||
[self.constellationBtn setTitle:@"巨蟹座" forState:UIControlStateNormal];
|
if (_userInfo.birth) {
|
||||||
self.constellationBtn.hidden = NO;
|
[self.constellationBtn setTitle:[self calculateConstellationWithMonth:userInfo.birth] forState:UIControlStateNormal];
|
||||||
|
self.constellationBtn.hidden = NO;
|
||||||
|
}
|
||||||
self.idLabel.text = [NSString stringWithFormat:@"ID:%ld", (long)_userInfo.erbanNo];
|
self.idLabel.text = [NSString stringWithFormat:@"ID:%ld", (long)_userInfo.erbanNo];
|
||||||
self.copysIdImageView.hidden = NO;
|
self.copysIdImageView.hidden = NO;
|
||||||
self.signLabel.text = _userInfo.userDesc.length > 0 ? _userInfo.userDesc : @"我是个默认签名";
|
self.signLabel.text = _userInfo.userDesc.length > 0 ? _userInfo.userDesc : @"我是个默认签名";
|
||||||
|
Reference in New Issue
Block a user