163 lines
5.6 KiB
Mathematica
163 lines
5.6 KiB
Mathematica
|
|
//
|
||
|
|
// YYSubsidySetVC.m
|
||
|
|
// SweetParty
|
||
|
|
//
|
||
|
|
// Created by bj_szd on 2023/12/25.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "YYSubsidySetVC.h"
|
||
|
|
#import "YYSubsidySetCell.h"
|
||
|
|
#import "YYSubsidySearchVC.h"
|
||
|
|
#import "SPFocusFansModel.h"
|
||
|
|
#import "YYRoomSetBiliAlert.h"
|
||
|
|
|
||
|
|
@interface YYSubsidySetVC () <UITextFieldDelegate, UITableViewDataSource, UITableViewDelegate>
|
||
|
|
|
||
|
|
@property (weak, nonatomic) IBOutlet UITextField *searchTF;
|
||
|
|
@property (weak, nonatomic) IBOutlet UIImageView *avatarImgV;
|
||
|
|
@property (weak, nonatomic) IBOutlet UILabel *nicknameLab;
|
||
|
|
@property (weak, nonatomic) IBOutlet UILabel *IDLab;
|
||
|
|
@property (weak, nonatomic) IBOutlet UILabel *valueLab;
|
||
|
|
@property (weak, nonatomic) IBOutlet UILabel *fenpeiLab;
|
||
|
|
@property (weak, nonatomic) IBOutlet UITableView *tableView;
|
||
|
|
|
||
|
|
@property (nonatomic, strong) NSArray *dataArray;
|
||
|
|
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation YYSubsidySetVC
|
||
|
|
|
||
|
|
- (void)viewDidLoad {
|
||
|
|
[super viewDidLoad];
|
||
|
|
|
||
|
|
[self showNaviBarWithTitle:@"房间补贴分配"];
|
||
|
|
|
||
|
|
[self createUI];
|
||
|
|
|
||
|
|
[self fetchData];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)createUI {
|
||
|
|
self.searchTF.delegate = self;
|
||
|
|
|
||
|
|
self.tableView.separatorStyle = NO;
|
||
|
|
self.tableView.delegate = self;
|
||
|
|
self.tableView.dataSource = self;
|
||
|
|
[self.tableView registerNib:[UINib nibWithNibName:@"YYSubsidySetCell" bundle:nil] forCellReuseIdentifier:@"YYSubsidySetCell"];
|
||
|
|
self.tableView.rowHeight = 90;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
|
||
|
|
[self onSearch];
|
||
|
|
return YES;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)onSearch {
|
||
|
|
if (self.searchTF.text.length <= 0) {
|
||
|
|
[HelpPageDefine showMessage:@"请输入搜索内容"];
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
NSDictionary *params = @{@"rid":C_string(self.rid), @"keywords":self.searchTF.text};
|
||
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/room/user_search" Loading:YES Hud:NO Success:^(id _Nonnull responseDic) {
|
||
|
|
NSArray *arr = [SPFocusFansModel mj_objectArrayWithKeyValuesArray:responseDic[@"data"]];
|
||
|
|
if (arr.count > 0) {
|
||
|
|
YYSubsidySearchVC *vc = [[YYSubsidySearchVC alloc] init];
|
||
|
|
vc.rid = self.rid;
|
||
|
|
vc.resultArr = arr;
|
||
|
|
[self.navigationController pushViewController:vc animated:YES];
|
||
|
|
WEAK_SELF
|
||
|
|
[vc setOnSuccessBlock:^{
|
||
|
|
[weakSelf fetchData];
|
||
|
|
}];
|
||
|
|
}else {
|
||
|
|
[HelpPageDefine showMessage:@"未搜索到相关用户"];
|
||
|
|
}
|
||
|
|
|
||
|
|
} Failure:^(id _Nonnull errorData) {
|
||
|
|
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)fetchData {
|
||
|
|
NSDictionary *params = @{@"rid":C_string(self.rid)};
|
||
|
|
[AFNetworkRequset.shared postRequestWithParams:params Path:@"/api/room/get_room_user_subsidy_list" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
|
||
|
|
YYSubsidySetModel *model = [YYSubsidySetModel mj_objectWithKeyValues:responseDic[@"data"][@"room_owner_info"]];
|
||
|
|
[self onUpdateUIWith:model];
|
||
|
|
|
||
|
|
NSArray *arr = [YYSubsidySetModel mj_objectArrayWithKeyValuesArray:responseDic[@"data"][@"room_subsidy_list"]];
|
||
|
|
self.dataArray = arr;
|
||
|
|
[self.tableView reloadData];
|
||
|
|
|
||
|
|
} Failure:^(id _Nonnull errorData) {
|
||
|
|
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)onUpdateUIWith:(YYSubsidySetModel *)model {
|
||
|
|
[self.avatarImgV sd_setImageWithURL:[NSURL URLWithString:model.head_pic] placeholderImage:kDefaultUserIcon];
|
||
|
|
self.nicknameLab.text = model.nick_name;
|
||
|
|
self.IDLab.text = [NSString stringWithFormat:@"%@", model.uid];
|
||
|
|
self.valueLab.text = [NSString stringWithFormat:@"%.2f元", model.subsidy_money];
|
||
|
|
self.fenpeiLab.text = [NSString stringWithFormat:@"%@%%", model.ratio];
|
||
|
|
}
|
||
|
|
|
||
|
|
#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 {
|
||
|
|
YYSubsidySetCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YYSubsidySetCell" forIndexPath:indexPath];
|
||
|
|
cell.selectionStyle = NO;
|
||
|
|
YYSubsidySetModel *model = self.dataArray[indexPath.row];
|
||
|
|
cell.model = model;
|
||
|
|
WEAK_SELF
|
||
|
|
[cell.deleteBtn buttonAddTaget:^(UIButton *btn) {
|
||
|
|
[weakSelf onDeleteWith:model];
|
||
|
|
} forControlEvents:UIControlEventTouchUpInside];
|
||
|
|
|
||
|
|
[cell.settingBtn buttonAddTaget:^(UIButton *btn) {
|
||
|
|
[weakSelf onSettingBili:model];
|
||
|
|
} forControlEvents:UIControlEventTouchUpInside];
|
||
|
|
|
||
|
|
return cell;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)onDeleteWith:(YYSubsidySetModel *)model {
|
||
|
|
NSDictionary *params = @{@"rid":C_string(self.rid), @"id":model.id};
|
||
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/room/del_room_user_subsidy" Loading:NO Hud:YES Success:^(id _Nonnull responseDic) {
|
||
|
|
[self fetchData];
|
||
|
|
|
||
|
|
} Failure:^(id _Nonnull errorData) {
|
||
|
|
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)onSettingBili:(YYSubsidySetModel *)model {
|
||
|
|
YYRoomSetBiliAlert *view = LoadNib(@"YYRoomSetBiliAlert");
|
||
|
|
view.frame = [UIScreen mainScreen].bounds;
|
||
|
|
[KEYWINDOW addSubview:view];
|
||
|
|
view.currentRatio = model.ratio;
|
||
|
|
[view setOnCompleteBlock:^(NSInteger ratio) {
|
||
|
|
NSDictionary *params = @{@"rid":C_string(self.rid), @"uid":model.uid, @"ratio":@(ratio)};
|
||
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/room/update_room_user_subsidy" Loading:NO Hud:YES Success:^(id _Nonnull responseDic) {
|
||
|
|
[self fetchData];
|
||
|
|
|
||
|
|
} Failure:^(id _Nonnull errorData) {
|
||
|
|
|
||
|
|
}];
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
|
|
YYSubsidySetModel *model = self.dataArray[indexPath.row];
|
||
|
|
[UIViewController goUserMainpageWith:model.uid withRid:@""];
|
||
|
|
}
|
||
|
|
|
||
|
|
@end
|