123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- //
- // YOUPAILZChatRoomInviationUpSeatListWindow.m
- // VQU
- //
- // Created by CY on 2021/11/5.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZChatRoomInviationUpSeatListWindow.h"
- #import "UIScrollView+LZRefresh.h"
- #import "YOUPAILZChatRoomInviationUpSeatCell.h"
- @interface YOUPAILZChatRoomInviationUpSeatListWindow ()<UITableViewDataSource,UITableViewDelegate>
- @property (nonatomic, weak)UITableView *youpaiptableView;
- @property (nonatomic, strong) NSString *youpaipendTime;
- @property (nonatomic, strong) NSMutableArray <YOUPAILZChatRoomMemberModel *>*youpaipdataSource;
- @end
- @implementation YOUPAILZChatRoomInviationUpSeatListWindow
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.baseView.hidden = YES;
- [self youpaifinitUI];
- [self youpaifrequestInviationListWithStatus:kRefreshNormal];
- }
- - (void)youpaifinitUI{
- UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 400.0f + SafeHeight)];
- bgV.backgroundColor = HexColorFromRGB(0x2A2935);
- [self.view addSubview:bgV];
- [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.offset(0.0f);
- make.height.offset(400.0f + SafeHeight);
- }];
- [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
-
-
- UIView *navV = [[UIView alloc] init];
- [bgV addSubview:navV];
- [navV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.offset(0.0f);
- make.height.offset(43.0f);
- }];
-
- [navV addLineWithColor:[[UIColor whiteColor] colorWithAlphaComponent:0.07f] lineRect:CGRectMake(0, 42.5f, KScreenWidth, 0.5f)];
-
- UILabel *titleL = [[UILabel alloc] init];
- titleL.text = @"邀人上麦";
- titleL.textColor = [UIColor whiteColor];
- titleL.font = LCBoldFont(16.0f);
- [navV addSubview:titleL];
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(navV);
- }];
-
- UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
- tableView.delegate = self;
- tableView.dataSource = self;
- tableView.rowHeight = 60.0f;
- tableView.estimatedRowHeight = 60.0f;
- tableView.estimatedSectionHeaderHeight = 0.0f;
- tableView.estimatedSectionFooterHeight = 0.0f;
- tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- tableView.backgroundColor = [UIColor clearColor];
- tableView.showsVerticalScrollIndicator = NO;
- [self.view addSubview:tableView];
- self.youpaiptableView = tableView;
- @weakify(self);
- [tableView setRefreshHeaderWithBlock:^{
- @strongify(self);
- [self youpaifrequestInviationListWithStatus:kRefreshHeader];
- }];
- [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.offset(0.0f);
- make.bottom.offset(-SafeHeight);
- make.top.equalTo(navV.mas_bottom).offset(0.0f);
- }];
-
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.youpaipdataSource.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- NSString *cellID = @"YOUPAILZChatRoomInviationUpSeatCell";
- YOUPAILZChatRoomInviationUpSeatCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
- if (cell == nil) {
- cell = [[YOUPAILZChatRoomInviationUpSeatCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
- }
- [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row] index:indexPath.row buttonType:LZChatRoomInviationUpSeatCellButtonTypeWithInviation rankType:LZChatRoomInviationUpSeatCellRankTypeWithDefault contributionName:@"贡献值"];
- @weakify(self);
- [cell setYoupaipinviationBtnClickBlock:^(YOUPAILZChatRoomMemberModel * _Nonnull model) {
- @strongify(self);
- [self youpaifinviationUpSeatWithModel:model];
- }];
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- /// 邀请上麦
- - (void)youpaifinviationUpSeatWithModel:(YOUPAILZChatRoomMemberModel *)model{
- [LCHttpHelper requestWithURLString:InviteUpperSeat parameters:@{@"room_id":self.youpaiproomId,@"seat":@(self.youpaipseatId),@"op_uid":model.youpaipid} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- } failure:^(NSError *error) {
- }];
- }
- /// 设置加载更多
- - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
- @weakify(self);
- [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
- @strongify(self);
- [self youpaifrequestInviationListWithStatus:kRefreshFooter];
- }];
- }
- - (void)youpaifrequestInviationListWithStatus:(kRefreshStatus)status{
- if (status == kRefreshFooter) {
-
- }else{
- self.youpaipendTime = @"0";
- }
- @weakify(self);
- [LCHttpHelper requestWithURLString:GetTalkOnlineUser parameters:@{@"room_id":self.youpaiproomId,@"endtime":self.youpaipendTime} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- [self.youpaiptableView endRefreshing:kRefreshAll];
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- if (status != kRefreshFooter) {
- [self.youpaipdataSource removeAllObjects];
- }
- NSDictionary *data = [dict objectForKey:@"data"];
- NSArray <YOUPAILZChatRoomMemberModel *>*list = [YOUPAILZChatRoomMemberModel mj_objectArrayWithKeyValuesArray:[data objectForKey:@"list"]];
- [self.youpaipdataSource addObjectsFromArray:list];
- [self.youpaiptableView reloadData];
- self.youpaipendTime = [data objectForKey:@"end_time"];
- [self youpaifrefreshFooterWithHidden:NO];
- }
- } failure:^(NSError *error) {
- @strongify(self);
- [self.youpaiptableView endRefreshing:kRefreshAll];
- }];
- }
- - (NSMutableArray<YOUPAILZChatRoomMemberModel *> *)youpaipdataSource{
- if (!_youpaipdataSource) {
- _youpaipdataSource = [NSMutableArray array];
- }
- return _youpaipdataSource;
- }
- @end
|