123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- //
- // YOUPAILZAnchorLiveCloseVC.m
- // TIANYAN
- //
- // Created by CY on 2021/5/26.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZAnchorLiveCloseVC.h"
- #import "YOUPAILZLiveAnchorVC.h"
- @interface YOUPAILZAnchorLiveCloseVC ()
- @property (nonatomic, weak) UIButton *youpaipreLiveBtn;
- @end
- @implementation YOUPAILZAnchorLiveCloseVC
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- self.navigationController.navigationBarHidden = YES;
- }
- - (void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
- self.navigationController.navigationBarHidden = NO;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = [UIColor blackColor];
- self.sx_disableInteractivePop = YES;
- [self youpaifinitUI];
- }
- - (void)youpaifinitUI{
- UIImageView *youpaipbgImgV = [[UIImageView alloc] initWithFrame:self.view.bounds];
- youpaipbgImgV.contentMode = UIViewContentModeScaleAspectFill;
- youpaipbgImgV.userInteractionEnabled = YES;
- youpaipbgImgV.clipsToBounds = YES;
- [youpaipbgImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipanchor_img]];
- [self.view addSubview:youpaipbgImgV];
-
- UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
- UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
- effectView.frame = youpaipbgImgV.bounds;
- [youpaipbgImgV addSubview:effectView];
-
-
-
-
-
- UILabel *youpaipnicknameL = [[UILabel alloc] init];
- youpaipnicknameL.font = LCFont(18.0f);
- youpaipnicknameL.textColor = [UIColor whiteColor];
- youpaipnicknameL.text = self.youpaipmodel.youpaipanchor_name;
- [youpaipbgImgV addSubview:youpaipnicknameL];
- [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(youpaipbgImgV.mas_centerY).offset(-(77.0f+ScaleSize(40.0f)));
- make.centerX.equalTo(youpaipbgImgV.mas_centerX);
- }];
-
- UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
- youpaipavatarImgV.layer.borderColor = [UIColor whiteColor].CGColor;
- youpaipavatarImgV.layer.borderWidth = 2.0f;
- youpaipavatarImgV.layer.cornerRadius = ScaleSize(45.0f);
- youpaipavatarImgV.clipsToBounds = YES;
- youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
- [youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipanchor_img]];
- [youpaipbgImgV addSubview:youpaipavatarImgV];
- [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(youpaipnicknameL.mas_top).offset(-ScaleSize(14.0f));
- make.centerX.equalTo(youpaipbgImgV.mas_centerX);
- make.size.mas_offset(CGSizeMake(ScaleSize(90.0f), ScaleSize(90.0f)));
- }];
-
- UILabel *titleL = [[UILabel alloc] init];
- titleL.font = LCFont(29.0f);
- titleL.textColor = [UIColor whiteColor];
- titleL.text = @"直播已结束";
- [youpaipbgImgV addSubview:titleL];
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(youpaipavatarImgV.mas_top).offset(-ScaleSize(20.0f));
- make.centerX.equalTo(youpaipbgImgV.mas_centerX);
- }];
-
- NSArray *headArr = @[@{@"count":self.youpaipmodel.youpaipcoin,@"title":LCStr(word16)},@{@"count":self.youpaipmodel.youpaiptotal_viewers,@"title":@"观看人数"}];//本场收益
- CGFloat width = (KScreenWidth - 24.0f) / headArr.count;
- for (NSInteger i = 0; i < headArr.count; i ++) {
- NSDictionary *dict = headArr[i];
- UIView *bgV = [[UIView alloc] init];
- [youpaipbgImgV addSubview:bgV];
- [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(12.0f + i * width);
- make.bottom.equalTo(youpaipbgImgV.mas_centerY).offset(0);
- make.width.offset(width);
- make.height.offset(77.0f);
- }];
-
- UILabel *youpaipcountL = [[UILabel alloc] init];
- youpaipcountL.font = LCBoldFont(29.0f);
- youpaipcountL.textColor = HexColorFromRGB(0xFFDD8D);
- youpaipcountL.textAlignment = NSTextAlignmentCenter;
- youpaipcountL.text = dict[@"count"];
- [bgV addSubview:youpaipcountL];
- [youpaipcountL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.offset(0.0f);
- make.left.offset(5.0f);
- make.right.offset(-5.0f);
- make.height.offset(40.0f);
- }];
-
- UILabel *titleDescL = [[UILabel alloc] init];
- titleDescL.font = LCFont(14.0f);
- titleDescL.textColor = [UIColor whiteColor];
- titleDescL.textAlignment = NSTextAlignmentCenter;
- titleDescL.text = dict[@"title"];
- titleDescL.backgroundColor = [HexColorFromRGB(0x000000) colorWithAlphaComponent:0.3f];
- titleDescL.layer.cornerRadius = 14.0f;
- titleDescL.clipsToBounds = YES;
- [bgV addSubview:titleDescL];
- [titleDescL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.size.mas_offset(CGSizeMake(96.0f, 28.0f));
- make.bottom.offset(0.0f);
- make.centerX.equalTo(bgV.mas_centerX);
- }];
-
- }
-
- NSArray *footerArr = @[@{@"count":self.youpaipmodel.youpaiplive_time,@"title":@"直播时长"},
- @{@"count":self.youpaipmodel.youpaipanchor_charm,@"title":@"魅力值"},
- @{@"count":self.youpaipmodel.youpaipfans,@"title":@"转化粉丝"}];
- CGFloat footerWidth = (KScreenWidth - 24.0f) / footerArr.count;
- for (NSInteger i = 0; i < footerArr.count; i ++) {
- NSDictionary *dict = footerArr[i];
- UIView *bgV = [[UIView alloc] init];
- [youpaipbgImgV addSubview:bgV];
- [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(12.0f + i * footerWidth);
- make.top.equalTo(youpaipbgImgV.mas_centerY).offset(28.0f);
- make.width.offset(footerWidth);
- make.height.offset(62.0f);
- }];
-
- UILabel *youpaipcountL = [[UILabel alloc] init];
- youpaipcountL.font = LCBoldFont(19.0f);
- youpaipcountL.textColor = [UIColor whiteColor];
- youpaipcountL.textAlignment = NSTextAlignmentCenter;
- youpaipcountL.text = dict[@"count"];
- [bgV addSubview:youpaipcountL];
- [youpaipcountL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.offset(7.0f);
- make.left.offset(5.0f);
- make.right.offset(-5.0f);
- make.height.offset(26.0f);
- }];
-
- UILabel *titleDescL = [[UILabel alloc] init];
- titleDescL.font = LCFont(14.0f);
- titleDescL.textColor = HexColorFromRGB(0xffffff);
- titleDescL.textAlignment = NSTextAlignmentCenter;
- titleDescL.text = dict[@"title"];
- [bgV addSubview:titleDescL];
- [titleDescL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(5.0f);
- make.right.offset(-5.0f);
- make.bottom.offset(0.0f);
- make.height.offset(20.0f);
- }];
-
- if (i < footerArr.count - 1) {
- UIView *line = [[UIView alloc] init];
- line.backgroundColor = HexColorFromRGB(0x838383);
- [bgV addSubview:line];
- [line mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.bottom.right.offset(0.0f);
- make.width.offset(0.5f);
- }];
- }
- }
-
- UIButton *confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [confirmBtn addTarget:self action:@selector(youpaifconfirmBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [confirmBtn setTitle:@"确定" forState:0];
- [confirmBtn setTitleColor:HexColorFromRGB(0xffffff) forState:0];
- confirmBtn.titleLabel.font = LCFont(17);
- [confirmBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 120.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
- confirmBtn.layer.cornerRadius = 24.0f;
- confirmBtn.layer.masksToBounds = YES;
- [youpaipbgImgV addSubview:confirmBtn];
- [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(60.0f);
- make.right.offset(-60.0f);
- make.top.equalTo(youpaipbgImgV.mas_centerY).offset(28.0f + 62.0f + ScaleSize(75.0f));
- make.height.offset(48.0f);
- }];
-
-
- UIButton *youpaipreLiveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [youpaipreLiveBtn addTarget:self action:@selector(youpaifreLiveBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [youpaipreLiveBtn setTitle:@"再次开播" forState:0];
- [youpaipreLiveBtn setTitleColor:HexColorFromRGB(0xffffff) forState:0];
- youpaipreLiveBtn.titleLabel.font = LCFont(17);
- [youpaipreLiveBtn setBackgroundColor:[HexColorFromRGB(0x9F9DA5) colorWithAlphaComponent:1.0f]];
- youpaipreLiveBtn.layer.cornerRadius = 24.0f;
- youpaipreLiveBtn.layer.masksToBounds = YES;
- youpaipreLiveBtn.layer.borderColor = HexColorFromRGB(0x979797).CGColor;
- youpaipreLiveBtn.layer.borderWidth = 1.0f;
- [youpaipbgImgV addSubview:youpaipreLiveBtn];
- self.youpaipreLiveBtn = youpaipreLiveBtn;
- [youpaipreLiveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(60.0f);
- make.right.offset(-60.0f);
- make.top.equalTo(confirmBtn.mas_bottom).offset(14.0f);
- make.height.offset(48.0f);
- }];
-
-
-
- }
- - (void)youpaifconfirmBtnClick{
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)youpaifreLiveBtnClick{
- self.youpaipreLiveBtn.userInteractionEnabled = NO;
- WeakSelf;
- [LCHttpHelper requestWithURLString:StatusLive parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- NSInteger live_status = [[[dict objectForKey:@"data"] objectForKey:@"live_status"] integerValue]; // 认证状态 1未认证 2已认证
- if (live_status != 1) {
- [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
- YOUPAILZLiveAnchorVC *anchorVC = [[YOUPAILZLiveAnchorVC alloc] init];
- anchorVC.youpaipshareModel = [YOUPAILZLiveShareModel mj_objectWithKeyValues:[[dict objectForKey:@"data"] objectForKey:@"share"]];
- anchorVC.youpaipcover = [[dict objectForKey:@"data"] objectForKey:@"cover"];
- anchorVC.hidesBottomBarWhenPushed = YES;
- NSArray *vcs = weakSelf.navigationController.viewControllers;
- NSMutableArray <UIViewController *>*nVcs = [NSMutableArray array];
- for (UIViewController *vc in vcs) {
- if (![vc isKindOfClass:[YOUPAILZAnchorLiveCloseVC class]]) {
- [nVcs addObject:vc];
- }
- }
-
- [nVcs addObject:anchorVC];
- [weakSelf.navigationController setViewControllers:nVcs.copy animated:YES];
- }
- }else{
- weakSelf.youpaipreLiveBtn.userInteractionEnabled = YES;
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- self.youpaipreLiveBtn.userInteractionEnabled = YES;
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- @end
|