// // QXIntimateMoreListCell.m // QXLive // // Created by 启星 on 2025/11/20. // #import "QXIntimateMoreListCell.h" #import "QXMineNetwork.h" #import "QXCustomAlertView.h" @interface QXIntimateMoreListCell() @property (nonatomic,strong)QXCustomAlertView *alertView; @end @implementation QXIntimateMoreListCell +(instancetype)cellWithTableView:(UITableView *)tableView{ static NSString *cellId = @"QXIntimateMoreListCell"; QXIntimateMoreListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; if (!cell) { cell = [[NSBundle mainBundle] loadNibNamed:cellId owner:nil options:nil].lastObject; cell.backgroundColor = [UIColor clearColor]; cell.contentView.backgroundColor = [UIColor clearColor]; [cell.leftHeaderView addRoundedCornersWithRadius:25]; cell.leftHeaderView.layer.borderWidth = 2; cell.leftHeaderView.layer.borderColor = RGB16(0xffffff).CGColor; [cell.timeLabel addRoundedCornersWithRadius:9]; } return cell; } - (IBAction)deleteAction:(id)sender { MJWeakSelf QXCustomAlertView *alertView = [[QXCustomAlertView alloc] init]; alertView.commitBlock = ^{ [weakSelf deleteRelation]; }; [alertView showInView:self.viewController.view title:@"您确定要解除本关系吗" message:[NSString stringWithFormat:@"解除关系需要%@金币",self.model.delete_me_coin] cancleTitle:@"取消" commitTitle:@"确定"]; } - (IBAction)topAction:(id)sender { MJWeakSelf QXCustomAlertView *alertView = [[QXCustomAlertView alloc] init]; alertView.commitBlock = ^{ [weakSelf topRelation]; }; [alertView showInView:self.viewController.view title:@"您确定要置顶本关系吗" message:@"" cancleTitle:@"取消" commitTitle:@"确定"]; } -(void)deleteRelation{ MJWeakSelf [QXMineNetwork deleteRelationWithId:self.model.id successBlock:^(NSDictionary * _Nonnull dict) { showToast(@"解除成功"); if (weakSelf.deleteSuccessBlock) { weakSelf.deleteSuccessBlock(weakSelf.model); } } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; } -(void)topRelation{ MJWeakSelf [QXMineNetwork topRelationWithId:self.model.id successBlock:^(NSDictionary * _Nonnull dict) { showToast(@"置顶成功"); if (weakSelf.topSuccessBlock) { weakSelf.topSuccessBlock(weakSelf.model); } } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; } - (IBAction)leftAction:(id)sender { if (self.delegate && [self.delegate respondsToSelector:@selector(didClickHeaderWithUserId:)]) { [self.delegate didClickHeaderWithUserId:self.userId]; } } - (IBAction)rightAction:(id)sender { NSString *userId = @""; if ([self.model.user_id1 isEqualToString:self.userId]) { userId = self.model.user_id2; }else{ userId = self.model.user_id1; } if (self.delegate && [self.delegate respondsToSelector:@selector(didClickHeaderWithUserId:)]) { [self.delegate didClickHeaderWithUserId:userId]; } } -(void)setModel:(QXRelationshipListModel *)model{ _model = model; if ([model.user_id1 isEqualToString:self.userId]) { [self.leftHeaderView setHeadIcon:model.avatar1 dress:@""]; self.leftNameLabel.text = model.nickname1; self.leftSexImageView.image = [UIImage imageNamed:model.sex1.intValue == 1?@"user_sex_boy":@"user_sex_girl"]; [self.rightHeaderView setHeadIcon:model.avatar2 dress:@""]; self.rightNameLabel.text = model.nickname2; self.rightSexImageView.image = [UIImage imageNamed:model.sex2.intValue == 1?@"user_sex_boy":@"user_sex_girl"]; }else{ [self.leftHeaderView setHeadIcon:model.avatar2 dress:@""]; self.leftNameLabel.text = model.nickname2; self.leftSexImageView.image = [UIImage imageNamed:model.sex2.intValue == 1?@"user_sex_boy":@"user_sex_girl"]; [self.rightHeaderView setHeadIcon:model.avatar1 dress:@""]; self.rightNameLabel.text = model.nickname1; self.rightSexImageView.image = [UIImage imageNamed:model.sex2.intValue == 1?@"user_sex_boy":@"user_sex_girl"]; } if ([self.userId isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { self.topBtn.hidden = YES; self.deleteBtn.hidden = YES; }else{ self.topBtn.hidden = NO; self.deleteBtn.hidden = NO; } NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970]; long long milliseconds = (long long)(currentTime); NSInteger time = model.end_time.longLongValue - milliseconds; self.timeLabel.text = [NSString stringWithFormat:@" %@ ",[NSString getTimeWithSecond:time]]; } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end