发现新朋友接口接入
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
#import "NetImageView.h"
|
||||
#import "ThemeColor.h"
|
||||
#import "XPButton.h"
|
||||
/// Model
|
||||
#import "UserInfoModel.h"
|
||||
|
||||
@interface XPFindNewFriendTableViewCell()
|
||||
/// 背景
|
||||
@@ -24,7 +26,7 @@
|
||||
@property (nonatomic, strong) UIImageView *onlineImageView;
|
||||
@property (nonatomic, strong) UIStackView *nameStackView;
|
||||
/// 贵族图标
|
||||
@property (nonatomic, strong) UIImageView *nobleImageView;
|
||||
@property (nonatomic, strong) NetImageView *nobleImageView;
|
||||
/// 昵称
|
||||
@property (nonatomic, strong) UILabel *nickLabel;
|
||||
@property (nonatomic, strong) UIStackView *constellationStackView;
|
||||
@@ -140,6 +142,7 @@
|
||||
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.nameStackView);
|
||||
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) {
|
||||
@@ -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
|
||||
|
||||
- (void)setRoomInfo:(HomeRecommendRoomModel *)roomInfo {
|
||||
self.nobleImageView.hidden = YES;
|
||||
self.nickLabel.text = @"用户昵称";
|
||||
[self.sexBtn setImage:[UIImage imageNamed:@"home_sex_female"] forState:UIControlStateNormal];
|
||||
self.sexBtn.backgroundColor = [ThemeColor colorWithHexString:@"#FF9CCE"];
|
||||
[self.sexBtn setTitle:@"22" forState:UIControlStateNormal];
|
||||
self.constellationLabel.text = @"巨蟹座";
|
||||
self.signLabel.text = @"我是个默认的个性签名";
|
||||
self.livingView.hidden = NO;
|
||||
self.statusLabel.text = @"直播中";
|
||||
// self.statusLabel.text = @"和TA聊";
|
||||
- (void)setRoomInfo:(UserInfoModel *)roomInfo {
|
||||
self.nickLabel.text = roomInfo.nick;
|
||||
if (roomInfo.gender == GenderType_Female) {
|
||||
[self.sexBtn setImage:[UIImage imageNamed:@"home_sex_female"] forState:UIControlStateNormal];
|
||||
self.sexBtn.backgroundColor = [ThemeColor colorWithHexString:@"#FF9CCE"];
|
||||
}else{
|
||||
[self.sexBtn setImage: [UIImage imageNamed:@"home_sex_man"] forState:UIControlStateNormal];
|
||||
self.sexBtn.backgroundColor = [ThemeColor colorWithHexString:@"#65D3F7"];
|
||||
}
|
||||
if (roomInfo.birth) {
|
||||
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 {
|
||||
@@ -221,9 +323,9 @@
|
||||
return _nameStackView;
|
||||
}
|
||||
|
||||
- (UIImageView *)nobleImageView {
|
||||
- (NetImageView *)nobleImageView {
|
||||
if (!_nobleImageView) {
|
||||
_nobleImageView = [[UIImageView alloc] init];
|
||||
_nobleImageView = [[NetImageView alloc] init];
|
||||
_nobleImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
}
|
||||
return _nobleImageView;
|
||||
|
||||
Reference in New Issue
Block a user