Commit 9e379fd8 authored by 刘俊宏's avatar 刘俊宏

添加webVC

parent 375fc9d6
......@@ -249,6 +249,8 @@
F969BF1E244EE67900C79953 /* GoodsManageListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = F969BF1C244EE67900C79953 /* GoodsManageListVC.swift */; };
F969BF1F244EE67900C79953 /* GoodsManageListVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = F969BF1D244EE67900C79953 /* GoodsManageListVC.xib */; };
F9DDBE922457BFEC00A32CB2 /* HUDEXT.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9DDBE912457BFEC00A32CB2 /* HUDEXT.swift */; };
F9DDBE962457D3EC00A32CB2 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9DDBE942457D3EC00A32CB2 /* WebViewController.swift */; };
F9DDBE972457D3EC00A32CB2 /* WebViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9DDBE952457D3EC00A32CB2 /* WebViewController.xib */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -545,6 +547,8 @@
F969BF1C244EE67900C79953 /* GoodsManageListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoodsManageListVC.swift; sourceTree = "<group>"; };
F969BF1D244EE67900C79953 /* GoodsManageListVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GoodsManageListVC.xib; sourceTree = "<group>"; };
F9DDBE912457BFEC00A32CB2 /* HUDEXT.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUDEXT.swift; sourceTree = "<group>"; };
F9DDBE942457D3EC00A32CB2 /* WebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = "<group>"; };
F9DDBE952457D3EC00A32CB2 /* WebViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WebViewController.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -797,6 +801,7 @@
E088CC882446FFA1000DAA8A /* Other */ = {
isa = PBXGroup;
children = (
F9DDBE932457D3CB00A32CB2 /* Web */,
F95A9ED324551DDC00867849 /* Parchment */,
F933F6D02452DAC300189561 /* TabBarVc */,
F933F6AD2452C65C00189561 /* HUD */,
......@@ -1400,6 +1405,15 @@
path = "商品管理";
sourceTree = "<group>";
};
F9DDBE932457D3CB00A32CB2 /* Web */ = {
isa = PBXGroup;
children = (
F9DDBE942457D3EC00A32CB2 /* WebViewController.swift */,
F9DDBE952457D3EC00A32CB2 /* WebViewController.xib */,
);
path = Web;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
......@@ -1532,6 +1546,7 @@
E0B6036F244D376900A56B38 /* KuWeiCell.xib in Resources */,
E0273DDA24551B6D00B3FCAE /* SendTimeSelectView.xib in Resources */,
E01C26B72446AF3100ADCC70 /* DemoViewController.xib in Resources */,
F9DDBE972457D3EC00A32CB2 /* WebViewController.xib in Resources */,
E0F97B0424512299001BD600 /* GLAlertSelectView.xib in Resources */,
E0C4F4BA244EEA7C00CC7E2F /* JiaTiJiaCell.xib in Resources */,
F9023F6E2449A9B100DD5A63 /* TitleAndTFCell.xib in Resources */,
......@@ -1736,6 +1751,7 @@
E02FD9EC2455627300E10E27 /* ChuKuViewController.swift in Sources */,
E0D197BB2448431C002B080C /* BabyCallback.m in Sources */,
F950FDDD24518B9500C40530 /* FSCalendarCollectionViewLayout.m in Sources */,
F9DDBE962457D3EC00A32CB2 /* WebViewController.swift in Sources */,
F961D26B24500FF6007FBE70 /* HeaderSelectView.swift in Sources */,
E09F4C9D2452BEBB00BE033D /* JiPaiFangShiViewController.swift in Sources */,
E0D4166424483058008DCAB4 /* ChangePassViewController.swift in Sources */,
......
//
// WebViewController.swift
// GeliBusinessPlatform
//
// Created by 刘俊宏 on 2020/4/28.
// Copyright © 2020 junye lu. All rights reserved.
//
import UIKit
import WebKit
class WebViewController: BaseViewController {
// wkWebView
lazy var wkWebView = WKWebView()
// 进度条
lazy var progressView = UIProgressView()
override func viewDidLoad() {
super.viewDidLoad()
navbar.title = ""
self.view.addSubview(navbar)
initInterface()
}
func initInterface() -> () {
let url = URL(string: "https://pay.gelifood.com/m/index.htm")
let request = URLRequest.init(url: url!, cachePolicy: .reloadRevalidatingCacheData, timeoutInterval: 10)
wkWebView.navigationDelegate = self
wkWebView.load(request)
self.view.addSubview(self.wkWebView)
self.wkWebView.snp.makeConstraints { (make) in
make.left.bottom.right.equalTo(0)
make.top.equalTo(navbar.snp.bottom)
}
wkWebView.addObserver(self, forKeyPath: "estimatedProgress", options: .new, context: nil)
progressView.progressTintColor = UIColor.init(named: "蓝色字体颜色")
progressView.trackTintColor = UIColor.clear
self.view.addSubview(self.progressView)
progressView.snp.makeConstraints { (make) in
make.left.right.equalTo(0)
make.top.equalTo(navbar.snp.bottom)
make.height.equalTo(2)
}
}
deinit {
print("con is deinit")
wkWebView.removeObserver(self, forKeyPath: "estimatedProgress")
}
}
extension WebViewController: WKNavigationDelegate
{
// 监听网页加载进度
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
print("进度=\(self.wkWebView.estimatedProgress)")
progressView.setProgress(Float(self.wkWebView.estimatedProgress), animated: true)
}
// 页面开始加载时调用
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
print("开始加载...")
progressView.setProgress(Float(0.2), animated: true)
// Log4jMessage(message: "开始加载...")
}
// 当内容开始返回时调用
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!){
print("当内容开始返回...")
progressView.setProgress(Float(0.7), animated: true)
// Log4jMessage(message: "当内容开始返回...")
}
// 页面加载完成之后调用
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!){
// Log4jMessage(message: "页面加载完成...")
print("页面加载完成...")
/// 获取网页title
navbar.title = self.wkWebView.title
UIView.animate(withDuration: 0.5) {
self.progressView.isHidden = true
}
}
// 页面加载失败时调用
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error){
// Log4jMessage(message: "页面加载失败...")
print("页面加载失败...")
UIView.animate(withDuration: 0.5) {
self.progressView.progress = 0.0
self.progressView.isHidden = true
}
/// 弹出提示框点击确定返回
let alertView = UIAlertController.init(title: "提示", message: "加载失败", preferredStyle: .alert)
let okAction = UIAlertAction.init(title:"确定", style: .default) { okAction in
_=self.navigationController?.popViewController(animated: true)
}
alertView.addAction(okAction)
self.present(alertView, animated: true, completion: nil)
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="WebViewController" customModuleProvider="target">
<connections>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
</view>
</objects>
</document>
......@@ -97,6 +97,8 @@ class PersonCenterViewController: BaseViewController,UITableViewDelegate,UITable
self.navigationController?.pushViewController(vc, animated: true)
}else if indexPath.row == 2{
//权限设置-弹窗
let vc = WebViewController()
self.navigationController?.pushViewController(vc, animated: true)
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment