Files
featherVoice/QXLive/Mine(音域)/View/家族/QXFamilyMemberCell.m

131 lines
5.9 KiB
Mathematica
Raw Normal View History

2025-11-28 22:43:06 +08:00
//
// QXFamilyMemberCell.m
// QXLive
//
// Created by on 2025/11/26.
//
#import "QXFamilyMemberCell.h"
#import "QXUserHomeHeaderView.h"
#import "QXCustomAlertView.h"
2025-12-01 18:42:49 +08:00
#import "QXMineNetwork.h"
2025-11-28 22:43:06 +08:00
@interface QXFamilyMemberCell()<UICollectionViewDataSource,UICollectionViewDelegate>
@end
@implementation QXFamilyMemberCell
+(instancetype)cellWithTableView:(UITableView *)tableView{
static NSString *cellId = @"QXFamilyMemberCell";
QXFamilyMemberCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell) {
cell = [[NSBundle mainBundle] loadNibNamed:cellId owner:nil options:nil].lastObject;
cell.flowLayout.itemSize = CGSizeMake(UserIconWidth, UserIconHeight);
cell.flowLayout.minimumLineSpacing = 7;
cell.flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
cell.collectionView.dataSource = cell;
cell.collectionView.delegate = cell;
cell.collectionView.backgroundColor = UIColor.clearColor;
[cell.collectionView registerClass:[QXTagImageCell class] forCellWithReuseIdentifier:@"QXTagImageCell"];
cell.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return cell;
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
-(void)setModel:(QXFamilyMemberModel *)model{
_model = model;
2025-12-01 18:42:49 +08:00
[self.headerView setHeadIcon:model.avatar dress:model.dress];
2025-11-28 22:43:06 +08:00
[self.headerView.nobilityImageView sd_setImageWithURL:[NSURL URLWithString:model.nobility_image]];
self.dayLabel.text = [NSString stringWithFormat:@"剩余租期:%@",model.end_day];
self.timesLabel.text = [NSString stringWithFormat:@"免费续约次数:%@",model.free_renewal];
self.nameLabel.text = model.nickname;
2025-12-04 14:11:00 +08:00
[self.todayPriceBtn setTitle:[NSString stringWithFormat:@"%.4f",model.today_earnings.doubleValue] forState:(UIControlStateNormal)];
[self.yestodayPriceBtn setTitle:[NSString stringWithFormat:@"%.4f",model.yesterday_earnings.doubleValue] forState:(UIControlStateNormal)];
2025-11-28 22:43:06 +08:00
[self.priceBtn setTitle:model.market_value forState:(UIControlStateNormal)];
self.onlineLabel.text = model.is_online==1?@"当前在线":@"当前离线";
self.continueBtn.hidden = model.is_show_sign.intValue==1?NO:YES;
}
- (IBAction)continueAction:(id)sender {
2025-12-01 18:42:49 +08:00
2025-11-28 22:43:06 +08:00
QXCustomAlertView *al = [[QXCustomAlertView alloc] init];
al.title = @"续约提示";
2025-12-01 18:42:49 +08:00
2025-11-28 22:43:06 +08:00
al.cancleTitle = @"取消";
al.commitTitle = @"确认续约";
al.isFromController = YES;
2025-12-01 18:42:49 +08:00
if (self.model.free_renewal.intValue>0) {
al.message = [NSString stringWithFormat:@"尊敬的用户:  您的徒弟【%@】当前为首次签约的 免费续约期。续约后,徒弟合约将延长%@天,您剩余的免费续约次数:%d次",self.model.nickname,self.model.free_re_sign_day,self.model.free_renewal.intValue-1];
}else{
NSInteger currentFeeInt = (NSInteger)ceil(self.model.market_value.doubleValue*self.model.sign_user_ratio.doubleValue/100.0);
NSString *currentFee = [NSString stringWithFormat:@"%ld",currentFeeInt];
al.message = [NSString stringWithFormat:@"尊敬的用户:本次续约将预估支付%@金币(【%@】身价的 %@%% )作为续约费用,续约后,师徒合约将延长 %@ 天\n注支付价格是预估价格徒弟身价是实时变化 续约后无法取消",currentFee,self.model.nickname,self.model.sign_user_ratio,self.model.sign_times];
}
MJWeakSelf
2025-11-28 22:43:06 +08:00
al.cancelBlock = ^{
[[QXGlobal shareGlobal] hideViewBlock:nil];
};
al.commitBlock = ^{
[[QXGlobal shareGlobal] hideViewBlock:nil];
2025-12-01 18:42:49 +08:00
if (weakSelf.model.free_renewal.intValue>0) {
[weakSelf networkFreeSign];
}else{
[weakSelf networkCoinSign];
}
2025-11-28 22:43:06 +08:00
};
[QXGlobal.shareGlobal showView:al popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:nil];
2025-12-01 18:42:49 +08:00
}
-(void)networkFreeSign{
__weak typeof(self) weakSelf = self;
[QXMineNetwork signFreeResignWithUserId:self.model.user_id successBlock:^(NSDictionary * _Nonnull dict) {
showToast(@"续约成功");
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
NSLog(@"⚠️ self has been deallocated, skipping hide operation");
return;
}
if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(needRefresh)]) {
[strongSelf.delegate needRefresh];
}
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(msg);
}];
}
-(void)networkCoinSign{
__weak typeof(self) weakSelf = self;
[QXMineNetwork signCoinResignWithUserId:self.model.user_id successBlock:^(NSDictionary * _Nonnull dict) {
showToast(@"续约成功");
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
NSLog(@"⚠️ self has been deallocated, skipping hide operation");
return;
}
if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(needRefresh)]) {
[strongSelf.delegate needRefresh];
}
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(msg);
}];
2025-11-28 22:43:06 +08:00
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
if (self.model==nil) {
return 0;
}
return self.model.icon.count;
}
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
QXTagImageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXTagImageCell" forIndexPath:indexPath];
cell.imageUrl = self.model.icon[indexPath.row];
return cell;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end