Files
featherVoice/QXLive/Room(房间)/View/用户信息/QXUserInfoRelationTableCell.m
2025-10-20 10:29:42 +08:00

122 lines
3.9 KiB
Objective-C

//
// QXUserInfoRelationTableCell.m
// QXLive
//
// Created by 启星 on 2025/8/1.
//
#import "QXUserInfoRelationTableCell.h"
#import "QXAlertView.h"
#import "QXMineNetwork.h"
@interface QXUserInfoRelationTableCell()
@property (nonatomic,strong)QXAlertView *alertView;
@end
@implementation QXUserInfoRelationTableCell
+(instancetype)cellWithTableView:(UITableView *)tableView{
static NSString *cellId = @"QXUserInfoRelationTableCell";
QXUserInfoRelationTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell) {
cell = [[NSBundle mainBundle] loadNibNamed:cellId owner:nil options:nil].lastObject;
cell.backgroundColor = [UIColor clearColor];
}
return cell;
}
-(void)setModel:(QXRelationshipListModel *)model{
_model = model;
if ([model.user_id1 isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) {
[self.rightHeaderView sd_setImageWithURL:[NSURL URLWithString:model.avatar1]];
[self.leftHeaderView sd_setImageWithURL:[NSURL URLWithString:model.avatar2]];
self.rightNameLabel.text = model.nickname1;
self.leftNameLabel.text = model.nickname2;
}else{
[self.leftHeaderView sd_setImageWithURL:[NSURL URLWithString:model.avatar1]];
[self.rightHeaderView sd_setImageWithURL:[NSURL URLWithString:model.avatar2]];
self.leftNameLabel.text = model.nickname1;
self.rightNameLabel.text = model.nickname2;
}
self.relationLabel.text = model.relation_name;
NSTimeInterval timeInterval = [[NSDate date] timeIntervalSince1970];
long long milliseconds = (long long)(timeInterval);
long endTime = model.end_time.longLongValue - milliseconds;
if (endTime<=0) {
self.dayLabel.text = @"-";
}else{
NSInteger day = endTime/(60*60*24);
NSInteger hour = endTime/3600%24;
self.dayLabel.text = [NSString stringWithFormat:@" %ld天 %ld小时 ",day,hour];
}
}
-(void)setIsList:(BOOL)isList{
_isList = isList;
self.topBtn.hidden = !isList;
self.deleteBtn.hidden = !isList;
}
- (IBAction)deleteAction:(id)sender {
MJWeakSelf
self.alertView.message = [NSString stringWithFormat:@"您确定要置顶本关系吗,解除关系需要%@金币",self.model.delete_me_coin];
[[QXGlobal shareGlobal] showView:self.alertView popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{
}];
self.alertView.commitBlock = ^{
[weakSelf deleteRelation];
};
}
-(void)deleteRelation{
MJWeakSelf
[QXMineNetwork deleteRelationWithId:self.model.id successBlock:^(NSDictionary * _Nonnull dict) {
showToast(@"解除成功");
if (weakSelf.topSuccessBlock) {
weakSelf.topSuccessBlock(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)topAction:(id)sender {
MJWeakSelf
self.alertView.message = @"您确定要置顶本关系吗";
[[QXGlobal shareGlobal] showView:self.alertView popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{
}];
self.alertView.commitBlock = ^{
[weakSelf topRelation];
};
}
-(QXAlertView *)alertView{
if (!_alertView) {
_alertView = [[QXAlertView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(300), ScaleWidth(175))];
}
return _alertView;
}
- (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