YOUPAILZAnchorLiveCloseVC.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. //
  2. // YOUPAILZAnchorLiveCloseVC.m
  3. // TIANYAN
  4. //
  5. // Created by CY on 2021/5/26.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZAnchorLiveCloseVC.h"
  9. #import "YOUPAILZLiveAnchorVC.h"
  10. @interface YOUPAILZAnchorLiveCloseVC ()
  11. @property (nonatomic, weak) UIButton *youpaipreLiveBtn;
  12. @end
  13. @implementation YOUPAILZAnchorLiveCloseVC
  14. - (void)viewWillAppear:(BOOL)animated{
  15. [super viewWillAppear:animated];
  16. self.navigationController.navigationBarHidden = YES;
  17. }
  18. - (void)viewDidAppear:(BOOL)animated{
  19. [super viewDidAppear:animated];
  20. }
  21. - (void)viewWillDisappear:(BOOL)animated{
  22. [super viewWillDisappear:animated];
  23. self.navigationController.navigationBarHidden = NO;
  24. }
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.view.backgroundColor = [UIColor blackColor];
  28. self.sx_disableInteractivePop = YES;
  29. [self youpaifinitUI];
  30. }
  31. - (void)youpaifinitUI{
  32. UIImageView *youpaipbgImgV = [[UIImageView alloc] initWithFrame:self.view.bounds];
  33. youpaipbgImgV.contentMode = UIViewContentModeScaleAspectFill;
  34. youpaipbgImgV.userInteractionEnabled = YES;
  35. youpaipbgImgV.clipsToBounds = YES;
  36. [youpaipbgImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipanchor_img]];
  37. [self.view addSubview:youpaipbgImgV];
  38. UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
  39. UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
  40. effectView.frame = youpaipbgImgV.bounds;
  41. [youpaipbgImgV addSubview:effectView];
  42. UILabel *youpaipnicknameL = [[UILabel alloc] init];
  43. youpaipnicknameL.font = LCFont(18.0f);
  44. youpaipnicknameL.textColor = [UIColor whiteColor];
  45. youpaipnicknameL.text = self.youpaipmodel.youpaipanchor_name;
  46. [youpaipbgImgV addSubview:youpaipnicknameL];
  47. [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.bottom.equalTo(youpaipbgImgV.mas_centerY).offset(-(77.0f+ScaleSize(40.0f)));
  49. make.centerX.equalTo(youpaipbgImgV.mas_centerX);
  50. }];
  51. UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
  52. youpaipavatarImgV.layer.borderColor = [UIColor whiteColor].CGColor;
  53. youpaipavatarImgV.layer.borderWidth = 2.0f;
  54. youpaipavatarImgV.layer.cornerRadius = ScaleSize(45.0f);
  55. youpaipavatarImgV.clipsToBounds = YES;
  56. youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  57. [youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipanchor_img]];
  58. [youpaipbgImgV addSubview:youpaipavatarImgV];
  59. [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.bottom.equalTo(youpaipnicknameL.mas_top).offset(-ScaleSize(14.0f));
  61. make.centerX.equalTo(youpaipbgImgV.mas_centerX);
  62. make.size.mas_offset(CGSizeMake(ScaleSize(90.0f), ScaleSize(90.0f)));
  63. }];
  64. UILabel *titleL = [[UILabel alloc] init];
  65. titleL.font = LCFont(29.0f);
  66. titleL.textColor = [UIColor whiteColor];
  67. titleL.text = @"直播已结束";
  68. [youpaipbgImgV addSubview:titleL];
  69. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.bottom.mas_equalTo(youpaipavatarImgV.mas_top).offset(-ScaleSize(20.0f));
  71. make.centerX.equalTo(youpaipbgImgV.mas_centerX);
  72. }];
  73. NSArray *headArr = @[@{@"count":self.youpaipmodel.youpaipcoin,@"title":LCStr(word16)},@{@"count":self.youpaipmodel.youpaiptotal_viewers,@"title":@"观看人数"}];//本场收益
  74. CGFloat width = (KScreenWidth - 24.0f) / headArr.count;
  75. for (NSInteger i = 0; i < headArr.count; i ++) {
  76. NSDictionary *dict = headArr[i];
  77. UIView *bgV = [[UIView alloc] init];
  78. [youpaipbgImgV addSubview:bgV];
  79. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.left.offset(12.0f + i * width);
  81. make.bottom.equalTo(youpaipbgImgV.mas_centerY).offset(0);
  82. make.width.offset(width);
  83. make.height.offset(77.0f);
  84. }];
  85. UILabel *youpaipcountL = [[UILabel alloc] init];
  86. youpaipcountL.font = LCBoldFont(29.0f);
  87. youpaipcountL.textColor = HexColorFromRGB(0xFFDD8D);
  88. youpaipcountL.textAlignment = NSTextAlignmentCenter;
  89. youpaipcountL.text = dict[@"count"];
  90. [bgV addSubview:youpaipcountL];
  91. [youpaipcountL mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.top.offset(0.0f);
  93. make.left.offset(5.0f);
  94. make.right.offset(-5.0f);
  95. make.height.offset(40.0f);
  96. }];
  97. UILabel *titleDescL = [[UILabel alloc] init];
  98. titleDescL.font = LCFont(14.0f);
  99. titleDescL.textColor = [UIColor whiteColor];
  100. titleDescL.textAlignment = NSTextAlignmentCenter;
  101. titleDescL.text = dict[@"title"];
  102. titleDescL.backgroundColor = [HexColorFromRGB(0x000000) colorWithAlphaComponent:0.3f];
  103. titleDescL.layer.cornerRadius = 14.0f;
  104. titleDescL.clipsToBounds = YES;
  105. [bgV addSubview:titleDescL];
  106. [titleDescL mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.size.mas_offset(CGSizeMake(96.0f, 28.0f));
  108. make.bottom.offset(0.0f);
  109. make.centerX.equalTo(bgV.mas_centerX);
  110. }];
  111. }
  112. NSArray *footerArr = @[@{@"count":self.youpaipmodel.youpaiplive_time,@"title":@"直播时长"},
  113. @{@"count":self.youpaipmodel.youpaipanchor_charm,@"title":@"魅力值"},
  114. @{@"count":self.youpaipmodel.youpaipfans,@"title":@"转化粉丝"}];
  115. CGFloat footerWidth = (KScreenWidth - 24.0f) / footerArr.count;
  116. for (NSInteger i = 0; i < footerArr.count; i ++) {
  117. NSDictionary *dict = footerArr[i];
  118. UIView *bgV = [[UIView alloc] init];
  119. [youpaipbgImgV addSubview:bgV];
  120. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.offset(12.0f + i * footerWidth);
  122. make.top.equalTo(youpaipbgImgV.mas_centerY).offset(28.0f);
  123. make.width.offset(footerWidth);
  124. make.height.offset(62.0f);
  125. }];
  126. UILabel *youpaipcountL = [[UILabel alloc] init];
  127. youpaipcountL.font = LCBoldFont(19.0f);
  128. youpaipcountL.textColor = [UIColor whiteColor];
  129. youpaipcountL.textAlignment = NSTextAlignmentCenter;
  130. youpaipcountL.text = dict[@"count"];
  131. [bgV addSubview:youpaipcountL];
  132. [youpaipcountL mas_makeConstraints:^(MASConstraintMaker *make) {
  133. make.top.offset(7.0f);
  134. make.left.offset(5.0f);
  135. make.right.offset(-5.0f);
  136. make.height.offset(26.0f);
  137. }];
  138. UILabel *titleDescL = [[UILabel alloc] init];
  139. titleDescL.font = LCFont(14.0f);
  140. titleDescL.textColor = HexColorFromRGB(0xffffff);
  141. titleDescL.textAlignment = NSTextAlignmentCenter;
  142. titleDescL.text = dict[@"title"];
  143. [bgV addSubview:titleDescL];
  144. [titleDescL mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.left.offset(5.0f);
  146. make.right.offset(-5.0f);
  147. make.bottom.offset(0.0f);
  148. make.height.offset(20.0f);
  149. }];
  150. if (i < footerArr.count - 1) {
  151. UIView *line = [[UIView alloc] init];
  152. line.backgroundColor = HexColorFromRGB(0x838383);
  153. [bgV addSubview:line];
  154. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.top.bottom.right.offset(0.0f);
  156. make.width.offset(0.5f);
  157. }];
  158. }
  159. }
  160. UIButton *confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  161. [confirmBtn addTarget:self action:@selector(youpaifconfirmBtnClick) forControlEvents:UIControlEventTouchUpInside];
  162. [confirmBtn setTitle:@"确定" forState:0];
  163. [confirmBtn setTitleColor:HexColorFromRGB(0xffffff) forState:0];
  164. confirmBtn.titleLabel.font = LCFont(17);
  165. [confirmBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 120.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  166. confirmBtn.layer.cornerRadius = 24.0f;
  167. confirmBtn.layer.masksToBounds = YES;
  168. [youpaipbgImgV addSubview:confirmBtn];
  169. [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  170. make.left.offset(60.0f);
  171. make.right.offset(-60.0f);
  172. make.top.equalTo(youpaipbgImgV.mas_centerY).offset(28.0f + 62.0f + ScaleSize(75.0f));
  173. make.height.offset(48.0f);
  174. }];
  175. UIButton *youpaipreLiveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  176. [youpaipreLiveBtn addTarget:self action:@selector(youpaifreLiveBtnClick) forControlEvents:UIControlEventTouchUpInside];
  177. [youpaipreLiveBtn setTitle:@"再次开播" forState:0];
  178. [youpaipreLiveBtn setTitleColor:HexColorFromRGB(0xffffff) forState:0];
  179. youpaipreLiveBtn.titleLabel.font = LCFont(17);
  180. [youpaipreLiveBtn setBackgroundColor:[HexColorFromRGB(0x9F9DA5) colorWithAlphaComponent:1.0f]];
  181. youpaipreLiveBtn.layer.cornerRadius = 24.0f;
  182. youpaipreLiveBtn.layer.masksToBounds = YES;
  183. youpaipreLiveBtn.layer.borderColor = HexColorFromRGB(0x979797).CGColor;
  184. youpaipreLiveBtn.layer.borderWidth = 1.0f;
  185. [youpaipbgImgV addSubview:youpaipreLiveBtn];
  186. self.youpaipreLiveBtn = youpaipreLiveBtn;
  187. [youpaipreLiveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  188. make.left.offset(60.0f);
  189. make.right.offset(-60.0f);
  190. make.top.equalTo(confirmBtn.mas_bottom).offset(14.0f);
  191. make.height.offset(48.0f);
  192. }];
  193. }
  194. - (void)youpaifconfirmBtnClick{
  195. [self.navigationController popViewControllerAnimated:YES];
  196. }
  197. - (void)youpaifreLiveBtnClick{
  198. self.youpaipreLiveBtn.userInteractionEnabled = NO;
  199. WeakSelf;
  200. [LCHttpHelper requestWithURLString:StatusLive parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  201. NSDictionary* dict = (NSDictionary*)responseObject;
  202. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  203. if (code == 0) {
  204. NSInteger live_status = [[[dict objectForKey:@"data"] objectForKey:@"live_status"] integerValue]; // 认证状态 1未认证 2已认证
  205. if (live_status != 1) {
  206. [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
  207. YOUPAILZLiveAnchorVC *anchorVC = [[YOUPAILZLiveAnchorVC alloc] init];
  208. anchorVC.youpaipshareModel = [YOUPAILZLiveShareModel mj_objectWithKeyValues:[[dict objectForKey:@"data"] objectForKey:@"share"]];
  209. anchorVC.youpaipcover = [[dict objectForKey:@"data"] objectForKey:@"cover"];
  210. anchorVC.hidesBottomBarWhenPushed = YES;
  211. NSArray *vcs = weakSelf.navigationController.viewControllers;
  212. NSMutableArray <UIViewController *>*nVcs = [NSMutableArray array];
  213. for (UIViewController *vc in vcs) {
  214. if (![vc isKindOfClass:[YOUPAILZAnchorLiveCloseVC class]]) {
  215. [nVcs addObject:vc];
  216. }
  217. }
  218. [nVcs addObject:anchorVC];
  219. [weakSelf.navigationController setViewControllers:nVcs.copy animated:YES];
  220. }
  221. }else{
  222. weakSelf.youpaipreLiveBtn.userInteractionEnabled = YES;
  223. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  224. }
  225. } failure:^(NSError *error) {
  226. self.youpaipreLiveBtn.userInteractionEnabled = YES;
  227. [ZCHUDHelper showTitle:error.localizedDescription];
  228. }];
  229. }
  230. @end