131 lines
5.9 KiB
Objective-C
131 lines
5.9 KiB
Objective-C
//
|
|
// QXFamilyMemberCell.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/11/26.
|
|
//
|
|
|
|
#import "QXFamilyMemberCell.h"
|
|
#import "QXUserHomeHeaderView.h"
|
|
#import "QXCustomAlertView.h"
|
|
#import "QXMineNetwork.h"
|
|
|
|
@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;
|
|
[self.headerView setHeadIcon:model.avatar dress:model.dress];
|
|
[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;
|
|
[self.todayPriceBtn setTitle:[NSString stringWithFormat:@"%.4f",model.today_earnings.doubleValue] forState:(UIControlStateNormal)];
|
|
[self.yestodayPriceBtn setTitle:[NSString stringWithFormat:@"%.4f",model.yesterday_earnings.doubleValue] forState:(UIControlStateNormal)];
|
|
[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 {
|
|
|
|
QXCustomAlertView *al = [[QXCustomAlertView alloc] init];
|
|
al.title = @"续约提示";
|
|
|
|
al.cancleTitle = @"取消";
|
|
al.commitTitle = @"确认续约";
|
|
al.isFromController = YES;
|
|
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
|
|
al.cancelBlock = ^{
|
|
[[QXGlobal shareGlobal] hideViewBlock:nil];
|
|
};
|
|
al.commitBlock = ^{
|
|
[[QXGlobal shareGlobal] hideViewBlock:nil];
|
|
if (weakSelf.model.free_renewal.intValue>0) {
|
|
[weakSelf networkFreeSign];
|
|
}else{
|
|
[weakSelf networkCoinSign];
|
|
}
|
|
};
|
|
[QXGlobal.shareGlobal showView:al popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:nil];
|
|
}
|
|
|
|
-(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);
|
|
}];
|
|
}
|
|
-(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
|