Commit 0af7d29c authored by pete谢兆麟's avatar pete谢兆麟

我的首页web

parent b4c497a3
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
0435FA7F2BA178C100024EAE /* YHCommonAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA7E2BA178C100024EAE /* YHCommonAlertView.swift */; }; 0435FA7F2BA178C100024EAE /* YHCommonAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA7E2BA178C100024EAE /* YHCommonAlertView.swift */; };
0435FA812BA186D600024EAE /* YHMyFileMethodTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA802BA186D600024EAE /* YHMyFileMethodTableViewCell.swift */; }; 0435FA812BA186D600024EAE /* YHMyFileMethodTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA802BA186D600024EAE /* YHMyFileMethodTableViewCell.swift */; };
0435FA832BA2DEB100024EAE /* YHCardButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA822BA2DEB100024EAE /* YHCardButton.swift */; }; 0435FA832BA2DEB100024EAE /* YHCardButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA822BA2DEB100024EAE /* YHCardButton.swift */; };
044413F72BC2786200784A14 /* YHHomeWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044413F62BC2786200784A14 /* YHHomeWebViewController.swift */; };
044413F92BC279D200784A14 /* YHHomeWebBottomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044413F82BC279D200784A14 /* YHHomeWebBottomView.swift */; };
044413FB2BC27E6F00784A14 /* YHHomeWebBottomButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044413FA2BC27E6F00784A14 /* YHHomeWebBottomButton.swift */; };
044867B42BA1953B00DFAD4A /* YHCertificateFilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044867B32BA1953B00DFAD4A /* YHCertificateFilterView.swift */; }; 044867B42BA1953B00DFAD4A /* YHCertificateFilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044867B32BA1953B00DFAD4A /* YHCertificateFilterView.swift */; };
044867B62BA1A03800DFAD4A /* YHCertificateFilterItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044867B52BA1A03800DFAD4A /* YHCertificateFilterItemCell.swift */; }; 044867B62BA1A03800DFAD4A /* YHCertificateFilterItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044867B52BA1A03800DFAD4A /* YHCertificateFilterItemCell.swift */; };
044867B82BA1C75700DFAD4A /* YHCertificateUploadFailTipsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044867B72BA1C75700DFAD4A /* YHCertificateUploadFailTipsView.swift */; }; 044867B82BA1C75700DFAD4A /* YHCertificateUploadFailTipsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044867B72BA1C75700DFAD4A /* YHCertificateUploadFailTipsView.swift */; };
...@@ -424,6 +427,9 @@ ...@@ -424,6 +427,9 @@
0435FA7E2BA178C100024EAE /* YHCommonAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCommonAlertView.swift; sourceTree = "<group>"; }; 0435FA7E2BA178C100024EAE /* YHCommonAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCommonAlertView.swift; sourceTree = "<group>"; };
0435FA802BA186D600024EAE /* YHMyFileMethodTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyFileMethodTableViewCell.swift; sourceTree = "<group>"; }; 0435FA802BA186D600024EAE /* YHMyFileMethodTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyFileMethodTableViewCell.swift; sourceTree = "<group>"; };
0435FA822BA2DEB100024EAE /* YHCardButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCardButton.swift; sourceTree = "<group>"; }; 0435FA822BA2DEB100024EAE /* YHCardButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCardButton.swift; sourceTree = "<group>"; };
044413F62BC2786200784A14 /* YHHomeWebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeWebViewController.swift; sourceTree = "<group>"; };
044413F82BC279D200784A14 /* YHHomeWebBottomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeWebBottomView.swift; sourceTree = "<group>"; };
044413FA2BC27E6F00784A14 /* YHHomeWebBottomButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeWebBottomButton.swift; sourceTree = "<group>"; };
044867B32BA1953B00DFAD4A /* YHCertificateFilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateFilterView.swift; sourceTree = "<group>"; }; 044867B32BA1953B00DFAD4A /* YHCertificateFilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateFilterView.swift; sourceTree = "<group>"; };
044867B52BA1A03800DFAD4A /* YHCertificateFilterItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateFilterItemCell.swift; sourceTree = "<group>"; }; 044867B52BA1A03800DFAD4A /* YHCertificateFilterItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateFilterItemCell.swift; sourceTree = "<group>"; };
044867B72BA1C75700DFAD4A /* YHCertificateUploadFailTipsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadFailTipsView.swift; sourceTree = "<group>"; }; 044867B72BA1C75700DFAD4A /* YHCertificateUploadFailTipsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadFailTipsView.swift; sourceTree = "<group>"; };
...@@ -2107,6 +2113,8 @@ ...@@ -2107,6 +2113,8 @@
A5C5B3222B57BF8F00A7C5D1 /* YHDavidCell1.swift */, A5C5B3222B57BF8F00A7C5D1 /* YHDavidCell1.swift */,
A5C5B3112B57B47D00A7C5D1 /* YHDavidCell0.swift */, A5C5B3112B57B47D00A7C5D1 /* YHDavidCell0.swift */,
A5C5B32C2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift */, A5C5B32C2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift */,
044413F82BC279D200784A14 /* YHHomeWebBottomView.swift */,
044413FA2BC27E6F00784A14 /* YHHomeWebBottomButton.swift */,
); );
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2117,6 +2125,7 @@ ...@@ -2117,6 +2125,7 @@
A5ACE95D2B4571BF002C94D2 /* YHHomeViewController.swift */, A5ACE95D2B4571BF002C94D2 /* YHHomeViewController.swift */,
A5C5B2FE2B55623700A7C5D1 /* YHMainContentBaseViewController.swift */, A5C5B2FE2B55623700A7C5D1 /* YHMainContentBaseViewController.swift */,
A5C5B2E52B4EC0BF00A7C5D1 /* YHDavidTestViewController.swift */, A5C5B2E52B4EC0BF00A7C5D1 /* YHDavidTestViewController.swift */,
044413F62BC2786200784A14 /* YHHomeWebViewController.swift */,
); );
path = C; path = C;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2390,11 +2399,13 @@ ...@@ -2390,11 +2399,13 @@
A5ACE93D2B4564F7002C94D2 /* UIButton+Extension.swift in Sources */, A5ACE93D2B4564F7002C94D2 /* UIButton+Extension.swift in Sources */,
045EEEA32B9F171A0022A143 /* YHCompanyModel.swift in Sources */, 045EEEA32B9F171A0022A143 /* YHCompanyModel.swift in Sources */,
045EEEC62B9F171A0022A143 /* YHOtherTextViewItemView.swift in Sources */, 045EEEC62B9F171A0022A143 /* YHOtherTextViewItemView.swift in Sources */,
044413F72BC2786200784A14 /* YHHomeWebViewController.swift in Sources */,
A5ACE9292B4564F7002C94D2 /* YHSmsCodeInputView.swift in Sources */, A5ACE9292B4564F7002C94D2 /* YHSmsCodeInputView.swift in Sources */,
A5ACE9452B4564F7002C94D2 /* YHHUDContainerView.swift in Sources */, A5ACE9452B4564F7002C94D2 /* YHHUDContainerView.swift in Sources */,
045EEEFD2B9F171A0022A143 /* YHSheetPickerViewType.swift in Sources */, 045EEEFD2B9F171A0022A143 /* YHSheetPickerViewType.swift in Sources */,
045EEEC72B9F171A0022A143 /* YHOtherYesOrNoItemView.swift in Sources */, 045EEEC72B9F171A0022A143 /* YHOtherYesOrNoItemView.swift in Sources */,
04A7BD172BA43A0F00BD35A2 /* YHMyDocumentsDetailViewModel.swift in Sources */, 04A7BD172BA43A0F00BD35A2 /* YHMyDocumentsDetailViewModel.swift in Sources */,
044413FB2BC27E6F00784A14 /* YHHomeWebBottomButton.swift in Sources */,
045EEEB32B9F171A0022A143 /* YHWorkFileSyncTableViewCell.swift in Sources */, 045EEEB32B9F171A0022A143 /* YHWorkFileSyncTableViewCell.swift in Sources */,
045EEEF12B9F171A0022A143 /* YHChildInfoContainerVC.swift in Sources */, 045EEEF12B9F171A0022A143 /* YHChildInfoContainerVC.swift in Sources */,
045EEF0B2B9F171A0022A143 /* YHBasicInfoFillViewController.swift in Sources */, 045EEF0B2B9F171A0022A143 /* YHBasicInfoFillViewController.swift in Sources */,
...@@ -2645,6 +2656,7 @@ ...@@ -2645,6 +2656,7 @@
A580371E2BAD784B0031C312 /* YHMySchemeViewModel.swift in Sources */, A580371E2BAD784B0031C312 /* YHMySchemeViewModel.swift in Sources */,
0425E6482BA96B4100A5E763 /* YHSchemeHeadScoreItemView.swift in Sources */, 0425E6482BA96B4100A5E763 /* YHSchemeHeadScoreItemView.swift in Sources */,
04A271252BAC33BB00652B1B /* YHFilePreviewTool.swift in Sources */, 04A271252BAC33BB00652B1B /* YHFilePreviewTool.swift in Sources */,
044413F92BC279D200784A14 /* YHHomeWebBottomView.swift in Sources */,
045EEEC32B9F171A0022A143 /* YHOtherResidenceFillView.swift in Sources */, 045EEEC32B9F171A0022A143 /* YHOtherResidenceFillView.swift in Sources */,
045EEE792B9F171A0022A143 /* YHPreviewViewModel.swift in Sources */, 045EEE792B9F171A0022A143 /* YHPreviewViewModel.swift in Sources */,
A517A4E12BB573EB000DEECD /* YHDocListCell.swift in Sources */, A517A4E12BB573EB000DEECD /* YHDocListCell.swift in Sources */,
......
...@@ -394,22 +394,8 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource { ...@@ -394,22 +394,8 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true) tableView.deselectRow(at: indexPath, animated: true)
printLog("点击了 tableView Cell \(indexPath.row)") let vc = YHHomeWebViewController()
// let vc = YHWebViewViewController() self.navigationController?.pushViewController(vc)
// vc.url = "https://auth.qiyuesuo.cn?ticket=bQngrvjj1TPHPnaOt91wKNtzO5iBNDfcwtMtgZdpdZxKIiDgW914qVqxQfloCUVT&channel=OPEN_V2"
let url = URL(string: "https://auth.qiyuesuo.cn?ticket=mw5mqO2qx5y%2F%2BqZuOKet7ct3JhAtlFkH4ar9JyyMas0gQ4YYg28iV43Cs8QqqvN8&channel=OPEN_V2")!
// 创建SFSafariViewController
let safariViewController = SFSafariViewController(url: url)
safariViewController.dismissButtonStyle = .close
// 设置代理
safariViewController.delegate = self
// 显示
// present(safariViewController, animated: true, completion: nil)
self.navigationController?.pushViewController(safariViewController)
// https://cloudapi.qiyuesuo.cn/contract/share/3202449385770287813?openPageToken=d004e5af-aab9-43e4-b813-c5a6a8c16497
} }
} }
......
//
// YHHomeWebViewController.swift
// galaxy
//
// Created by EDY on 2024/4/7.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import WebKit
class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
var webview = WKWebView()
var progBar = UIProgressView()
var bottomView: YHHomeWebBottomView!
var url = "https://upload-cdn.galaxy-immi.com/crm/production/1620271613711.pdf"
override func viewDidLoad() {
super.viewDidLoad()
//获取导航栏高度
let navHeight = self.navigationController?.navigationBar.frame.height
//获取状态栏高度
let statusHeight = k_Height_statusBar()
// 创建wkwebview
webview = WKWebView(frame: CGRect(x: 0, y: statusHeight + navHeight!, width: self.view.frame.width, height: self.view.frame.height))
webview.navigationDelegate = self
// 创建网址
let url = NSURL(string: url)
// 创建请求
let request = NSURLRequest(url: url! as URL)
// 加载请求
webview.load(request as URLRequest)
// 添加wkwebview
self.view.addSubview(webview)
// 加载网页的进度条
progBar = UIProgressView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 30))
progBar.progress = 0.0
progBar.tintColor = UIColor.brandMainColor
webview.addSubview(progBar)
// 监听网页加载的进度
webview.addObserver(self, forKeyPath: "estimatedProgress", options: .new, context: nil)
bottomView = {
let view = YHHomeWebBottomView()
view.likeBlock = { [weak self] flag in
guard let self = self else { return }
if flag {
YHHUD.flash(message: "已点赞")
} else {
YHHUD.flash(message: "已取消点赞")
}
}
view.starBlock = { [weak self] flag in
guard let self = self else { return }
if flag {
YHHUD.flash(message: "已收藏")
} else {
YHHUD.flash(message: "已取消收藏")
}
}
return view
}()
view.addSubview(bottomView)
bottomView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.height.equalTo(59 + k_Height_safeAreaInsetsBottom())
}
}
deinit {
webview.removeObserver(self, forKeyPath: "estimatedProgress")
}
// MARK: - WKNavigationDelegate
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
self.navigationItem.title = webview.title
}
// MARK: - WKUIDelegate
func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
// 实现非安全链接的跳转。如果目标主视图不为空,则允许导航
if !(navigationAction.targetFrame?.isMainFrame != nil) {
webview.load(navigationAction.request)
}
return nil
}
func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
// 修复弹窗弹出的问题
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (_) -> Void in
completionHandler()
}))
self.present(alert, animated: true, completion: nil)
}
// MARK: - webview function
@objc func toBack() {
if webview.canGoBack {
webview.goBack()
}
}
@objc func toForward() {
if webview.canGoForward {
webview.goForward()
}
}
// MARK: - KVO
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == "estimatedProgress" {
self.progBar.alpha = 1.0
progBar.setProgress(Float(webview.estimatedProgress), animated: true)
//进度条的值最大为1.0
if(self.webview.estimatedProgress >= 1.0) {
UIView.animate(withDuration: 0.3, delay: 0.1, options: .curveEaseInOut, animations: { () -> Void in
self.progBar.alpha = 0.0
}, completion: { (finished:Bool) -> Void in
self.progBar.progress = 0
})
}
}
}
override class func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
}
}
//
// YHHomeWebBottomButton.swift
// galaxy
//
// Created by EDY on 2024/4/7.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeWebBottomButton: UIButton {
var topImageView: UIImageView!
var bottomTitleLabel: UILabel!
override init(frame: CGRect) {
super.init(frame: frame)
setView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setView() {
topImageView = {
let view = UIImageView()
return view
}()
addSubview(topImageView)
topImageView.snp.makeConstraints { make in
make.top.centerX.equalToSuperview()
make.width.height.equalTo(21)
}
bottomTitleLabel = {
let label = UILabel()
label.font = UIFont.PFSC_B(ofSize: 11)
label.textAlignment = .center
label.textColor = UIColor.mainTextColor
return label
}()
addSubview(bottomTitleLabel)
bottomTitleLabel.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(15)
}
}
func setContent(_ image: String, _ title: String) {
bottomTitleLabel.text = title
topImageView.image = UIImage(named: image)
}
/*
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
// Drawing code
}
*/
}
//
// YHHomeWebBottomView.swift
// galaxy
//
// Created by EDY on 2024/4/7.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeWebBottomView: UIView {
typealias Block = (Bool) -> ()
var likeBlock: Block?
var starBlock: Block?
private var likeButton: YHHomeWebBottomButton!
private var starButton: YHHomeWebBottomButton!
var isStar: Bool = false {
didSet {
if isStar {
starButton.setContent("home_web_stared", "34")
} else {
starButton.setContent("home_web_star", "34")
}
}
}//是否收藏
var isLike: Bool = false {
didSet {
if isLike {
likeButton.setContent("home_web_liked", "34")
} else {
likeButton.setContent("home_web_like", "34")
}
}
}//是否点赞
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
setUpView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setUpView() {
likeButton = {
let button = YHHomeWebBottomButton()
button.setContent("home_web_like", "652")
button.addTarget(self, action: #selector(likeBtnClick), for: .touchUpInside)
return button
}()
addSubview(likeButton)
likeButton.snp.makeConstraints { make in
make.right.equalTo(-31)
make.top.equalTo(10)
make.height.equalTo(39)
make.width.equalTo(24)
}
starButton = {
let button = YHHomeWebBottomButton()
button.setContent("home_web_star", "34")
button.addTarget(self, action: #selector(starBtnClick), for: .touchUpInside)
return button
}()
addSubview(starButton)
starButton.snp.makeConstraints { make in
make.right.equalTo(-79)
make.top.equalTo(10)
make.height.equalTo(39)
make.width.equalTo(24)
}
}
@objc private func likeBtnClick() {
isLike = !isLike
if let block = likeBlock {
block(isLike)
}
}
@objc private func starBtnClick() {
isStar = !isStar
if let block = starBlock {
block(isStar)
}
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "home_web_like@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "home_web_like@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "home_web_liked@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "home_web_liked@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "home_web_star@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "home_web_star@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "home_web_stared@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "home_web_stared@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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