YBLiveOrVideo.m 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // YBLiveOrVideo.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2019/11/27.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "YBLiveOrVideo.h"
  9. #import "TCVideoRecordViewController.h"
  10. #import "YBLiveVC.h"
  11. #import "PubH5.h"
  12. #import "YBVipVC.h"
  13. typedef NS_ENUM(NSInteger,YBSelType){
  14. TypeSel_Live,
  15. TypeSel_Video,
  16. };
  17. @implementation YBLiveOrVideo
  18. - (void)awakeFromNib {
  19. [super awakeFromNib];
  20. _closeBottom.constant = ShowDiff+18;
  21. // [_bgView layoutIfNeeded];
  22. //
  23. // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_bgView.bounds byRoundingCorners:UIRectCornerTopRight|UIRectCornerTopLeft cornerRadii:CGSizeMake(10, 10)];
  24. // CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  25. // maskLayer.frame = _bgView.bounds;
  26. // maskLayer.path = maskPath.CGPath;
  27. // _bgView.layer.mask = maskLayer;
  28. //
  29. // _videoBtn = [PublicObj setUpImgDownText:_videoBtn space:8];
  30. // _liveBtn = [PublicObj setUpImgDownText:_liveBtn space:8];
  31. }
  32. +(instancetype)showLiveOrVideoSel {
  33. YBLiveOrVideo *lv = [[[NSBundle mainBundle]loadNibNamed:@"YBLiveOrVideo" owner:nil options:nil]objectAtIndex:0];
  34. [lv setupView];
  35. return lv;
  36. }
  37. -(void)setupView {
  38. self.frame = [UIScreen mainScreen].bounds;
  39. [_bgView layoutIfNeeded];
  40. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_bgView.bounds byRoundingCorners:UIRectCornerTopRight|UIRectCornerTopLeft cornerRadii:CGSizeMake(10, 10)];
  41. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  42. maskLayer.frame = _bgView.bounds;
  43. maskLayer.path = maskPath.CGPath;
  44. _bgView.layer.mask = maskLayer;
  45. [_videoBtn setTitle:YZMsg(@"发布视频-mid") forState:0];
  46. [_liveBtn setTitle:YZMsg(@"开启直播") forState:0];
  47. _videoBtn = [PublicObj setUpImgDownText:_videoBtn space:8];
  48. _liveBtn = [PublicObj setUpImgDownText:_liveBtn space:8];
  49. [[UIApplication sharedApplication].delegate.window addSubview:self];
  50. [UIView animateWithDuration:0.3 animations:^{
  51. } completion:^(BOOL finished) {
  52. self.backgroundColor = RGB_COLOR(@"#000000", 0.3);
  53. }];
  54. }
  55. -(void)dismiss {
  56. [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  57. [self removeFromSuperview];
  58. }
  59. - (IBAction)clickVideoBtn:(id)sender {
  60. [self dismiss];
  61. NSString *videoLimit = minstr([YBPower getVideoStatus]);
  62. NSString *videoMsg = minstr([YBPower getVideoMsg]);
  63. if ([videoLimit isEqual:@"1"]) {
  64. TCVideoRecordViewController *rVC = [[TCVideoRecordViewController alloc]init];
  65. rVC.recordType = RecordType_Normal;
  66. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:rVC animated:YES];
  67. }else {
  68. // [self showAlert:TypeSel_Video andAlertMsg:videoMsg];
  69. //[MBProgressHUD showPop:videoMsg];
  70. NSString *vipSwitch = minstr([YBPower getVipSwitch]);
  71. if ([vipSwitch isEqual:@"0"]) {
  72. NSDictionary *contentDic = @{@"title":@"",
  73. @"msg":videoMsg,
  74. @"left":@"",
  75. @"right":YZMsg(@"确定")};
  76. [YBAlertView showAlertView:contentDic complete:^(int eventType) {
  77. }];
  78. }else{
  79. [self showAlert:TypeSel_Video andAlertMsg:videoMsg];
  80. }
  81. //[MBProgressHUD showPop:videoMsg];
  82. }
  83. }
  84. - (IBAction)clickLiveBtn:(id)sender {
  85. [self dismiss];
  86. NSString *liveLimit = minstr([YBPower getLiveStatus]);
  87. NSString *liveMsg = minstr([YBPower getLiveMsg]);
  88. if ([liveLimit isEqual:@"1"]) {
  89. [MBProgressHUD showMessage:@""];
  90. [YBNetworking postWithUrl:@"Live.getLiveParameters" Dic:@{} Suc:^(int code, id info, NSString *msg) {
  91. [MBProgressHUD hideHUD];
  92. if (code == 0) {
  93. NSDictionary *infoDic = [info firstObject];
  94. YBLiveVC *liveVC = [[YBLiveVC alloc]init];
  95. liveVC.pushSettingDic = [infoDic valueForKey:@"ios"];
  96. liveVC.has_hotliveorder = minstr([infoDic valueForKey:@"has_hotliveorder"]);
  97. liveVC.hotliveorderDic =[infoDic valueForKey:@"hotliveorder"];
  98. // 是否禁止开播
  99. BOOL isBan = minstr([infoDic valueForKey:@"liveban_score"]);
  100. [YBPower saveBanLiveStatus:isBan];
  101. NSString *banStr = minstr([infoDic valueForKey:@"liveban_msg"]);
  102. [YBPower saveBanLiveMsg:banStr];
  103. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:liveVC animated:YES];
  104. }else {
  105. [MBProgressHUD showPop:msg];
  106. }
  107. } Fail:^(id fail) {
  108. [MBProgressHUD hideHUD];
  109. }];
  110. }else {
  111. [self showAlert:TypeSel_Live andAlertMsg:liveMsg];
  112. //[MBProgressHUD showPop:liveMsg];
  113. }
  114. }
  115. -(void)showAlert:(YBSelType)selType andAlertMsg:(NSString *)alertMsg; {
  116. NSDictionary *contentDic = @{@"title":@"",
  117. @"msg":alertMsg,
  118. @"left":YZMsg(@"取消"),
  119. @"right":(selType == TypeSel_Live)?YZMsg(@"权限说明"):YZMsg(@"开通会员")};
  120. [YBAlertView showAlertView:contentDic complete:^(int eventType) {
  121. if (eventType == 1) {
  122. NSString *url = [NSString stringWithFormat:@"%@/appapi/liveauthority/index?uid=%@&token=%@",h5url,[Config getOwnID],[Config getOwnToken]];
  123. if (selType == TypeSel_Video) {
  124. //url = [NSString stringWithFormat:@"%@/Appapi/Auth/index?uid=%@&token=%@",h5url,[Config getOwnID],[Config getOwnToken]];;
  125. YBVipVC *vipVC = [[YBVipVC alloc]init];
  126. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:vipVC animated:YES];
  127. }else {
  128. PubH5 *h5VC = [[PubH5 alloc]init];
  129. h5VC.url = url;
  130. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:h5VC animated:YES];
  131. }
  132. }
  133. }];
  134. }
  135. - (IBAction)clickCloseBtn:(id)sender {
  136. [self dismiss];
  137. }
  138. @end