530 lines
20 KiB
Mathematica
530 lines
20 KiB
Mathematica
|
|
//
|
||
|
|
// RoomSongView.m
|
||
|
|
// romantic
|
||
|
|
//
|
||
|
|
// Created by 八角_马方圆 on 2021/12/30.
|
||
|
|
// Copyright © 2021 romantic. All rights reserved.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "RoomSongView.h"
|
||
|
|
#import "JXCategoryTitleView.h"
|
||
|
|
#import "RoomSongListCell.h"
|
||
|
|
#import "RoomSongYidianCell.h"
|
||
|
|
|
||
|
|
@interface RoomSongView ()<JXCategoryViewDelegate, UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, UIScrollViewDelegate>
|
||
|
|
|
||
|
|
@property (nonatomic, strong) UIView *mainView;
|
||
|
|
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
||
|
|
@property (nonatomic, strong) UIScrollView *bgScrollView;
|
||
|
|
@property (nonatomic, strong) UILabel *yidianNumLab;
|
||
|
|
@property (nonatomic, strong) UITableView *firstTableV;
|
||
|
|
@property (nonatomic, strong) NSMutableArray *firstDataArray;
|
||
|
|
@property (nonatomic, assign) NSInteger page;
|
||
|
|
@property (nonatomic, strong) UITableView *secondTableV;
|
||
|
|
@property (nonatomic, strong) NSMutableArray *secondDataArray;
|
||
|
|
|
||
|
|
@property (nonatomic, strong) UITableView *searchTableV;
|
||
|
|
@property (nonatomic, strong) NSMutableArray *searchDataArray;
|
||
|
|
@property (nonatomic, assign) NSInteger searchPage;
|
||
|
|
|
||
|
|
@property (nonatomic, strong) UIView *searchBgV;
|
||
|
|
@property (nonatomic, strong) UITextField *searchTF;
|
||
|
|
@property (nonatomic, strong) UIButton *cancelBtn;
|
||
|
|
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation RoomSongView
|
||
|
|
|
||
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
||
|
|
{
|
||
|
|
self = [super initWithFrame:frame];
|
||
|
|
if (self) {
|
||
|
|
self.firstDataArray = [NSMutableArray arrayWithCapacity:0];
|
||
|
|
self.secondDataArray = [NSMutableArray arrayWithCapacity:0];
|
||
|
|
self.searchDataArray = [NSMutableArray arrayWithCapacity:0];
|
||
|
|
self.page = 1;
|
||
|
|
self.searchPage = 1;
|
||
|
|
|
||
|
|
[self createUI];
|
||
|
|
|
||
|
|
// 设置下拉和上拉刷新
|
||
|
|
WEAK_SELF;
|
||
|
|
[ZJUIUtil refreshWithWhiteHeader:self.firstTableV refresh:^{
|
||
|
|
[weakSelf loadDataIsRefresh:YES];
|
||
|
|
}];
|
||
|
|
[ZJUIUtil refreshWithWhiteFooter:self.firstTableV refresh:^{
|
||
|
|
[weakSelf loadDataIsRefresh:NO];
|
||
|
|
}];
|
||
|
|
|
||
|
|
[ZJUIUtil refreshWithWhiteHeader:self.searchTableV refresh:^{
|
||
|
|
[weakSelf loadSearchDataIsRefresh:YES];
|
||
|
|
}];
|
||
|
|
[ZJUIUtil refreshWithWhiteFooter:self.searchTableV refresh:^{
|
||
|
|
[weakSelf loadSearchDataIsRefresh:NO];
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
return self;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)onShow {
|
||
|
|
[UIApplication.sharedApplication.keyWindow addSubview:self];
|
||
|
|
self.mainView.transform = CGAffineTransformMakeTranslation(0, 480);
|
||
|
|
[UIView animateWithDuration:0.25 animations:^{
|
||
|
|
self.mainView.transform = CGAffineTransformIdentity;
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)onDismiss {
|
||
|
|
[UIView animateWithDuration:0.25 animations:^{
|
||
|
|
self.mainView.transform = CGAffineTransformMakeTranslation(0, 480);
|
||
|
|
} completion:^(BOOL finished) {
|
||
|
|
[self removeFromSuperview];
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)setViewModel:(RCMicRoomViewModel *)viewModel {
|
||
|
|
_viewModel = viewModel;
|
||
|
|
|
||
|
|
[self loadDataIsRefresh:YES];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)loadDataIsRefresh:(BOOL)isRefresh {
|
||
|
|
if (isRefresh) {
|
||
|
|
self.page = 1;
|
||
|
|
}else {
|
||
|
|
self.page ++;
|
||
|
|
}
|
||
|
|
NSDictionary *dict = @{@"page":@(self.page), @"page_limit":@"20"};
|
||
|
|
|
||
|
|
[SVProgressHUD showWithStatus:nil];
|
||
|
|
[RCMicHTTP postWithURLString:@"/api/agora/song_list" parameters:dict response:^(RCMicHTTPResult *result) {
|
||
|
|
[SVProgressHUD dismiss];
|
||
|
|
if (result.success) {
|
||
|
|
if (result.errorCode == 200) {
|
||
|
|
if (isRefresh) {
|
||
|
|
[self.firstDataArray removeAllObjects];
|
||
|
|
}
|
||
|
|
NSArray *arr = [RoomSongListModel mj_objectArrayWithKeyValuesArray:result.content];
|
||
|
|
[self.firstDataArray addObjectsFromArray:arr];
|
||
|
|
[self.firstTableV reloadData];
|
||
|
|
}else {
|
||
|
|
[SVProgressHUD showInfoWithStatus:result.message];
|
||
|
|
}
|
||
|
|
}else {
|
||
|
|
[SVProgressHUD showInfoWithStatus:@"网络错误"];
|
||
|
|
}
|
||
|
|
[self.firstTableV.mj_header endRefreshing];
|
||
|
|
[self.firstTableV.mj_footer endRefreshing];
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)onUpdateYiDian:(NSArray *)array {
|
||
|
|
[self.secondDataArray removeAllObjects];
|
||
|
|
[self.secondDataArray addObjectsFromArray:array];
|
||
|
|
[self.secondTableV reloadData];
|
||
|
|
|
||
|
|
// self.yidianNumLab.text = [NSString stringWithFormat:@"已点(%ld)", array.count];
|
||
|
|
_titleView.titles = @[@"点歌", [NSString stringWithFormat:@"已点(%ld)", array.count]];
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)createUI {
|
||
|
|
self.backgroundColor = [kBlackColor colorWithAlphaComponent:0.3];
|
||
|
|
|
||
|
|
WEAK_SELF
|
||
|
|
UIView *tapView = [[UIView alloc] init];
|
||
|
|
tapView.userInteractionEnabled = YES;
|
||
|
|
[tapView dg_Tapped:^{
|
||
|
|
[weakSelf onDismiss];
|
||
|
|
}];
|
||
|
|
[self addSubview:tapView];
|
||
|
|
|
||
|
|
_mainView = [[UIView alloc] init];
|
||
|
|
// _mainView.backgroundColor = HEXCOLOR(0x16181E);
|
||
|
|
[self addSubview:_mainView];
|
||
|
|
UIImageView *bgImgV = [ControlCreator createImageView:_mainView rect:CGRectZero imageName:@"common_alert_bg" backguoundColor:nil];
|
||
|
|
bgImgV.contentMode = UIViewContentModeScaleToFill;
|
||
|
|
[bgImgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.edges.mas_equalTo(0);
|
||
|
|
}];
|
||
|
|
|
||
|
|
[_mainView addSubview:self.titleView];
|
||
|
|
|
||
|
|
// _yidianNumLab = [ControlCreator createLabel:nil rect:CGRectZero text:@"0" font:YBMediumFont(10) color:HEXCOLOR(0xFFFFFF) backguoundColor:nil align:NSTextAlignmentLeft lines:1];
|
||
|
|
// [_mainView addSubview:_yidianNumLab];
|
||
|
|
|
||
|
|
UIView *titleLine = [[UIView alloc] init];
|
||
|
|
titleLine.backgroundColor = [kWhiteColor colorWithAlphaComponent:0.1];
|
||
|
|
[_mainView addSubview:titleLine];
|
||
|
|
|
||
|
|
_bgScrollView = [[UIScrollView alloc] init];
|
||
|
|
_bgScrollView.delegate = self;
|
||
|
|
_bgScrollView.pagingEnabled = YES;
|
||
|
|
[_mainView addSubview:_bgScrollView];
|
||
|
|
|
||
|
|
UIButton *cancelBtn = [ControlCreator createButton:nil rect:CGRectZero text:@"取消" font:YBMediumFont(14) color:[kWhiteColor colorWithAlphaComponent:0.6] backguoundColor:nil imageName:nil target:self action:@selector(onCancelSearch)];
|
||
|
|
cancelBtn.hidden = YES;
|
||
|
|
[_bgScrollView addSubview:cancelBtn];
|
||
|
|
self.cancelBtn = cancelBtn;
|
||
|
|
|
||
|
|
_searchBgV = [[UIView alloc] init];
|
||
|
|
_searchBgV.backgroundColor = [kWhiteColor colorWithAlphaComponent:0.06];
|
||
|
|
_searchBgV.layer.cornerRadius = 18;
|
||
|
|
_searchBgV.layer.masksToBounds = YES;
|
||
|
|
[_bgScrollView addSubview:_searchBgV];
|
||
|
|
|
||
|
|
UIImageView *seachImgV = [ControlCreator createImageView:nil rect:CGRectZero imageName:@"ktv_search" backguoundColor:nil];
|
||
|
|
[_searchBgV addSubview:seachImgV];
|
||
|
|
|
||
|
|
_searchTF = [ControlCreator createTextField:nil rect:CGRectZero placeholder:@"请输入歌名搜索" placeholderColor:[kWhiteColor colorWithAlphaComponent:0.4] text:nil font:YBMediumFont(12) color:kWhiteColor backguoundColor:nil];
|
||
|
|
_searchTF.delegate = self;
|
||
|
|
_searchTF.clearButtonMode = UITextFieldViewModeWhileEditing;
|
||
|
|
[_searchBgV addSubview:_searchTF];
|
||
|
|
|
||
|
|
[_bgScrollView addSubview:self.firstTableV];
|
||
|
|
[_bgScrollView addSubview:self.secondTableV];
|
||
|
|
[_bgScrollView addSubview:self.searchTableV];
|
||
|
|
|
||
|
|
[self.firstTableV registerNib:[UINib nibWithNibName:@"RoomSongListCell" bundle:nil] forCellReuseIdentifier:@"RoomSongListCell"];
|
||
|
|
[self.secondTableV registerNib:[UINib nibWithNibName:@"RoomSongYidianCell" bundle:nil] forCellReuseIdentifier:@"RoomSongYidianCell"];
|
||
|
|
[self.searchTableV registerNib:[UINib nibWithNibName:@"RoomSongListCell" bundle:nil] forCellReuseIdentifier:@"RoomSongListCell"];
|
||
|
|
|
||
|
|
[tapView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.top.left.right.equalTo(self);
|
||
|
|
make.bottom.equalTo(_mainView.mas_top);
|
||
|
|
}];
|
||
|
|
|
||
|
|
[_mainView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.left.right.bottom.equalTo(self);
|
||
|
|
make.height.mas_equalTo(480);
|
||
|
|
}];
|
||
|
|
|
||
|
|
[_titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.top.centerX.equalTo(_mainView);
|
||
|
|
make.width.mas_equalTo(APPW);
|
||
|
|
make.height.mas_equalTo(52);
|
||
|
|
}];
|
||
|
|
|
||
|
|
// [_yidianNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
// make.left.equalTo(_titleView.mas_right).offset(-60);
|
||
|
|
// make.top.equalTo(_titleView).offset(15);
|
||
|
|
// make.width.mas_equalTo(50);
|
||
|
|
// make.height.mas_equalTo(12);
|
||
|
|
// }];
|
||
|
|
|
||
|
|
[titleLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.bottom.equalTo(_titleView);
|
||
|
|
make.left.right.equalTo(_mainView);
|
||
|
|
make.height.mas_equalTo(0.5);
|
||
|
|
}];
|
||
|
|
|
||
|
|
[_bgScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.top.equalTo(_titleView.mas_bottom);
|
||
|
|
make.left.right.bottom.equalTo(_mainView);
|
||
|
|
}];
|
||
|
|
|
||
|
|
[cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.centerY.equalTo(_searchBgV);
|
||
|
|
make.left.equalTo(_bgScrollView).offset(ScreenWidth-15-40);
|
||
|
|
make.size.mas_equalTo(CGSizeMake(40, 30));
|
||
|
|
}];
|
||
|
|
|
||
|
|
[_searchBgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.top.equalTo(_titleView.mas_bottom).offset(10);
|
||
|
|
make.left.equalTo(_bgScrollView).offset(15);
|
||
|
|
make.width.mas_equalTo(ScreenWidth-30);
|
||
|
|
make.height.mas_equalTo(36);
|
||
|
|
}];
|
||
|
|
|
||
|
|
[seachImgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.left.equalTo(_searchBgV).offset(20);
|
||
|
|
make.centerY.equalTo(_searchBgV);
|
||
|
|
make.size.mas_equalTo(CGSizeMake(15, 15));
|
||
|
|
}];
|
||
|
|
|
||
|
|
[_searchTF mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.left.equalTo(seachImgV.mas_right).offset(7);
|
||
|
|
make.right.equalTo(_searchBgV).offset(-15);
|
||
|
|
make.top.bottom.equalTo(_searchBgV);
|
||
|
|
}];
|
||
|
|
|
||
|
|
[_firstTableV mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.top.equalTo(_searchBgV.mas_bottom).offset(10);
|
||
|
|
make.left.bottom.equalTo(_bgScrollView);
|
||
|
|
make.width.equalTo(_bgScrollView);
|
||
|
|
}];
|
||
|
|
|
||
|
|
[_secondTableV mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.left.equalTo(_firstTableV.mas_right);
|
||
|
|
make.top.right.bottom.equalTo(_bgScrollView);
|
||
|
|
make.width.height.equalTo(_bgScrollView);
|
||
|
|
}];
|
||
|
|
|
||
|
|
[_searchTableV mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.edges.equalTo(_firstTableV);
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)onCancelSearch {
|
||
|
|
self.searchTF.text = @"";
|
||
|
|
[self.searchTF resignFirstResponder];
|
||
|
|
[self.searchBgV mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.width.mas_equalTo(ScreenWidth-30);
|
||
|
|
}];
|
||
|
|
self.searchTableV.hidden = YES;
|
||
|
|
self.cancelBtn.hidden = YES;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
|
||
|
|
[self.searchBgV mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.width.mas_equalTo(ScreenWidth-30-15-40);
|
||
|
|
}];
|
||
|
|
self.searchTableV.hidden = NO;
|
||
|
|
self.cancelBtn.hidden = NO;
|
||
|
|
|
||
|
|
return YES;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
|
||
|
|
[self.searchTF resignFirstResponder];
|
||
|
|
[self loadSearchDataIsRefresh:YES];
|
||
|
|
|
||
|
|
return YES;
|
||
|
|
}
|
||
|
|
|
||
|
|
#pragma mark - Table view data source
|
||
|
|
|
||
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||
|
|
if (tableView == self.firstTableV) {
|
||
|
|
return self.firstDataArray.count;
|
||
|
|
}else if (tableView == self.secondTableV) {
|
||
|
|
return self.secondDataArray.count;
|
||
|
|
}else {
|
||
|
|
return self.searchDataArray.count;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
|
|
if (tableView == self.firstTableV) {
|
||
|
|
RoomSongListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RoomSongListCell" forIndexPath:indexPath];
|
||
|
|
cell.selectionStyle = NO;
|
||
|
|
RoomSongListModel *model = self.firstDataArray[indexPath.row];
|
||
|
|
cell.model = model;
|
||
|
|
WEAK_SELF
|
||
|
|
[cell.diangeBtn buttonAddTaget:^(UIButton *btn) {
|
||
|
|
[weakSelf onDianGe:model qingchang:NO];
|
||
|
|
} forControlEvents:UIControlEventTouchUpInside];
|
||
|
|
|
||
|
|
[cell.qingchangBtn buttonAddTaget:^(UIButton *btn) {
|
||
|
|
[weakSelf onDianGe:model qingchang:YES];
|
||
|
|
} forControlEvents:UIControlEventTouchUpInside];
|
||
|
|
|
||
|
|
// cell.diangeBtn.enabled = YES;
|
||
|
|
// cell.diangeBtn.backgroundColor = HEXCOLOR(0xFFFFFF);
|
||
|
|
// for (RoomSongListModel *obj in self.secondDataArray) {
|
||
|
|
// if (obj.song_code == model.song_code) {
|
||
|
|
// cell.diangeBtn.enabled = NO;
|
||
|
|
// cell.diangeBtn.backgroundColor = [HEXCOLOR(0xFFFFFF) colorWithAlphaComponent:0.2];
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
return cell;
|
||
|
|
}else if (tableView == self.secondTableV) {
|
||
|
|
RoomSongYidianCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RoomSongYidianCell" forIndexPath:indexPath];
|
||
|
|
cell.selectionStyle = NO;
|
||
|
|
RoomSongListModel *model = self.secondDataArray[indexPath.row];
|
||
|
|
cell.model = model;
|
||
|
|
|
||
|
|
// cell.orderLab.text = [NSString stringWithFormat:@"%ld", indexPath.row+1];
|
||
|
|
// if (0 == indexPath.row) {
|
||
|
|
// cell.playingImgV.hidden = NO;
|
||
|
|
// cell.orderLab.hidden = YES;
|
||
|
|
// cell.tagLab.hidden = NO;
|
||
|
|
// }else {
|
||
|
|
// cell.playingImgV.hidden = YES;
|
||
|
|
// cell.orderLab.hidden = NO;
|
||
|
|
// cell.tagLab.hidden = YES;
|
||
|
|
// }
|
||
|
|
if (0 == indexPath.row) {
|
||
|
|
// cell.tagLab.layer.borderWidth = 1;
|
||
|
|
// cell.tagLab.backgroundColor = kClearColor;
|
||
|
|
// cell.tagLab.textColor = HEXCOLOR(0xFF99E9);
|
||
|
|
[cell.statusButton setImage:ImageNamed(@"ktv_yidian_songing") forState:(UIControlStateNormal)];
|
||
|
|
}else {
|
||
|
|
// cell.tagLab.layer.borderWidth = 0;
|
||
|
|
// cell.tagLab.backgroundColor = HEXCOLORA(0xFFFFFF, 0.06);
|
||
|
|
// cell.tagLab.textColor = HEXCOLOR(0xC0BCCF);
|
||
|
|
[cell.statusButton setImage:ImageNamed(@"ktv_yiding_waiting") forState:(UIControlStateNormal)];
|
||
|
|
}
|
||
|
|
|
||
|
|
return cell;
|
||
|
|
}else {
|
||
|
|
RoomSongListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RoomSongListCell" forIndexPath:indexPath];
|
||
|
|
cell.selectionStyle = NO;
|
||
|
|
RoomSongListModel *model = self.searchDataArray[indexPath.row];
|
||
|
|
cell.model = model;
|
||
|
|
WEAK_SELF
|
||
|
|
[cell.diangeBtn buttonAddTaget:^(UIButton *btn) {
|
||
|
|
[weakSelf onDianGe:model qingchang:NO];
|
||
|
|
} forControlEvents:UIControlEventTouchUpInside];
|
||
|
|
|
||
|
|
[cell.qingchangBtn buttonAddTaget:^(UIButton *btn) {
|
||
|
|
[weakSelf onDianGe:model qingchang:YES];
|
||
|
|
} forControlEvents:UIControlEventTouchUpInside];
|
||
|
|
|
||
|
|
// cell.diangeBtn.enabled = YES;
|
||
|
|
// cell.diangeBtn.backgroundColor = HEXCOLOR(0xFFFFFF);
|
||
|
|
// for (RoomSongListModel *obj in self.secondDataArray) {
|
||
|
|
// if (obj.song_code == model.song_code) {
|
||
|
|
// cell.diangeBtn.enabled = NO;
|
||
|
|
// cell.diangeBtn.backgroundColor = [HEXCOLOR(0xFFFFFF) colorWithAlphaComponent:0.2];
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
return cell;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)onDianGe:(RoomSongListModel *)model qingchang:(BOOL)qingchang {
|
||
|
|
if (self.viewModel.role == RCMicRoleType_Audience) {
|
||
|
|
[SVProgressHUD showInfoWithStatus:@"请先上麦"];
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
NSDictionary *dict = @{@"rid":self.viewModel.roomInfo.roomId, @"song_code":@(model.song_code), @"is_accapella":qingchang?@"1":@"2"};
|
||
|
|
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
|
||
|
|
[paras addEntriesFromDictionary:dict];
|
||
|
|
|
||
|
|
[SVProgressHUD showWithStatus:nil];
|
||
|
|
[RCMicHTTP postWithURLString:@"/api/agora/dot_song" parameters:paras response:^(RCMicHTTPResult *result) {
|
||
|
|
[SVProgressHUD dismiss];
|
||
|
|
if (result.success) {
|
||
|
|
if (result.errorCode == 200) {
|
||
|
|
[SVProgressHUD showInfoWithStatus:@"点歌成功"];
|
||
|
|
}else {
|
||
|
|
[SVProgressHUD showInfoWithStatus:result.message];
|
||
|
|
}
|
||
|
|
}else {
|
||
|
|
[SVProgressHUD showInfoWithStatus:@"网络错误"];
|
||
|
|
}
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
||
|
|
[self.bgScrollView setContentOffset:CGPointMake(ScreenWidth*index, 0) animated:YES];
|
||
|
|
}
|
||
|
|
|
||
|
|
#pragma mark -------------------搜索相关-------------------------
|
||
|
|
- (void)loadSearchDataIsRefresh:(BOOL)isRefresh {
|
||
|
|
if (isRefresh) {
|
||
|
|
self.searchPage = 1;
|
||
|
|
}else {
|
||
|
|
self.searchPage ++;
|
||
|
|
}
|
||
|
|
NSDictionary *dict = @{@"name":C_string(self.searchTF.text), @"page":@(self.searchPage)};
|
||
|
|
|
||
|
|
[SVProgressHUD showWithStatus:nil];
|
||
|
|
[RCMicHTTP postWithURLString:@"/api/agora/song_list" parameters:dict response:^(RCMicHTTPResult *result) {
|
||
|
|
[SVProgressHUD dismiss];
|
||
|
|
if (result.success) {
|
||
|
|
if (result.errorCode == 200) {
|
||
|
|
if (isRefresh) {
|
||
|
|
[self.searchDataArray removeAllObjects];
|
||
|
|
}
|
||
|
|
NSArray *arr = [RoomSongListModel mj_objectArrayWithKeyValuesArray:result.content];
|
||
|
|
[self.searchDataArray addObjectsFromArray:arr];
|
||
|
|
[self.searchTableV reloadData];
|
||
|
|
}else {
|
||
|
|
[SVProgressHUD showInfoWithStatus:result.message];
|
||
|
|
}
|
||
|
|
}else {
|
||
|
|
[SVProgressHUD showInfoWithStatus:@"网络错误"];
|
||
|
|
}
|
||
|
|
[self.searchTableV.mj_header endRefreshing];
|
||
|
|
[self.searchTableV.mj_footer endRefreshing];
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (JXCategoryTitleView *)titleView{
|
||
|
|
if (!_titleView) {
|
||
|
|
_titleView = [[JXCategoryTitleView alloc] init];
|
||
|
|
_titleView.titles = @[@"点歌", @"已点"];
|
||
|
|
_titleView.backgroundColor = [UIColor clearColor];
|
||
|
|
_titleView.delegate = self;
|
||
|
|
_titleView.defaultSelectedIndex = 0;
|
||
|
|
_titleView.titleFont = YBMediumFont(16);
|
||
|
|
_titleView.titleSelectedFont = YBBoldFont(18);
|
||
|
|
_titleView.titleColor = HEXCOLORA(0xFFFFFF, 0.5);
|
||
|
|
_titleView.titleSelectedColor = kWhiteColor;
|
||
|
|
_titleView.contentEdgeInsetLeft = 85;
|
||
|
|
_titleView.contentEdgeInsetRight = 85;
|
||
|
|
|
||
|
|
// JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
|
||
|
|
// lineView.indicatorColor = [HEXCOLOR(0xFFFFFF) colorWithAlphaComponent:0.1];
|
||
|
|
// lineView.indicatorWidth = 35;
|
||
|
|
// lineView.indicatorHeight = 6;
|
||
|
|
// lineView.indicatorCornerRadius = 3;
|
||
|
|
// lineView.verticalMargin = 14;
|
||
|
|
// _titleView.indicators = @[lineView];
|
||
|
|
|
||
|
|
}
|
||
|
|
return _titleView;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (UITableView *)firstTableV {
|
||
|
|
if (!_firstTableV) {
|
||
|
|
_firstTableV = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||
|
|
_firstTableV.backgroundColor = kClearColor;
|
||
|
|
_firstTableV.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
||
|
|
_firstTableV.dataSource = self;
|
||
|
|
_firstTableV.delegate = self;
|
||
|
|
_firstTableV.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||
|
|
_firstTableV.rowHeight = 70;
|
||
|
|
}
|
||
|
|
return _firstTableV;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (UITableView *)secondTableV {
|
||
|
|
if (!_secondTableV) {
|
||
|
|
_secondTableV = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||
|
|
_secondTableV.backgroundColor = kClearColor;
|
||
|
|
_secondTableV.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
||
|
|
_secondTableV.dataSource = self;
|
||
|
|
_secondTableV.delegate = self;
|
||
|
|
_secondTableV.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||
|
|
_secondTableV.rowHeight = 70;
|
||
|
|
}
|
||
|
|
return _secondTableV;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (UITableView *)searchTableV {
|
||
|
|
if (!_searchTableV) {
|
||
|
|
_searchTableV = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||
|
|
_searchTableV.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(APPW, 450) direction:FXGradientChangeDirectionVertical startColor:HEXCOLOR(0x4B348D) endColor:HEXCOLOR(0x1A055F)];
|
||
|
|
_searchTableV.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
||
|
|
_searchTableV.dataSource = self;
|
||
|
|
_searchTableV.delegate = self;
|
||
|
|
_searchTableV.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||
|
|
_searchTableV.rowHeight = 70;
|
||
|
|
_searchTableV.hidden = YES;
|
||
|
|
}
|
||
|
|
return _searchTableV;
|
||
|
|
}
|
||
|
|
|
||
|
|
#pragma mark - 左右滑
|
||
|
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||
|
|
if (scrollView == self.bgScrollView) {
|
||
|
|
CGFloat offsetX = scrollView.contentOffset.x;
|
||
|
|
if (offsetX <= 0) {
|
||
|
|
[self.titleView selectItemAtIndex:0];
|
||
|
|
}else if (offsetX >= ScreenWidth) {
|
||
|
|
[self.titleView selectItemAtIndex:1];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@end
|