299 lines
12 KiB
Objective-C
299 lines
12 KiB
Objective-C
//
|
|
// BottleUserNearbyTableViewCell.m
|
|
// TreeHole
|
|
//
|
|
// Created by 郑创权 on 2022/10/7.
|
|
//
|
|
|
|
#import "BottleUserNearbyTableViewCell.h"
|
|
@interface BottleUserNearbyTableViewCell()
|
|
|
|
@property (nonatomic, strong)UIView* bgContentView;
|
|
@property (nonatomic, strong)UIImageView* userImgV;
|
|
@property (nonatomic, strong)UIImageView* userVipImgV;
|
|
@property (nonatomic, strong)UILabel* userNameLab;
|
|
@property (nonatomic, strong)UIImageView* userSexImgv;
|
|
@property (nonatomic, strong)UILabel* userSignatureLab;
|
|
@property (nonatomic, strong)UILabel* userAddressLab;
|
|
@property (nonatomic, strong)UIView* userPhotoView;
|
|
@property (nonatomic, strong)UIView *nianVipView;
|
|
|
|
@end
|
|
|
|
@implementation BottleUserNearbyTableViewCell
|
|
|
|
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
// [self setupUI];
|
|
self.contentView.backgroundColor = [UIColor clearColor];
|
|
self.backgroundColor = [UIColor clearColor];
|
|
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
[self.contentView addSubview:self.bgContentView];
|
|
_bgContentView.sd_layout.leftSpaceToView(self.contentView, 17).rightSpaceToView(self.contentView, 17).bottomSpaceToView(self.contentView, 15).topSpaceToView(self.contentView, 0);
|
|
[self.bgContentView addSubview:self.userImgV];
|
|
_userImgV.sd_layout.leftSpaceToView(self.bgContentView, 6).topSpaceToView(self.bgContentView, 15).widthIs(46).heightIs(46);
|
|
|
|
[self.bgContentView addSubview:self.userVipImgV];
|
|
_userVipImgV.sd_layout.widthIs(12).heightIs(12).leftSpaceToView(_userImgV, -14).topSpaceToView(_userImgV, -14);
|
|
|
|
self.userVipImgV.backgroundColor = [UIColor redColor];
|
|
|
|
[self.bgContentView addSubview:self.userNameLab];
|
|
_userNameLab.sd_layout.leftSpaceToView(_userImgV, 12).topSpaceToView(self.bgContentView, 12).heightIs(22);
|
|
|
|
[self.bgContentView addSubview:self.userSexImgv];
|
|
_userSexImgv.sd_layout.leftSpaceToView(_userNameLab, 6).widthIs(26).heightIs(16).centerYEqualToView(_userNameLab);
|
|
|
|
// [self.userSexImgv updateLayout];
|
|
|
|
// UIView* nianVipView = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.userSexImgv.frame)+2,FIX_SIZE(13), 34, FIX_SIZE(16))];
|
|
|
|
[self.bgContentView addSubview:self.nianVipView];
|
|
self.nianVipView.sd_layout.leftSpaceToView(_userSexImgv, 4).topSpaceToView(self.bgContentView, FIX_SIZE(14)).widthIs(34).heightIs(15);
|
|
|
|
self.nianVipView.layer.cornerRadius = 8;
|
|
self.nianVipView.layer.masksToBounds = YES;
|
|
[ self.nianVipView updateLayout];
|
|
|
|
CAGradientLayer *gl = [CAGradientLayer layer];
|
|
gl.frame = CGRectMake(0,0,self.nianVipView.width,self.nianVipView.height);
|
|
gl.startPoint = CGPointMake(0, 0.5);
|
|
gl.endPoint = CGPointMake(1, 0.5);
|
|
gl.colors = @[(__bridge id)HEX_COLOR(0xE4B18B).CGColor, (__bridge id)HEX_COLOR(0xFFF4EC).CGColor, (__bridge id)HEX_COLOR(0xE4B18B).CGColor];;
|
|
gl.locations = @[@(0), @(0.5f), @(1.0f)];
|
|
[self.nianVipView.layer addSublayer:gl];
|
|
|
|
UILabel* nianVipLab = [[UILabel alloc]initWithFrame:self.nianVipView.bounds];
|
|
|
|
nianVipLab.text = @"年VIP";
|
|
|
|
nianVipLab.textColor = HEX_COLOR(0x000000);
|
|
nianVipLab.textAlignment = NSTextAlignmentCenter;
|
|
nianVipLab.font = MT_FONT_MEDIUM_SIZE(10);
|
|
[self.nianVipView addSubview:nianVipLab];
|
|
|
|
self.nianVipView.hidden = YES;
|
|
|
|
[self.bgContentView addSubview:self.userAddressLab];
|
|
_userAddressLab.sd_layout.rightSpaceToView(self.bgContentView, 10).centerYEqualToView(self.userNameLab).heightIs(17).widthIs(48);
|
|
|
|
[self.bgContentView addSubview:self.userSignatureLab];
|
|
_userSignatureLab.sd_layout.leftEqualToView(_userNameLab).rightSpaceToView(_userAddressLab, 0).heightIs(17).topSpaceToView(_userNameLab, 12);
|
|
|
|
[self.bgContentView addSubview:self.userPhotoView];
|
|
_userPhotoView.sd_layout.leftEqualToView(_userNameLab).rightSpaceToView(_userAddressLab, 0).topSpaceToView(_userSignatureLab, 14).bottomSpaceToView(self.bgContentView, 12);
|
|
|
|
|
|
|
|
|
|
// self.bgContentView.sd_layout
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(UIView *)bgContentView{
|
|
if (!_bgContentView) {
|
|
_bgContentView = [[UIView alloc]initWithFrame:CGRectZero];
|
|
_bgContentView.layer.masksToBounds = YES;
|
|
_bgContentView.layer.cornerRadius = 8;
|
|
_bgContentView.backgroundColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.1);
|
|
}
|
|
return _bgContentView;
|
|
}
|
|
|
|
-(UIImageView *)userImgV{
|
|
if (!_userImgV) {
|
|
_userImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
|
|
_userImgV.contentMode = UIViewContentModeScaleAspectFill;
|
|
_userImgV.layer.cornerRadius = 23;
|
|
_userImgV.layer.masksToBounds = YES;
|
|
|
|
}
|
|
return _userImgV;
|
|
}
|
|
|
|
-(UIImageView *)userVipImgV{
|
|
if (!_userVipImgV) {
|
|
_userVipImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
|
|
_userVipImgV.contentMode = UIViewContentModeScaleAspectFill;
|
|
_userVipImgV.image = [UIImage imageNamed:@"vip_tag"];
|
|
_userVipImgV.hidden = YES;
|
|
}
|
|
return _userVipImgV;
|
|
}
|
|
|
|
-(UILabel *)userNameLab{
|
|
if (!_userNameLab) {
|
|
_userNameLab = [[UILabel alloc]initWithFrame:CGRectZero];
|
|
_userNameLab.textColor = COLOR_WITH_RGB(0xFFFFFF);
|
|
_userNameLab.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(16);
|
|
_userNameLab.textAlignment = NSTextAlignmentLeft;
|
|
}
|
|
return _userNameLab;
|
|
}
|
|
|
|
-(UILabel *)userAddressLab{
|
|
if (!_userAddressLab) {
|
|
_userAddressLab = [[UILabel alloc]initWithFrame:CGRectZero];
|
|
_userAddressLab.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.65);
|
|
_userAddressLab.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(12);
|
|
_userAddressLab.textAlignment = NSTextAlignmentLeft;
|
|
}
|
|
return _userAddressLab;
|
|
}
|
|
|
|
-(UILabel *)userSignatureLab{
|
|
if (!_userSignatureLab) {
|
|
_userSignatureLab = [[UILabel alloc]initWithFrame:CGRectZero];
|
|
_userSignatureLab.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.9);
|
|
_userSignatureLab.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(12);
|
|
_userSignatureLab.textAlignment = NSTextAlignmentLeft;
|
|
}
|
|
return _userSignatureLab;
|
|
}
|
|
|
|
-(UIImageView *)userSexImgv{
|
|
if (!_userSexImgv) {
|
|
_userSexImgv = [[UIImageView alloc]initWithFrame:CGRectZero];
|
|
|
|
}
|
|
return _userSexImgv;
|
|
}
|
|
|
|
-(UIView *)nianVipView{
|
|
if (!_nianVipView) {
|
|
_nianVipView = [[UIView alloc]init];
|
|
|
|
}
|
|
return _nianVipView;
|
|
}
|
|
|
|
|
|
-(UIView *)userPhotoView{
|
|
if (!_userPhotoView) {
|
|
_userPhotoView = [[UIView alloc]initWithFrame:CGRectZero];
|
|
CGFloat imgVWidth = FIX_SIZE(83);
|
|
CGFloat imgVJiange = (SCREEN_WIDTH - 34 - 64 - 9 - imgVWidth*3)/2.0;
|
|
for (int i = 0; i < 3; i++) {
|
|
UIImageView* tempImgV = [[UIImageView alloc]initWithFrame:CGRectZero];
|
|
tempImgV.contentMode = UIViewContentModeScaleAspectFill;
|
|
tempImgV.layer.cornerRadius = 4;
|
|
tempImgV.layer.masksToBounds = YES;
|
|
tempImgV.tag = 300001+i;
|
|
tempImgV.userInteractionEnabled = YES;
|
|
UITapGestureRecognizer* tapClickTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(bowerPhoto:)];
|
|
[tempImgV addGestureRecognizer:tapClickTap];
|
|
[_userPhotoView addSubview:tempImgV];
|
|
tempImgV.sd_layout.leftSpaceToView(_userPhotoView, (imgVWidth + imgVJiange)*i).widthIs(imgVWidth).heightIs(imgVWidth).topSpaceToView(_userPhotoView, 0);
|
|
//点击后查看图片大图组建
|
|
// [PYAppService showImageBrowserWithImageURLs:self.detailInfo.images index:indexPath.item];
|
|
}
|
|
}
|
|
return _userPhotoView;
|
|
}
|
|
|
|
-(void)setDataModel:(userNearbyModel *)dataModel{
|
|
_dataModel = dataModel;
|
|
[_userImgV sd_setImageWithURL:[NSURL URLWithString:_dataModel.avatar] placeholderImage:[UIImage imageNamed:@"TH_defalut_avatar"]];
|
|
if ([_dataModel.user_vip_kind isEqualToString:@"1"]) {
|
|
_userNameLab.textColor = COLOR_WITH_RGB(0xF8D07D);
|
|
_userVipImgV.hidden = NO;
|
|
}else{
|
|
_userNameLab.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.9);
|
|
_userVipImgV.hidden = YES;
|
|
}
|
|
if([_dataModel.gender_str isEqualToString:@"CD"]){
|
|
_userSexImgv.image = [UIImage imageNamed:@"TH_cd_tag"];
|
|
}else if([_dataModel.gender_str isEqualToString:@"TS"]){
|
|
_userSexImgv.image = [UIImage imageNamed:@"TH_ts_tag"];
|
|
}else{
|
|
_userSexImgv.image = [UIImage imageNamed:@"TH_zn_tag"];
|
|
}
|
|
NSArray* addArray = [_dataModel.user_local componentsSeparatedByString:@"·"];
|
|
NSString* jdAddressStr = addArray.lastObject;
|
|
if ([_shaiXuanDict[@"sx_gjsx"] isEqualToString:@"全部"]) {
|
|
_userAddressLab.text = [NSString stringWithFormat:@"来自%@",jdAddressStr.length>0?jdAddressStr:@"火星"];
|
|
}else if ([_shaiXuanDict[@"sx_gjsx"] isEqualToString:@"VIP"]){
|
|
_userAddressLab.text = [NSString stringWithFormat:@"来自%@",jdAddressStr.length>0?jdAddressStr:@"火星"];
|
|
}else if ([_shaiXuanDict[@"sx_gjsx"] isEqualToString:@"在线"]){
|
|
if (dataModel.user_open_duration.integerValue <= 10) {
|
|
_userAddressLab.text = @"刚刚在线";
|
|
}else if (dataModel.user_open_duration.integerValue <= 60){
|
|
_userAddressLab.text = [NSString stringWithFormat:@"%ld分钟前在线",(long)dataModel.user_open_duration.integerValue];
|
|
}else if (dataModel.user_open_duration.integerValue <= 1440){
|
|
_userAddressLab.text = [NSString stringWithFormat:@"%ld小时前在线",(long)dataModel.user_open_duration.integerValue/60];
|
|
}else{
|
|
_userAddressLab.text = @"最近来过";
|
|
}
|
|
|
|
}else if ([_shaiXuanDict[@"sx_gjsx"] isEqualToString:@"新人"]){
|
|
if (dataModel.user_create_duration.integerValue <= 1) {
|
|
_userAddressLab.text = @"刚刚加入";
|
|
}else if (dataModel.user_create_duration.integerValue <= 24){
|
|
_userAddressLab.text = @"今日加入";
|
|
}else{
|
|
_userAddressLab.text = @"最近加入";
|
|
}
|
|
}else{
|
|
_userAddressLab.text = [NSString stringWithFormat:@"来自%@",jdAddressStr.length>0?jdAddressStr:@"火星"];
|
|
}
|
|
|
|
_userNameLab.text = _dataModel.nickname;
|
|
|
|
|
|
#warning 1
|
|
if(_dataModel.user_vip_kind.intValue <= 0) {
|
|
_nianVipView.hidden = [_dataModel.user_vip_kind intValue]!=10;
|
|
} else {
|
|
_nianVipView.hidden = false;
|
|
UILabel *tipLabel = _nianVipView.subviews.firstObject;
|
|
if (_dataModel.user_vip_kind.intValue == 1) {
|
|
tipLabel.text = @"VIP";
|
|
} else if (_dataModel.user_vip_kind.intValue == 10) {
|
|
tipLabel.text = @"年VIP";
|
|
} else {
|
|
tipLabel.text = @"年VIP";
|
|
}
|
|
}
|
|
|
|
|
|
CGSize size = [_userNameLab.text sizeWithMaxWidth:150 font:_userNameLab.font];
|
|
_userNameLab.sd_resetLayout.leftSpaceToView(_userImgV, 12).topSpaceToView(self.bgContentView, 12).heightIs(22).widthIs(size.width);
|
|
|
|
CGSize addressSize = [_userAddressLab.text sizeWithMaxWidth:150 font:_userAddressLab.font];
|
|
_userAddressLab.sd_resetLayout.rightSpaceToView(self.bgContentView, 10).centerYEqualToView(self.userNameLab).heightIs(17).widthIs(addressSize.width);
|
|
_userSignatureLab.text = _dataModel.introduction.length>0?_dataModel.introduction:@"本人太懒了还没有个性简介~";
|
|
if (_dataModel.user_photo.length > 0) {
|
|
_userPhotoView.hidden = NO;
|
|
NSArray* imgURLArray = [_dataModel.user_photo componentsSeparatedByString:@"\n"];
|
|
for (int i = 0; i < 3; i++) {
|
|
UIImageView* coverImgV = (UIImageView*)[self viewWithTag:300001+i];
|
|
|
|
coverImgV.hidden = (i > (imgURLArray.count - 1));
|
|
if (!coverImgV.isHidden) {
|
|
[coverImgV sd_setImageWithURL:[NSURL URLWithString:imgURLArray[i]] placeholderImage:[UIImage imageNamed:@"TH_defalut_avatar"]];
|
|
}
|
|
}
|
|
}else{
|
|
_userPhotoView.hidden = YES;
|
|
}
|
|
|
|
|
|
// tempImgV.tag = 300001+i;
|
|
}
|
|
|
|
|
|
-(void)bowerPhoto:(UITapGestureRecognizer*)tap{
|
|
NSArray* imgURLArray = [_dataModel.user_photo componentsSeparatedByString:@"\n"];
|
|
if( (tap.view.tag%300001)+1 > imgURLArray.count){
|
|
NSLog(@"避免越界");
|
|
return;
|
|
}
|
|
NSLog(@"tap.view.tag : %ld",tap.view.tag%300001);
|
|
if (imgURLArray.count > 0) {
|
|
[PYAppService showImageBrowserWithImageURLs:imgURLArray index:tap.view.tag%300001];
|
|
}
|
|
|
|
}
|
|
@end
|