RoomLiveMicView.m 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. //
  2. // RoomLiveMicView.m
  3. // UniversalApp
  4. //
  5. // Created by bogokj on 2019/8/1.
  6. // Copyright © 2019 voidcat. All rights reserved.
  7. //
  8. #import "RoomLiveMicView.h"
  9. #import "RoomUsers.h"
  10. #import "RoomUserCell.h"
  11. #import "RoomMasterCell.h"
  12. #import "RoomUserInfo.h"
  13. #import "RoomModel.h"
  14. #import "BogoRODispatchModel.h"
  15. #import "VoiceHTTPManger.h"
  16. #import "TrueLoveButton.h"
  17. @interface RoomLiveMicView ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,RoomUserCellDelegate,RoomMasterCellDelegate>
  18. @property(nonatomic, strong) UICollectionView *collectionView;
  19. @property(nonatomic, strong) QMUIButton *shareBtn;
  20. @property(nonatomic, strong) UIButton *trueLoveBtn;
  21. @property(nonatomic, strong) NSMutableDictionary *cellDict;
  22. @property(nonatomic, strong) QMUIFillButton *AnnouncementBtn;
  23. //@property(nonatomic, strong) UIButton *numberBtn;
  24. @property(nonatomic, strong) TrueLoveButton *trueLoveButton;
  25. @property(nonatomic, strong) UIView *bgView;
  26. @property(nonatomic, strong) UIImageView *iconImageView1;
  27. @property(nonatomic, strong) UIImageView *rankImageView1;
  28. @property(nonatomic, strong) UIImageView *iconImageView2;
  29. @property(nonatomic, strong) UIImageView *rankImageView2;
  30. @property(nonatomic, strong) UIImageView *iconImageView3;
  31. @property(nonatomic, strong) UIImageView *rankImageView3;
  32. @property(nonatomic, strong) UIView *roomOrderDispatchView;
  33. @property(nonatomic, strong) UILabel *titleLabel;
  34. @property(nonatomic, strong) UIButton *infoBtn;
  35. @property(nonatomic, strong) NSTimer *timer;
  36. @property(nonatomic, assign) int timeCount;
  37. @end
  38. @implementation RoomLiveMicView
  39. - (instancetype)initWithFrame:(CGRect)frame{
  40. if (self = [super initWithFrame:frame]) {
  41. [self setUpView];
  42. }
  43. return self;
  44. }
  45. - (void)setUpView {
  46. self.backgroundColor = kClearColor;
  47. [self addSubview:self.collectionView];
  48. // self.layer.borderColor = UIColor.redColor.CGColor;
  49. // self.layer.borderWidth = 1;
  50. // [self addSubview:self.trueLoveBtn];
  51. self.clipsToBounds = NO;
  52. _AnnouncementBtn = ({
  53. QMUIFillButton * button = [[QMUIFillButton alloc]initWithFrame:CGRectZero];
  54. // button.spacingBetweenImageAndTitle = 1;
  55. [button setTitle:ASLocalizedString(@"公告") forState:UIControlStateNormal];
  56. [button.titleLabel setFont:[UIFont systemFontOfSize:10]];
  57. [button setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  58. [button setBackgroundImage:[UIImage imageNamed:@"公告 (1)"] forState:UIControlStateNormal];
  59. button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -20);
  60. // button.layer.borderColor = UIColor.redColor.CGColor;
  61. // button.layer.borderWidth = 1;
  62. // button.layer.cornerRadius = 13;
  63. // button.clipsToBounds = YES;
  64. button.backgroundColor = UIColor.clearColor;
  65. [button addTarget:self action:@selector(AnnouncementBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  66. button;
  67. });
  68. _trueLoveButton = ({
  69. TrueLoveButton * button = [TrueLoveButton getView];
  70. // button.layer.cornerRadius = 13;
  71. // button.clipsToBounds = YES;
  72. // button.backgroundColor = [kWhiteColor colorWithAlphaComponent:0.15];
  73. //添加手势
  74. UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTrueLoveButtonRecognizer)];
  75. [button addGestureRecognizer:tapGesture];
  76. button;
  77. });
  78. [self addSubview:_AnnouncementBtn];
  79. [self addSubview:_trueLoveButton];
  80. _voiceOnlineNumBtn = ({
  81. UIButton * button = [[UIButton alloc]initWithFrame:CGRectZero];
  82. [button setTitle:ASLocalizedString(@"0在线") forState:UIControlStateNormal];
  83. [button.titleLabel setFont:[UIFont systemFontOfSize:11]];
  84. [button setTitleColor:kWhiteColor forState:UIControlStateNormal];
  85. button.layer.cornerRadius = 13;
  86. button.clipsToBounds = YES;
  87. button.backgroundColor = [kWhiteColor colorWithAlphaComponent:0.15];
  88. [button addTarget:self action:@selector(numBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  89. button.hidden = YES;
  90. button;
  91. });
  92. [self addSubview:_voiceOnlineNumBtn];
  93. //
  94. // self.bgView = [[UIView alloc]init];
  95. // self.bgView.backgroundColor = kClearColor;
  96. // [self addSubview:self.bgView];
  97. [_AnnouncementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.left.mas_equalTo(@8);
  99. make.top.mas_equalTo(15);
  100. // make.bottom.equalTo(self.trueLoveBtn);
  101. make.width.mas_equalTo(50);
  102. make.height.mas_equalTo(20);
  103. }];
  104. [_trueLoveButton mas_makeConstraints:^(MASConstraintMaker *make) {
  105. make.left.mas_equalTo(_AnnouncementBtn.mas_right).offset(8);
  106. make.centerY.mas_equalTo(_AnnouncementBtn);
  107. // make.bottom.equalTo(self.trueLoveBtn);
  108. make.width.mas_equalTo(50);
  109. make.height.mas_equalTo(20);
  110. }];
  111. [_voiceOnlineNumBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.right.equalTo(self.mas_right).offset(-10);
  113. make.centerY.equalTo(_trueLoveButton);
  114. make.width.mas_equalTo(64);
  115. make.height.mas_equalTo(26);
  116. }];
  117. //
  118. // [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  119. //
  120. // make.right.equalTo(self.trueLoveBtn.mas_left).offset(-3);
  121. // make.bottom.equalTo(_AnnouncementBtn.mas_bottom).offset(1.5);
  122. // make.height.mas_equalTo(40);
  123. // make.width.mas_equalTo(100);
  124. //
  125. // }];
  126. //
  127. //
  128. // for (int i = 0; i < 3; i ++) {
  129. //
  130. //
  131. //
  132. // UIImageView * iconImageView1 = [[UIImageView alloc]init];
  133. // iconImageView1.contentMode = UIViewContentModeScaleAspectFill;
  134. // iconImageView1.clipsToBounds = YES;
  135. // [self.bgView addSubview:iconImageView1];
  136. //
  137. //
  138. //
  139. //
  140. // UIImageView * rankImageView1 = [[UIImageView alloc]init];
  141. // rankImageView1.contentMode = UIViewContentModeScaleAspectFill;
  142. //
  143. // [self.bgView addSubview:rankImageView1];
  144. //
  145. //
  146. //
  147. // if (i == 0) {
  148. // self.iconImageView1 = iconImageView1;
  149. // self.rankImageView1 = rankImageView1;
  150. //
  151. // iconImageView1.layer.cornerRadius = 13;
  152. //
  153. // [iconImageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  154. // make.bottom.mas_equalTo(-1.5);
  155. // make.left.mas_equalTo(4);
  156. // make.size.mas_equalTo(26);
  157. // }];
  158. //
  159. // [rankImageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  160. // make.bottom.mas_equalTo(0);
  161. // make.left.mas_equalTo(0);
  162. // make.width.mas_equalTo(31);
  163. // make.height.mas_equalTo(38);
  164. //
  165. // }];
  166. //
  167. //
  168. // }else if (i == 1){
  169. // self.iconImageView2 = iconImageView1;
  170. // self.rankImageView2 = rankImageView1;
  171. //
  172. // iconImageView1.layer.cornerRadius = 13;
  173. //
  174. // [iconImageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  175. // make.bottom.mas_equalTo(-1.5);
  176. // make.left.mas_equalTo(4+31);
  177. // make.size.mas_equalTo(26);
  178. // }];
  179. //
  180. // [rankImageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  181. // make.bottom.mas_equalTo(0);
  182. // make.left.mas_equalTo(31);
  183. // make.width.mas_equalTo(31);
  184. // make.height.mas_equalTo(40);
  185. //
  186. // }];
  187. //
  188. // }else {
  189. // self.iconImageView3 = iconImageView1;
  190. // self.rankImageView3 = rankImageView1;
  191. //
  192. // iconImageView1.layer.cornerRadius = 12.5;
  193. //
  194. // [iconImageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  195. // make.bottom.mas_equalTo(-1.5);
  196. // make.left.mas_equalTo(31+31.5+1+3.5);
  197. // make.size.mas_equalTo(25);
  198. // }];
  199. //
  200. // [rankImageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  201. // make.bottom.mas_equalTo(0);
  202. // make.left.mas_equalTo(31+31.5+1);
  203. // make.width.mas_equalTo(30);
  204. // make.height.mas_equalTo(40);
  205. //
  206. // }];
  207. //
  208. // }
  209. //
  210. //
  211. //
  212. //
  213. //
  214. //
  215. //
  216. // }
  217. //
  218. [self addSubview:self.roomOrderDispatchView];
  219. [self.roomOrderDispatchView mas_makeConstraints:^(MASConstraintMaker *make) {
  220. make.top.equalTo(_AnnouncementBtn.mas_bottom).offset(15);
  221. make.centerX.mas_equalTo(0);
  222. make.width.mas_equalTo(100);
  223. make.height.mas_equalTo(100);
  224. }];
  225. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  226. make.top.mas_equalTo(0);
  227. make.centerX.mas_equalTo(0);
  228. }];
  229. [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  230. make.top.equalTo(self.titleLabel.mas_bottom).offset(5);
  231. make.centerX.mas_equalTo(0);
  232. }];
  233. [self.infoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  234. make.top.equalTo(self.timeLabel.mas_bottom).offset(5);
  235. make.centerX.mas_equalTo(0);
  236. make.width.mas_equalTo(65);
  237. make.height.mas_equalTo(21);
  238. }];
  239. // UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(kScreenW - 50, 3, 50, 50)];
  240. // button.backgroundColor = KBlueColor;
  241. // [button setTitle:@"调试" forState:UIControlStateNormal];
  242. // [button setTitleColor:kWhiteColor forState:UIControlStateNormal];
  243. // [button addTarget:self action:@selector(debug) forControlEvents:UIControlEventTouchUpInside];
  244. // [self addSubview:button];
  245. }
  246. - (void)handleTrueLoveButtonRecognizer {
  247. if([self.delegate respondsToSelector:@selector(micViewdidClickRoomTrueLove)])
  248. {
  249. [self.delegate micViewdidClickRoomTrueLove];
  250. }
  251. }
  252. - (void)debug {
  253. }
  254. - (void)setUpViewddd {
  255. self.backgroundColor = kClearColor;
  256. [self addSubview:self.collectionView];
  257. // [self addSubview:self.shareBtn];
  258. // [self addSubview:self.trueLoveBtn];
  259. }
  260. - (void)setUsers:(RoomUsers *)users{
  261. _users = users;
  262. RoomUserInfo *model = self.users.dataArray[0];
  263. [self.collectionView reloadData];
  264. }
  265. - (void)setModel:(RoomModel *)model{
  266. _model = model;
  267. [self.shareBtn setTitle:[NSString stringWithFormat:@"ID:%@",model.voice.luck.integerValue ? model.voice.luck : model.voice.user_id] forState:UIControlStateNormal];
  268. self.is_open_guest = (model.voice.room_type.intValue == 2);
  269. [self.collectionView reloadData];
  270. self.roomOrderDispatchView.hidden = !self.is_open_guest;
  271. // self.bgView.hidden = self.is_open_guest;
  272. // self.trueLoveBtn.hidden = self.is_open_guest;
  273. }
  274. - (void)setOrder:(BogoRODispatchModel *)order{
  275. _order = order;
  276. if ([_timer isValid]) {
  277. [_timer invalidate];
  278. }
  279. _timer =nil;
  280. if (order.status.intValue == 2) {
  281. self.timeLabel.text = @"00:00";
  282. } else {
  283. self.timeCount = order.duration_time.intValue;
  284. self.timeLabel.text = [NSString stringWithFormat:@"%02d:%02d",_timeCount / 60,_timeCount % 60];
  285. _timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
  286. }
  287. }
  288. - (void)timerAction {
  289. _timeCount ++;
  290. self.timeLabel.text = [NSString stringWithFormat:@"%02d:%02d",_timeCount / 60,_timeCount % 60];
  291. }
  292. //*/
  293. - (void)shareBtnAction:(QMUIButton *)sender{
  294. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:didClickShareBtn:)]) {
  295. [self.delegate micView:self didClickShareBtn:sender];
  296. }
  297. }
  298. - (void)trueLoveBtnAction:(UIButton *)sender{
  299. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:didClickTrueLoveBtn:)]) {
  300. [self.delegate micView:self didClickTrueLoveBtn:sender];
  301. }
  302. }
  303. - (void)AnnouncementBtnAction:(UIButton *)sender {
  304. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:didClickAnnouncementBtn:)]) {
  305. [self.delegate micView:self didClickAnnouncementBtn:sender];
  306. }
  307. }
  308. - (void)numBtnAction:(UIButton *)sender {
  309. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:didClickNumberBtn:)]) {
  310. [self.delegate micView:self didClickNumberBtn:sender];
  311. }
  312. }
  313. - (void)infoBtnAction:(UIButton *)sender {
  314. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:didClickRoomOrderDispatchInfoBtn:)]) {
  315. [self.delegate micView:self didClickRoomOrderDispatchInfoBtn:sender];
  316. }
  317. }
  318. - (void)refreshData{
  319. /*
  320. __weak __typeof(self)weakSelf = self;
  321. //http://www.bogo.voice.broadcast/mapi/public/index.php/api/Voice_api/get_voice_userlist
  322. NSString *url = [[CYURLUtils sharedCYURLUtils] makeURLWithC:@"Voice_api" A:@"get_voice_userlist"];
  323. [CYNET POSTv2:url parameters:@{@"id":_model.voice.id} responseCache:^(id responseObject) {
  324. //do nothing
  325. } success:^(id responseObject) {
  326. __strong __typeof(weakSelf)strongSelf = weakSelf;
  327. if ([[responseObject objectForKey:@"code"] integerValue] == 1) {
  328. // [strongSelf.dataArray removeAllObjects];
  329. // for (NSDictionary *dict in responseObject[@"userlist"]) {
  330. // RoomUserInfo *model = [RoomUserInfo mj_objectWithKeyValues:dict];
  331. // [strongSelf.dataArray addObject:model];
  332. // }
  333. // [strongSelf.numberBtn setTitle:[NSString stringWithFormat:@"在线人数%ld",strongSelf.dataArray.count] forState:UIControlStateNormal];
  334. // _number = strongSelf.dataArray.count;
  335. // [strongSelf.collectionView reloadData];
  336. NSArray * temp = responseObject[@"userlist"];
  337. [strongSelf.numBtn setTitle:[NSString stringWithFormat:ASLocalizedString(@"%ld在线"),temp.count] forState:UIControlStateNormal];
  338. CGSize btnSize = [_numBtn sizeThatFits:CGSizeMake(kScreenW-80-104, 26)];
  339. [_numBtn mas_updateConstraints:^(MASConstraintMaker *make) {
  340. make.width.mas_equalTo(btnSize.width+16);
  341. }];
  342. }
  343. } failure:^(NSString *error) {
  344. [[HUDHelper sharedInstance] tipMessage:error];
  345. } hasCache:NO];
  346. */
  347. }
  348. #pragma mark - RoomUserCellDelegate
  349. - (void)userCell:(RoomUserCell *)userCell didClickGiftView:(UIView *)giftView{
  350. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:userCell:didClickGiftView:)]) {
  351. [self.delegate micView:self userCell:userCell didClickGiftView:giftView];
  352. }
  353. }
  354. - (void)masterCell:(RoomMasterCell *)masterCell didClickGiftView:(UIView *)giftView{
  355. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:masterCell:didClickGiftView:)]) {
  356. [self.delegate micView:self masterCell:masterCell didClickGiftView:giftView];
  357. }
  358. }
  359. - (void)masterCell:(RoomMasterCell *)masterCell didClickUser:(RoomUserInfo *)model{
  360. if (!model.user_id.integerValue) {
  361. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:didClickLinkBtnIndex:)]) {
  362. [self.delegate micView:self didClickLinkBtnIndex:0];
  363. }
  364. }else{
  365. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:didClickUser:)]) {
  366. [self.delegate micView:self didClickUser:model];
  367. }
  368. }
  369. }
  370. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  371. return self.model.wheat_type_list.count;
  372. }
  373. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  374. if (indexPath.item == 0) {
  375. RoomMasterCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([RoomMasterCell class]) forIndexPath:indexPath];
  376. cell.is_open_guest = self.is_open_guest;
  377. RoomUserInfo *model = self.users.dataArray[indexPath.item];
  378. model.location = @"1";
  379. // [cell setModel:model];
  380. [cell setWheatModel:self.model.wheat_type_list[indexPath.item]];
  381. cell.delegate = self;
  382. return cell;
  383. }
  384. // 每次先从字典中根据IndexPath取出唯一标识符
  385. NSString *identifier = [self.cellDict objectForKey:[NSString stringWithFormat:@"%@", indexPath]];
  386. // 如果取出的唯一标示符不存在,则初始化唯一标示符,并将其存入字典中,对应唯一标示符注册Cell
  387. if (identifier == nil) {
  388. identifier = [NSString stringWithFormat:@"%@%@", @"RoomUserCell", [NSString stringWithFormat:@"%@", indexPath]];
  389. [self.cellDict setValue:identifier forKey:[NSString stringWithFormat:@"%@", indexPath]];
  390. // 注册Cell
  391. [self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([RoomUserCell class]) bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:identifier];
  392. }
  393. RoomUserCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
  394. cell.is_open_guest = self.is_open_guest;
  395. RoomUserInfo *model = self.users.dataArray[indexPath.item ];
  396. model.location = [NSString stringWithFormat:@"%ld",indexPath.item ];
  397. // [cell setModel:model];
  398. [cell setWheatModel:self.model.wheat_type_list[indexPath.item ]];
  399. cell.delegate = self;
  400. return cell;
  401. }
  402. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
  403. if (_is_open_guest) {
  404. if (indexPath.item == 0) {
  405. //暂时这样位置
  406. return CGSizeMake(collectionView.width/2.3, 130);
  407. }else if (indexPath.item == 1){
  408. return CGSizeMake(collectionView.width/2.3, 130);
  409. }
  410. else{
  411. return CGSizeMake(collectionView.width / 4, 110);
  412. }
  413. }
  414. if(self.model.wheat_type_list.count == 11)
  415. {
  416. if (indexPath.item == 0) {
  417. return CGSizeMake(collectionView.width, 130);
  418. }else{
  419. return CGSizeMake(collectionView.width / 5, 115);
  420. }
  421. }
  422. if(self.model.wheat_type_list.count == 5 || self.model.wheat_type_list.count == 10 || self.model.wheat_type_list.count == 15)
  423. {
  424. return CGSizeMake(collectionView.width / 5, 115);
  425. }
  426. else if(self.model.wheat_type_list.count == 20)
  427. {
  428. return CGSizeMake(collectionView.width / 5, 115);
  429. }
  430. else
  431. {
  432. if (indexPath.item == 0) {
  433. return CGSizeMake(collectionView.width, 130);
  434. }else{
  435. return CGSizeMake(collectionView.width / 4, 115);
  436. }
  437. }
  438. // return CGSizeMake(collectionView.width / 4, 115);
  439. }
  440. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
  441. return 0;
  442. }
  443. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
  444. return 0;
  445. }
  446. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
  447. return UIEdgeInsetsMake(0, 0, 0, 0);
  448. }
  449. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  450. if (indexPath.item==0) {
  451. return;
  452. }
  453. Wheat_Type_List *model = self.model.wheat_type_list[indexPath.item];
  454. if (model.even_wheat.user_id <= 0) {
  455. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:didClickLinkBtnIndex:)]) {
  456. // [self.delegate micView:self didClickLinkBtnIndex:indexPath.item + 1];
  457. [self.delegate micView:self didClickLinkBtnIndex:indexPath.item ];
  458. }
  459. }else{
  460. if (self.delegate && [self.delegate respondsToSelector:@selector(micView:didClickUser:)]) {
  461. [self.delegate micView:self didClickUser:model];
  462. }
  463. }
  464. }
  465. - (void)ApplyForMicrophone
  466. {
  467. }
  468. - (UICollectionView *)collectionView{
  469. if (!_collectionView) {
  470. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
  471. _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(15, 40, self.width - 30, self.height - 40) collectionViewLayout:layout];
  472. _collectionView.delegate = self;
  473. _collectionView.dataSource = self;
  474. _collectionView.backgroundColor = kClearColor;
  475. _collectionView.showsVerticalScrollIndicator = NO;
  476. _collectionView.clipsToBounds = NO;
  477. // [_collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([RoomUserCell class]) bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:NSStringFromClass([RoomUserCell class])];
  478. [_collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([RoomMasterCell class]) bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:NSStringFromClass([RoomMasterCell class])];
  479. }
  480. return _collectionView;
  481. }
  482. - (QMUIButton *)shareBtn{
  483. if (!_shareBtn) {
  484. _shareBtn = [[QMUIButton alloc]initWithFrame:CGRectMake(-15, 6, 100, 30)];
  485. [_shareBtn setImage:[UIImage imageNamed:@"share"] forState:UIControlStateNormal];
  486. _shareBtn.layer.cornerRadius = 15;
  487. _shareBtn.clipsToBounds = YES;
  488. _shareBtn.imagePosition = QMUIButtonImagePositionRight;
  489. _shareBtn.backgroundColor = [kBlackColor colorWithAlphaComponent:0.1];
  490. [_shareBtn setTitle:@"ID:" forState:UIControlStateNormal];
  491. [_shareBtn setTitleColor:[UIColor colorWithHexString:@"#909299"] forState:UIControlStateNormal];
  492. [_shareBtn.titleLabel setFont:[UIFont systemFontOfSize:11]];
  493. [_shareBtn setSpacingBetweenImageAndTitle:3];
  494. _shareBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  495. [_shareBtn addTarget:self action:@selector(shareBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  496. }
  497. return _shareBtn;
  498. }
  499. - (UIButton *)trueLoveBtn{
  500. if (!_trueLoveBtn) {
  501. _trueLoveBtn = [[QMUIButton alloc]initWithFrame:CGRectMake(0, 15, 30, 30)];
  502. _trueLoveBtn.right = self.width - 18;
  503. [_trueLoveBtn setImage:[UIImage imageNamed:@"go1_"] forState:UIControlStateNormal];
  504. [_trueLoveBtn addTarget:self action:@selector(trueLoveBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  505. }
  506. return _trueLoveBtn;
  507. }
  508. //- (UIButton *)trueLoveBtn{
  509. // if (!_trueLoveBtn) {
  510. // _trueLoveBtn = [[QMUIButton alloc]initWithFrame:CGRectMake(0, 2, 43, 39)];
  511. // _trueLoveBtn.right = self.width - 18;
  512. // [_trueLoveBtn setImage:[UIImage imageNamed:@"love_list"] forState:UIControlStateNormal];
  513. // [_trueLoveBtn addTarget:self action:@selector(trueLoveBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  514. // }
  515. // return _trueLoveBtn;
  516. //}
  517. - (RoomUserInfo *)emptyUser{
  518. RoomUserInfo *user = [[RoomUserInfo alloc]init];
  519. user.user_id = @"0";
  520. return user;
  521. }
  522. - (NSMutableDictionary *)cellDict{
  523. if (!_cellDict) {
  524. _cellDict = [NSMutableDictionary dictionary];
  525. }
  526. return _cellDict;
  527. }
  528. - (UIView *)roomOrderDispatchView{
  529. if (!_roomOrderDispatchView) {
  530. _roomOrderDispatchView = [[UIView alloc]init];
  531. _roomOrderDispatchView.backgroundColor = kClearColor;
  532. _roomOrderDispatchView.hidden = YES;
  533. [_roomOrderDispatchView addSubview:self.titleLabel];
  534. [_roomOrderDispatchView addSubview:self.timeLabel];
  535. [_roomOrderDispatchView addSubview:self.infoBtn];
  536. }
  537. return _roomOrderDispatchView;
  538. }
  539. - (UILabel *)titleLabel{
  540. if (!_titleLabel) {
  541. _titleLabel = [[UILabel alloc]init];
  542. _titleLabel.textColor = kWhiteColor;
  543. _titleLabel.text = ASLocalizedString(@"派单计时");
  544. _titleLabel.font = [UIFont systemFontOfSize:11];
  545. }
  546. return _titleLabel;
  547. }
  548. - (UILabel *)timeLabel{
  549. if (!_timeLabel) {
  550. _timeLabel = [[UILabel alloc]init];
  551. _timeLabel.textColor = [UIColor colorWithHexString:@"#FF7200"];
  552. _timeLabel.text = ASLocalizedString(@"00:00");
  553. _timeLabel.font = [UIFont systemFontOfSize:15];
  554. }
  555. return _timeLabel;
  556. }
  557. - (UIButton *)infoBtn{
  558. if (!_infoBtn) {
  559. _infoBtn = [[UIButton alloc]init];
  560. [_infoBtn.titleLabel setFont:[UIFont systemFontOfSize:11]];
  561. [_infoBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
  562. _infoBtn.layer.cornerRadius = 21/2.0;
  563. _infoBtn.clipsToBounds = YES;
  564. _infoBtn.backgroundColor = [kWhiteColor colorWithAlphaComponent:0.1];
  565. [_infoBtn setTitle:ASLocalizedString(@"派单详情") forState:UIControlStateNormal];
  566. // [_applyBtn.layer addSublayer:gl];
  567. [_infoBtn addTarget:self action:@selector(infoBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  568. }
  569. return _infoBtn;
  570. }
  571. @end