| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- //
- // RoomMicUserListView.m
- // UniversalApp
- //
- // Created by bogokj on 2019/8/8.
- // Copyright © 2019 voidcat. All rights reserved.
- //
- #import "RoomMicUserListView.h"
- //#import "RoomMicManageCell.h"
- #import "RoomModel.h"
- #import "RoomUserInfo.h"
- #import "BGRoomMicManageCell.h"
- #import "HTSegmentedScrollView.h"
- #import "VoiceHTTPManger.h"
- @interface RoomMicUserListView ()<UITableViewDelegate,UITableViewDataSource,RoomMicManageCellDelegate>
- @property(nonatomic, strong) UIButton *backBtn;
- @property(nonatomic, strong) UILabel *applyLabel;
- @property(nonatomic, strong) UIView *shadowView;
- @property(nonatomic, strong) UITableView *tableView;
- @property(nonatomic, strong) UITableView *tableView2;
- @property(nonatomic, strong) QMUIButton *searchBtn;
- @end
- @implementation RoomMicUserListView
- - (instancetype)initWithFrame:(CGRect)frame{
- if (self = [super initWithFrame:frame]) {
-
-
- HTSegmentedScrollView *segView = [[HTSegmentedScrollView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, self.height)];
- [self addSubview:segView];
-
- [segView addSegmentedItems:@[ASLocalizedString(@"上麦申请"), ASLocalizedString(@"麦位管理")]];
-
-
-
-
-
- self.backgroundColor = kWhiteColor;
-
- UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.width, 50)];
- titleLabel.textColor = kAppGrayColor1;
- titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
- titleLabel.textAlignment = NSTextAlignmentCenter;
- titleLabel.text = ASLocalizedString(@"抱人上麦");
- titleLabel.hidden = YES;
- [self addSubview:titleLabel];
- [self addSubview:self.searchBtn];
- self.searchBtn.hidden = YES;
- [self addSubview:self.backBtn];
- // [self addSubview:self.tableView];
-
-
- [segView addScrollViews:@[self.tableView, self.tableView2]];
-
-
- }
- return self;
- }
- - (void)searchBtnAction:(QMUIButton *)sender{
-
- // if (self.delegate && [self.delegate respondsToSelector:@selector(userListView:didClicSearchBtn:)]) {
- // [self.delegate userListView:self didClicSearchBtn:sender];
- // }
-
-
- [self addSearchTF];
-
-
-
- }
- -(void)request
- {
-
- }
- - (void)addSearchTF {
-
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:ASLocalizedString(@"请输入用户ID:") message:nil preferredStyle:UIAlertControllerStyleAlert];
- //增加确定按钮;
- [alertController addAction:[UIAlertAction actionWithTitle:ASLocalizedString(@"抱TA上麦") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //获取第1个输入框;
- UITextField *userNameTextField = alertController.textFields.firstObject;
-
- //获取第2个输入框;
- // UITextField *passwordTextField = alertController.textFields.lastObject;
-
- NSLog(@"用户ID = %@",userNameTextField.text);
- if (StrValid(userNameTextField.text)) {
- [self searchID:userNameTextField.text];
- }
- }]];
-
- //增加取消按钮;
- [alertController addAction:[UIAlertAction actionWithTitle:ASLocalizedString(@"取消") style:UIAlertActionStyleDefault handler:nil]];
-
- //定义第一个输入框;
- [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
- textField.placeholder = ASLocalizedString(@"请输入用户ID");
- textField.keyboardType = UIKeyboardTypeNumberPad;
- }];
- // //定义第二个输入框;
- // [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
- // textField.placeholder = @"请输入密码";
- // }];
-
- [self.vc presentViewController:alertController animated:true completion:nil];
-
-
-
-
- }
- - (void)searchID:(NSString *)ID {
-
- BOOL ret = NO;
- for (RoomUserInfo *model in self.dataArray) {
- if ([model.user_id isEqualToString:ID]) {
- ret = YES;
- // RoomMicManageCell * messageCell = [[RoomMicManageCell alloc]init];
- BGRoomMicManageCell * messageCell = [[BGRoomMicManageCell alloc]init];
- messageCell.model = model;
- if (self.delegate && [self.delegate respondsToSelector:@selector(userListView:manageCell:didClickManageBtn:)]) {
- [self.delegate userListView:self manageCell:messageCell didClickManageBtn:nil];
- }
- }
- }
-
- if (ret == NO) {
-
- }
-
- }
- - (void)reqeustData {
-
- [self.voiceApi requestWheatListType:@"0" block:^(NSDictionary *selfPtr) {
- NSMutableArray *dataArr = [NSMutableArray modelArrayWithClass:RoomUserInfo.class json:selfPtr[@"data"]];
- self.dataArray = dataArr;
- [self.tableView reloadData];
- }];
-
- [self.voiceApi requestWheatListType:@"1" block:^(NSDictionary *selfPtr) {
- NSMutableArray *dataArr = [NSMutableArray modelArrayWithClass:RoomUserInfo.class json:selfPtr[@"data"]];
- self.dataArray2 = dataArr;
- [self.tableView2 reloadData];
- }];
-
-
- }
- - (void)setModel:(RoomModel *)model{
- _model = model;
- [self requestData];
- }
- - (void)requestData{
- __weak __typeof(self)weakSelf = self;
- //http://www.bogo.voice.broadcast/mapi/public/index.php/api/Voice_Additional_api/voice_up_list
-
- /*
-
- NSString *url = [[CYURLUtils sharedCYURLUtils] makeVoiceURLWithC:@"Voice_Additional_api" A:@"voice_up_list"];
- [CYNET POSTv2:url parameters:@{@"voice_id":self.model.voice.user_id} responseCache:^(id responseObject) {
- //do nothing
- } success:^(id responseObject) {
- __strong __typeof(weakSelf)strongSelf = weakSelf;
- if ([[responseObject objectForKey:@"code"] integerValue] == 1) {
- [strongSelf.dataArray removeAllObjects];
- for (NSDictionary *dict in responseObject[@"list"]) {
- RoomUserInfo *model = [RoomUserInfo mj_objectWithKeyValues:dict];
- model.user_name = model.user_nickname;
- model.user_img = model.avatar;
- [strongSelf.dataArray addObject:model];
- }
- [strongSelf.applyLabel setText:[NSString stringWithFormat:ASLocalizedString(@" 房间在线 (%ld人)"),strongSelf.dataArray.count]];
- [strongSelf.tableView reloadData];
- }
- } failure:^(NSString *error) {
- [[HUDHelper sharedInstance] tipMessage:error];
- } hasCache:NO];
-
- */
- }
- - (void)backBtnAction:(UIButton *)sender{
- [self hide];
- }
- - (void)manageCell:(RoomMicManageCell *)messageCell didClickManageBtn:(UIButton *)sender{
- if (self.delegate && [self.delegate respondsToSelector:@selector(userListView:manageCell:didClickManageBtn:)]) {
- [self.delegate userListView:self manageCell:messageCell didClickManageBtn:sender];
- }
- }
- - (void)show:(UIView *)superView{
- [superView addSubview:self.shadowView];
- [superView addSubview:self];
- [self reqeustData];
- __weak __typeof(self)weakSelf = self;
- [UIView animateWithDuration:0.25 animations:^{
- __strong __typeof(weakSelf)strongSelf = weakSelf;
- strongSelf.frame = CGRectMake(0, kScreenH - strongSelf.height, strongSelf.width, strongSelf.height);
- }];
- }
- - (void)hide{
- __weak __typeof(self)weakSelf = self;
- [UIView animateWithDuration:0.25 animations:^{
- __strong __typeof(weakSelf)strongSelf = weakSelf;
- strongSelf.frame = CGRectMake(0, kScreenH, strongSelf.width, strongSelf.height);
- } completion:^(BOOL finished) {
- __strong __typeof(weakSelf)strongSelf = weakSelf;
- [strongSelf.shadowView removeFromSuperview];
- [strongSelf removeFromSuperview];
- }];
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- if(tableView == self.tableView)
- {
- return self.dataArray.count;
- }
- else
- {
- return self.dataArray2.count;
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- // RoomMicManageCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([RoomMicManageCell class]) forIndexPath:indexPath];
- BGRoomMicManageCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([BGRoomMicManageCell class]) forIndexPath:indexPath];
- cell.delegate = self;
-
- if(tableView == self.tableView)
- {
- [cell setType:RoomMicManageCellTypeApplyList];
- [cell setModel:self.dataArray[indexPath.row]];
- }
- else
- {
- [cell setType:RoomMicManageCellTypeManageView];
- [cell setModel:self.dataArray2[indexPath.row]];
- }
-
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 60;
- }
- //- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
- // return self.applyLabel;
- //}
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return 0.01;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return 0.01;
- }
- - (UIButton *)backBtn{
- if (!_backBtn) {
- _backBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 70, 50)];
- [_backBtn setImage:[UIImage imageNamed:@"back_b"] forState:UIControlStateNormal];
- // [_backBtn setTitle:@"返回" forState:UIControlStateNormal];
- // [_backBtn.titleLabel setFont:[UIFont systemFontOfSize:15]];
- // [_backBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
- [_backBtn addTarget:self action:@selector(backBtnAction:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _backBtn;
- }
- - (UITableView *)tableView{
- if (!_tableView) {
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.width, self.height - 50) style:UITableViewStylePlain];
- // [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([RoomMicManageCell class]) bundle:[NSBundle mainBundle]] forCellReuseIdentifier:NSStringFromClass([RoomMicManageCell class])];
- [_tableView registerClass:[BGRoomMicManageCell class] forCellReuseIdentifier:NSStringFromClass([BGRoomMicManageCell class])];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.backgroundColor = kClearColor;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- }
- return _tableView;
- }
- - (UITableView *)tableView2{
- if (!_tableView2) {
- _tableView2 = [[UITableView alloc]initWithFrame:CGRectMake(0, 50, self.width, self.height - 50) style:UITableViewStylePlain];
- // [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([RoomMicManageCell class]) bundle:[NSBundle mainBundle]] forCellReuseIdentifier:NSStringFromClass([RoomMicManageCell class])];
- [_tableView2 registerClass:[BGRoomMicManageCell class] forCellReuseIdentifier:NSStringFromClass([BGRoomMicManageCell class])];
- _tableView2.delegate = self;
- _tableView2.dataSource = self;
- _tableView2.backgroundColor = kClearColor;
- _tableView2.separatorStyle = UITableViewCellSeparatorStyleNone;
- }
- return _tableView2;
- }
- - (NSMutableArray *)dataArray{
- if (!_dataArray) {
- _dataArray = [NSMutableArray array];
- }
- return _dataArray;
- }
- - (NSMutableArray *)dataArray2{
- if (!_dataArray2) {
- _dataArray2 = [NSMutableArray array];
- }
- return _dataArray2;
- }
- - (UIView *)shadowView{
- if (!_shadowView) {
- _shadowView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
- _shadowView.backgroundColor = [kBlackColor colorWithAlphaComponent:0.4];
- _shadowView.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hide)];
- [_shadowView addGestureRecognizer:tap];
- }
- return _shadowView;
- }
- - (QMUIButton *)searchBtn{
- if (!_searchBtn) {
- _searchBtn = [[QMUIButton alloc]initWithFrame:CGRectMake(self.width- 80, 0, 70, 50)];
- _searchBtn.imagePosition = QMUIButtonImagePositionRight;
- // _searchBtn.backgroundColor = [UIColor colorWithHexString:@"#EDEDED"];
- _searchBtn.spacingBetweenImageAndTitle = 30;
- [_searchBtn setImage:[UIImage imageNamed:@"seach"] forState:UIControlStateNormal];
- [_searchBtn setTitle:@"" forState:UIControlStateNormal];
- // _searchBtn.layer.cornerRadius = 17;
- _searchBtn.clipsToBounds = YES;
- [_searchBtn addTarget:self action:@selector(searchBtnAction:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _searchBtn;
- }
- @end
|