| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 |
- //
- // MOLiveCenterView.m
- // MiMoLive
- //
- // Created by SuperC on 2023/12/5.
- //
- //一页的size
- #define kPageSize 15
- #import "MOLiveCenterView.h"
- #import "MOLiveCenterTableView.h"
- #import "MOLiveCenterRecordListView.h"
- #import "MOCenterDataModels.h"
- @interface MOLiveCenterView ()
- @property (weak, nonatomic) IBOutlet UIView *bgView;
- @property (weak, nonatomic) IBOutlet UILabel *topTitleLab;
- @property (weak, nonatomic) IBOutlet UIView *allIncomeView;
- @property (weak, nonatomic) IBOutlet UIButton *incomeTitleBtn;
- @property (weak, nonatomic) IBOutlet UIButton *goldNumBtn;
- @property (weak, nonatomic) IBOutlet UIView *fanView;
- @property (weak, nonatomic) IBOutlet UIButton *fanTitleBtn;
- @property (weak, nonatomic) IBOutlet UIButton *fanUpNumBtn;
- @property (weak, nonatomic) IBOutlet UIView *memberView;
- @property (weak, nonatomic) IBOutlet UIButton *memberTitleBtn;
- @property (weak, nonatomic) IBOutlet UIButton *memberNumBtn;
- @property (weak, nonatomic) IBOutlet UIView *populartyView;
- @property (weak, nonatomic) IBOutlet UIButton *populartyTitleBtn;
- @property (weak, nonatomic) IBOutlet UIButton *populartyNumBtn;
- @property (weak, nonatomic) IBOutlet BigBtn *giftBtn;
- @property (weak, nonatomic) IBOutlet BigBtn *ticketBtn;
- @property (weak, nonatomic) IBOutlet BigBtn *otherBtn;
- @property (weak, nonatomic) IBOutlet UILabel *totalLab;
- /** 当前选中的下标 */
- @property (nonatomic, assign) NSInteger selectIndex;
- @property (nonatomic, strong) MOLiveCenterTableView *giftTableView;
- @property (nonatomic, strong) MOLiveCenterTableView *ticketTableView;
- @property (nonatomic, strong) MOLiveCenterTableView *otherTableView;
- @property (nonatomic, copy) NSString *giftNext;
- @property (nonatomic, copy) NSString *ticketNext;
- @property (nonatomic, strong) MOLiveCenterData *baseModel;
- @property (nonatomic, strong) MOLiveCenterRecordListView *recordView;
- @end
- @implementation MOLiveCenterView
- + (instancetype)moLiveCenterView{
- return [[[NSBundle mainBundle] loadNibNamed:@"MOLiveCenterView" owner:self options:nil] firstObject];
- }
- - (void)awakeFromNib{
- [super awakeFromNib];
-
- self.topTitleLab.font = [MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalTitleFontStr];
-
- self.giftBtn.font = [MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr];
- self.ticketBtn.font = [MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr];
- self.otherBtn.font = [MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr];
-
- self.bgView.layer.cornerRadius = 12.0;
- self.bgView.layer.masksToBounds = YES;
- self.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMinXMaxYCorner;
-
- self.allIncomeView.layer.cornerRadius = 10.0;
- self.allIncomeView.layer.masksToBounds = YES;
- self.incomeTitleBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
- self.goldNumBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
-
- self.fanView.layer.cornerRadius = 10.0;
- self.fanView.layer.masksToBounds = YES;
- self.fanTitleBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
- self.fanUpNumBtn.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
- self.fanUpNumBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 8);
-
- self.memberView.layer.cornerRadius = 10.0;
- self.memberView.layer.masksToBounds = YES;
- self.memberTitleBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
- self.memberNumBtn.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
- self.memberNumBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 8);
-
- self.populartyView.layer.cornerRadius = 10.0;
- self.populartyView.layer.masksToBounds = YES;
- self.populartyTitleBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
- self.populartyNumBtn.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
- self.populartyNumBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 8);
-
- self.giftBtn.layer.cornerRadius = 24.0 / 2.0;
- self.giftBtn.layer.masksToBounds = YES;
-
- self.ticketBtn.layer.cornerRadius = 24.0 / 2.0;
- self.ticketBtn.layer.masksToBounds = YES;
-
- self.otherBtn.layer.cornerRadius = 24.0 / 2.0;
- self.otherBtn.layer.masksToBounds = YES;
-
- CGFloat bgWidth = SCREENWIDTH - 90.0;
- CGFloat btnWidth = (bgWidth - 15.0 * 2 - 12.0 * 2) / 3.0;
- CGFloat btnHeight = 24.0;
-
- NSArray *normalColorArr = @[[MOTools colorWithHexString:@"#FFFFFF" alpha:1.0],[MOTools colorWithHexString:@"#FFFFFF" alpha:1.0]];
- UIImage *normalImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, (SCREENWIDTH - 36.0 * 2), 50.0) Colors:normalColorArr GradientType:0];
-
- NSArray *selectColorArr = @[kBaseBtnBgColor,kBaseBtnBgColor];
- UIImage *selectImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, (SCREENWIDTH - 36.0 * 2), 50.0) Colors:selectColorArr GradientType:0];
- [self.giftBtn setBackgroundImage:normalImage forState:UIControlStateNormal];
- [self.giftBtn setBackgroundImage:selectImage forState:UIControlStateSelected];
-
- [self.ticketBtn setBackgroundImage:normalImage forState:UIControlStateNormal];
- [self.ticketBtn setBackgroundImage:selectImage forState:UIControlStateSelected];
-
- [self.otherBtn setBackgroundImage:normalImage forState:UIControlStateNormal];
- [self.otherBtn setBackgroundImage:selectImage forState:UIControlStateSelected];
-
- [self.bgView addSubview:self.giftTableView];
- [self.giftTableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.totalLab.mas_bottom).offset(6.0);
- make.left.bottom.right.equalTo(self.bgView);
- }];
-
- [self.bgView addSubview:self.ticketTableView];
- [self.ticketTableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.totalLab.mas_bottom).offset(6.0);
- make.left.bottom.right.equalTo(self.bgView);
- }];
-
- [self.bgView addSubview:self.otherTableView];
- [self.otherTableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.totalLab.mas_bottom).offset(6.0);
- make.left.bottom.right.equalTo(self.bgView);
- }];
- [self setTableViewBlock];
-
- self.selectIndex = 0;
- self.giftNext = @"";
- self.ticketNext = @"";
- }
- - (void)setTableViewBlock{
-
- WEAKSELF
- //MARK: 礼物Cell点击
- self.giftTableView.cellClickBlock = ^(MOPersonList * _Nonnull cellModel) {
- [weakSelf showLiveCenterRecordWith:cellModel.userBase isWish:NO];
- };
-
- self.otherTableView.wishCellClickBlock = ^{
- [weakSelf showLiveCenterRecordWith:nil isWish:YES];
- };
- }
- - (void)showLiveCenterRecordWith:(MOUserBase *)userModel isWish:(BOOL)isWish{
-
- CGFloat width = SCREENWIDTH - 90.0;
-
- [self addSubview:self.recordView];
- [self.recordView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self).offset(90.0);
- make.width.equalTo(@(width));
- make.top.bottom.equalTo(self);
- }];
- self.recordView.roomId = self.roomId;
-
- if(isWish){
- self.recordView.cellType = MOLiveCenterRecordWishCellType;
- }
- else{
- self.recordView.cellType = MOLiveCenterRecordGiftCellType;
- self.recordView.userInfo = userModel;
- }
-
- [self.recordView showLiveCenterRecordListView];
- [self.recordView getHttpFirstData];
- }
- - (void)getAllHttpData{
-
- NSString *roomId = self.roomId;
- if(roomId.length == 0){
- return;
- }
-
- [self getHttpDataAboutCentenInfoWith:roomId];
-
- NSDictionary *giftPage = @{@"size":@(kPageSize),@"next":self.giftNext};
- NSDictionary *giftDict = @{@"page":giftPage,
- @"roomId":roomId};
- [self getHttpDataAboutGiftListWisthDict:giftDict];
-
- NSDictionary *ticketPage = @{@"size":@(kPageSize),@"next":self.ticketNext};
- NSDictionary *ticketDict = @{@"page":ticketPage,
- @"roomId":roomId};
- [self getHttpDataAboutTicketListWisthDict:ticketDict];
- }
- - (void)getHttpDataAboutCentenInfoWith:(NSString *)roomId{
-
- WEAKSELF
- NSDictionary *dict = @{@"id":roomId};
- [kHttpManager theLiveCenterInfoWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- // MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- weakSelf.baseModel = [MOLiveCenterData modelObjectWithDictionary:data[@"data"]];
- [weakSelf setUIProperty];
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)setUIProperty{
-
- CGFloat allGoldNum = self.baseModel.giftGoldenBean + self.baseModel.ticketGoldenBean + self.baseModel.otherGoldenBean + self.baseModel.likeGoldenBean + self.baseModel.divideGoldenBean;
-
- [self.goldNumBtn setTitle:[NSString stringWithFormat:@"%.f",allGoldNum] forState:UIControlStateNormal];
- [self.fanUpNumBtn setTitle:[NSString stringWithFormat:@"%.f",self.baseModel.fans] forState:UIControlStateNormal];
- [self.memberNumBtn setTitle:[NSString stringWithFormat:@"%.f",self.baseModel.members] forState:UIControlStateNormal];
- [self.populartyNumBtn setTitle:[NSString stringWithFormat:@"%.f",self.baseModel.popularity] forState:UIControlStateNormal];
-
- self.totalLab.text = [NSString stringWithFormat:@"Total %.f",self.baseModel.giftGoldenBean];
-
- self.otherTableView.otherGoldenBean = self.baseModel.otherGoldenBean;
- self.otherTableView.likeGoldenBean = self.baseModel.likeGoldenBean;
- self.otherTableView.divideGoldenBean = self.baseModel.divideGoldenBean;
- [self.otherTableView reloadData];
-
- }
- - (void)getHttpDataAboutGiftListWisthDict:(NSDictionary *)dict{
- WEAKSELF
- [kHttpManager theLiveCenterAboutGiftUserWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- __strong typeof(weakSelf) self = weakSelf;
- [self.giftTableView.mj_footer endRefreshing];
- if(kCode_Success){
- // MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
-
- MOPersonData *personModel = [MOPersonData modelObjectWithDictionary:data[@"data"]];
- if(personModel.next == nil || personModel.next.length == 0){
- if(self.giftNext == nil || self.giftNext.length == 0){
- //第一页
- self.giftTableView.dataArr = [personModel.personList mutableCopy];
- }
- else{
- //最后一页
- [self.giftTableView.dataArr addObjectsFromArray:personModel.personList];
- }
- self.giftNext = @"";
-
- [self.giftTableView.mj_footer endRefreshingWithNoMoreData];
- }
- else{
- self.giftNext = personModel.next;
- [self.giftTableView.dataArr addObjectsFromArray:personModel.personList];
-
- }
-
- [self.giftTableView reloadData];
- self.giftTableView.mj_footer.hidden = (self.giftTableView.dataArr.count > 0) ? NO : YES;
-
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (void)getHttpDataAboutTicketListWisthDict:(NSDictionary *)dict{
- WEAKSELF
- [kHttpManager theLiveCenterAboutTicketWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- __strong typeof(weakSelf) self = weakSelf;
- [self.ticketTableView.mj_footer endRefreshing];
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- MOPersonData *personModel = [MOPersonData modelObjectWithDictionary:data[@"data"]];
- if(personModel.next == nil || personModel.next.length == 0){
- if(self.ticketNext == nil || self.ticketNext.length == 0){
- //第一页
- self.ticketTableView.dataArr = [personModel.personList mutableCopy];
- }
- else{
- //最后一页
- [self.ticketTableView.dataArr addObjectsFromArray:personModel.personList];
- }
- self.ticketNext = @"";
-
- [self.ticketTableView.mj_footer endRefreshingWithNoMoreData];
- }
- else{
- self.ticketNext = personModel.next;
- [self.ticketTableView.dataArr addObjectsFromArray:personModel.personList];
- }
- [self.ticketTableView reloadData];
- self.ticketTableView.mj_footer.hidden = (self.ticketTableView.dataArr.count > 0) ? NO : YES;
-
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- //关闭 视图
- - (IBAction)closeBtnClick:(id)sender {
- [self dismissLiveCenterView];
- }
- - (IBAction)typeChangeBtnClick:(BigBtn *)sender {
- if(sender == self.giftBtn){
- self.selectIndex = 0;
- }
- else if (sender == self.ticketBtn){
- self.selectIndex = 1;
- }
- else{
- self.selectIndex = 2;
- }
- }
- - (void)setSelectIndex:(NSInteger)selectIndex{
- _selectIndex = selectIndex;
-
- if(selectIndex == 0){
- self.giftBtn.selected = YES;
- self.ticketBtn.selected = NO;
- self.otherBtn.selected = NO;
-
- self.giftTableView.hidden = NO;
- self.ticketTableView.hidden = YES;
- self.otherTableView.hidden = YES;
-
- self.totalLab.text = [NSString stringWithFormat:@"Total %.f",self.baseModel.giftGoldenBean];
- }
- else if (selectIndex == 1){
- self.giftBtn.selected = NO;
- self.ticketBtn.selected = YES;
- self.otherBtn.selected = NO;
-
- self.giftTableView.hidden = YES;
- self.ticketTableView.hidden = NO;
- self.otherTableView.hidden = YES;
-
- self.totalLab.text = [NSString stringWithFormat:@"Total %.f",self.baseModel.ticketGoldenBean];
- }
- else{
- self.giftBtn.selected = NO;
- self.ticketBtn.selected = NO;
- self.otherBtn.selected = YES;
-
- self.giftTableView.hidden = YES;
- self.ticketTableView.hidden = YES;
- self.otherTableView.hidden = NO;
- self.otherTableView.otherGoldenBean = self.baseModel.otherGoldenBean;
- self.otherTableView.likeGoldenBean = self.baseModel.likeGoldenBean;
-
- CGFloat otherTotalNum = self.baseModel.otherGoldenBean + self.baseModel.likeGoldenBean + self.baseModel.divideGoldenBean;
- self.totalLab.text = [NSString stringWithFormat:@"Total %.f",otherTotalNum];
- }
-
- }
- #pragma mark - Show
- - (void)showLiveCenterView{
- self.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
-
- CGRect actionViewRect = self.bgView.frame;
- actionViewRect.origin.x = SCREENWIDTH;
- self.bgView.frame = actionViewRect;
-
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^{
- CGRect actionViewRect = weakSelf.bgView.frame;
- actionViewRect.origin.x = 90.0;
- weakSelf.bgView.frame = actionViewRect;
- }];
-
- //不能滑动
- SendNotification(@"MOShowLivePagesVCCannotScroll")
- }
- - (void)dismissLiveCenterView{
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^
- {
- CGRect actionSheetViewRect = weakSelf.bgView.frame;
- actionSheetViewRect.origin.x = SCREENWIDTH;
- weakSelf.bgView.frame = actionSheetViewRect;
- } completion:^(BOOL finished)
- {
- [self removeFromSuperview];
- }];
-
- //可以滑动
- SendNotification(@"MOShowLivePagesVCCanScroll")
- }
- #pragma mark - Lazy
- - (MOLiveCenterTableView *)giftTableView{
- if(!_giftTableView){
- _giftTableView = [[MOLiveCenterTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _giftTableView.backgroundColor = [UIColor clearColor];
-
- _giftTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _giftTableView.separatorInset = UIEdgeInsetsZero;
- _giftTableView.cellType = MOLiveCenterUserCellType;
- _giftTableView.rowHeight = 65.0;
-
- WEAKSELF
- _giftTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
-
- if(weakSelf.giftNext.length == 0){
- return;
- }
-
- NSString *roomId = weakSelf.roomId;
- if(roomId.length == 0){
- return;
- }
-
- NSDictionary *giftPage = @{@"size":@(kPageSize),@"next":weakSelf.giftNext};
- NSDictionary *giftDict = @{@"page":giftPage,
- @"roomId":roomId};
- [weakSelf getHttpDataAboutGiftListWisthDict:giftDict];
- }];
-
- _giftTableView.mj_footer.hidden = YES;
- }
-
- return _giftTableView;
- }
- - (MOLiveCenterTableView *)ticketTableView{
- if(!_ticketTableView){
- _ticketTableView = [[MOLiveCenterTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _ticketTableView.backgroundColor = [UIColor clearColor];
-
- _ticketTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _ticketTableView.separatorInset = UIEdgeInsetsZero;
- _ticketTableView.cellType = MOLiveCenterUserCellType;
- _ticketTableView.rowHeight = 65.0;
-
- WEAKSELF
- _ticketTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
-
- if(weakSelf.giftNext.length == 0){
- return;
- }
-
- NSString *roomId = weakSelf.roomId;
- if(roomId.length == 0){
- return;
- }
-
- NSDictionary *ticketPage = @{@"size":@(kPageSize),@"next":weakSelf.ticketNext};
- NSDictionary *ticketDict = @{@"page":ticketPage,
- @"roomId":roomId};
- [weakSelf getHttpDataAboutTicketListWisthDict:ticketDict];
- }];
-
- _ticketTableView.mj_footer.hidden = YES;
- }
-
- return _ticketTableView;
- }
- - (MOLiveCenterTableView *)otherTableView{
- if(!_otherTableView){
- _otherTableView = [[MOLiveCenterTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _otherTableView.backgroundColor = [UIColor clearColor];
-
- _otherTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _otherTableView.separatorInset = UIEdgeInsetsZero;
- _otherTableView.cellType = MOLiveCenterWishListCellType;
- _otherTableView.rowHeight = 65.0;
- }
-
- return _otherTableView;
- }
- - (MOLiveCenterRecordListView *)recordView{
- if(!_recordView){
- _recordView = [MOLiveCenterRecordListView moLiveCenterRecordListView];
- }
- return _recordView;
- }
- @end
|