// // RoomSubsidyVC.m // YaYin // // Created by dlan on 2023/1/14. // Copyright © 2023 YaYin. All rights reserved. // #import "RoomSubsidyVC.h" #import "SubsidyCell.h" #import "BuTieModel.h" #import "YYSubsidySetVC.h" #import "UIButton+BAKit.h" #import @interface RoomSubsidyVC () @property (weak, nonatomic) IBOutlet UIView *containerView; //上周流水 @property (weak, nonatomic) IBOutlet UILabel *lastMonthLab; //当前流水 @property (weak, nonatomic) IBOutlet UILabel *currentLab; //获得补贴 @property (weak, nonatomic) IBOutlet UILabel *subsidyLab; @property (weak, nonatomic) IBOutlet UIButton *fenpeiBtn; @property (weak, nonatomic) IBOutlet UIView *tabBackView; @property (weak, nonatomic) IBOutlet UILabel *noOpenLab; @property (weak, nonatomic) IBOutlet UIView *bottomBgView; @property (weak, nonatomic) IBOutlet UIView *webViewCover; @property (strong, nonatomic) WKWebView *webView; @property(nonatomic, strong) UITableView *myTableView; @property(nonatomic, copy) NSArray *dataAry; @property(nonatomic, strong) BuTieModel *model; @end @implementation RoomSubsidyVC - (void)viewDidLoad { [super viewDidLoad]; if (self.isLucky) { [self showNaviBarWithTitle:@"幸运补贴"]; }else { [self showNaviBarWithTitle:@"房间补贴"]; // [ControlCreator createButton:self.view rect:CGRectMake(ScreenWidth-60-15, yb_StatusBar_H+7, 60, 30) text:@"幸运补贴" font:YBMediumFont(14) color:HEXCOLOR(0x333333) backguoundColor:nil imageName:nil target:self action:@selector(onLucky)]; // self.subsidyLab.hidden = YES; } [self.fenpeiBtn ba_button_setButtonLayoutType:BAKit_ButtonLayoutTypeCenterImageRight padding:6]; [self.tabBackView addSubview:self.myTableView]; [self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.tabBackView); }]; [self getRequest]; [self onJudgeOpen]; self.containerView.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(APPW-30, 136) direction:FXGradientChangeDirectionHorizontal startColor:HEXCOLOR(0xC1FFED) endColor:HEXCOLOR(0x13FFBB)]; //狸猫新增 [self setupWebview]; } - (void)setupWebview { WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init]; configuration.userContentController = [[WKUserContentController alloc] init]; configuration.preferences = [[WKPreferences alloc] init]; configuration.preferences.minimumFontSize = 10; configuration.preferences.javaScriptEnabled = YES; configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES; _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, APPW, APPH) configuration:configuration]; _webView.navigationDelegate = self; _webView.UIDelegate = self; _webView.backgroundColor = kClearColor; _webView.scrollView.backgroundColor = kClearColor; [self.webViewCover addSubview:_webView]; NSURL *url = [NSURL URLWithString:[VERSION_HTTPS_SERVER stringByAppendingString:@"index.php/index/index/page_show?id=18"]]; [_webView loadRequest:[NSURLRequest requestWithURL:url]]; [_webView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(_webViewCover); }]; } - (void)onLucky { RoomSubsidyVC *vc = [[RoomSubsidyVC alloc] init]; vc.rid = self.rid; vc.isLucky = YES; [self.navigationController pushViewController:vc animated:YES]; } - (IBAction)onFenpei:(id)sender { YYSubsidySetVC *vc = [[YYSubsidySetVC alloc] init]; vc.rid = self.rid; [self.navigationController pushViewController:vc animated:YES]; } - (void)onJudgeOpen { NSDictionary *params = @{@"rid":C_string(self.rid)}; [AFNetworkRequset.shared postRequestWithParams:params Path:@"/api/room/get_room_is_earnings_info" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) { //是否有收益 1是2否 NSInteger is_earnings = [responseDic[@"data"] safeIntForKey:@"is_earnings"]; if (is_earnings == 1) { self.noOpenLab.hidden = YES; //狸猫客户要做成单页 self.bottomBgView.hidden = YES; }else { self.noOpenLab.hidden = NO; self.bottomBgView.hidden = YES; } if (self.isLucky == NO) { self.bottomBgView.hidden = YES; } } Failure:^(id _Nonnull errorData) { }]; } - (void)getRequest { NSDictionary *params = @{@"rid":C_string(self.rid)}; NSString *urlStr = @"/api/room/room_subsidy_info"; if (self.isLucky) { urlStr = @"/api/room/room_lucky_subsidy_info"; } WEAK_SELF [AFNetworkRequset.shared postRequestWithParams:params Path:urlStr Loading:NO Hud:NO Success:^(id _Nonnull responseDic) { weakSelf.model = [BuTieModel mj_objectWithKeyValues:responseDic[@"data"]]; weakSelf.dataAry = weakSelf.model.room_subsidy_info; [weakSelf updateHeadInfo]; [weakSelf.myTableView reloadData]; } Failure:^(id _Nonnull errorData) { }]; } - (void)updateHeadInfo { self.lastMonthLab.text = [NSString stringWithFormat:@"%.2f元", _model.last_week_income]; self.currentLab.text = [NSString stringWithFormat:@"当前流水:%.2f元", _model.week_income]; self.subsidyLab.text = [NSString stringWithFormat:@"%.2f元", _model.last_week_subsidy_money]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.dataAry.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 56; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier = @"SubsidyCell"; SubsidyCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (!cell) { cell = [[SubsidyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]; } NSDictionary *dic = self.dataAry[indexPath.row]; cell.numLab.text = NSStringFormat(@"%@",minStr(dic[@"level_name"])); cell.liushuiLab.text = NSStringFormat(@"%@",minStr(dic[@"total_gift_price"])); cell.butieLab.text = NSStringFormat(@"%@",minStr(dic[@"money"])); return cell; } #pragma mark - 懒加载 - (UITableView *)myTableView { if (!_myTableView) { _myTableView = [[UITableView alloc] initWithFrame:CGRectZero style:0]; _myTableView.delegate = self; _myTableView.dataSource = self; _myTableView.backgroundColor = kClearColor; _myTableView.separatorStyle = 0; [_myTableView registerNib:[UINib nibWithNibName:@"SubsidyCell" bundle:nil] forCellReuseIdentifier:@"SubsidyCell"]; } return _myTableView; } @end