123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- //
- // YOUPAILCResponseView.m
- // LiveChat
- //
- // Created by 张灿 on 2018/9/17.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCResponseView.h"
- #import "YOUPAIHRAgeSexView.h"
- #import "YMFeesSettingInfoModel.h"
- @implementation YOUPAILCResponseView
- - (instancetype)initWithModel:(YOUPAILCVideoChatModel*)callModel{
- if (self = [super init]) {
- self.youpaipcallModel = callModel;
- [self youpaifsetupView];
- if (self.youpaipcallModel.youpaipfrom_gender==1) {
- [self getPrice];
- }
- NSLog(@"当前用户的用户-121--:%ld",(long)self.youpaipcallModel.youpaipfrom_gender);
- }
- return self;
- }
- - (void)getPrice{
- @weakify(self)
- [LCHttpHelper requestWithURLString:AnchorGetPrice parameters:@{
- @"anchor_id":self.youpaipcallModel.youpaipfrom_uid,
- @"is_new":@(1)
- } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- YMFeesSettingInfoModel *mdoel = [YMFeesSettingInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
- NSString *str1 = [NSString stringWithFormat:@" %@",mdoel.video_price];
- self.priceLabel.attributedText = [LCTools setRichTextWithTitle:@"对方将获得" subTitle:str1 titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFC83B) titleFontSize:12 subTitleFontSize:12];
-
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)youpaifsetupView{
-
- self.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);//模糊视图
- UIView *bgView = [UIView new];
- [self addSubview:bgView];
- [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self);
- }];
- bgView.backgroundColor = [UIColor clearColor];
-
-
- UIImageView* backImgView = [[UIImageView alloc]init];
- [backImgView setUserInteractionEnabled:YES];
- [bgView addSubview:backImgView];
- [backImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(bgView);
- }];
-
- //backImgView.contentMode = UIViewContentModeScaleAspectFill;
- NSURL *url = [LCTools getImageUrlWithAddress:self.youpaipcallModel.youpaipfrom_avatar];
- [backImgView sd_setImageWithURL:url placeholderImage:nil];
-
-
- [backImgView addSubview:self.effectView];
- [self.effectView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(backImgView);
- }];
-
-
- UIImageView* logImgView = [[UIImageView alloc]init];
- [backImgView addSubview:logImgView];
- [logImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(WHScreenEqualWidth(86));
- make.centerX.equalTo(bgView);
- make.top.equalTo(bgView).offset(WHScreenEqualWidth(200));
- }];
- [logImgView.layer setCornerRadius:WHScreenEqualWidth(5)];
- [logImgView.layer setMasksToBounds:YES];
- logImgView.contentMode = UIViewContentModeScaleAspectFill;
- [logImgView sd_setImageWithURL:url placeholderImage:nil];
-
-
- [bgView addSubview:backImgView];
- //邀请女神通话
- UILabel *youpaipTopLabel = [UILabel new];
- [bgView addSubview:youpaipTopLabel];
-
- youpaipTopLabel.text = @"邀请你视频通话";
- youpaipTopLabel.textColor = LCWhiteColor;
- youpaipTopLabel.backgroundColor = UIColor.clearColor;
- youpaipTopLabel.layer.cornerRadius = 15;
- youpaipTopLabel.clipsToBounds = YES;
- youpaipTopLabel.font = [UIFont systemFontOfSize:14];
- youpaipTopLabel.textAlignment = NSTextAlignmentCenter;
-
- //昵称
- UILabel* nickLabel = [[UILabel alloc]init];
- [bgView addSubview:nickLabel];
- [nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(bgView);
- make.top.equalTo(logImgView.mas_bottom).offset(WHScreenEqualWidth(16));
- }];
- nickLabel.text = self.youpaipcallModel.youpaipfrom_nickname;
- nickLabel.textAlignment = NSTextAlignmentCenter;
- nickLabel.textColor = [UIColor whiteColor];
- nickLabel.font = LCBoldFont(22);
-
-
- [youpaipTopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(bgView);
- make.top.equalTo(nickLabel.mas_bottom).offset(40);
- make.height.mas_equalTo(31);
- make.width.mas_equalTo(134.5);
- }];
-
- //性别
- YOUPAIHRAgeSexView *sexView = [YOUPAIHRAgeSexView new];
- sexView.hidden = YES;
- [bgView addSubview:sexView];
- [sexView makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(nickLabel.mas_right).offset(0);
- make.centerY.mas_equalTo(nickLabel);
- make.size.mas_equalTo(CGSizeMake(30, 14));
- }];
- [sexView youpaifreloadWith:self.youpaipcallModel.youpaipfrom_gender Age:self.youpaipcallModel.youpaipfrom_age];
- //向你发起 视频聊天
-
- // UILabel* callLabel = [[UILabel alloc]init];
- // [bgView addSubview:callLabel];
- // [callLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.centerY.mas_equalTo(-30);
- // make.centerX.mas_equalTo(0);
- //
- // }];
- // callLabel.text = @"向她发起 视频聊天";
- // callLabel.textAlignment = NSTextAlignmentCenter;
- // callLabel.textColor = [UIColor whiteColor];
- // callLabel.font = [UIFont systemFontOfSize:14];
-
- //价格
- UILabel* priceLabel = [[UILabel alloc]init];
- priceLabel.textAlignment = NSTextAlignmentCenter;
- [bgView addSubview:priceLabel];
- [priceLabel makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(bgView).offset(WHScreenEqualWidth(14));
- make.top.mas_equalTo(nickLabel.mas_bottom).offset(3);
- }];
- self.priceLabel=priceLabel;
-
-
- //钻石
- UIImageView *zuanshiImage = [UIImageView new];
- zuanshiImage.hidden = YES;
- [bgView addSubview:zuanshiImage];
- [zuanshiImage mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(priceLabel.mas_left).offset(WHScreenEqualWidth(-10));
- make.centerY.equalTo(priceLabel);
- make.size.mas_equalTo(CGSizeMake(14, 14));
- }];
- zuanshiImage.image = [UIImage imageNamed:@"vqu_images_guard_zuanshi"];
-
-
-
- [backImgView addSubview:self.cancelBtn];
- [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(WHScreenEqualWidth(94.0f));
- make.left.equalTo(self).offset(WHScreenEqualWidth(55.0f));
- make.bottom.mas_equalTo(WHScreenEqualWidth(-111));
- }];
- [backImgView addSubview:self.cancelImgv];
- [self.cancelImgv mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(WHScreenEqualWidth(70.0f));
- make.center.equalTo(self.cancelBtn);
- }];
-
- [backImgView addSubview:self.cancelLab];
- [self.cancelLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(self.cancelBtn.mas_width);
- make.centerX.equalTo(self.cancelBtn);
- make.top.equalTo(self.cancelBtn.mas_bottom).offset(WHScreenEqualWidth(12.0f));
- }];
-
- [backImgView addSubview:self.agreeImageView];
- [self.agreeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(WHScreenEqualWidth(70.0f));
- make.right.equalTo(self).offset(WHScreenEqualWidth(-68.0f));
- make.centerY.equalTo(self.cancelBtn);
- }];
-
- [backImgView addSubview:self.confimPlayer];
- [self.confimPlayer mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(WHScreenEqualWidth(60.0f));
- make.centerY.equalTo(self.cancelBtn);
- make.right.equalTo(self).offset(WHScreenEqualWidth(-75.0f));
- }];
- [backImgView addSubview:self.confimLab];
- [self.confimLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(self.confimPlayer.mas_width);
- make.centerX.equalTo(self.confimPlayer);
- make.centerY.equalTo(self.cancelLab);
- }];
-
- // //bottomView
- // UIView * bottomView = [UIView new];
- // [bgView addSubview:bottomView];
- // [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.mas_equalTo(0);
- // make.right.mas_equalTo(0);
- // make.top.mas_equalTo(293);
- // make.bottom.mas_equalTo(0);
- // }];
- // bottomView.backgroundColor = [UIColor whiteColor];
- // bottomView.layer.cornerRadius = 12;
- // bottomView.clipsToBounds = YES;
- //
- //
- // UIButton* closeBtn = [[UIButton alloc]init];
- // [bottomView addSubview:closeBtn];
- // [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- //
- // make.centerY.mas_equalTo(0);
- // make.size.mas_equalTo(CGSizeMake(135, 49));
- // make.left.mas_equalTo(11.5);
- // }];
- // [closeBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(135, 49) FromColors:@[LZF5F4F7Color,LZF5F4F7Color] ByGradientType:1] forState:UIControlStateNormal];
- // [closeBtn addTarget:self action:@selector(youpaifcancelClick) forControlEvents:(UIControlEventTouchUpInside)];
- // self.youpaipcancelBtn = closeBtn;
- // closeBtn.layer.cornerRadius = 24.5;
- // closeBtn.clipsToBounds = YES;
- // [closeBtn setTitle:@"拒绝" forState:UIControlStateNormal];
- // [closeBtn setTitleColor:LZ273145Color forState:UIControlStateNormal];
- // closeBtn.titleLabel.font = [UIFont systemFontOfSize:16];
- //
- // UIButton* confirmBtn = [[UIButton alloc]init];
- // [bottomView addSubview:confirmBtn];
- // [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.right.mas_equalTo(-11.5);
- // make.centerY.mas_equalTo(0);
- // make.size.mas_equalTo(CGSizeMake(135, 49));
- // }];
- // [confirmBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(135, 49) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:1] forState:UIControlStateNormal];
- // [confirmBtn addTarget:self action:@selector(confirmClick) forControlEvents:(UIControlEventTouchUpInside)];
- // confirmBtn.layer.cornerRadius = 24.5;
- // confirmBtn.clipsToBounds = YES;
- // [confirmBtn setTitle:@"接听" forState:UIControlStateNormal];
- // [confirmBtn setTitleColor:LCWhiteColor forState:UIControlStateNormal];
- // closeBtn.titleLabel.font = [UIFont systemFontOfSize:16];
- // self.youpaipconfirmBtn = confirmBtn;
-
- // UIButton* cancelBtn = [[UIButton alloc]init];
- // [self addSubview:cancelBtn];
- // [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.mas_equalTo(74);
- // make.bottom.mas_equalTo(-(SafeHeight+59));
- // make.size.mas_equalTo(CGSizeMake(64, 64));
- // }];
- // [cancelBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_video_end_new"] forState:UIControlStateNormal];
- // [cancelBtn addTarget:self action:@selector(youpaifcancelClick) forControlEvents:(UIControlEventTouchUpInside)];
- //
- //
- //
- //
-
- }
- - (void)youpaifcloseBtnClick{
- if (self.youpaipdelegate && [self.youpaipdelegate respondsToSelector:@selector(youpaifcolseResBtnClick)]) {
- [self.youpaipdelegate youpaifcolseResBtnClick];
- }
- }
- - (void)confirmClick{
- if (self.youpaipdelegate && [self.youpaipdelegate respondsToSelector:@selector(youpaifconfirmBtnClick)]) {
- [self.youpaipdelegate youpaifconfirmBtnClick];
- }
- }
- - (void)youpaifcancelClick{
- if (self.youpaipdelegate && [self.youpaipdelegate respondsToSelector:@selector(youpaifcancelBtnClick)]) {
- [self.youpaipdelegate youpaifcancelBtnClick];
- }
- }
- - (void)youpaiftimePadding{
- __block int timeout= 180;
- WeakSelf;
- dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
- dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
- self.youpaiptimer = timer;
- dispatch_source_set_timer(timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
- dispatch_source_set_event_handler(timer, ^{
- if(timeout<=0){
- dispatch_source_cancel(timer);
- dispatch_async(dispatch_get_main_queue(), ^{
- [self.youpaiptimeLabel removeFromSuperview];
- });
- }else{
- dispatch_async(dispatch_get_main_queue(), ^{
- //设置界面的按钮显示 根据自己需求设置
- self.youpaiptimeLabel.text = [NSString stringWithFormat:@"%ds",timeout];
- });
- timeout--;
-
- }
- });
- dispatch_resume(timer);
-
- }
- - (UIVisualEffectView *)effectView{
- if (_effectView == nil) {
- UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
- _effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
- }
- return _effectView;
- }
- #pragma mark- get set
- - (UIButton *)cancelBtn{
- if(!_cancelBtn){
- _cancelBtn = [[UIButton alloc] init];
- //[_cancelBtn setImage:[UIImage imageNamed:@"vqu_images_video_end_baibao"] forState:UIControlStateNormal];
- [_cancelBtn addTarget:self action:@selector(youpaifcancelClick) forControlEvents:UIControlEventTouchUpInside];
- }
- return _cancelBtn;
- }
- - (UIImageView *)cancelImgv {
- if (!_cancelImgv) {
- _cancelImgv = [[UIImageView alloc] init];
- _cancelImgv.image = [UIImage imageNamed:@"vqu_images_video_end_baibao"];
- _cancelImgv.contentMode = UIViewContentModeScaleToFill;
- }
- return _cancelImgv;
- }
- - (UILabel *)cancelLab{
- if(!_cancelLab){
- _cancelLab = [[UILabel alloc] init];
- [_cancelLab setText:@"取消"];
- [_cancelLab setTextColor:[UIColor whiteColor]];
- [_cancelLab setFont:[UIFont systemFontOfSize:14.0f]];
- [_cancelLab setTextAlignment:NSTextAlignmentCenter];
- }
- return _cancelLab;
- }
- #pragma mark - 接听来电
- - (SVGAPlayer *)confimPlayer{
- if(!_confimPlayer){
- _confimPlayer = [[SVGAPlayer alloc] initWithFrame:[UIScreen mainScreen].bounds];
- _confimPlayer.contentMode = UIViewContentModeScaleAspectFit;
- _confimPlayer.delegate = self;
- _confimPlayer.userInteractionEnabled = YES;
- _confimPlayer.loops = 100; //无限循环播放
- _confimPlayer.clearsAfterStop = NO;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(confirmClick)];
- [_confimPlayer addGestureRecognizer:tap];
- }
- return _confimPlayer;
- }
- - (UIImageView *)agreeImageView{
- if(!_agreeImageView){
- _agreeImageView = [[UIImageView alloc] init];
- [_agreeImageView setImage:[UIImage imageNamed:@"vqu_images_video_start_new"]];
- }
- return _agreeImageView;
- }
- - (UILabel *)confimLab{
- if(!_confimLab){
- _confimLab = [[UILabel alloc] init];
- [_confimLab setText:@"接听"];
- [_confimLab setTextColor:[UIColor whiteColor]];
- [_confimLab setFont:[UIFont systemFontOfSize:14.0f]];
- [_confimLab setTextAlignment:NSTextAlignmentCenter];
- }
- return _confimLab;
- }
- // SVGAPlayerDelegate
- - (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player{
- self.confimPlayer.videoItem = nil;
- }
- @end
|