SLiveHeadInfoView.m 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. //
  2. // SLiveHeadInfoView.m
  3. // BuguLive
  4. //
  5. // Created by 丁凯 on 2017/7/10.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "SLiveHeadInfoView.h"
  9. #import "InformationModel.h"
  10. #import "cuserModel.h"
  11. #import "SLiveReportView.h"
  12. #import "dataModel.h"
  13. @implementation SLiveHeadInfoView
  14. - (void)awakeFromNib
  15. {
  16. [super awakeFromNib];
  17. self.concertBtn.userInteractionEnabled = self.fansBtn.userInteractionEnabled = self.SendOutBtn.userInteractionEnabled = self.ticketBtn.userInteractionEnabled = NO;
  18. self.userInteractionEnabled = NO;
  19. self.bgImgView.backgroundColor = kClearColor;
  20. self.bgImgView.layer.cornerRadius = 5;
  21. self.bgImgView.contentMode = UIViewContentModeScaleToFill;
  22. self.bgImgView.layer.masksToBounds = YES;
  23. self.bgImgView.userInteractionEnabled = NO;
  24. self.bigBottomView.userInteractionEnabled = NO;
  25. self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0];
  26. self.bigBottomView.backgroundColor = kWhiteColor;
  27. self.bigBottomView.layer.cornerRadius = 5;
  28. self.bigBottomView.layer.masksToBounds = YES;
  29. UITapGestureRecognizer *viewTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(myTap)];
  30. viewTap.delegate = self;
  31. [self addGestureRecognizer:viewTap];
  32. self.bHeadImgView.layer.cornerRadius = 35*kScaleHeight;
  33. self.bHeadImgView.layer.masksToBounds = YES;
  34. self.sHeadImgView.layer.cornerRadius = self.sHeadImgView.height/2.0f;
  35. self.sHeadImgView.layer.masksToBounds = YES;
  36. self.iconImgView.layer.cornerRadius = self.iconImgView.height/2.0f;
  37. self.iconImgView.layer.masksToBounds = YES;
  38. self.addressBtn.spacingBetweenImageAndTitle = 5;
  39. self.identifitionBtn.spacingBetweenImageAndTitle = 5;
  40. [self.followBtn setTitleColor:kAppMainColor forState:UIControlStateNormal];
  41. [self.privateLetterBtn setTitleColor:kAppMainColor forState:UIControlStateNormal];
  42. [self.replyBtn setTitleColor:kAppMainColor forState:UIControlStateNormal];
  43. [self.mainViewBtn2 setTitleColor:kAppMainColor forState:UIControlStateNormal];
  44. [self.mainViewBtn setTitleColor:kAppMainColor forState:UIControlStateNormal];
  45. // self.identifitionLabel.textColor = kAppMainColor;
  46. // self.outPutLabel.textColor = kAppMainColor;
  47. [self.reportBtn setTitleColor:[UIColor colorWithHexString:@"#9D21FE"] forState:UIControlStateNormal];
  48. //控件高度之间的距离
  49. self.HlineView.backgroundColor = self.VlineView1.backgroundColor = self.VlineView2.backgroundColor = kAppSpaceColor2;
  50. self.nameBottomViewSpaceH.constant = self.nameBottomViewSpaceH.constant*kScaleHeight;
  51. self.identifitionViewSpaceH.constant = self.identifitionViewSpaceH.constant*kScaleHeight;
  52. // self.cfBottomViewSpaceH.constant = self.cfBottomViewSpaceH.constant*kScaleHeight;
  53. self.HLineViewSpaceH.constant = self.HLineViewSpaceH.constant*kScaleHeight;
  54. self.bHeadImgViewSpaceH.constant = self.bHeadImgViewSpaceH.constant*kScaleHeight;
  55. self.signLabelSpaceH.constant = self.signLabelSpaceH.constant*kScaleHeight;
  56. self.HLineViewSpaceH.constant = self.HLineViewSpaceH.constant*kScaleHeight;
  57. //控件的高度
  58. self.identifitionBottomViewHeight.constant = self.identifitionBottomViewHeight.constant*kScaleHeight;
  59. self.bHeadImgViewHeight.constant = self.bHeadImgViewHeight.constant*kScaleHeight;
  60. self.nameBottomViewHeight.constant = self.nameBottomViewHeight.constant*kScaleHeight;
  61. self.accountBottomViewHeight.constant = self.accountBottomViewHeight.constant*kScaleHeight;
  62. self.signBottomViewHeight.constant = self.signBottomViewHeight.constant*kScaleHeight;
  63. self.CfBottomViewHight.constant = self.CfBottomViewHight.constant*kScaleHeight;
  64. self.OtBottomViewHeight.constant = self.OtBottomViewHeight.constant*kScaleHeight;
  65. self.concertBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  66. self.concertBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  67. self.fansBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  68. self.SendOutBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  69. self.ticketBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  70. self.nobleImgView.hidden = YES;
  71. self.nobleTopImgView.hidden = YES;
  72. }
  73. - (void)updateUIWithModel:(UserModel *)model withRoom:(id<FWShowLiveRoomAble>)room
  74. {
  75. self.user_id = model.user_id;
  76. self.myRoom = room;
  77. NSMutableDictionary *dictM = [[NSMutableDictionary alloc]init];
  78. [dictM setObject:@"user" forKey:@"ctl"];
  79. [dictM setObject:@"userinfo" forKey:@"act"];
  80. if ([[room liveHost] imUserId].length)
  81. {
  82. [dictM setObject:[[room liveHost] imUserId] forKey:@"podcast_id"];
  83. }
  84. if (model.user_id.length)
  85. {
  86. [dictM setObject:model.user_id forKey:@"to_user_id"];
  87. }
  88. if (StringFromInt([room liveAVRoomId]).length)
  89. {
  90. [dictM setObject:StringFromInt([room liveAVRoomId]) forKey:@"room_id"];
  91. }
  92. FWWeakify(self)
  93. [self.httpsManager POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson)
  94. {
  95. FWStrongify(self)
  96. if ([responseJson toInt:@"status"] == 1)
  97. {
  98. [self JsonDict:responseJson andUserId:model.user_id];
  99. }else
  100. {
  101. [FanweMessage alertHUD:[responseJson toString:@"error"]];
  102. }
  103. self.userInteractionEnabled = YES;
  104. self.bigBottomView.userInteractionEnabled = YES;
  105. } FailureBlock:^(NSError *error)
  106. {
  107. self.userInteractionEnabled = YES;
  108. self.bigBottomView.userInteractionEnabled = YES;
  109. }];
  110. }
  111. //解析数据
  112. -(void)JsonDict:(NSDictionary *)dict andUserId:(NSString *)userId
  113. {
  114. UserModel *uModel;
  115. cuserModel *cModel;
  116. InformationModel *model = [InformationModel mj_objectWithKeyValues:dict];
  117. if (model.user)
  118. {
  119. uModel = model.user;
  120. }else
  121. {
  122. uModel = [[UserModel alloc]init];
  123. }
  124. [self.bgImgView sd_setImageWithURL:[NSURL URLWithString:uModel.star_box] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  125. // CGSize size=image.size;
  126. }];
  127. // [self.vipImgView sd_setImageWithURL:[NSURL URLWithString:uModel.noble_icon]];
  128. if ([[GlobalVariables sharedInstance].appModel.open_noble isEqualToString:@"0"]) {
  129. // self.vipImgView.hidden = YES;
  130. self.bgImgView.hidden = YES;
  131. self.sexRightRankConstraint.constant = 5;
  132. }
  133. if ([uModel.is_vip isEqualToString:@"0"]) {
  134. self.vipImgView.hidden = YES;
  135. self.sexRightRankConstraint.constant = 5;
  136. }else{
  137. self.vipImgView.hidden = NO;
  138. self.sexRightRankConstraint.constant = 30;
  139. }
  140. if (uModel.nobleid.intValue > 0) {
  141. self.nobleImgView.hidden = NO;
  142. self.sexRightRankConstraint.constant = self.sexRightRankConstraint.constant + 45 + 5;
  143. [self.nobleImgView sd_setImageWithURL:[NSURL URLWithString:uModel.noble_icon]];
  144. [self.nobleTopImgView sd_setImageWithURL:[NSURL URLWithString:uModel.noble_shop]];
  145. self.nobleTopImgView.hidden = NO;
  146. }else{
  147. self.nobleImgView.hidden = YES;
  148. self.nobleTopImgView.hidden = YES;
  149. }
  150. if (model.cuser)
  151. {
  152. cModel = model.cuser;
  153. }else
  154. {
  155. cModel = [[cuserModel alloc]init];
  156. }
  157. self.headImgViewStr = uModel.head_image;
  158. [self.bHeadImgView sd_setImageWithURL:[NSURL URLWithString:uModel.head_image] placeholderImage:kDefaultPreloadHeadImg];
  159. if ([uModel.is_authentication intValue]>0) {
  160. if (uModel.noble_avatar && ![uModel.noble_avatar isEqualToString:@""])
  161. {
  162. self.iconImgView.hidden = NO;
  163. [self.iconImgView sd_setImageWithURL:[NSURL URLWithString:uModel.noble_avatar] placeholderImage:kDefaultPreloadHeadImg];
  164. }else{
  165. self.iconImgView.hidden = YES;
  166. }
  167. }else{
  168. self.iconImgView.hidden = YES;
  169. }
  170. self.iconImgView.hidden = YES;
  171. if (cModel.head_image)
  172. {
  173. self.sHeadImgView.hidden = NO;
  174. [self.sHeadImgView sd_setImageWithURL:[NSURL URLWithString:cModel.head_image]];
  175. }else
  176. {
  177. self.sHeadImgView.hidden = YES;
  178. }
  179. self.nick_name = uModel.nick_name;
  180. if (uModel.nick_name.length < 1)
  181. {
  182. uModel.nick_name = @"fanwe";
  183. }
  184. self.is_robot = uModel.is_robot;
  185. NSString *nameString = [NSString stringWithFormat:@"%@",uModel.nick_name];
  186. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:nameString];
  187. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:17.0]} range:NSMakeRange(0, nameString.length)];
  188. CGFloat width =[nameString sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]}].width;
  189. self.nameLabel.attributedText = attr;
  190. if (width + 65 >(301*kScaleWidth))
  191. {
  192. width = 301*kScaleWidth -65;
  193. self.nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  194. }
  195. self.nameBottomViewWidth.constant = width + 55;
  196. if ([model.user.sex isEqualToString:@"1"])
  197. {
  198. [self.sexImgView setImage:[UIImage imageNamed:@"com_male_selected"]];
  199. }else
  200. {
  201. [self.sexImgView setImage:[UIImage imageNamed:@"com_female_selected"]];
  202. }
  203. self.rankImgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"level%@",model.user.user_level]];
  204. self.show_admin = model.show_admin;
  205. self.show_tipoff = model.show_tipoff;
  206. self.has_admin = model.has_admin;
  207. self.has_focus = model.has_focus;
  208. self.is_forbid =model.is_forbid;
  209. if (uModel.user_id.length < 1)
  210. {
  211. uModel.user_id = ASLocalizedString(@"布谷");
  212. }
  213. NSString *rommString;
  214. if ([uModel.luck_num intValue] > 0)
  215. {
  216. rommString = [NSString stringWithFormat:@"%@:%@",self.BuguLive.appModel.account_name,uModel.luck_num];
  217. }else
  218. {
  219. rommString = [NSString stringWithFormat:@"%@:%@",self.BuguLive.appModel.account_name,uModel.user_id];
  220. }
  221. NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:rommString];
  222. [attr1 setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:13.0]} range:NSMakeRange(0, rommString.length)];
  223. CGFloat width1 =[rommString sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}].width;
  224. self.accountLabel.attributedText = attr1;
  225. if (uModel.city.length < 1)
  226. {
  227. uModel.city = ASLocalizedString(@"火星");
  228. }
  229. NSString *addressString = [NSString stringWithFormat:@"%@",uModel.city];
  230. NSMutableAttributedString *attr2 = [[NSMutableAttributedString alloc] initWithString:addressString];
  231. [attr2 setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:13.0]} range:NSMakeRange(0, addressString.length)];
  232. CGFloat width2 =[addressString sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}].width;
  233. if (width1 + width2 + 25 > 301*kScaleWidth)
  234. {
  235. self.placeLabelWidth.constant = 301*kScaleWidth - 25- width1;
  236. self.accountLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  237. self.accountBottomViewWidth.constant = 301*kScaleWidth;
  238. }else
  239. {
  240. self.placeLabelWidth.constant = width2+5;
  241. self.accountBottomViewWidth.constant = width2+width1+25;
  242. }
  243. self.placeLabel.attributedText = attr2;
  244. [self.addressBtn setTitle:uModel.city forState:UIControlStateNormal];
  245. [self.addressBtn sizeToFit];
  246. if (uModel.v_explain.length > 0)
  247. {
  248. self.identifitionView.hidden = NO;
  249. NSString *explainString = [NSString stringWithFormat:ASLocalizedString(@"认证:%@"),uModel.v_explain];
  250. NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:explainString];
  251. CGFloat width3 =[explainString sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}].width;
  252. self.identifitionLabel.attributedText = attr1;
  253. if (width3 +30 > 301*kScaleWidth)
  254. {
  255. self.identifitionBottomViewWidth.constant = 301*kScaleWidth;
  256. self.identifitionLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  257. }else
  258. {
  259. self.identifitionBottomViewWidth.constant = width3+30;
  260. }
  261. self.identifitionBtn.hidden = NO;
  262. }else
  263. {
  264. self.identifitionBtn.hidden = YES;
  265. // self.identifitionView.hidden = YES;
  266. // self.identifitionImgView.hidden = YES;
  267. // self.identifitionLabel.hidden = YES;
  268. // self.identifitionBottomViewHeight.constant = 0;
  269. // self.identifitionViewSpaceH.constant = 0;
  270. // self.bigBottomViewHeight.constant =self.bigBottomViewHeight.constant -23*(kScreenH/667.00);
  271. }
  272. self.identifitionLabel.text = rommString;
  273. if (uModel.signature.length < 1)
  274. {
  275. uModel.signature = ASLocalizedString(@"TA好像忘记写签名了");
  276. }
  277. self.siginLabel.font = [UIFont systemFontOfSize:13];
  278. NSString *likeString = [NSString stringWithFormat:@"%@",uModel.signature];
  279. NSMutableAttributedString *attr6 = [[NSMutableAttributedString alloc] initWithString:likeString];
  280. self.siginLabel.attributedText = attr6;
  281. if ([[IMAPlatform sharedInstance].host.imUserId isEqualToString:userId])
  282. {
  283. self.bBottomView.hidden = YES;
  284. self.mainViewBtn2.hidden = NO;
  285. }else
  286. {
  287. self.bBottomView.hidden = NO;
  288. self.mainViewBtn2.hidden = YES;
  289. }
  290. //关注
  291. NSString *n_focus_count = @"0";
  292. if (uModel.n_focus_count.length > 0)
  293. {
  294. n_focus_count = uModel.n_focus_count;
  295. }
  296. //粉丝
  297. NSString *focusCount = @"0";
  298. if (uModel.n_fans_count.length > 0)
  299. {
  300. focusCount = uModel.n_fans_count;
  301. }
  302. //送出
  303. NSString *n_use_diamonds = @"0";
  304. if (uModel.n_use_diamonds.length > 0 )
  305. {
  306. n_use_diamonds = uModel.n_use_diamonds;
  307. }
  308. //映票
  309. NSString *n_ticket = @"0";
  310. if (uModel.n_ticket.length > 0)
  311. {
  312. n_ticket = uModel.n_ticket;
  313. }
  314. self.concertBtn.titleLabel.numberOfLines = 0;
  315. self.fansBtn.titleLabel.numberOfLines = 0;
  316. self.ticketBtn.titleLabel.numberOfLines = 0;
  317. self.SendOutBtn.titleLabel.numberOfLines = 0;
  318. [self.concertBtn setTitle:[NSString stringWithFormat:ASLocalizedString(@"%@\n关注"),n_focus_count] forState:UIControlStateNormal];
  319. [self.fansBtn setTitle:[NSString stringWithFormat:ASLocalizedString(@"%@\n粉丝"),focusCount] forState:UIControlStateNormal];
  320. [self.SendOutBtn setTitle:[NSString stringWithFormat:ASLocalizedString(@"%@\n送出"),n_use_diamonds] forState:UIControlStateNormal];
  321. [self.ticketBtn setTitle:[NSString stringWithFormat:@"%@\n%@",n_ticket,self.BuguLive.appModel.ticket_name] forState:UIControlStateNormal];
  322. //判断是管理还是举报
  323. if (model.show_tipoff == 1)
  324. {
  325. [self.reportBtn setTitle:ASLocalizedString(@"举报")forState:0];
  326. }
  327. if (model.show_admin == 1 || model.show_admin == 2)
  328. {
  329. [self.reportBtn setTitle:ASLocalizedString(@"管理")forState:0];
  330. }else if(model.show_tipoff == 0 && model.show_admin == 0)
  331. {
  332. [self.reportBtn setTitle:@"" forState:0];
  333. }
  334. //判断是否已关注
  335. if (model.has_focus == 0 )
  336. {
  337. [self.followBtn setTitle:ASLocalizedString(@"关注")forState:0];
  338. [self.followBtn setTitleColor:kAppNewMainColor forState:0];
  339. // self.followBtn.userInteractionEnabled = YES;
  340. }else
  341. {
  342. [self.followBtn setTitle:ASLocalizedString(@"已关注")forState:0];
  343. [self.followBtn setTitleColor:[UIColor lightGrayColor] forState:0];
  344. // self.followBtn.userInteractionEnabled = NO;
  345. }
  346. if ([[[IMAPlatform sharedInstance].host imUserId] isEqualToString:self.user_id])
  347. {
  348. self.mainViewBtn2.hidden = NO;
  349. self.bBottomView.hidden = YES;
  350. self.HlineView.hidden = NO;
  351. self.bBottomView.hidden = YES;
  352. // MG_BOTTOM_MARGIN
  353. if (0) {
  354. self.bigBottomViewHeight.constant = kRealValue(320);
  355. self.bgImageHeightConstraint.constant = kRealValue(338);
  356. }
  357. else{
  358. self.bigBottomViewHeight.constant = kRealValue(350);
  359. self.bgImageHeightConstraint.constant = kRealValue(368);
  360. }
  361. }else{
  362. self.HlineView.hidden = NO;
  363. if (0) {
  364. self.bigBottomViewHeight.constant = kRealValue(320);
  365. self.bgImageHeightConstraint.constant = kRealValue(338);
  366. }else{
  367. self.bigBottomViewHeight.constant = kRealValue(350);
  368. self.bgImageHeightConstraint.constant = kRealValue(368);
  369. }
  370. }
  371. if ([[[_myRoom liveHost] imUserId] isEqualToString:[[IMAPlatform sharedInstance].host imUserId]] && [[[_myRoom liveHost] imUserId] isEqualToString:self.user_id] )
  372. {
  373. self.mainViewBtn2.hidden = YES;
  374. self.bBottomView.hidden = YES;
  375. self.HlineView.hidden = YES;
  376. if (0) {
  377. self.bigBottomViewHeight.constant = kRealValue(280);
  378. self.bgImageHeightConstraint.constant = kRealValue(293);
  379. }else{
  380. self.bigBottomViewHeight.constant = kRealValue(320);
  381. self.bgImageHeightConstraint.constant = kRealValue(338);
  382. }
  383. }
  384. }
  385. #pragma mark 0举报 管理 1删除 2主页 3关注 4私信 5回复
  386. - (IBAction)btnClick:(UIButton *)sender
  387. {
  388. switch (sender.tag)
  389. {
  390. case 0:
  391. {
  392. [self reportOrManager];
  393. }
  394. break;
  395. case 1:
  396. {
  397. [self myTap];
  398. }
  399. break;
  400. case 2:
  401. {
  402. [self goToHomePageVC];
  403. }
  404. break;
  405. case 3:
  406. {
  407. [self creatConcern];
  408. }
  409. break;
  410. case 4:
  411. {
  412. [self privateletter];
  413. }
  414. break;
  415. case 5:
  416. {
  417. [self reply];
  418. }
  419. break;
  420. default:
  421. break;
  422. }
  423. }
  424. #pragma mark 管理和举报
  425. - (void)reportOrManager
  426. {
  427. if (self.show_tipoff == 1 && self.show_admin == 0)//是否显示举报
  428. {
  429. [self removeFromSuperview];
  430. [self getReportView];
  431. }
  432. if (self.show_admin == 1)//管理员
  433. {
  434. UIActionSheet *headImgSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  435. [headImgSheet addButtonWithTitle:ASLocalizedString(@"举报")];
  436. if (self.is_forbid == 1)
  437. {
  438. [headImgSheet addButtonWithTitle:ASLocalizedString(@"解除禁言")];
  439. }else
  440. {
  441. [headImgSheet addButtonWithTitle:ASLocalizedString(@"禁言")];
  442. }
  443. [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消")];
  444. headImgSheet.cancelButtonIndex = headImgSheet.numberOfButtons-1;
  445. headImgSheet.delegate = self;
  446. [headImgSheet showInView:[UIApplication sharedApplication].keyWindow];
  447. }
  448. if (self.show_admin == 2)//主播
  449. {
  450. if (self.has_admin == 0)
  451. {
  452. UIActionSheet *headImgSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  453. [headImgSheet addButtonWithTitle:ASLocalizedString(@"设置为管理员")];
  454. [headImgSheet addButtonWithTitle:ASLocalizedString(@"管理员列表")];
  455. if (self.is_forbid == 1)
  456. {
  457. [headImgSheet addButtonWithTitle:ASLocalizedString(@"解除禁言")];
  458. }else
  459. {
  460. [headImgSheet addButtonWithTitle:ASLocalizedString(@"禁言")];
  461. }
  462. [headImgSheet addButtonWithTitle:ASLocalizedString(@"踢人")];
  463. [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消")];
  464. headImgSheet.cancelButtonIndex = headImgSheet.numberOfButtons-1;
  465. headImgSheet.delegate = self;
  466. [headImgSheet showInView:[UIApplication sharedApplication].keyWindow];
  467. }else if (self.has_admin == 1)
  468. {
  469. UIActionSheet *headImgSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  470. [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消管理员")];
  471. [headImgSheet addButtonWithTitle:ASLocalizedString(@"管理员列表")];
  472. if (self.is_forbid == 1)
  473. {
  474. [headImgSheet addButtonWithTitle:ASLocalizedString(@"解除禁言")];
  475. }else
  476. {
  477. [headImgSheet addButtonWithTitle:ASLocalizedString(@"禁言")];
  478. }
  479. [headImgSheet addButtonWithTitle:ASLocalizedString(@"踢人")];
  480. [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消")];
  481. headImgSheet.cancelButtonIndex = headImgSheet.numberOfButtons-1;
  482. headImgSheet.delegate = self;
  483. [headImgSheet showInView:[UIApplication sharedApplication].keyWindow];
  484. }
  485. }
  486. }
  487. - (void)showGagSheet
  488. {
  489. UIActionSheet * gagActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:ASLocalizedString(@"取消")destructiveButtonTitle:nil otherButtonTitles:ASLocalizedString(@"10分钟"),ASLocalizedString(@"1小时"),ASLocalizedString(@"12小时"),ASLocalizedString(@"1天"),ASLocalizedString(@"永久"),nil];
  490. gagActionSheet.tag = 500;
  491. [gagActionSheet showInView:[UIApplication sharedApplication].keyWindow];
  492. }
  493. - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger) buttonIndex
  494. {
  495. NSMutableDictionary *dictM = [[NSMutableDictionary alloc]init];
  496. if (actionSheet.tag == 500)
  497. {
  498. [dictM setObject:@"user" forKey:@"ctl"];
  499. [dictM setObject:@"forbid_send_msg" forKey:@"act"];
  500. [dictM setObject:[self.myRoom liveIMChatRoomId] forKey:@"group_id"];
  501. [dictM setObject:[NSString stringWithFormat:@"%@",self.user_id] forKey:@"to_user_id"];
  502. if (buttonIndex != actionSheet.numberOfButtons-1)
  503. {
  504. if (buttonIndex == 0) {
  505. [dictM setObject:@"600" forKey:@"second"];
  506. }
  507. else if (buttonIndex == 1)
  508. {
  509. [dictM setObject:@"3600" forKey:@"second"];
  510. }
  511. else if (buttonIndex == 2)
  512. {
  513. [dictM setObject:@(3600*12) forKey:@"second"];
  514. }
  515. else if (buttonIndex == 3)
  516. {
  517. [dictM setObject:@(3600*24) forKey:@"second"];
  518. }
  519. else if (buttonIndex == 4)
  520. {
  521. [dictM setObject:@(3600*240) forKey:@"second"];
  522. }
  523. FWWeakify(self)
  524. [self.httpsManager POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson)
  525. {
  526. FWStrongify(self)
  527. if ([responseJson toInt:@"status"] == 1)
  528. {
  529. self.is_forbid = [responseJson toInt:@"is_forbid"];
  530. }
  531. } FailureBlock:^(NSError *error)
  532. {
  533. [FanweMessage alert:ASLocalizedString(@"禁言失败")];
  534. }];
  535. }
  536. }
  537. else
  538. {
  539. if (self.show_admin == 1)//管理员
  540. {
  541. if (buttonIndex == 0)//举报
  542. {
  543. [self getReportView];
  544. }
  545. else if (buttonIndex == 1)
  546. {
  547. [self clickGagButton];
  548. }else if (buttonIndex == 2){
  549. [self clickBan];
  550. }
  551. }
  552. else if (self.show_admin == 2)//主播
  553. {
  554. if (buttonIndex == 0)//取消/设置管理员
  555. {
  556. [dictM setObject:@"user" forKey:@"ctl"];
  557. [dictM setObject:@"set_admin" forKey:@"act"];
  558. [dictM setObject:[NSString stringWithFormat:@"%@",self.user_id] forKey:@"to_user_id"];
  559. [dictM setObject:[NSString stringWithFormat:@"%d",[self.myRoom liveAVRoomId]] forKey:@"room_id"];
  560. FWWeakify(self)
  561. [self.httpsManager POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson){
  562. FWStrongify(self)
  563. self.has_admin = [responseJson toInt:@"has_admin"];
  564. if ([responseJson toInt:@"status"] == 1)
  565. {
  566. if (self.has_admin == 1)
  567. {
  568. [FanweMessage alertHUD:ASLocalizedString(@"设置管理员成功")];
  569. }
  570. else if (self.has_admin == 0)
  571. {
  572. [FanweMessage alertHUD:ASLocalizedString(@"取消管理员成功")];
  573. }
  574. }
  575. } FailureBlock:^(NSError *error)
  576. {
  577. [FanweMessage alertHUD:ASLocalizedString(@"管理员设置,请重新操作")];
  578. }];
  579. }
  580. else if (buttonIndex == 1)//管理员列表
  581. {
  582. [self goToManagerList];
  583. }
  584. else if (buttonIndex == 2)//禁言
  585. {
  586. [self clickGagButton];
  587. }else if (buttonIndex == 3){
  588. [self clickBan];
  589. }
  590. }
  591. }
  592. }
  593. //关注和取消关注
  594. - (void)creatConcern
  595. {
  596. NSMutableDictionary *dictM = [[NSMutableDictionary alloc]init];
  597. [dictM setObject:@"user" forKey:@"ctl"];
  598. [dictM setObject:@"follow" forKey:@"act"];
  599. [dictM setObject:[NSString stringWithFormat:@"%@",self.user_id] forKey:@"to_user_id"];
  600. FWWeakify(self)
  601. [self.httpsManager POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson)
  602. {
  603. FWStrongify(self)
  604. _has_focus = [responseJson toInt:@"has_focus"];
  605. if ([responseJson toInt:@"status"] == 1)
  606. {
  607. NSMutableDictionary *mDict = [[NSMutableDictionary alloc]init];
  608. if (self.has_focus == 1)//已关注
  609. {
  610. [self.followBtn setTitle:ASLocalizedString(@"已关注")forState:0];
  611. [mDict setObject:@"0" forKey:@"isShowFollow"];
  612. [self.followBtn setTitleColor:[UIColor lightGrayColor] forState:0];
  613. // self.followBtn.userInteractionEnabled = NO;
  614. }
  615. else if (self.has_focus == 0)//关注
  616. {
  617. [mDict setObject:@"1" forKey:@"isShowFollow"];
  618. [self.followBtn setTitle:ASLocalizedString(@"关注")forState:0];
  619. [self.followBtn setTitleColor:kAppNewMainColor forState:0];
  620. }
  621. [mDict setObject:[responseJson toString:@"follow_msg"] forKey:@"follow_msg"];
  622. if (self.user_id.length)
  623. {
  624. [mDict setObject:self.user_id forKey:@"userId"];
  625. }
  626. [[NSNotificationCenter defaultCenter]postNotificationName:@"liveIsShowFollow" object:mDict];
  627. }
  628. } FailureBlock:^(NSError *error)
  629. {
  630. NSLog(@"error===%@",error);
  631. }];
  632. }
  633. #pragma mark 用来解决跟tableview等的手势冲突问题
  634. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
  635. {
  636. if ([touch.view isDescendantOfView:self.bigBottomView])
  637. {
  638. return NO;
  639. }else
  640. {
  641. return YES;
  642. }
  643. }
  644. #pragma mark 点击空白的地方删除view
  645. - (void)myTap
  646. {
  647. if (self.infoDelegate)
  648. {
  649. if ([self.infoDelegate respondsToSelector:@selector(operationHeadView:andUserId:andNameStr:andUserImgUrl:andIs_robot:andViewType:)])
  650. {
  651. [self.infoDelegate operationHeadView:self andUserId:nil andNameStr:nil andUserImgUrl:nil andIs_robot:NO andViewType:1];
  652. }
  653. }
  654. }
  655. #pragma mark 进入主页
  656. - (void)goToHomePageVC
  657. {
  658. if (self.infoDelegate)
  659. {
  660. if ([self.infoDelegate respondsToSelector:@selector(operationHeadView:andUserId:andNameStr:andUserImgUrl:andIs_robot:andViewType:)])
  661. {
  662. [self.infoDelegate operationHeadView:self andUserId:self.user_id andNameStr:nil andUserImgUrl:nil andIs_robot:NO andViewType:2];
  663. }
  664. }
  665. }
  666. #pragma mark 管理员列表的获取
  667. - (void)goToManagerList
  668. {
  669. if (self.infoDelegate)
  670. {
  671. if ([self.infoDelegate respondsToSelector:@selector(operationHeadView:andUserId:andNameStr:andUserImgUrl:andIs_robot:andViewType:)])
  672. {
  673. [self.infoDelegate operationHeadView:self andUserId:nil andNameStr:nil andUserImgUrl:nil andIs_robot:NO andViewType:3];
  674. }
  675. }
  676. }
  677. //点击踢人
  678. -(void)clickBan{
  679. NSMutableDictionary * dictM = [NSMutableDictionary dictionary];
  680. [dictM setObject:@"video" forKey:@"ctl"];
  681. [dictM setObject:@"kicking" forKey:@"act"];
  682. [dictM setObject:[NSString stringWithFormat:@"%d",[self.myRoom liveAVRoomId]] forKey:@"room_id"];
  683. [dictM setObject:[NSString stringWithFormat:@"%@",self.user_id] forKey:@"user_id"];
  684. FWWeakify(self)
  685. [self.httpsManager POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson){
  686. FWStrongify(self)
  687. // self.has_admin = [responseJson toInt:@"has_admin"];
  688. if ([responseJson toInt:@"status"] == 1)
  689. {
  690. [FanweMessage alertHUD:ASLocalizedString(@"踢人成功")];
  691. if (self.infoDelegate && [self.infoDelegate respondsToSelector:@selector(clickHeadViewRefresh)]) {
  692. [self.infoDelegate clickHeadViewRefresh];
  693. }
  694. // [_liveUIViewController.liveView.topView refreshTicketCount:[NSString stringWithFormat:@"%ld",(long)_voteNumber]];
  695. // [_liveUIViewController.liveView.topView refreshLiveAudienceList:customMessageModel];
  696. }
  697. } FailureBlock:^(NSError *error)
  698. {
  699. [FanweMessage alertHUD:ASLocalizedString(@"踢人失败")];
  700. }];
  701. }
  702. #pragma mark 回复的响应
  703. - (void)reply
  704. {
  705. if (self.infoDelegate)
  706. {
  707. if ([self.infoDelegate respondsToSelector:@selector(operationHeadView:andUserId:andNameStr:andUserImgUrl:andIs_robot:andViewType:)])
  708. {
  709. [self.infoDelegate operationHeadView:self andUserId:nil andNameStr:self.nick_name andUserImgUrl:nil andIs_robot:NO andViewType:4];
  710. }
  711. }
  712. }
  713. #pragma mark 显示举报View
  714. - (void)getReportView
  715. {
  716. if (self.infoDelegate)
  717. {
  718. if ([self.infoDelegate respondsToSelector:@selector(operationHeadView:andUserId:andNameStr:andUserImgUrl:andIs_robot:andViewType:)])
  719. {
  720. [self.infoDelegate operationHeadView:self andUserId:self.user_id andNameStr:nil andUserImgUrl:nil andIs_robot:NO andViewType:5];
  721. }
  722. }
  723. }
  724. #pragma mark 私信的响应事件
  725. - (void)privateletter
  726. {
  727. if (self.infoDelegate)
  728. {
  729. if ([self.infoDelegate respondsToSelector:@selector(operationHeadView:andUserId:andNameStr:andUserImgUrl:andIs_robot:andViewType:)])
  730. {
  731. [self.infoDelegate operationHeadView:self andUserId:self.user_id andNameStr:self.nick_name andUserImgUrl:self.headImgViewStr andIs_robot:self.is_robot andViewType:6];
  732. }
  733. }
  734. }
  735. - (void)clickGagButton
  736. {
  737. if (self.is_forbid == 1)
  738. {
  739. //取消禁言
  740. NSMutableDictionary * dictM = [NSMutableDictionary dictionary];
  741. [dictM setObject:@"user" forKey:@"ctl"];
  742. [dictM setObject:@"forbid_send_msg" forKey:@"act"];
  743. [dictM setObject:[self.myRoom liveIMChatRoomId] forKey:@"group_id"];
  744. [dictM setObject:[NSString stringWithFormat:@"%@",self.user_id] forKey:@"to_user_id"];
  745. [dictM setObject:@0 forKey:@"second"];
  746. FWWeakify(self)
  747. [self.httpsManager POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson)
  748. {
  749. FWStrongify(self)
  750. if ([responseJson toInt:@"status"] == 1)
  751. {
  752. self.is_forbid = [responseJson toInt:@"is_forbid"];
  753. }
  754. } FailureBlock:^(NSError *error)
  755. {
  756. }];
  757. }
  758. else
  759. {
  760. //禁言
  761. [self showGagSheet];
  762. }
  763. }
  764. @end