@interface YKWithdrawalOfCashViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;//首页列表
@property (nonatomic, strong) YKWithdrawalOfCashAmountOfWithdrawalViewBankInfoModel *bankInfoModel;//YKWithdrawalOfCashAmountOfWithdrawalViewBankInfoModel
@end
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self setUpView];
[self setUpLayouts];
[self requestData];
[self handelEvent];
[self notification];
}
//导航栏title
- (void)setupNavigationItems
{
[super setupNavigationItems];
self.title = @"提现";
self.titleView.tintColor = UIColorWhite;
self.navigationItem.leftBarButtonItem = [UIBarButtonItem qmui_itemWithImage:UIImageMake(@"nav_back") target:self action:@selector(back)];
self.navigationItem.leftBarButtonItem.tintColor = UIColorWhite;
}
- (void)back{
[self.navigationController popViewControllerAnimated:YES];
}
//导航栏背景色
- (UIImage *)qmui_navigationBarBackgroundImage
{
return [JFTool gradientImageWithColors:@[RGBAColor(240, 197, 129, 1.0), RGBAColor(248, 220, 164, 1.0)] size:CGSizeMake(ZXJ_SCREEN_W, ZXJ_NavigationBar_H)];;
}
//状态栏
- (UIStatusBarStyle)preferredStatusBarStyle
{
if (@available(iOS 13.0, *)) {
return UIStatusBarStyleLightContent;
} else {
// Fallback on earlier versions
return UIStatusBarStyleDefault;
}
}
- (void)setUpView{
[self.view addSubview:self.tableView];
}
- (void)setUpLayouts{
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(ZXJ_NavigationBar_H);
make.left.right.mas_equalTo(0);
make.bottom.mas_equalTo(-ZXJ_Safe_Bottom_H);
}];
}
- (void)requestData{
//判断是否是户主,户主拥有添加房间和编辑的权限,非户主只能查看👀
// self.isUserFamilyMaster = [XLMineFamilyManageentRequest isUserFamilyMaster:[XLFamilyManager sharedInstance].currentFamily];
//登录时获得家庭信息
// self.dataSource = [XLMineFamilyManageentRequest getFamilyManagementView:[XLFamilyManager sharedInstance].currentFamily];
self.bankInfoModel =
[self.tableView reloadData];
}
- (void)handelEvent{
}
- (void)notification{
// 注册通知,也是观察通知,接收通知消息和值
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getUpdateFamilyNotificationAction:) name:XL_UpdateFamilyNotification object:nil];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCardSourceFromLocal:) name:XL_UpdateAllDevicesNotification object:nil];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCardSourceFromLocal:) name:XL_DeviceControlReportNotification object:nil];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCardSourceFromLocal:) name:XL_DeviceInfoReportNotification object:nil];
}
//设备本地缓存数据
- (void)getCardSourceFromLocal:(NSNotification*)note{
[self requestData];//更新界面
}
- (void)getUpdateFamilyNotificationAction:(NSNotification*)note{
NSDictionary *dict = note.userInfo;
NSString *result = dict[@"result"];
NSLog(@"接收到通知内容:%@",result);
[self requestData];//更新界面
}
#pragma mark - table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
CGFloat heightForRow = 92;
if(indexPath.section == 0){
heightForRow = 92;
}else if (indexPath.section == 1){
heightForRow = 334;
}else if (indexPath.section == 2){
heightForRow = 139;
}else{
heightForRow = 92;
}
return heightForRow;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0.1f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 6.1f;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section == 0){//可提现金额
static NSString *const cellID = @"YKWithdrawalOfCashHeaderViewCell";
YKWithdrawalOfCashHeaderViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
// cell.model = self.dataSource[indexPath.section][indexPath.row];
return cell;
}else if (indexPath.section == 1){//提现金额
static NSString *const cellID = @"YKWithdrawalOfCashAmountOfWithdrawalViewCell";
YKWithdrawalOfCashAmountOfWithdrawalViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
// cell.model = self.dataSource[indexPath.section][indexPath.row];
return cell;
}else if (indexPath.section == 2){//提现说明
static NSString *const cellID = @"YKWithdrawalOfCashInstructionsForWithdrawalViewCell";
YKWithdrawalOfCashInstructionsForWithdrawalViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
cell.model = self.dataSource[indexPath.section][indexPath.row];
return cell;
}else{//其他
static NSString *const cellID = @"YKWithdrawalOfCashHeaderViewCell";
YKWithdrawalOfCashHeaderViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
// cell.model = self.dataSource[indexPath.section][indexPath.row];
return cell;
}
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
ZXJSectionCornerViewAttribute *attribute = [ZXJSectionCornerViewAttribute new];
attribute.radius = 10.f;
attribute.lineLeftMargin = 32.f;
attribute.lineRightMargin = 32.f;
attribute.separatorColor = RGBAColor(224, 229, 229, 1.0);
[tableView tableView:tableView willDisplayCell:cell forRowAtIndexPath:indexPath withAttribute:attribute];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"点击了第%ld组第%ld行",indexPath.section,indexPath.row);
}
#pragma mark - Setter && Getter 懒加载
- (UITableView *)tableView{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.delegate = self;
_tableView.backgroundColor = RGBAColor(245, 245, 245, 1.0);
_tableView.dataSource = self;
// 假设你的UITableView实例名为tableView
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 44.0; // 提供一个估算的行高,这个值可以根据你的需求调整
//注册cell
[_tableView registerClass:[YKWithdrawalOfCashHeaderViewCell class] forCellReuseIdentifier:NSStringFromClass([YKWithdrawalOfCashHeaderViewCell class])];
[_tableView registerClass:[YKWithdrawalOfCashAmountOfWithdrawalViewCell class] forCellReuseIdentifier:NSStringFromClass([YKWithdrawalOfCashAmountOfWithdrawalViewCell class])];
[_tableView registerClass:[YKWithdrawalOfCashInstructionsForWithdrawalViewCell class] forCellReuseIdentifier:NSStringFromClass([YKWithdrawalOfCashInstructionsForWithdrawalViewCell class])];
// 这是全部去掉cell下划线
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
// UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ZXJ_SCREEN_W, ZXJ_Tabbar_H+12)];
// _tableView.tableFooterView = footView;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
return _tableView;
}