Commit 25ea41f7 authored by Steven杜宇's avatar Steven杜宇

// 我的证书

parent 655dd12c
......@@ -220,6 +220,7 @@
049A48A82B49417300D0C641 /* YHAboutUsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */; };
049A48AA2B49536000D0C641 /* YHAboutUsAdvantageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A92B49536000D0C641 /* YHAboutUsAdvantageCell.swift */; };
04A271232BABFF3200652B1B /* YHCertificateUploadTypeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A271222BABFF3200652B1B /* YHCertificateUploadTypeCell.swift */; };
04A271252BAC33BB00652B1B /* YHFilePreviewTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A271242BAC33BB00652B1B /* YHFilePreviewTool.swift */; };
04A671592B9F18C800C1FB91 /* YHCertificateUploadSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A671582B9F18C800C1FB91 /* YHCertificateUploadSheetView.swift */; };
04A6715C2B9FE9EA00C1FB91 /* YHUploadContentVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A6715B2B9FE9EA00C1FB91 /* YHUploadContentVC.swift */; };
04A6715E2B9FFCA700C1FB91 /* YHCertificateNameCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A6715D2B9FFCA700C1FB91 /* YHCertificateNameCell.swift */; };
......@@ -603,6 +604,7 @@
049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsViewController.swift; sourceTree = "<group>"; };
049A48A92B49536000D0C641 /* YHAboutUsAdvantageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsAdvantageCell.swift; sourceTree = "<group>"; };
04A271222BABFF3200652B1B /* YHCertificateUploadTypeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadTypeCell.swift; sourceTree = "<group>"; };
04A271242BAC33BB00652B1B /* YHFilePreviewTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFilePreviewTool.swift; sourceTree = "<group>"; };
04A671582B9F18C800C1FB91 /* YHCertificateUploadSheetView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadSheetView.swift; sourceTree = "<group>"; };
04A6715B2B9FE9EA00C1FB91 /* YHUploadContentVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHUploadContentVC.swift; sourceTree = "<group>"; };
04A6715D2B9FFCA700C1FB91 /* YHCertificateNameCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateNameCell.swift; sourceTree = "<group>"; };
......@@ -1650,6 +1652,7 @@
isa = PBXGroup;
children = (
A592FE962BA6DB340062FACA /* YHCertificateViewModel.swift */,
04A271242BAC33BB00652B1B /* YHFilePreviewTool.swift */,
);
path = VM;
sourceTree = "<group>";
......@@ -2494,6 +2497,7 @@
045EEE922B9F171A0022A143 /* YHPreviewInfoNameAndSubNameItemView.swift in Sources */,
045EEEF92B9F171A0022A143 /* YHFormItemTitleCell.swift in Sources */,
0425E6482BA96B4100A5E763 /* YHSchemeHeadScoreItemView.swift in Sources */,
04A271252BAC33BB00652B1B /* YHFilePreviewTool.swift in Sources */,
045EEEC32B9F171A0022A143 /* YHOtherResidenceFillView.swift in Sources */,
045EEE792B9F171A0022A143 /* YHPreviewViewModel.swift in Sources */,
0493B3DE2BA80C2300AF9393 /* YHCertificateFilterButton.swift in Sources */,
......
......@@ -19,7 +19,11 @@ class YHCertificateResourceUploadVC: YHBaseViewController {
var items:[YHSupplementInfo] = []
var viewModel: YHCertificateViewModel = YHCertificateViewModel()
var categoryInfo: YHCategoryData!
lazy var previewFileTool:YHFilePreviewTool = {
let tool = YHFilePreviewTool(targetVC: self)
return tool
}()
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
......@@ -107,10 +111,12 @@ extension YHCertificateResourceUploadVC: UITableViewDelegate, UITableViewDataSou
guard let self = self else { return }
let view = YHCertificateTemplateSheetView.templateView(item.templateInfo)
view.scanTemplateBlock = {
[weak self] temlateInfo in
[weak self] path in
guard let self = self else { return }
let vc = UIViewController()
self.navigationController?.pushViewController(vc)
if let url = path?.url, !url.isEmpty {
print(url)
self.previewFileTool.openXLSXRemoteFile(urlString:url)
}
}
view.show()
}
......@@ -297,6 +303,14 @@ extension YHCertificateResourceUploadVC {
let sheetView = YHCertificateUploadSheetView.sheetView
sheetView.templateInfo = supplementInfo.templateInfo
sheetView.clickTemplateBlock = {
[weak self] path in
if let url = path?.url, !url.isEmpty {
guard let self = self else { return }
print(url)
self.previewFileTool.openXLSXRemoteFile(urlString:url)
}
}
sheetView.uploadFilesBlock = {
[weak self] fileUrl in
guard let self = self else { return }
......
......@@ -31,6 +31,10 @@ class YHUploadContentVC: YHBaseViewController {
var templateArr:[YHMaterialPath] = []
var items:[YHContentUrl] = []
var selectEditItem: YHContentUrl?
lazy var previewFileTool:YHFilePreviewTool = {
let tool = YHFilePreviewTool(targetVC: self)
return tool
}()
var renameInputView: YHFileRenameInputView = {
let view = YHFileRenameInputView.inputView(defalutText: "请输入名称")
......@@ -176,11 +180,6 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
cell.update(bottomMargin: 20)
if 0 <= indexPath.row && indexPath.row < templateArr.count {
cell.templatePath = templateArr[indexPath.row]
cell.templateClick = {
[weak self] path in
guard let self = self else { return }
// 查看模版 uploadInfo.templateInfo
}
}
return cell
}
......@@ -393,6 +392,10 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
if indexPath.section == 0 { // 模版列表
if 0 <= indexPath.row && indexPath.row < templateArr.count {
let path = templateArr[indexPath.row]
print(path.url)
if !path.url.isEmpty {
self.previewFileTool.openXLSXRemoteFile(urlString:path.url)
}
}
} else if indexPath.section == 1 { // 证件列表
......
......@@ -72,21 +72,12 @@ class YHCertificateSampleTemplateView: UIView {
class YHCertificateTemplateCell: UITableViewCell {
static let cellReuseIdentifier = "YHCertificateTemplateCell"
var templateClick:((YHMaterialPath?)->())?
var templatePath: YHMaterialPath?
lazy var templateView: YHCertificateSampleTemplateView = {
let view = YHCertificateSampleTemplateView(frame:CGRectZero)
let tap = UITapGestureRecognizer(target:self, action:#selector(didTemplateTap))
view.addGestureRecognizer(tap)
return view
}()
@objc func didTemplateTap() {
templateClick?(templatePath)
}
required init?(coder: NSCoder) {
super.init(coder: coder)
......
......@@ -28,7 +28,7 @@ class YHCertificateTemplateSheetView: UIView {
var templateArr: [YHMaterialPath] = []
var templateInfo: YHTemplateInfo?
var scanTemplateBlock: ((YHTemplateInfo?)->())?
var scanTemplateBlock: ((YHMaterialPath?)->())?
lazy var blackMaskView: UIView = {
let view = UIView()
......@@ -203,13 +203,6 @@ class YHCertificateTemplateSheetView: UIView {
self.removeFromSuperview()
}
@objc func didTemplateViewClicked() {
if let scanTemplateBlock = scanTemplateBlock {
scanTemplateBlock(templateInfo)
}
dismiss()
}
@objc func didClickKnownBtn() {
dismiss()
}
......@@ -232,9 +225,6 @@ extension YHCertificateTemplateSheetView: UITableViewDelegate, UITableViewDataSo
cell.update(bottomMargin: 20)
if 0 <= indexPath.row && indexPath.row < templateArr.count {
cell.templatePath = templateArr[indexPath.row]
cell.templateClick = {
[weak self] path in
}
}
return cell
}
......@@ -242,6 +232,8 @@ extension YHCertificateTemplateSheetView: UITableViewDelegate, UITableViewDataSo
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.row && indexPath.row < templateArr.count {
let path = templateArr[indexPath.row]
scanTemplateBlock?(path)
dismiss()
}
}
......
......@@ -58,6 +58,8 @@ class YHCertificateUploadSheetView: UIView {
var uploadFilesBlock:((URL)->())?
// 上传图片
var uploadImageBlock:((UIImage)->())?
// 点击模版
var clickTemplateBlock:((YHMaterialPath?)->())?
lazy var blackMaskView: UIView = {
let view = UIView()
......@@ -236,12 +238,8 @@ extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSour
if indexPath.section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateTemplateCell.cellReuseIdentifier, for: indexPath) as! YHCertificateTemplateCell
cell.update(bottomMargin:20)
if 0 <= indexPath.row && indexPath.row < templateArr.count {
cell.templatePath = templateArr[indexPath.row]
cell.templateClick = {
[weak self] path in
}
}
return cell
}
......@@ -258,6 +256,8 @@ extension YHCertificateUploadSheetView: UITableViewDelegate, UITableViewDataSour
if indexPath.section == 0 { // 模版列表
if 0 <= indexPath.row && indexPath.row < templateArr.count {
let path = templateArr[indexPath.row]
clickTemplateBlock?(path)
dismiss()
}
} else if indexPath.section == 1 { // 操作列表
......
//
// YHFilePreviewTool.swift
// galaxy
//
// Created by edy on 2024/3/21.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHFilePreviewTool: NSObject {
weak var targetVC: UIViewController!
init(targetVC: UIViewController!) {
self.targetVC = targetVC
}
func openXLSXRemoteFile(urlString: String) {
guard let url = URL(string: urlString) else { return }
let configuration = URLSessionConfiguration.default
let session = URLSession(configuration: configuration)
DispatchQueue.main.async {
YHHUD.show(.progress(message: "加载文件中..."))
}
let task = session.downloadTask(with: url) { (tempLocalUrl, response, error) in
DispatchQueue.main.async {
YHHUD.hide()
}
if let tempLocalUrl = tempLocalUrl, error == nil {
// 下载完成,尝试打开文件
let fileManager = FileManager.default
let destination = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(response?.suggestedFilename ?? UUID().uuidString)
try? fileManager.moveItem(at: tempLocalUrl, to: destination)
// 打开文件
self.openXLSXFile(at: destination)
} else {
print("Error downloading the file: \(error?.localizedDescription ?? "Unknown error")")
DispatchQueue.main.async {
YHHUD.flash(message: "加载文件失败")
}
}
}
task.resume()
}
func openXLSXFile(at fileURL: URL) {
let controller = UIDocumentInteractionController(url: fileURL)
controller.delegate = self
DispatchQueue.main.async {
controller.presentPreview(animated: true)
}
}
}
extension YHFilePreviewTool: UIDocumentInteractionControllerDelegate {
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
return targetVC
}
}
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