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

101 lines
3.1 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// QXUserInfoRelationCell.m
// QXLive
//
// Created by 启星 on 2025/7/21.
//
#import "QXUserInfoRelationCell.h"
#import "QXMineNetwork.h"
#import "QXAlertView.h"
@interface QXUserInfoRelationCell()
@property (nonatomic,strong)QXAlertView *alertView;
@end
@implementation QXUserInfoRelationCell
-(void)setModel:(QXRelationshipListModel *)model{
_model = model;
[self.bgImageView sd_setImageWithURL:[NSURL URLWithString:model.image]];
if ([model.user_id1 isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) {
[self.userHeader1 sd_setImageWithURL:[NSURL URLWithString:model.avatar1]];
[self.userHeader2 sd_setImageWithURL:[NSURL URLWithString:model.avatar2]];
self.userNameLabel1.text = model.nickname1;
self.userNameLabel2.text = model.nickname2;
}else{
[self.userHeader2 sd_setImageWithURL:[NSURL URLWithString:model.avatar1]];
[self.userHeader1 sd_setImageWithURL:[NSURL URLWithString:model.avatar2]];
self.userNameLabel2.text = model.nickname1;
self.userNameLabel1.text = model.nickname2;
}
self.relationNameLabel.text = model.relation_name;
NSInteger day = model.time_day.longLongValue/(60*60*24);
NSInteger hour = model.time_day.longLongValue%(60*60);
self.timeLabel.text = [NSString stringWithFormat:@" %ld天 %ld小时 ",day,hour];
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
// [self.bgImageView addRoundedCornersWithRadius:8];
}
- (IBAction)deleteAction:(id)sender {
MJWeakSelf
self.alertView.message = @"您确定要置顶本关系吗解除关系需要50金币";
[[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;
}
@end