RoomSetViewController.m 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. //
  2. // RoomSetViewController.m
  3. // UniversalApp
  4. //
  5. // Created by bugu on 2020/3/23.
  6. // Copyright © 2020 voidcat. All rights reserved.
  7. //
  8. #import "RoomSetViewController.h"
  9. #import "BGRoomSetHeadCell.h"
  10. #import "BGRoomSetNoticeCell.h"
  11. #import "BGRoomSetChannelCell.h"
  12. #import "BGRoomSetPwdCell.h"
  13. #import "SetCell.h"
  14. #import "RoomModel.h"
  15. #import "CYImagePickerViewController.h"
  16. #import "BGRoomManagerViewController.h"
  17. #import "BGRoomBGImageViewController.h"
  18. #import "RoomBGImageModel.h"
  19. #import "BGRoomDataViewController.h"
  20. #import "VoiceRoomSetInfoModel.h"
  21. @interface RoomSetViewController ()<QMUITableViewDelegate,QMUITableViewDataSource>
  22. @property(nonatomic, strong) NSMutableArray *dataArray;
  23. @property(nonatomic, copy) NSString *voice_avatar;
  24. @property(nonatomic, strong) NSMutableArray *channelDataArray;
  25. @property(nonatomic, strong) QMUITextField *textField;
  26. @property(nonatomic, strong) QMUITextView *textView;
  27. @property(nonatomic, strong) VideoClassifiedModel *channelModel;
  28. @property(nonatomic, assign) BOOL onPwd;
  29. @property(nonatomic, strong) QMUITextField *pwdTextField;
  30. @property(nonatomic, strong) RoomBGImageModel *selectModel;
  31. @property(nonatomic, copy) NSString *voice_bg;//id
  32. @property(nonatomic, copy) NSString *voice_bg_image;//url
  33. //房间头像
  34. @property(nonatomic, strong) NSIndexPath * imageIndexPath;
  35. @property(nonatomic, strong) VoiceRoomSetInfoModel *infoModel;
  36. @property(nonatomic, strong) UIButton *postButton;
  37. @end
  38. @implementation RoomSetViewController
  39. - (void)viewWillAppear:(BOOL)animated{
  40. [super viewWillAppear:animated];
  41. }
  42. - (void)backBtnClicked{
  43. [self dismissViewControllerAnimated:YES completion:nil];
  44. }
  45. - (void)viewDidLoad {
  46. [super viewDidLoad];
  47. // Do any additional setup after loading the view.
  48. self.title = ASLocalizedString(@"房间设置");
  49. [self setUpView];
  50. }
  51. -(void)setUpView{
  52. UIImageView *backImage = [[UIImageView alloc] init];
  53. backImage.image = [UIImage imageNamed:@"背景 (5)"];
  54. [self.view addSubview:backImage];
  55. [backImage mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.edges.equalTo(self.view);
  57. }];
  58. //添加返回按钮与标题
  59. UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  60. backBtn.frame = CGRectMake(0, 0, 44, 44);
  61. [backBtn setImage:[UIImage imageNamed:@"back_w"] forState:UIControlStateNormal];
  62. [self.view addSubview:backBtn];
  63. [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.top.mas_equalTo(kStatusBarHeight);
  65. make.left.mas_equalTo(13.5);
  66. make.width.and.height.mas_equalTo(44);
  67. }];
  68. [backBtn addTarget:self action:@selector(backBtnClicked) forControlEvents:UIControlEventTouchUpInside];
  69. UILabel *titleLabel = [[UILabel alloc] init];
  70. titleLabel.text = ASLocalizedString(@"管理");
  71. titleLabel.textColor = [UIColor whiteColor];
  72. titleLabel.font = [UIFont systemFontOfSize:16];
  73. [self.view addSubview:titleLabel];
  74. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.centerY.equalTo(backBtn);
  76. make.centerX.equalTo(self.view);
  77. }];
  78. [self.view addSubview:titleLabel];
  79. self.tableView.dataSource = self;
  80. self.tableView.delegate = self;
  81. [self.view addSubview:self.tableView];
  82. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.top.mas_equalTo(titleLabel.mas_bottom).offset(8);
  84. make.bottom.equalTo(self.view).offset(-11);
  85. make.left.and.right.equalTo(self.view);
  86. }];
  87. self.tableView.frame = self.view.bounds;
  88. self.tableView.height = kScreenH - kTopHeight;
  89. self.tableView.backgroundColor = [UIColor clearColor];
  90. [self.tableView registerClass:[BGRoomSetHeadCell class] forCellReuseIdentifier:NSStringFromClass([BGRoomSetHeadCell class])];
  91. [self.tableView registerClass:[BGRoomSetNoticeCell class] forCellReuseIdentifier:NSStringFromClass([BGRoomSetNoticeCell class])];
  92. [self.tableView registerClass:[BGRoomSetChannelCell class] forCellReuseIdentifier:NSStringFromClass([BGRoomSetChannelCell class])];
  93. [self.tableView registerClass:[BGRoomSetPwdCell class] forCellReuseIdentifier:NSStringFromClass([BGRoomSetPwdCell class])];
  94. [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([SetCell class]) bundle:[NSBundle mainBundle]] forCellReuseIdentifier:NSStringFromClass([SetCell class])];
  95. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  96. self.tableView.mj_header = nil;
  97. self.tableView.mj_footer = nil;
  98. self.postButton = [UIButton buttonWithType:UIButtonTypeCustom];
  99. self.postButton.backgroundColor = [UIColor qmui_colorWithHexString:@"#AE2CF1"];
  100. self.postButton.layer.cornerRadius = 22;
  101. self.postButton.layer.masksToBounds = YES;
  102. self.postButton.titleLabel.font = [UIFont systemFontOfSize:15];
  103. [self.postButton setTitle:ASLocalizedString(@"保存") forState:UIControlStateNormal];
  104. [self.postButton addTarget:self action:@selector(postButtonAction) forControlEvents:UIControlEventTouchUpInside];
  105. self.postButton.backgroundColor = [UIColor qmui_colorWithHexString:@"#AE2CF1"];
  106. [self.view addSubview:self.postButton];
  107. [self.postButton mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.height.mas_equalTo(44);
  109. make.left.mas_equalTo(10);
  110. make.right.mas_equalTo(-10);
  111. make.bottom.mas_equalTo(-20);
  112. }];
  113. NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
  114. [dict setValue:@"voice" forKey:@"ctl"];
  115. [dict setValue:@"get_manage_voice" forKey:@"act"];
  116. [dict setValue:self.model.room_id forKey:@"room_id"];
  117. [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  118. self.infoModel = [VoiceRoomSetInfoModel modelWithJSON:responseJson[@"data"]];
  119. self.onPwd = self.infoModel.password.length > 0;
  120. //不是房主,是管理员
  121. //is_room_administrator 房主是2,管理员是1
  122. if (self.infoModel.is_room_administrator == 2) {
  123. [self.dataArray addObject:@{@"leftTitle":ASLocalizedString(@"管理员"),@"rightTitle":@""}];
  124. [self.dataArray addObject:@{@"leftTitle":ASLocalizedString(@"房间背景"),@"rightTitle":@""}];
  125. [self.dataArray addObject:@{@"leftTitle":ASLocalizedString(@"房间数据"),@"rightTitle":@""}];
  126. } else {
  127. [self.dataArray addObject:@{@"leftTitle":ASLocalizedString(@"房间背景"),@"rightTitle":@""}];
  128. [self.dataArray addObject:@{@"leftTitle":ASLocalizedString(@"房间数据"),@"rightTitle":@""}];
  129. }
  130. [self.tableView reloadData];
  131. [self requestData];
  132. } FailureBlock:^(NSError *error) {
  133. }];
  134. // [self.dataArray addObject:@{@"leftTitle":@"",@"rightTitle":@""}];
  135. // [self.dataArray addObject:@{@"leftTitle":@"房间名称",@"rightTitle":self.model.voice.title}];
  136. // [self addNavigationItemWithTitles:@[ASLocalizedString(@"保存")] isLeft:NO target:self action:@selector(saveBtnAction) tags:@[@(1001)] colors:@[]];
  137. // NSMutableArray *tempArray = [NSMutableArray arrayWithArray:[GlobalVariable sharedGlobalVariable].hallTypeList];
  138. // [tempArray removeObjectAtIndex:0];
  139. // [tempArray removeObjectAtIndex:0];
  140. //
  141. // [self.channelDataArray setArray:tempArray];
  142. }
  143. - (void)startBtnAction {
  144. [self submitData];
  145. }
  146. - (void)saveBtnAction{
  147. [self.view endEditing:YES];
  148. [self updateData];
  149. }
  150. - (void)submitData {
  151. //开启直播设置接口
  152. if (!self.textField.text.length) {
  153. [[BGHUDHelper sharedInstance] tipMessage:self.textField.placeholder];
  154. return;
  155. }
  156. // NSString *url=[[CYURLUtils sharedCYURLUtils]makeVoiceURLWithC:@"voice_api" A:@"start_voice"];
  157. //
  158. //
  159. // NSMutableDictionary * param = [NSMutableDictionary dictionary];
  160. //
  161. // if (StrValid(self.textField.text)) {
  162. // [param setObject:self.textField.text forKey:@"voice_title"];
  163. //
  164. // }
  165. //
  166. // if (self.voice_avatar) {
  167. // [param setObject:self.voice_avatar forKey:@"voice_img"];
  168. //
  169. // }
  170. //
  171. // if (StrValid(self.textView.text)) {
  172. // [param setObject:self.textView.text forKey:@"announcement"];
  173. //
  174. // }
  175. //
  176. // if (self.voice_bg) {
  177. // [param setObject:self.voice_bg forKey:@"voice_bg"];
  178. //
  179. // }
  180. //
  181. //
  182. // if (self.channelModel) {
  183. // [param setObject:self.channelModel.id forKey:@"voice_theme_id"];
  184. //
  185. // }
  186. //
  187. //
  188. // [CYNET POST:url parameters:param responseCache:^(id responseObject) {
  189. //
  190. // } success:^(id responseObject) {
  191. //
  192. //
  193. //
  194. //
  195. //
  196. //
  197. //
  198. // } failure:^(NSString *error) {
  199. //
  200. // [[BGHUDHelper sharedInstance] tipMessage:error];
  201. //
  202. // } hasCache:NO];
  203. }
  204. - (void)updateData {
  205. // if (!self.textField.text.length) {
  206. // [[BGHUDHelper sharedInstance] tipMessage:@"未输入标题"];
  207. // return;
  208. // }
  209. // if ([self.textField.text isEqualToString:self.model.voice.title]) {
  210. // return;
  211. // }
  212. if (!self.textField.text.length) {
  213. [[BGHUDHelper sharedInstance] tipMessage:self.textField.placeholder];
  214. return;
  215. }
  216. // [NSString verify_dirty_word:self.textField.text];
  217. //
  218. // if (self.textView.text.length) {
  219. //
  220. // [NSString verify_dirty_word:self.textView.text];
  221. //
  222. // }
  223. if (self.onPwd) {
  224. if (self.pwdTextField.text.length != 6) {
  225. [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"请输入完整密码")];;
  226. return;
  227. }
  228. }
  229. // NSString *url=[[CYURLUtils sharedCYURLUtils]makeVoiceURLWithC:@"voice_api" A:@"save_voice"];
  230. NSMutableDictionary * param = [NSMutableDictionary dictionary];
  231. // [param setObject:self.model.voice.id forKey:@"id"];
  232. if (StrValid(self.textField.text)) {
  233. [param setObject:SafeStr(self.textField.text) forKey:@"voice_title"];
  234. }
  235. if (self.voice_avatar) {
  236. [param setObject:self.voice_avatar forKey:@"voice_img"];
  237. }
  238. if (StrValid(self.textView.text)) {
  239. [param setObject:self.textView.text forKey:@"announcement"];
  240. }
  241. // if (self.voice_bg) {
  242. // [param setObject:self.voice_bg forKey:@"voice_bg"];
  243. // }else{
  244. // [param setObject:self.set forKey:@"voice_bg"];
  245. // }
  246. //
  247. //
  248. // if (self.channelModel) {
  249. // [param setObject:self.channelModel.id forKey:@"voice_theme_id"];
  250. //
  251. // }else{
  252. //
  253. // [param setObject:self.model.voice.voice_type forKey:@"voice_theme_id"];
  254. //
  255. // }
  256. if (self.onPwd) {
  257. [param setObject:@(self.onPwd) forKey:@"voice_status"];
  258. [param setObject:self.pwdTextField.text forKey:@"voice_psd"];
  259. } else {
  260. [param setObject:@(-1) forKey:@"voice_status"];
  261. [param setObject:@"" forKey:@"voice_psd"];
  262. }
  263. @weakify(self)
  264. // [CYNET POST:url parameters:param responseCache:^(id responseObject) {
  265. //
  266. // } success:^(id responseObject) {
  267. //
  268. // @strongify(self)
  269. //
  270. // [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"设置成功")];
  271. //
  272. //
  273. // [self dismissViewControllerAnimated:YES completion:nil];
  274. //
  275. // kAppDelegate.containerVC.roomVc.model.voice.title = self.textField.text;
  276. //
  277. // if (StrValid(self.textView.text)) {
  278. // kAppDelegate.containerVC.roomVc.model.voice.announcement = self.textView.text;
  279. //
  280. // }
  281. // if (self.channelModel) {
  282. // kAppDelegate.containerVC.roomVc.model.voice.voice_type = self.channelModel.id;
  283. //
  284. // }
  285. // if (self.voice_bg) {
  286. // kAppDelegate.containerVC.roomVc.model.voice.voice_bg_image = self.voice_bg_image;
  287. //
  288. // }
  289. // kAppDelegate.containerVC.roomVc.model.voice.voice_status = [NSString stringWithFormat:@"%@",@(self.onPwd)];
  290. //
  291. // if (self.onPwd) {
  292. // kAppDelegate.containerVC.roomVc.model.voice.voice_psd = self.pwdTextField.text;
  293. //
  294. //
  295. // } else {
  296. // kAppDelegate.containerVC.roomVc.model.voice.voice_psd = @"";
  297. //
  298. // }
  299. //
  300. //
  301. //
  302. // } failure:^(NSString *error) {
  303. //
  304. // [[BGHUDHelper sharedInstance] tipMessage:error];
  305. //
  306. //
  307. // } hasCache:NO];
  308. }
  309. /*
  310. - (void)saveAvatar {
  311. if (!StrValid(self.voice_avatar)) {
  312. return;
  313. }
  314. //http://www.bogo.voice.broadcast/mapi/public/index.php/api/Voice_api/save_voice
  315. NSString *url = [[CYURLUtils sharedCYURLUtils] makeURLWithC:@"Voice_api" A:@"save_voice"];
  316. __weak __typeof(self)weakSelf = self;
  317. [CYNET POSTv2:url parameters:@{@"avatar":self.voice_avatar.length ? self.voice_avatar : @"",@"id":self.model.voice.id} responseCache:^(id responseObject) {
  318. //do nothing
  319. } success:^(id responseObject) {
  320. __strong __typeof(weakSelf)strongSelf = weakSelf;
  321. if ([[responseObject objectForKey:@"code"] integerValue] == 1) {
  322. [[BGHUDHelper sharedInstance] tipMessage:@"更新成功"];
  323. // [strongSelf dismissViewControllerAnimated:YES completion:nil];
  324. }
  325. } failure:^(NSString *error) {
  326. [[BGHUDHelper sharedInstance] tipMessage:error];
  327. } hasCache:NO];
  328. }
  329. - (void)saveTitle {
  330. if (!self.textField.text.length) {
  331. [[BGHUDHelper sharedInstance] tipMessage:@"未输入标题"];
  332. return;
  333. }
  334. if ([self.textField.text isEqualToString:self.model.voice.title]) {
  335. return;
  336. }
  337. __weak __typeof(self)weakSelf = self;
  338. //http://www.bogo.voice.broadcast/mapi/public/index.php/api/Voice_api/upd_voice_title
  339. NSString *url = [[CYURLUtils sharedCYURLUtils] makeURLWithC:@"Voice_api" A:@"save_voice"];
  340. [CYNET POSTv2:url parameters:@{@"id":self.model.voice.id,@"title":self.textField.text} responseCache:^(id responseObject) {
  341. //do nothing
  342. } success:^(id responseObject) {
  343. if ([[responseObject objectForKey:@"code"] integerValue] == 1) {
  344. __strong __typeof(weakSelf)strongSelf = weakSelf;
  345. [[BGHUDHelper sharedInstance] tipMessage:@"标题修改成功"];
  346. kAppDelegate.containerVC.roomVc.model.voice.title = strongSelf.textField.text;
  347. // [strongSelf dismissViewControllerAnimated:YES completion:nil];
  348. }
  349. } failure:^(NSString *error) {
  350. [[BGHUDHelper sharedInstance] tipMessage:error];
  351. } hasCache:NO];
  352. }
  353. - (void)saveAnnouncement{
  354. if (!self.textView.text.length) {
  355. [[BGHUDHelper sharedInstance] tipMessage:@"未输入公告"];
  356. return;
  357. }
  358. if ([self.textView.text isEqualToString:self.model.voice.announcement]) {
  359. return;
  360. } //http://www.bogo.voice.broadcast/mapi/public/index.php/api/Voice_Additional_api/upd_announcement
  361. __weak __typeof(self)weakSelf = self;
  362. NSString *url = [[CYURLUtils sharedCYURLUtils] makeURLWithC:@"Voice_Additional_api" A:@"upd_announcement"];
  363. [CYNET POSTv2:url parameters:@{@"id":self.model.voice.id,@"announcement":self.textView.text} responseCache:^(id responseObject) {
  364. //do nothing
  365. } success:^(id responseObject) {
  366. if ([[responseObject objectForKey:@"code"] integerValue] == 1) {
  367. __strong __typeof(weakSelf)strongSelf = weakSelf;
  368. [[BGHUDHelper sharedInstance] tipMessage:@"公告设置成功"];
  369. kAppDelegate.containerVC.roomVc.model.voice.announcement = self.textView.text;
  370. // [strongSelf dismissViewControllerAnimated:YES completion:nil];
  371. }
  372. } failure:^(NSString *error) {
  373. [[BGHUDHelper sharedInstance] tipMessage:error];
  374. } hasCache:NO];
  375. }
  376. - (void)saveChannel{
  377. if ([self.channelModel.id isEqualToString:self.model.voice.voice_type]) {
  378. return;
  379. }
  380. if (!self.channelModel) {
  381. return;
  382. } //http://www.bogo.voice.broadcast/mapi/public/index.php/api/Voice_api/selected_voice_type
  383. __weak __typeof(self)weakSelf = self;
  384. NSString *url = [[CYURLUtils sharedCYURLUtils] makeURLWithC:@"Voice_api" A:@"selected_voice_type"];
  385. [CYNET POSTv2:url parameters:@{@"id":self.model.voice.id,@"voice_type":self.channelModel.id} responseCache:^(id responseObject) {
  386. //do nothing
  387. } success:^(id responseObject) {
  388. __strong __typeof(weakSelf)strongSelf = weakSelf;
  389. if ([[responseObject objectForKey:@"code"] integerValue] == 1) {
  390. //更换成功
  391. kAppDelegate.containerVC.roomVc.model.voice.voice_type = self.channelModel.id;
  392. }
  393. } failure:^(NSString *error) {
  394. [[BGHUDHelper sharedInstance] tipMessage:error];
  395. } hasCache:NO];
  396. }
  397. - (void)savePwd{
  398. __weak __typeof(self)weakSelf = self;
  399. // if (self.model.voice.voice_status.intValue == self.onPwd && [[self.pwdTextField.text md5] isEqualToString:self.model.voice.voice_psd]) {
  400. //
  401. // return;
  402. // }
  403. #warning 后台保存的md5,所以就不判断状态了
  404. //
  405. if (self.onPwd) {
  406. if (self.pwdTextField.text.length < 6) {
  407. return;
  408. }
  409. //http://www.bogo.voice.broadcast/mapi/public/index.php/api/Voice_api/voice_psd
  410. NSString *url = [[CYURLUtils sharedCYURLUtils] makeURLWithC:@"Voice_api" A:@"voice_psd"];
  411. [CYNET POSTv2:url parameters:@{@"voice_psd":self.pwdTextField.text,@"id":self.model.voice.id} responseCache:^(id responseObject) {
  412. //do nothing
  413. } success:^(id responseObject) {
  414. if ([[responseObject objectForKey:@"code"] integerValue] == 1) {
  415. __strong __typeof(weakSelf)strongSelf = weakSelf;
  416. [[BGHUDHelper sharedInstance] tipMessage:@"密码设置成功"];
  417. // strongSelf.model.voice.voice_psd = [passwordView.inputView.textValue md5String];
  418. strongSelf.model.voice.voice_status = @"1";
  419. // [passwordView hide];
  420. }
  421. } failure:^(NSString *error) {
  422. // [[BGHUDHelper sharedInstance] tipMessage:error];
  423. } hasCache:NO];
  424. } else {
  425. //http://www.bogo.voice.broadcast/mapi/public/index.php/api/Voice_api/voice_psd
  426. NSString *url = [[CYURLUtils sharedCYURLUtils] makeURLWithC:@"Voice_api" A:@"voice_psd"];
  427. [CYNET POSTv2:url parameters:@{@"voice_psd":@"-1",@"id":self.model.voice.id} responseCache:^(id responseObject) {
  428. //do nothing
  429. } success:^(id responseObject) {
  430. __strong __typeof(weakSelf)strongSelf = weakSelf;
  431. if ([[responseObject objectForKey:@"code"] integerValue] == 1) {
  432. [[BGHUDHelper sharedInstance] tipMessage:@"解除房间锁成功"];
  433. strongSelf.model.voice.voice_psd = @"";
  434. strongSelf.model.voice.voice_status = @"0";
  435. }
  436. } failure:^(NSString *error) {
  437. // [[BGHUDHelper sharedInstance] tipMessage:error];
  438. } hasCache:NO];
  439. }
  440. }
  441. */
  442. #pragma mark - QMUITableViewDelegate
  443. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  444. return 2;
  445. }
  446. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  447. if (section == 0) {
  448. return 6;
  449. }
  450. return self.dataArray.count;
  451. }
  452. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  453. if (indexPath.section == 0) {
  454. if (indexPath.row == 0) {
  455. return 120;
  456. }
  457. if (indexPath.row == 2 || indexPath.row == 4) {
  458. return 0.1;
  459. }
  460. if (indexPath.row == 3) {
  461. return 97;
  462. }
  463. if (indexPath.row == 1) {
  464. return ceil(self.channelDataArray.count/3.0)*65+10*2;
  465. }
  466. if (indexPath.row == 5) {
  467. return 60;
  468. }
  469. return 35;
  470. }
  471. return 55;
  472. }
  473. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  474. __weak __typeof(self)weakSelf = self;
  475. if (indexPath.section == 0) {
  476. if (indexPath.row == 0) {
  477. BGRoomSetHeadCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([BGRoomSetHeadCell class]) forIndexPath:indexPath];
  478. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  479. cell.selectImgBlock = ^{
  480. [self onAlbumAction];
  481. };
  482. if (self.infoModel.live_image) {
  483. [cell.iconBtn sd_setImageWithURL:[NSURL URLWithString:SafeStr(self.infoModel.live_image)] forState:UIControlStateNormal];
  484. cell.iconBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
  485. cell.iconTipLabel.text = ASLocalizedString(@"更改房间头像");
  486. }
  487. self.textField = cell.titleTextField;
  488. if (self.isOpen) {
  489. }else{
  490. if (!StrValid(cell.titleTextField.text)) {
  491. cell.titleTextField.text = self.infoModel.title;
  492. }
  493. }
  494. return cell;
  495. }
  496. else if (indexPath.row == 2 || indexPath.row == 4) {
  497. SetCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SetCell class]) forIndexPath:indexPath];
  498. cell.hidden = YES;
  499. return cell;
  500. }
  501. else if (indexPath.row == 3) {
  502. BGRoomSetNoticeCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([BGRoomSetNoticeCell class]) forIndexPath:indexPath];
  503. cell.textChange = ^(NSString * _Nonnull text) {
  504. self.infoModel.announcement = text;
  505. };
  506. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  507. self.textView = cell.titleTextView;
  508. if (self.isOpen) {
  509. }else{
  510. if (!StrValid(cell.titleTextView.text)) {
  511. cell.titleTextView.text = self.model.announcement;
  512. }
  513. }
  514. return cell;
  515. }else if (indexPath.row == 1) {
  516. BGRoomSetChannelCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([BGRoomSetChannelCell class]) forIndexPath:indexPath];
  517. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  518. cell.channelDataArray = self.channelDataArray;
  519. cell.selectedChannel = ^(VideoClassifiedModel * _Nonnull model) {
  520. __strong __typeof(weakSelf)strongSelf = weakSelf;
  521. strongSelf.channelModel = model;
  522. self.infoModel.classified_id = [NSString stringWithFormat:@"%ld",(long)model.classified_id];
  523. NSLog(@"点击的 infoModel %@",self.infoModel.classified_id);
  524. };
  525. cell.voice_type = self.infoModel.classified_id;
  526. return cell;
  527. }else if (indexPath.row == 5) {
  528. BGRoomSetPwdCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([BGRoomSetPwdCell class]) forIndexPath:indexPath];
  529. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  530. cell.passwordView.txtPassword.text = self.infoModel.password;
  531. cell.titleTextField.text = self.infoModel.password;
  532. cell.openBtn.selected = self.infoModel.password.length > 0;
  533. cell.pwdTextChangeBlock = ^(NSString * _Nonnull text) {
  534. self.infoModel.password = text;
  535. };
  536. cell.pwdStatusBlock = ^(UIButton * _Nonnull sender) {
  537. __strong __typeof(weakSelf)strongSelf = weakSelf;
  538. strongSelf.onPwd = sender.selected;
  539. };
  540. self.pwdTextField = cell.titleTextField;
  541. return cell;
  542. }
  543. SetCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SetCell class]) forIndexPath:indexPath];
  544. if (indexPath.row == 2) {
  545. [cell setLeftTitle:ASLocalizedString(@"Mic mode")];
  546. } else {
  547. [cell setLeftTitle:ASLocalizedString(@"房间上锁")];
  548. }
  549. // [cell setRightTitle:@""];
  550. [cell setType:SetCellTypeRoomSet];
  551. cell.leftMediumFont = 16;
  552. cell.rightImageView.hidden = YES;
  553. cell.nextBtn.hidden = YES;
  554. return cell;
  555. } else {
  556. SetCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SetCell class]) forIndexPath:indexPath];
  557. NSDictionary *dict = self.dataArray[indexPath.row];
  558. [cell setLeftTitle:dict[@"leftTitle"]];
  559. [cell setRightTitle:dict[@"rightTitle"]];
  560. [cell setType:SetCellTypeRoomSet];
  561. cell.leftMediumFont = 16;
  562. cell.rightImageView.hidden = YES;
  563. cell.nextBtn.hidden = NO;
  564. return cell;
  565. }
  566. return [UITableViewCell new];
  567. }
  568. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  569. if (indexPath.section == 0) {
  570. if (indexPath.row == 0){
  571. }
  572. } else {
  573. NSDictionary *dict = self.dataArray[indexPath.row];
  574. NSString * leftTitle = dict[@"leftTitle"];
  575. if ([leftTitle isEqualToString:ASLocalizedString(@"主持人")]) {
  576. BGRoomManagerViewController * vc = [[BGRoomManagerViewController alloc]init];
  577. vc.model = self.model;
  578. vc.name = @"主持人";
  579. [self.navigationController pushViewController:vc animated:YES];
  580. } else if ([leftTitle isEqualToString:ASLocalizedString(@"管理员")]){
  581. BGRoomManagerViewController * vc = [[BGRoomManagerViewController alloc]init];
  582. vc.model = self.model;
  583. vc.name = @"管理员";
  584. BGNavigationController *nav = [[BGNavigationController alloc] initWithRootViewController:vc];
  585. if (@available(iOS 13.0, *)) {
  586. UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
  587. appearance.backgroundColor = [UIColor whiteColor];
  588. appearance.shadowColor = [UIColor clearColor];
  589. nav.navigationBar.standardAppearance = appearance;
  590. nav.navigationBar.scrollEdgeAppearance = appearance;
  591. }
  592. [self presentViewController:nav animated:YES completion:nil];
  593. }else if ([leftTitle isEqualToString:ASLocalizedString(@"房间背景")]){
  594. SetCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  595. BGRoomBGImageViewController * vc = [[BGRoomBGImageViewController alloc]init];
  596. vc.model = self.model;
  597. vc.room_id = self.model.room_id;
  598. if (self.selectModel) {
  599. vc.selectModel = self.selectModel;
  600. }
  601. vc.editRoomBGChangedCallBack = ^(RoomBGImageModel *selectModel) {
  602. self.selectModel = selectModel;
  603. self.voice_bg = selectModel.id;
  604. self.voice_bg_image = selectModel.image;
  605. if (StrValid(selectModel.name)) {
  606. [cell setRightTitle:selectModel.name];
  607. } else {
  608. [cell setRightTitle:ASLocalizedString(@"已选择")];
  609. }
  610. };
  611. BGNavigationController *nav = [[BGNavigationController alloc] initWithRootViewController:vc];
  612. //返回按钮
  613. if (@available(iOS 13.0, *)) {
  614. UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
  615. appearance.shadowImage = [UIImage imageWithColor:kWhiteColor];
  616. [appearance configureWithOpaqueBackground];
  617. appearance.backgroundColor = kWhiteColor;
  618. nav.navigationBar.standardAppearance = appearance;
  619. nav.navigationBar.scrollEdgeAppearance = appearance;
  620. [nav.navigationBar setShadowImage:nil];
  621. [nav.navigationBar setShadowImage:[UIImage imageWithColor:kWhiteColor]];
  622. [nav.navigationBar setBackgroundImage: [UIImage imageWithColor:kWhiteColor] forBarMetrics:UIBarMetricsDefault];
  623. } else {
  624. // Fallback on earlier versions
  625. }
  626. [self presentViewController:nav animated:NO completion:nil];
  627. }else if ([leftTitle isEqualToString:ASLocalizedString(@"房间数据")]){
  628. NSString *tmpUrlStr = [NSString stringWithFormat:@"%@?room_id=%@",[GlobalVariables sharedInstance].appModel.h5_url.room_flow,self.model.room_id];
  629. BGMainWebViewController *tmpController = [BGMainWebViewController webControlerWithUrlStr:tmpUrlStr isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES isShowCloseBtn:NO];
  630. BGNavigationController *tmpNav = [[BGNavigationController alloc] initWithRootViewController:tmpController];
  631. [self presentViewController:tmpNav animated:NO completion:nil];
  632. }
  633. }
  634. }
  635. - (void)selectImgAtIndexPath:(NSIndexPath *)indexPath {
  636. self.imageIndexPath = indexPath;
  637. // [self addPhotoAction];
  638. }
  639. - (void)onAlbumAction {
  640. CYImagePickerViewController *imagePickerVc=[[CYImagePickerViewController alloc]initWithMaxImagesCount:1 columnNumber:4 delegate:self pushPhotoPickerVc:NO];
  641. [imagePickerVc.navigationController.navigationBar setTintColor:[UIColor blackColor]];
  642. // 图片
  643. imagePickerVc.allowPickingVideo = NO;
  644. // 设置竖屏下的裁剪尺寸
  645. NSInteger left = 0;
  646. NSInteger widthHeight = self.view.width;
  647. NSInteger top = (self.view.height - widthHeight) / 2;
  648. imagePickerVc.cropRect = CGRectMake(left, top, widthHeight, widthHeight);
  649. imagePickerVc.allowCrop = YES;
  650. __block typeof(self)blockself =self;
  651. // 你可以通过block或者代理,来得到用户选择的照片.
  652. @weakify(self)
  653. [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  654. if(photos.count >0){
  655. @strongify(self)
  656. [self addImageDone:photos.firstObject];
  657. }
  658. }];
  659. imagePickerVc.naviTitleColor = [UIColor blackColor];;
  660. imagePickerVc.barItemTextColor = [UIColor blackColor];
  661. [blockself presentViewController:imagePickerVc animated:YES completion:nil];
  662. }
  663. - (void)takePhotoAction{
  664. }
  665. - (void)addImageDone:(UIImage *)image {
  666. [[FDHUDManager defaultManager] showLoading:@"正在上传" ToView:self.view];
  667. [[FDOSSManager defaultManager] setup:^{
  668. [[FDOSSManager defaultManager] UPLOAD:UIImagePNGRepresentation(image) progress:^(float percent) {
  669. NSLog(@"上传进度:%f",percent);
  670. } success:^(NSString * _Nonnull resultStr) {
  671. self.infoModel.live_image = resultStr;
  672. dispatch_async(dispatch_get_main_queue(), ^{
  673. [self.tableView reloadData];
  674. [[FDHUDManager defaultManager] hideLoading];
  675. });
  676. } failure:^(NSError * _Nonnull error) {
  677. dispatch_async(dispatch_get_main_queue(), ^{
  678. [[FDHUDManager defaultManager] show:error.localizedDescription ToView:self.view];
  679. });
  680. }];
  681. }];
  682. return;
  683. @weakify(self)
  684. // if (KGlobalVariable.appmodel.upload_type.intValue == 1) {
  685. // [QiNiuLogic QiNiuUplaodImage:image WithQiuNiuInfo:_qiniuInfo Block:^(id selfPtr) {
  686. // NSLog(@"selfPtr:%@",selfPtr);
  687. // @strongify(self)
  688. // self.voice_avatar = [NSString stringWithFormat:@"%@/%@",self.qiniuInfo.domain,((QiNiuInfoModel *)selfPtr).fileKey];
  689. // }];
  690. // } else if (KGlobalVariable.appmodel.upload_type.intValue == 2){
  691. // [QCloudCOSLogic getQCloudCOSTokenSuccess:^(id object) {
  692. // QCloudCOSInfoModel *qInfo = object;
  693. //
  694. // [QCloudCOSLogic QCloudCOSUploadImage:image WithQCloudCOSInfo:qInfo Block:^(id object) {
  695. // @strongify(self)
  696. // QCloudUploadObjectResult * uploadResult = object;
  697. // self.voice_avatar = uploadResult.location;
  698. //
  699. // }];
  700. //
  701. //
  702. // }];
  703. // }
  704. }
  705. - (void)requestData{
  706. // NSDictionary *dict = self.dataArray[2];
  707. // NSString * leftTitle = dict[@"leftTitle"];
  708. __weak __typeof(self)weakSelf = self;
  709. //http://www.bogo.voice.broadcast/mapi/public/index.php/api/Voice_api/get_voice_bg
  710. // NSString *url = [[CYURLUtils sharedCYURLUtils] makeVoiceURLWithC:@"Voice_api" A:@"get_voice_bg"];
  711. // [CYNET POSTv2:url parameters:@{@"id":StrValid(self.model.voice.id)?self.model.voice.id : [IMAPlatform sharedInstance].host.userId} responseCache:^(id responseObject) {
  712. // //do nothing
  713. // } success:^(id responseObject) {
  714. // if ([[responseObject objectForKey:@"code"] integerValue] == 1) {
  715. // __strong __typeof(weakSelf)strongSelf = weakSelf;
  716. // for (NSDictionary *dict in responseObject[@"voice_bg_list"]) {
  717. // RoomBGImageModel *model = [RoomBGImageModel mj_objectWithKeyValues:dict];
  718. // if ([model.image isEqualToString:SafeStr(self.model.voice.voice_bg_image)]) {
  719. // model.selected = YES;
  720. // strongSelf.selectModel = model;
  721. //
  722. // [strongSelf.dataArray replaceObjectAtIndex:2 withObject:@{@"leftTitle":ASLocalizedString(@"房间背景"),@"rightTitle":model.name ? model.name :ASLocalizedString(@"已选择")}];
  723. //
  724. // }
  725. // }
  726. // [strongSelf.tableView reloadData];
  727. // }
  728. // } failure:^(NSString *error) {
  729. // [[BGHUDHelper sharedInstance] tipMessage:error];
  730. // } hasCache:NO];
  731. }
  732. /*
  733. - (void)selectImgAtIndexPathdddd:(NSIndexPath *)indexPath {
  734. CYImagePickerViewController *imagePickerVc = [[CYImagePickerViewController alloc] initWithMaxImagesCount:1 delegate:self];
  735. [imagePickerVc.navigationController.navigationBar setTintColor:[UIColor blackColor]];
  736. imagePickerVc.naviBgColor = [UIColor blackColor];
  737. imagePickerVc.allowPickingVideo = NO;
  738. // 设置竖屏下的裁剪尺寸
  739. NSInteger left = 0;
  740. NSInteger widthHeight = self.view.width;
  741. NSInteger top = (self.view.height - widthHeight) / 2;
  742. imagePickerVc.cropRect = CGRectMake(left, top, widthHeight, widthHeight);
  743. imagePickerVc.allowCrop = YES;
  744. __weak __typeof(self)weakSelf = self;
  745. [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  746. BGRoomSetHeadCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
  747. // [cell.middleImageView setImage:photos.firstObject];
  748. [cell.iconBtn setBackgroundImage:photos.firstObject forState:UIControlStateNormal];
  749. [cell.iconBtn setImage:nil forState:UIControlStateNormal];
  750. __strong __typeof(weakSelf)strongSelf = weakSelf;
  751. __weak __typeof(strongSelf)weakSelf2 = strongSelf;
  752. [QiNiuLogic QiNiuUplaodImage:photos.firstObject WithQiuNiuInfo:_qiniuInfo Block:^(id selfPtr) {
  753. NSLog(@"selfPtr:%@",selfPtr);
  754. __strong __typeof(weakSelf2)strongSelf2 = weakSelf2;
  755. strongSelf2.voice_avatar = [NSString stringWithFormat:@"%@/%@",self.qiniuInfo.domain,((QiNiuInfoModel *)selfPtr).fileKey];
  756. }];
  757. }];
  758. imagePickerVc.naviTitleColor = [UIColor blackColor];
  759. imagePickerVc.barItemTextColor = [UIColor blackColor];
  760. imagePickerVc.oKButtonTitleColorNormal = [UIColor blackColor];
  761. imagePickerVc.showSelectBtn = YES;
  762. [self presentViewController:imagePickerVc animated:YES completion:nil];
  763. }
  764. */
  765. - (NSMutableArray *)dataArray{
  766. if (!_dataArray) {
  767. _dataArray = [NSMutableArray array];
  768. }
  769. return _dataArray;
  770. }
  771. - (NSMutableArray *)channelDataArray{
  772. _channelDataArray = [NSMutableArray array];
  773. for (VideoClassifiedModel *model in self.BuguLive.appModel.video_classified) {
  774. if(model.classified_id == self.infoModel.classified_id.intValue)
  775. {
  776. model.isSelected = YES;
  777. }
  778. else
  779. {
  780. model.isSelected = NO;
  781. }
  782. [_channelDataArray addObject:model];
  783. }
  784. return _channelDataArray;
  785. }
  786. - (void)postButtonAction {
  787. NSDictionary *info = [self.infoModel mj_JSONObject];
  788. NSLog(@"提交信息");
  789. NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
  790. [dict setValue:@"voice" forKey:@"ctl"];
  791. [dict setValue:@"save_voice" forKey:@"act"];
  792. [dict setValue:self.model.room_id forKey:@"room_id"];
  793. [dict addEntriesFromDictionary:info];
  794. [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  795. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"保存成功")];
  796. } FailureBlock:^(NSError *error) {
  797. }];
  798. }
  799. @end