123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- //
- // YOUPAILCBigCastProtocolVC.m
- // LiveChat
- //
- // Created by 张灿 on 2018/8/31.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCBigCastProtocolVC.h"
- #import "ZCBaseWebView.h"
- @interface YOUPAILCBigCastProtocolVC ()<ZCBaseWebViewDelegate>
- @property (nonatomic, strong) UIProgressView *youpaipprogressView;
- @property (nonatomic, strong) ZCBaseWebView *youpaipwebView;
- @property (nonatomic,strong)NSString *youpaipcontentUrl;
- @end
- @implementation YOUPAILCBigCastProtocolVC
- - (ZCBaseWebView *)youpaipwebView
- {
- if (!_youpaipwebView) {
- CGRect frame = CGRectMake(0, NavBarHeight, KScreenWidth,KScreenHeight-NavBarHeight-70-SafeHeight);
- _youpaipwebView = [[ZCBaseWebView alloc] initWithFrame:frame];
- _youpaipwebView.contentUrl = self.youpaipcontentUrl;
- _youpaipwebView.delegate = self;
- }
- return _youpaipwebView;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.youpaipcontentUrl = [NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,serviceH5];
- self.automaticallyAdjustsScrollViewInsets = NO;
- // self.view.backgroundColor = [UIColor clearColor];
- [self.view addSubview:self.youpaipwebView];
- self.title = @"相语欢颜女神服务协议";
- [self initProgress];
- [self.view addSubview:self.youpaipprogressView];
- [self.youpaipwebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.youpaipcontentUrl]]];
- if (@available(iOS 11.0, *)) {
-
- self.youpaipwebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- }
- UIButton* startBtn = [[UIButton alloc]initWithFrame:CGRectMake(40, KScreenHeight-60-SafeHeight, KScreenWidth-80, 50)];
- startBtn.backgroundColor = HexColorFromRGB(0x4F4B5B);
- startBtn.titleLabel.font = LCFont15;
- startBtn.layer.cornerRadius = 25.0;
- startBtn.layer.masksToBounds = YES;
-
- [startBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- [startBtn addTarget:self action:@selector(agreeClick) forControlEvents:(UIControlEventTouchUpInside)];
- [self.view addSubview:startBtn];
- if (self.youpaipagree) {
- [startBtn setBackgroundImage:nil forState:(UIControlStateNormal)];
- startBtn.userInteractionEnabled = NO;
- [startBtn setTitle:@"已同意女神服务协议" forState:(UIControlStateNormal)];
- }else{
- [startBtn setBackgroundImage:[LCTools ColorImage:startBtn.mj_size FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight] forState:(UIControlStateNormal)];
- startBtn.userInteractionEnabled = YES;
- [startBtn setTitle:@"同意女神服务协议" forState:(UIControlStateNormal)];
- }
-
- }
- - (void)initProgress
- {
-
- CGRect barFrame = CGRectMake(0, NavBarHeight, KScreenWidth, 2.0f);
- self.youpaipprogressView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault];
- self.youpaipprogressView.tintColor = [UIColor greenColor];
- self.youpaipprogressView.frame = barFrame;
- self.youpaipprogressView.transform = CGAffineTransformMakeScale(1.0f,2.0f);
- self.youpaipprogressView.backgroundColor = [UIColor clearColor];
- self.youpaipprogressView.trackTintColor=[UIColor clearColor];
- self.youpaipprogressView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
- [self.youpaipprogressView setProgress:0 animated:NO];
- }
- #pragma mark hxwebview 的代理方法
- -(void)webViewDidFinishLoad:(ZCBaseWebView *)webView
- {
- self.title = self.youpaipwebView.title;
- }
- -(void)webView:(ZCBaseWebView *)webView updateProgress:(double)progress
- {
- [self.youpaipprogressView setProgress:progress animated:YES];
- if (progress>=1.f) {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self.youpaipprogressView setProgress:0 animated:NO];
- });
- }
- }
- -(void)webView:(ZCBaseWebView *)webView didFailLoadWithError:(NSError *)error
- {
- NSLog(@"error:%@",error);
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- self.navigationController.navigationBarHidden = NO;
- [self.view addSubview:self.youpaipprogressView];
- // 禁用返回手势
-
- self.sx_disableInteractivePop = YES;
-
-
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- if (self.youpaipneedHideNav) {
- self.navigationController.navigationBarHidden = YES;
- }else{
- self.navigationController.navigationBarHidden = NO;
- }
- // 开启返回手势
- self.sx_disableInteractivePop = NO;
-
-
- }
- - (void)dealloc{
- [_youpaipprogressView removeFromSuperview];
- [self.youpaipwebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
- }
- - (void)agreeClick{
- @weakify(self);
- [LCHttpHelper requestWithURLString:AgreeBigCastProtocol parameters:@{@"agreement":@1} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {
- // [ZCHUDHelper showTitle:@"已同意女神服务协议"];
- if (self.agreeProtocolBlock != nil) {
- self.agreeProtocolBlock();
- }
- // [self.navigationController popViewControllerAnimated:YES];
- }
- } failure:^(NSError *error) {
-
- }];
- }
- @end
|