This commit is contained in:
liyuhua
2023-11-23 18:23:09 +08:00
parent 05e0da7740
commit 6f4610044d
2 changed files with 27 additions and 7 deletions

View File

@@ -156,4 +156,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: cc88fa05da662ee682fc0eeb502faab221faa032 PODFILE CHECKSUM: cc88fa05da662ee682fc0eeb502faab221faa032
COCOAPODS: 1.14.2 COCOAPODS: 1.12.1

View File

@@ -98,7 +98,29 @@ NSString * const kJSGetUid = @"getUid";
} }
}]; }];
} }
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler{
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
dispatch_async(dispatch_get_main_queue(), ^{
NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust];
completionHandler(NSURLSessionAuthChallengeUseCredential,card);
});
}
}
//
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
//progressView
self.progressView.hidden = YES;
}
//
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
//progressView
self.progressView.hidden = YES;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context { - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context {
if ([keyPath isEqualToString:@"estimatedProgress"]) { if ([keyPath isEqualToString:@"estimatedProgress"]) {
self.progressView.progress = self.webview.estimatedProgress; self.progressView.progress = self.webview.estimatedProgress;
@@ -155,21 +177,19 @@ NSString * const kJSGetUid = @"getUid";
if (![_url hasPrefix:@"http"] && ![_url hasPrefix:@"https"]){ if (![_url hasPrefix:@"http"] && ![_url hasPrefix:@"https"]){
_url = [NSString stringWithFormat:@"%@/%@", API_HOST_H5_URL, _url]; _url = [NSString stringWithFormat:@"%@/%@", API_HOST_H5_URL, _url];
} }
if (![_url containsString:@"alipayh5"]) {
if (![_url containsString:@"?"]) { if (![_url containsString:@"?"]) {
_url = [NSString stringWithFormat:@"%@?platform=%@", _url, [YYUtility appName]]; _url = [NSString stringWithFormat:@"%@?platform=%@", _url, [YYUtility appName]];
} else { } else {
_url = [NSString stringWithFormat:@"%@&platform=%@", _url, [YYUtility appName]]; _url = [NSString stringWithFormat:@"%@&platform=%@", _url, [YYUtility appName]];
} }
}
// urlString // urlString
NSString *noSpaceTextUrl = [_url stringByReplacingOccurrencesOfString:@" " withString:@""]; NSString *noSpaceTextUrl = [_url stringByReplacingOccurrencesOfString:@" " withString:@""];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:noSpaceTextUrl]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:noSpaceTextUrl]];
if ([_url containsString:@"wx.tenpay"]) {
[request setValue:[NSString stringWithFormat:@"xdx.%@://", CompanyFirstDomainByWeChatRegister] forHTTPHeaderField:@"Referer"];
}
[self.webview loadRequest:request]; [self.webview loadRequest:request];
} }
@@ -215,7 +235,7 @@ NSString * const kJSGetUid = @"getUid";
CGSize size = [UIScreen mainScreen].bounds.size; CGSize size = [UIScreen mainScreen].bounds.size;
_webview = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, size.width,size.height) configuration:configuration]; _webview = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, size.width,size.height) configuration:configuration];
_webview.navigationDelegate = self; _webview.navigationDelegate = self;
//KVOWKWebViewestimatedProgress //KVOWKWebViewestimatedProgress
[_webview addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil]; [_webview addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];