YOUPAILCResponseView.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. //
  2. // YOUPAILCResponseView.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/9/17.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCResponseView.h"
  9. #import "YOUPAIHRAgeSexView.h"
  10. #import "YMFeesSettingInfoModel.h"
  11. @implementation YOUPAILCResponseView
  12. - (instancetype)initWithModel:(YOUPAILCVideoChatModel*)callModel{
  13. if (self = [super init]) {
  14. self.youpaipcallModel = callModel;
  15. [self youpaifsetupView];
  16. if (self.youpaipcallModel.youpaipfrom_gender==1) {
  17. [self getPrice];
  18. }
  19. NSLog(@"当前用户的用户-121--:%ld",(long)self.youpaipcallModel.youpaipfrom_gender);
  20. }
  21. return self;
  22. }
  23. - (void)getPrice{
  24. @weakify(self)
  25. [LCHttpHelper requestWithURLString:AnchorGetPrice parameters:@{
  26. @"anchor_id":self.youpaipcallModel.youpaipfrom_uid,
  27. @"is_new":@(1)
  28. } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  29. @strongify(self)
  30. NSDictionary* dict = (NSDictionary*)responseObject;
  31. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  32. if (code == 0) {
  33. YMFeesSettingInfoModel *mdoel = [YMFeesSettingInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
  34. NSString *str1 = [NSString stringWithFormat:@" %@",mdoel.video_price];
  35. self.priceLabel.attributedText = [LCTools setRichTextWithTitle:@"对方将获得" subTitle:str1 titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFC83B) titleFontSize:12 subTitleFontSize:12];
  36. }else{
  37. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  38. }
  39. } failure:^(NSError *error) {
  40. [ZCHUDHelper showTitle:error.localizedDescription];
  41. }];
  42. }
  43. - (void)youpaifsetupView{
  44. self.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);//模糊视图
  45. UIView *bgView = [UIView new];
  46. [self addSubview:bgView];
  47. [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.edges.equalTo(self);
  49. }];
  50. bgView.backgroundColor = [UIColor clearColor];
  51. UIImageView* backImgView = [[UIImageView alloc]init];
  52. [backImgView setUserInteractionEnabled:YES];
  53. [bgView addSubview:backImgView];
  54. [backImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.edges.equalTo(bgView);
  56. }];
  57. //backImgView.contentMode = UIViewContentModeScaleAspectFill;
  58. NSURL *url = [LCTools getImageUrlWithAddress:self.youpaipcallModel.youpaipfrom_avatar];
  59. [backImgView sd_setImageWithURL:url placeholderImage:nil];
  60. [backImgView addSubview:self.effectView];
  61. [self.effectView mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.edges.equalTo(backImgView);
  63. }];
  64. UIImageView* logImgView = [[UIImageView alloc]init];
  65. [backImgView addSubview:logImgView];
  66. [logImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.width.height.mas_equalTo(WHScreenEqualWidth(86));
  68. make.centerX.equalTo(bgView);
  69. make.top.equalTo(bgView).offset(WHScreenEqualWidth(200));
  70. }];
  71. [logImgView.layer setCornerRadius:WHScreenEqualWidth(5)];
  72. [logImgView.layer setMasksToBounds:YES];
  73. logImgView.contentMode = UIViewContentModeScaleAspectFill;
  74. [logImgView sd_setImageWithURL:url placeholderImage:nil];
  75. [bgView addSubview:backImgView];
  76. //邀请女神通话
  77. UILabel *youpaipTopLabel = [UILabel new];
  78. [bgView addSubview:youpaipTopLabel];
  79. youpaipTopLabel.text = @"邀请你视频通话";
  80. youpaipTopLabel.textColor = LCWhiteColor;
  81. youpaipTopLabel.backgroundColor = UIColor.clearColor;
  82. youpaipTopLabel.layer.cornerRadius = 15;
  83. youpaipTopLabel.clipsToBounds = YES;
  84. youpaipTopLabel.font = [UIFont systemFontOfSize:14];
  85. youpaipTopLabel.textAlignment = NSTextAlignmentCenter;
  86. //昵称
  87. UILabel* nickLabel = [[UILabel alloc]init];
  88. [bgView addSubview:nickLabel];
  89. [nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.centerX.equalTo(bgView);
  91. make.top.equalTo(logImgView.mas_bottom).offset(WHScreenEqualWidth(16));
  92. }];
  93. nickLabel.text = self.youpaipcallModel.youpaipfrom_nickname;
  94. nickLabel.textAlignment = NSTextAlignmentCenter;
  95. nickLabel.textColor = [UIColor whiteColor];
  96. nickLabel.font = LCBoldFont(22);
  97. [youpaipTopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.centerX.equalTo(bgView);
  99. make.top.equalTo(nickLabel.mas_bottom).offset(40);
  100. make.height.mas_equalTo(31);
  101. make.width.mas_equalTo(134.5);
  102. }];
  103. //性别
  104. YOUPAIHRAgeSexView *sexView = [YOUPAIHRAgeSexView new];
  105. sexView.hidden = YES;
  106. [bgView addSubview:sexView];
  107. [sexView makeConstraints:^(MASConstraintMaker *make) {
  108. make.left.mas_equalTo(nickLabel.mas_right).offset(0);
  109. make.centerY.mas_equalTo(nickLabel);
  110. make.size.mas_equalTo(CGSizeMake(30, 14));
  111. }];
  112. [sexView youpaifreloadWith:self.youpaipcallModel.youpaipfrom_gender Age:self.youpaipcallModel.youpaipfrom_age];
  113. //向你发起 视频聊天
  114. // UILabel* callLabel = [[UILabel alloc]init];
  115. // [bgView addSubview:callLabel];
  116. // [callLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  117. // make.centerY.mas_equalTo(-30);
  118. // make.centerX.mas_equalTo(0);
  119. //
  120. // }];
  121. // callLabel.text = @"向她发起 视频聊天";
  122. // callLabel.textAlignment = NSTextAlignmentCenter;
  123. // callLabel.textColor = [UIColor whiteColor];
  124. // callLabel.font = [UIFont systemFontOfSize:14];
  125. //价格
  126. UILabel* priceLabel = [[UILabel alloc]init];
  127. priceLabel.textAlignment = NSTextAlignmentCenter;
  128. [bgView addSubview:priceLabel];
  129. [priceLabel makeConstraints:^(MASConstraintMaker *make) {
  130. make.centerX.equalTo(bgView).offset(WHScreenEqualWidth(14));
  131. make.top.mas_equalTo(nickLabel.mas_bottom).offset(3);
  132. }];
  133. self.priceLabel=priceLabel;
  134. //钻石
  135. UIImageView *zuanshiImage = [UIImageView new];
  136. zuanshiImage.hidden = YES;
  137. [bgView addSubview:zuanshiImage];
  138. [zuanshiImage mas_makeConstraints:^(MASConstraintMaker *make) {
  139. make.right.equalTo(priceLabel.mas_left).offset(WHScreenEqualWidth(-10));
  140. make.centerY.equalTo(priceLabel);
  141. make.size.mas_equalTo(CGSizeMake(14, 14));
  142. }];
  143. zuanshiImage.image = [UIImage imageNamed:@"vqu_images_guard_zuanshi"];
  144. [backImgView addSubview:self.cancelBtn];
  145. [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  146. make.width.height.mas_equalTo(WHScreenEqualWidth(94.0f));
  147. make.left.equalTo(self).offset(WHScreenEqualWidth(55.0f));
  148. make.bottom.mas_equalTo(WHScreenEqualWidth(-111));
  149. }];
  150. [backImgView addSubview:self.cancelImgv];
  151. [self.cancelImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  152. make.width.height.mas_equalTo(WHScreenEqualWidth(70.0f));
  153. make.center.equalTo(self.cancelBtn);
  154. }];
  155. [backImgView addSubview:self.cancelLab];
  156. [self.cancelLab mas_makeConstraints:^(MASConstraintMaker *make) {
  157. make.width.equalTo(self.cancelBtn.mas_width);
  158. make.centerX.equalTo(self.cancelBtn);
  159. make.top.equalTo(self.cancelBtn.mas_bottom).offset(WHScreenEqualWidth(12.0f));
  160. }];
  161. [backImgView addSubview:self.agreeImageView];
  162. [self.agreeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  163. make.width.height.mas_equalTo(WHScreenEqualWidth(70.0f));
  164. make.right.equalTo(self).offset(WHScreenEqualWidth(-68.0f));
  165. make.centerY.equalTo(self.cancelBtn);
  166. }];
  167. [backImgView addSubview:self.confimPlayer];
  168. [self.confimPlayer mas_makeConstraints:^(MASConstraintMaker *make) {
  169. make.width.height.mas_equalTo(WHScreenEqualWidth(60.0f));
  170. make.centerY.equalTo(self.cancelBtn);
  171. make.right.equalTo(self).offset(WHScreenEqualWidth(-75.0f));
  172. }];
  173. [backImgView addSubview:self.confimLab];
  174. [self.confimLab mas_makeConstraints:^(MASConstraintMaker *make) {
  175. make.width.equalTo(self.confimPlayer.mas_width);
  176. make.centerX.equalTo(self.confimPlayer);
  177. make.centerY.equalTo(self.cancelLab);
  178. }];
  179. // //bottomView
  180. // UIView * bottomView = [UIView new];
  181. // [bgView addSubview:bottomView];
  182. // [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  183. // make.left.mas_equalTo(0);
  184. // make.right.mas_equalTo(0);
  185. // make.top.mas_equalTo(293);
  186. // make.bottom.mas_equalTo(0);
  187. // }];
  188. // bottomView.backgroundColor = [UIColor whiteColor];
  189. // bottomView.layer.cornerRadius = 12;
  190. // bottomView.clipsToBounds = YES;
  191. //
  192. //
  193. // UIButton* closeBtn = [[UIButton alloc]init];
  194. // [bottomView addSubview:closeBtn];
  195. // [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  196. //
  197. // make.centerY.mas_equalTo(0);
  198. // make.size.mas_equalTo(CGSizeMake(135, 49));
  199. // make.left.mas_equalTo(11.5);
  200. // }];
  201. // [closeBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(135, 49) FromColors:@[LZF5F4F7Color,LZF5F4F7Color] ByGradientType:1] forState:UIControlStateNormal];
  202. // [closeBtn addTarget:self action:@selector(youpaifcancelClick) forControlEvents:(UIControlEventTouchUpInside)];
  203. // self.youpaipcancelBtn = closeBtn;
  204. // closeBtn.layer.cornerRadius = 24.5;
  205. // closeBtn.clipsToBounds = YES;
  206. // [closeBtn setTitle:@"拒绝" forState:UIControlStateNormal];
  207. // [closeBtn setTitleColor:LZ273145Color forState:UIControlStateNormal];
  208. // closeBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  209. //
  210. // UIButton* confirmBtn = [[UIButton alloc]init];
  211. // [bottomView addSubview:confirmBtn];
  212. // [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  213. // make.right.mas_equalTo(-11.5);
  214. // make.centerY.mas_equalTo(0);
  215. // make.size.mas_equalTo(CGSizeMake(135, 49));
  216. // }];
  217. // [confirmBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(135, 49) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:1] forState:UIControlStateNormal];
  218. // [confirmBtn addTarget:self action:@selector(confirmClick) forControlEvents:(UIControlEventTouchUpInside)];
  219. // confirmBtn.layer.cornerRadius = 24.5;
  220. // confirmBtn.clipsToBounds = YES;
  221. // [confirmBtn setTitle:@"接听" forState:UIControlStateNormal];
  222. // [confirmBtn setTitleColor:LCWhiteColor forState:UIControlStateNormal];
  223. // closeBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  224. // self.youpaipconfirmBtn = confirmBtn;
  225. // UIButton* cancelBtn = [[UIButton alloc]init];
  226. // [self addSubview:cancelBtn];
  227. // [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  228. // make.left.mas_equalTo(74);
  229. // make.bottom.mas_equalTo(-(SafeHeight+59));
  230. // make.size.mas_equalTo(CGSizeMake(64, 64));
  231. // }];
  232. // [cancelBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_video_end_new"] forState:UIControlStateNormal];
  233. // [cancelBtn addTarget:self action:@selector(youpaifcancelClick) forControlEvents:(UIControlEventTouchUpInside)];
  234. //
  235. //
  236. //
  237. //
  238. }
  239. - (void)youpaifcloseBtnClick{
  240. if (self.youpaipdelegate && [self.youpaipdelegate respondsToSelector:@selector(youpaifcolseResBtnClick)]) {
  241. [self.youpaipdelegate youpaifcolseResBtnClick];
  242. }
  243. }
  244. - (void)confirmClick{
  245. if (self.youpaipdelegate && [self.youpaipdelegate respondsToSelector:@selector(youpaifconfirmBtnClick)]) {
  246. [self.youpaipdelegate youpaifconfirmBtnClick];
  247. }
  248. }
  249. - (void)youpaifcancelClick{
  250. if (self.youpaipdelegate && [self.youpaipdelegate respondsToSelector:@selector(youpaifcancelBtnClick)]) {
  251. [self.youpaipdelegate youpaifcancelBtnClick];
  252. }
  253. }
  254. - (void)youpaiftimePadding{
  255. __block int timeout= 180;
  256. WeakSelf;
  257. dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
  258. dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
  259. self.youpaiptimer = timer;
  260. dispatch_source_set_timer(timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
  261. dispatch_source_set_event_handler(timer, ^{
  262. if(timeout<=0){
  263. dispatch_source_cancel(timer);
  264. dispatch_async(dispatch_get_main_queue(), ^{
  265. [self.youpaiptimeLabel removeFromSuperview];
  266. });
  267. }else{
  268. dispatch_async(dispatch_get_main_queue(), ^{
  269. //设置界面的按钮显示 根据自己需求设置
  270. self.youpaiptimeLabel.text = [NSString stringWithFormat:@"%ds",timeout];
  271. });
  272. timeout--;
  273. }
  274. });
  275. dispatch_resume(timer);
  276. }
  277. - (UIVisualEffectView *)effectView{
  278. if (_effectView == nil) {
  279. UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
  280. _effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
  281. }
  282. return _effectView;
  283. }
  284. #pragma mark- get set
  285. - (UIButton *)cancelBtn{
  286. if(!_cancelBtn){
  287. _cancelBtn = [[UIButton alloc] init];
  288. //[_cancelBtn setImage:[UIImage imageNamed:@"vqu_images_video_end_baibao"] forState:UIControlStateNormal];
  289. [_cancelBtn addTarget:self action:@selector(youpaifcancelClick) forControlEvents:UIControlEventTouchUpInside];
  290. }
  291. return _cancelBtn;
  292. }
  293. - (UIImageView *)cancelImgv {
  294. if (!_cancelImgv) {
  295. _cancelImgv = [[UIImageView alloc] init];
  296. _cancelImgv.image = [UIImage imageNamed:@"vqu_images_video_end_baibao"];
  297. _cancelImgv.contentMode = UIViewContentModeScaleToFill;
  298. }
  299. return _cancelImgv;
  300. }
  301. - (UILabel *)cancelLab{
  302. if(!_cancelLab){
  303. _cancelLab = [[UILabel alloc] init];
  304. [_cancelLab setText:@"取消"];
  305. [_cancelLab setTextColor:[UIColor whiteColor]];
  306. [_cancelLab setFont:[UIFont systemFontOfSize:14.0f]];
  307. [_cancelLab setTextAlignment:NSTextAlignmentCenter];
  308. }
  309. return _cancelLab;
  310. }
  311. #pragma mark - 接听来电
  312. - (SVGAPlayer *)confimPlayer{
  313. if(!_confimPlayer){
  314. _confimPlayer = [[SVGAPlayer alloc] initWithFrame:[UIScreen mainScreen].bounds];
  315. _confimPlayer.contentMode = UIViewContentModeScaleAspectFit;
  316. _confimPlayer.delegate = self;
  317. _confimPlayer.userInteractionEnabled = YES;
  318. _confimPlayer.loops = 100; //无限循环播放
  319. _confimPlayer.clearsAfterStop = NO;
  320. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(confirmClick)];
  321. [_confimPlayer addGestureRecognizer:tap];
  322. }
  323. return _confimPlayer;
  324. }
  325. - (UIImageView *)agreeImageView{
  326. if(!_agreeImageView){
  327. _agreeImageView = [[UIImageView alloc] init];
  328. [_agreeImageView setImage:[UIImage imageNamed:@"vqu_images_video_start_new"]];
  329. }
  330. return _agreeImageView;
  331. }
  332. - (UILabel *)confimLab{
  333. if(!_confimLab){
  334. _confimLab = [[UILabel alloc] init];
  335. [_confimLab setText:@"接听"];
  336. [_confimLab setTextColor:[UIColor whiteColor]];
  337. [_confimLab setFont:[UIFont systemFontOfSize:14.0f]];
  338. [_confimLab setTextAlignment:NSTextAlignmentCenter];
  339. }
  340. return _confimLab;
  341. }
  342. // SVGAPlayerDelegate
  343. - (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player{
  344. self.confimPlayer.videoItem = nil;
  345. }
  346. @end