Files
yuyin_ios/SweetParty/主类/音悦新增/麦位弹框子列表/YYMicAlertMiyouView.m
2025-08-08 11:05:33 +08:00

132 lines
3.8 KiB
Objective-C
Executable File

//
// YYMicAlertMiyouView.m
// SweetParty
//
// Created by bj_szd on 2023/12/25.
//
#import "YYMicAlertMiyouView.h"
#import "YYMicAlertMiyouCell.h"
#import "LMDeleteMiyouAlertView.h"
@interface YYMicAlertMiyouView () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) NSArray *dataArray;
@property(nonatomic, assign) NSInteger type;//1密友 2签约
@property(nonatomic, copy) NSString *uid;
@end
@implementation YYMicAlertMiyouView
- (void)awakeFromNib {
[super awakeFromNib];
[self createUI];
}
- (void)onUpdateUIWith:(NSInteger)type uid:(NSString *)uid {
_type = type;
_uid = uid;
if (type == 1) {
self.titleLab.text = @"密友";
}else if (type == 2) {
self.titleLab.text = @"签约艺人";
}
[self fetchData];
}
- (void)fetchData {
NSDictionary *params = @{};
NSString *urlStr = @"";
if (self.type == 1) {
urlStr = @"/api/dating_room/get_user_relation_list";
params = @{@"page":@(1), @"page_limit":@(1000), @"user_id":C_string(self.uid)};
}else if (self.type == 2) {
urlStr = @"/api/Contract/get_user_contract_list";
params = @{@"page":@(1), @"page_limit":@(1000), @"uid":C_string(self.uid)};
}
[AFNetworkRequset.shared postRequestWithParams:params Path:urlStr Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
NSArray *arr = [SPFocusFansModel mj_objectArrayWithKeyValuesArray:responseDic[@"data"]];
if (self.type == 1) {
arr = [SPFocusFansModel mj_objectArrayWithKeyValuesArray:responseDic[@"data"][@"list"]];
self.titleLab.text = [NSString stringWithFormat:@"密友(%@)", responseDic[@"data"][@"count"]];
}
self.dataArray = arr;
[self.tableView reloadData];
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)createUI {
WEAK_SELF
[self.touchImgV dg_Tapped:^{
[weakSelf removeFromSuperview];
}];
self.tableView.separatorStyle = NO;
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.tableView registerNib:[UINib nibWithNibName:@"YYMicAlertMiyouCell" bundle:nil] forCellReuseIdentifier:@"YYMicAlertMiyouCell"];
self.tableView.rowHeight = 72;
}
- (IBAction)onDismiss:(id)sender {
[self removeFromSuperview];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
YYMicAlertMiyouCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YYMicAlertMiyouCell" forIndexPath:indexPath];
cell.selectionStyle = NO;
if (self.type == 2) {
cell.tagView.hidden = cell.coinImgV.hidden = cell.coinLab.hidden = YES;
}
SPFocusFansModel *model = self.dataArray[indexPath.row];
[cell onUpdateUIWith:model type:self.type];
if (![_uid isEqualToString:[BJUserManager userInfo].uid]){
cell.moreButton.hidden = YES;
cell.tagRight.constant = 15;
}
WEAK_SELF;
cell.moreBlock = ^{
[weakSelf showDeleteViewWithFID:model.id];
};
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SPFocusFansModel *model = self.dataArray[indexPath.row];
[UIViewController goUserMainpageWith:model.uid withRid:@""];
[self removeFromSuperview];
}
- (void)showDeleteViewWithFID:(NSString *)fid
{
LMDeleteMiyouAlertView *deletev = LoadNib(@"LMDeleteMiyouAlertView");
deletev.frame = CGRectMake(0, 0, APPW, APPH);
[MainWindow() addSubview:deletev];
deletev.fid = fid;
[deletev sheetViewforViewAppear];
WEAK_SELF;
deletev.sucBlock = ^{
[weakSelf fetchData];
};
}
@end