| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580 |
- //
- // MOLiveMemberListView.m
- // MiMoLive
- //
- // Created by SuperC on 2023/11/19.
- //
- //一页的size
- #define kPageSize 15
- #import "MOLiveMemberListView.h"
- #import "MORankListView.h"
- #import "MOLiveVipListView.h"
- #import "MORoomContriView.h"
- @interface MOLiveMemberListView ()
- @property (weak, nonatomic) IBOutlet UIView *bgView;
- @property (weak, nonatomic) IBOutlet UIButton *inviteBtn;
- @property (nonatomic, strong) MOMemberTableView *audienceTableView;
- /** 图层调整 -> 现在为管理员 */
- @property (nonatomic, strong) MOMemberTableView *vipTableView;
- @property (nonatomic, strong) MORoomContriView *contributionView;
- @property (nonatomic, strong) MOLiveVipListView *vipListView;
- @property (weak, nonatomic) IBOutlet UIStackView *btnBgStack;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *stackRight;
- @property (nonatomic, assign) NSInteger stackRightNum;
- @property (weak, nonatomic) IBOutlet UIStackView *numStack;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *numStackRight;
- @property (weak, nonatomic) IBOutlet UIButton *audienceBtn;
- @property (weak, nonatomic) IBOutlet UIButton *contributionBtn;
- @property (weak, nonatomic) IBOutlet UIButton *vipBtn;
- @property (weak, nonatomic) IBOutlet UILabel *audienceNumLab;
- @property (weak, nonatomic) IBOutlet UILabel *contributionNumLab;
- @property (weak, nonatomic) IBOutlet UILabel *vipNumLab;
- @property (nonatomic, assign) double vipMembers;
- @property (nonatomic, assign) double memberMembers;
- @property (nonatomic, assign) double manageMembers;
- @property (nonatomic, assign) double vipMember2;
- /** 下标 */
- @property (nonatomic, copy) NSString *audienceNext;
- /** 下标 */
- @property (nonatomic, copy) NSString *vipNext;
- @property (nonatomic, strong) UIImageView *lineView;
- /** 当前选中的列表 */
- @property (nonatomic, assign) NSInteger selectIndex;
- @end
- @implementation MOLiveMemberListView
- + (instancetype)moLiveMemberListView{
- return [[[NSBundle mainBundle] loadNibNamed:@"MOLiveMemberListView" owner:self options:nil] firstObject];
- }
- - (void)awakeFromNib{
- [super awakeFromNib];
-
- self.bgView.layer.cornerRadius = 16.0;
- self.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
- self.bgView.layer.masksToBounds = YES;
-
- self.inviteBtn.layer.cornerRadius = 25.0 / 2.0;
- self.inviteBtn.layer.masksToBounds = YES;
- // NSArray *colorArr = @[[MOTools colorWithHexString:@"#FF62EE" alpha:1.0],[MOTools colorWithHexString:@"#9923FF" alpha:1.0]];
- // UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, 70.0, 25.0) Colors:colorArr GradientType:0];
- // [self.inviteBtn setBackgroundImage:image forState:UIControlStateNormal];
- [self.inviteBtn setBackgroundColor:kBaseBtnBgColor];
- [self.inviteBtn setFont:[MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr]];
-
- [self.audienceBtn setFont:[MOTextTools poppinsBoldFont:16.0]];
- [self.contributionBtn setFont:[MOTextTools poppinsMediumFont:16.0]];
- [self.vipBtn setFont:[MOTextTools poppinsMediumFont:16.0]];
-
- self.audienceNumLab.font = [MOTextTools poppinsMediumFont:11.0];
- self.contributionNumLab.font = [MOTextTools poppinsMediumFont:11.0];
- self.vipNumLab.font = [MOTextTools poppinsMediumFont:11.0];
-
- [self.audienceBtn setTitleColor:kBaseTextColor_1 forState:UIControlStateSelected];
- [self.audienceBtn setTitleColor:kBaseTextColor_3 forState:UIControlStateNormal];
- self.audienceBtn.tag = 90;
-
- [self.contributionBtn setTitleColor:kBaseTextColor_1 forState:UIControlStateSelected];
- [self.contributionBtn setTitleColor:kBaseTextColor_3 forState:UIControlStateNormal];
- self.contributionBtn.tag = 92;
-
- [self.vipBtn setTitleColor:kBaseTextColor_1 forState:UIControlStateSelected];
- [self.vipBtn setTitleColor:kBaseTextColor_3 forState:UIControlStateNormal];
- self.vipBtn.tag = 91;
-
- [self.audienceNumLab setTextColor:kBaseTextColor_1];
- [self.contributionNumLab setTextColor:kBaseTextColor_3];
- [self.vipNumLab setTextColor:kBaseTextColor_3];
-
- self.stackRightNum = 0.0;
- CGFloat baseWidth = (SCREENWIDTH - self.stackRightNum) / 4.0;
- [self.bgView addSubview:self.lineView];
- [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.btnBgStack.mas_centerX).offset(baseWidth * -1.0);
- make.width.equalTo(@40.0);
- make.height.equalTo(@2.0);
- make.top.equalTo(self.bgView).offset(48.0);
- }];
-
- UIView *lineTwoView = [[UIView alloc] init];
- lineTwoView.backgroundColor = [MOTools colorWithHexString:@"#DADCE6" alpha:0.6];
- [self.bgView addSubview:lineTwoView];
- [lineTwoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgView).offset(50.0);
- make.left.right.equalTo(self.bgView);
- make.height.equalTo(@0.5);
- }];
-
- [self.bgView addSubview:self.audienceTableView];
- [self.audienceTableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.equalTo(self.bgView);
- make.top.equalTo(lineTwoView.mas_bottom).offset(7.0);
- }];
-
- [self.bgView addSubview:self.vipTableView];
- [self.vipTableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.equalTo(self.bgView);
- make.top.equalTo(lineTwoView.mas_bottom).offset(7.0);
- }];
- self.vipTableView.hidden = YES;
-
- [self.bgView addSubview:self.contributionView];
- [self.contributionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.equalTo(self.bgView);
- make.top.equalTo(lineTwoView.mas_bottom);
- }];
- self.contributionView.hidden = YES;
-
- [self setTableViewBlock];
-
- self.audienceBtn.selected = YES;
-
- self.audienceNext = @"";
- self.vipNext = @"";
-
- }
- //MARK: cell点击事件
- - (void)setTableViewBlock{
- WEAKSELF
- self.audienceTableView.cellClickBlock = ^(MOUserBase * _Nonnull cellModel) {
- [weakSelf theCellClickWith:cellModel];
- };
- self.audienceTableView.inviteBlock = ^{
- [weakSelf theInviteBtnClick];
- };
- self.audienceTableView.headBtnClickBlock = ^{
- [weakSelf showVipListView];
- };
-
-
- self.vipTableView.cellClickBlock = ^(MOUserBase * _Nonnull cellModel) {
- [weakSelf theCellClickWith:cellModel];
- };
- self.vipTableView.inviteBlock = ^{
- [weakSelf theInviteBtnClick];
- };
-
- self.contributionView.headBtnClickBlock = ^(MOUserBase * _Nonnull userBase) {
-
- weakSelf.contriHeadClickBlock ? weakSelf.contriHeadClickBlock(userBase) : nil;
-
- [weakSelf dismissListView];
- };
- }
- - (void)showVipListView{
- WEAKSELF
- [self addSubview:self.vipListView];
- [self.vipListView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self).offset(0);
- make.width.equalTo(@(SCREENWIDTH));
- make.height.equalTo(@502.0);
- make.bottom.equalTo(self);
- }];
- self.vipListView.roomId = self.roomId;
- [self.vipListView showLiveVipListView];
- [self.vipListView getFirstHttpData];
-
- self.vipListView.cellClickBlock = ^(MOUserBase * _Nonnull cellModel) {
- [weakSelf theCellClickWith:cellModel];
- };
- }
- - (void)theCellClickWith:(MOUserBase *)model{
-
- self.cellClickBlock ? self.cellClickBlock(model) : nil;
-
- [self dismissListView];
- }
- - (void)theInviteBtnClick{
- self.inviteBlock ? self.inviteBlock() : nil;
- }
- - (void)setIsCreatLive:(BOOL)isCreatLive{
- _isCreatLive = isCreatLive;
- if(!isCreatLive){
- self.inviteBtn.hidden = YES;
- self.stackRight.constant = 0.0;
- self.stackRightNum = 0.0;
- }
- self.selectIndex = 0;
- }
- - (void)getAllHttpData{
-
- //观众
- NSDictionary *audiencePage = @{@"size":@(kPageSize),@"next":self.audienceNext};
- NSDictionary *audienceDict = @{@"page":audiencePage,
- @"roomId":self.roomId};
- [self getAudienceHttpDataWith:audienceDict];
-
- NSDictionary *vipPage = @{@"size":@(kPageSize),@"next":self.vipNext};
- NSDictionary *vipDict = @{@"page":vipPage,
- @"roomId":self.roomId};
- [self getVipHttpDataWith:vipDict];
-
- // //管理员
- // NSDictionary *manageDict = @{@"id":self.roomId};
- // [self getManagerHttpDataWith:manageDict];
-
- //贡献榜
- self.contributionView.roomId = self.roomId;
- }
- //获取在线观众
- - (void)getAudienceHttpDataWith:(NSDictionary *)dict{
- WEAKSELF
- [kHttpManager toGetJoinMembersAboutLiveWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- __strong typeof(weakSelf) self = weakSelf;
- [self.audienceTableView.mj_footer endRefreshing];
-
- if(kCode_Success){
- // MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
-
- MOLiveMemberData *baseModel = [MOLiveMemberData modelObjectWithDictionary:data[@"data"]];
- if(baseModel.next == nil || baseModel.next.length == 0){
- if(self.audienceNext == nil || self.audienceNext.length == 0){
- //第一页
- self.audienceTableView.dataArr = [baseModel.userBase mutableCopy];
-
- self.memberMembers = baseModel.memberMembers;
- self.vipMembers = baseModel.vipMembers;
- self.vipMember2 = baseModel.vipMember2;
- self.manageMembers = baseModel.manageMembers;
- [self updataUIWithProperty];
- }
- else{
- //最后一页
- [self.audienceTableView toAddUserListDataWith:baseModel.userBase];
- }
- self.audienceNext = @"";
-
- [self.audienceTableView.mj_footer endRefreshingWithNoMoreData];
- }
- else{
- if(self.audienceNext == nil || self.audienceNext.length == 0){
- self.memberMembers = baseModel.memberMembers;
- self.vipMembers = baseModel.vipMembers;
- self.vipMember2 = baseModel.vipMember2;
- self.manageMembers = baseModel.manageMembers;
- [self updataUIWithProperty];
- }
- self.audienceNext = baseModel.next;
- [self.audienceTableView toAddUserListDataWith:baseModel.userBase];
- }
- self.audienceTableView.theVipNum = self.vipMembers;
- [self.audienceTableView reloadData];
- self.audienceTableView.mj_footer.hidden = (self.audienceTableView.dataArr.count > 0) ? NO : YES;
-
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)updataUIWithProperty{
- // MORtmJosnEntity *jsonEntity = (MORtmJosnEntity *)self.roomStatusEntity.data;
- // self.audienceNumLab.text = [NSString stringWithFormat:@"%.f",jsonEntity.v];
- // self.vipNumLab.text = [NSString stringWithFormat:@"%.f",jsonEntity.m];
- self.audienceNumLab.text = [NSString stringWithFormat:@"%.f",self.memberMembers];
- self.vipNumLab.text = [NSString stringWithFormat:@"%.f",self.vipMember2];
- }
- - (void)getVipHttpDataWith:(NSDictionary *)dict{
- WEAKSELF
- [kHttpManager toGetJoinManagesAboutLiveWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- __strong typeof(weakSelf) self = weakSelf;
- [self.vipTableView.mj_footer endRefreshing];
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
-
- MOLiveMemberData *baseModel = [MOLiveMemberData modelObjectWithDictionary:data[@"data"]];
- if(baseModel.next == nil || baseModel.next.length == 0){
- if(self.vipNext == nil || self.vipNext.length == 0){
- //第一页
- self.vipTableView.dataArr = [baseModel.userBase mutableCopy];
- }
- else{
- //最后一页
- //最后一页
- [self.vipTableView toAddUserListDataWith:baseModel.userBase];
- }
- self.vipNext = @"";
- [self.vipTableView.mj_footer endRefreshingWithNoMoreData];
- }
- else{
- self.vipNext = baseModel.next;
- [self.vipTableView toAddUserListDataWith:baseModel.userBase];
- }
- [self.vipTableView reloadData];
- self.vipTableView.mj_footer.hidden = (self.audienceTableView.dataArr.count > 0) ? NO : YES;
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)getManagerHttpDataWith:(NSDictionary *)dict{
- WEAKSELF
- [kHttpManager toGetJoinManagesAboutLiveWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- __strong typeof(weakSelf) self = weakSelf;
-
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
-
- MOLiveMemberData *baseModel = [MOLiveMemberData modelObjectWithDictionary:data[@"data"]];
- self.vipTableView.dataArr = [baseModel.userBase mutableCopy];
- [self.vipTableView reloadData];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (IBAction)changeListClick:(UIButton *)sender {
-
- if(self.vipListView.isShow){
- [self.vipListView dismissLiveVipListView];
- }
-
- if(sender == self.audienceBtn){
- //观众列表
- self.selectIndex = 0;
- }
- else if (sender == self.vipBtn){
- //贡献榜列表
- self.selectIndex = 1;
- }
- else{
- //VIP 列表
- self.selectIndex = 2;
- }
- }
- - (void)setSelectIndex:(NSInteger)selectIndex{
-
- UIButton *oldBtn = [self viewWithTag:(_selectIndex + 90)];
- oldBtn.selected = NO;
- [oldBtn setFont:[MOTextTools poppinsMediumFont:16.0]];
-
- UIButton *newBtn = [self viewWithTag:(selectIndex + 90)];
- newBtn.selected = YES;
- [newBtn setFont:[MOTextTools poppinsBoldFont:16.0]];
-
- _selectIndex = selectIndex;
-
- CGFloat baseWidth = (SCREENWIDTH - self.stackRightNum) / 4.0;
-
- if(selectIndex == 0){
- [self.lineView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.btnBgStack.mas_centerX).offset(baseWidth * -1.0);
- }];
-
- self.audienceTableView.hidden = NO;
- self.contributionView.hidden = YES;
- self.vipTableView.hidden = YES;
-
- [self.audienceNumLab setTextColor:kBaseTextColor_1];
- [self.contributionNumLab setTextColor:kBaseTextColor_3];
- [self.vipNumLab setTextColor:kBaseTextColor_3];
- }
- else if (selectIndex == 1){
- [self.lineView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.btnBgStack.mas_centerX).offset(baseWidth * 1.0);
- }];
-
- self.audienceTableView.hidden = YES;
- self.contributionView.hidden = YES;
- self.vipTableView.hidden = NO;
-
- [self.audienceNumLab setTextColor:kBaseTextColor_3];
- [self.contributionNumLab setTextColor:kBaseTextColor_3];
- [self.vipNumLab setTextColor:kBaseTextColor_1];
- }
- else{
- [self.lineView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.btnBgStack.mas_centerX).offset(baseWidth * 2.0);
- }];
-
- self.audienceTableView.hidden = YES;
- self.contributionView.hidden = NO;
- self.vipTableView.hidden = YES;
-
- [self.audienceNumLab setTextColor:kBaseTextColor_3];
- [self.contributionNumLab setTextColor:kBaseTextColor_3];
- [self.vipNumLab setTextColor:kBaseTextColor_3];
- }
-
- [UIView animateWithDuration:0.3 animations:^
- {
- [self layoutIfNeeded];
- }];
- }
- - (IBAction)dismissBtnClick:(id)sender {
- //隐藏
- [self dismissListView];
- }
- - (IBAction)inviteBtnClick:(id)sender {
- //邀请
- self.inviteBlock ? self.inviteBlock() : nil;
- [self dismissListView];
- }
- - (void)showListView{
- self.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
-
- CGRect actionViewRect = self.bgView.frame;
- actionViewRect.origin.y = SCREENHEIGHT;
- self.bgView.frame = actionViewRect;
-
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^{
- CGRect actionViewRect = weakSelf.bgView.frame;
- actionViewRect.origin.y = SCREENHEIGHT - 560;
- weakSelf.bgView.frame = actionViewRect;
- }];
-
- //不能滑动
- SendNotification(@"MOShowLivePagesVCCannotScroll")
- }
- - (void)dismissListView{
- //完成下移动画
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^
- {
- CGRect actionSheetViewRect = weakSelf.bgView.frame;
- actionSheetViewRect.origin.y = SCREENHEIGHT;
- weakSelf.bgView.frame = actionSheetViewRect;
- } completion:^(BOOL finished)
- {
- [self removeFromSuperview];
- }];
-
- //可以滑动
- SendNotification(@"MOShowLivePagesVCCanScroll")
- }
- #pragma mark - Lazy
- - (MOMemberTableView *)audienceTableView{
- if(!_audienceTableView){
- _audienceTableView = [[MOMemberTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _audienceTableView.backgroundColor = [UIColor clearColor];
-
- _audienceTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _audienceTableView.separatorInset = UIEdgeInsetsZero;
- _audienceTableView.rowHeight = 76.0;
- _audienceTableView.listType = MOMemberListTypeAudience;
-
- WEAKSELF
- _audienceTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
-
- if(weakSelf.audienceNext.length == 0){
- return;
- }
-
- NSDictionary *audiencePage = @{@"size":@(kPageSize),@"next":weakSelf.audienceNext};
- NSDictionary *audienceDict = @{@"page":audiencePage,
- @"roomId":weakSelf.roomId};
- [weakSelf getAudienceHttpDataWith:audienceDict];
- }];
-
- _audienceTableView.mj_footer.hidden = YES;
- }
-
- return _audienceTableView;
- }
- - (MOMemberTableView *)vipTableView{
- if(!_vipTableView){
- _vipTableView = [[MOMemberTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _vipTableView.backgroundColor = [UIColor clearColor];
-
- _vipTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _vipTableView.separatorInset = UIEdgeInsetsZero;
- _vipTableView.rowHeight = 76.0;
-
- //UI逻辑改动, 现在这里是管理员列表
- _vipTableView.listType = MOMemberListTypeAdmin;
-
- WEAKSELF
- _vipTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
-
- if(weakSelf.audienceNext.length == 0){
- return;
- }
-
- NSDictionary *audiencePage = @{@"size":@(kPageSize),@"next":weakSelf.vipNext};
- NSDictionary *audienceDict = @{@"page":audiencePage,
- @"roomId":weakSelf.roomId};
- [weakSelf getAudienceHttpDataWith:audienceDict];
- }];
-
- _vipTableView.mj_footer.hidden = YES;
- }
-
- return _vipTableView;
- }
- - (MORoomContriView *)contributionView{
- if(!_contributionView){
- _contributionView = [[MORoomContriView alloc] init];
-
- }
- return _contributionView;
- }
- - (UIImageView *)lineView{
- if (_lineView == nil){
- _lineView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 40.0, 2.0)];
-
- NSArray *colorArr = @[[MOTools colorWithHexString:@"#4363FF" alpha:1.0],[MOTools colorWithHexString:@"#4363FF" alpha:1.0]];
- UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, 40.0, 2.0) Colors:colorArr GradientType:0];
- [_lineView setImage:image];
-
- _lineView.layer.cornerRadius = 2.0 / 2.0;
- _lineView.layer.masksToBounds = YES;
-
- }
-
- return _lineView;
- }
- - (MOLiveVipListView *)vipListView{
- if(!_vipListView){
- _vipListView = [MOLiveVipListView moLiveVipListView];
- }
- return _vipListView;
- }
- @end
|