Commit c33c2ab7 authored by Steven杜宇's avatar Steven杜宇

// 我的证件

parent 162975a9
...@@ -93,8 +93,11 @@ class YHUploadContentVC: YHBaseViewController { ...@@ -93,8 +93,11 @@ class YHUploadContentVC: YHBaseViewController {
} }
@objc func didClickUploadBtn() { @objc func didClickUploadBtn() {
YHCertificateUploadSheetView.sheetView.show {
[weak self] actionType in
guard let self = self else { return }
print("%d", actionType.rawValue)
}
} }
func createUI() { func createUI() {
...@@ -146,6 +149,12 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource { ...@@ -146,6 +149,12 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateTemplateCell.cellReuseIdentifier, for: indexPath) as! YHCertificateTemplateCell let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateTemplateCell.cellReuseIdentifier, for: indexPath) as! YHCertificateTemplateCell
cell.templateInfo = uploadInfo.templateInfo cell.templateInfo = uploadInfo.templateInfo
cell.templateClick = {
[weak self] in
guard let self = self else { return }
// 查看模版 uploadInfo.templateInfo
}
return cell return cell
} }
...@@ -166,10 +175,17 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource { ...@@ -166,10 +175,17 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
[weak self] editType in [weak self] editType in
guard let self = self else { return } guard let self = self else { return }
print("editType:\(editType.rawValue)") print("editType:\(editType.rawValue)")
if editType == .rename {
if editType == .rename { // 重命名
IQKeyboardManager.shared.enable = false IQKeyboardManager.shared.enable = false
renameInputView.textField.text = contentItem.name renameInputView.textField.text = contentItem.name
renameInputView.textField.becomeFirstResponder() renameInputView.textField.becomeFirstResponder()
} else if editType == .delete { // 删除
self.updateCertificateItem(contentItem, operation: "del", rename: "")
} else if editType == .preview { // 预览
// 预览 contentItem
} }
}.show() }.show()
} }
...@@ -334,6 +350,7 @@ extension YHUploadContentVC { ...@@ -334,6 +350,7 @@ extension YHUploadContentVC {
items.removeAll() items.removeAll()
if let listInfo = listInfo { if let listInfo = listInfo {
categoryInfo = listInfo.categoryData
let arr = listInfo.supplementList let arr = listInfo.supplementList
for item in arr { for item in arr {
items.append(contentsOf: item.contentUrl) items.append(contentsOf: item.contentUrl)
...@@ -366,13 +383,16 @@ extension YHUploadContentVC { ...@@ -366,13 +383,16 @@ extension YHUploadContentVC {
"operation" : operation, "operation" : operation,
] ]
self.viewModel.updateCertificates(params: params) { self.viewModel.updateCertificates(params: params) {
success in
[weak self] success in
guard let self = self else { return }
if operation == "del" { if operation == "del" {
YHHUD.flash(message: success ? "删除成功" : "删除失败") YHHUD.flash(message: success ? "删除成功" : "删除失败")
} else if operation == "rename" { } else if operation == "rename" {
YHHUD.flash(message: success ? "重命名成功" : "重命名失败") YHHUD.flash(message: success ? "重命名成功" : "重命名失败")
} }
requestList()
} }
} }
......
...@@ -11,6 +11,9 @@ import UIKit ...@@ -11,6 +11,9 @@ import UIKit
class YHCertificateTemplateCell: UITableViewCell { class YHCertificateTemplateCell: UITableViewCell {
static let cellReuseIdentifier = "YHCertificateTemplateCell" static let cellReuseIdentifier = "YHCertificateTemplateCell"
var templateClick:(()->())?
var templateInfo: YHTemplateInfo? { var templateInfo: YHTemplateInfo? {
didSet { didSet {
guard let templateInfo = templateInfo else { guard let templateInfo = templateInfo else {
...@@ -66,10 +69,16 @@ class YHCertificateTemplateCell: UITableViewCell { ...@@ -66,10 +69,16 @@ class YHCertificateTemplateCell: UITableViewCell {
lazy var templateView: YHCertificateSampleTemplateView = { lazy var templateView: YHCertificateSampleTemplateView = {
let view = YHCertificateSampleTemplateView(frame:CGRectZero) let view = YHCertificateSampleTemplateView(frame:CGRectZero)
// let tap = UITapGestureRecognizer(target:self, action:#selector(action(_:))) let tap = UITapGestureRecognizer(target:self, action:#selector(didTemplateTap))
// view.addGestureRecognizer(tap) view.addGestureRecognizer(tap)
return view return view
}() }()
@objc func didTemplateTap() {
if let templateClick = templateClick {
templateClick()
}
}
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
......
...@@ -483,12 +483,8 @@ extension YHCertificateUploadSheetView: UIDocumentPickerDelegate { ...@@ -483,12 +483,8 @@ extension YHCertificateUploadSheetView: UIDocumentPickerDelegate {
var error: NSError? var error: NSError?
fileCoordinator.coordinate(readingItemAt: url, options:[.forUploading], error: &error) { fileCoordinator.coordinate(readingItemAt: url, options:[.forUploading], error: &error) {
newFileUrl in newFileUrl in
uploadFile(newFileUrl)
if let fileData = try? Data(contentsOf: newFileUrl) {
// 将文件数据上传到服务器
uploadFile(fileData)
dismiss() dismiss()
}
} }
url.stopAccessingSecurityScopedResource() url.stopAccessingSecurityScopedResource()
if let error = error { if let error = error {
...@@ -504,9 +500,12 @@ extension YHCertificateUploadSheetView: UIDocumentPickerDelegate { ...@@ -504,9 +500,12 @@ extension YHCertificateUploadSheetView: UIDocumentPickerDelegate {
} }
func uploadFile(_ data: Data) { func uploadFile(_ fileUrl: URL) {
let format = String(format: "%.2fM", Double(data.count)/(1024.0 * 1024.0)) if let fileData = try? Data(contentsOf: fileUrl) {
print("\(format)") // 将文件数据上传到服务器
let size = String(format: "%.2fM", Double(fileData.count)/(1024.0 * 1024.0))
print("\(size)")
}
} }
} }
...@@ -30,6 +30,8 @@ class YHFileRenameInputView: UIView { ...@@ -30,6 +30,8 @@ class YHFileRenameInputView: UIView {
lazy var whiteContentView: UIView = { lazy var whiteContentView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .white view.backgroundColor = .white
let tap = UITapGestureRecognizer(target: self, action: #selector(didWhiteContentViewTap))
view.addGestureRecognizer(tap)
return view return view
}() }()
...@@ -180,6 +182,10 @@ extension YHFileRenameInputView { ...@@ -180,6 +182,10 @@ extension YHFileRenameInputView {
UIApplication.shared.yhKeyWindow()?.endEditing(true) UIApplication.shared.yhKeyWindow()?.endEditing(true)
} }
@objc func didWhiteContentViewTap() {
self.textField.becomeFirstResponder()
}
@objc func didClickCancelBtn() { @objc func didClickCancelBtn() {
dismiss() dismiss()
} }
......
...@@ -136,7 +136,7 @@ class YHCertificateViewModel: YHBaseViewModel { ...@@ -136,7 +136,7 @@ class YHCertificateViewModel: YHBaseViewModel {
} }
} }
// 上传/重命名/删除 证件
func updateCertificates(params:[String : Any], isSilient:Bool = false, callBack:@escaping ((Bool)->())) { func updateCertificates(params:[String : Any], isSilient:Bool = false, callBack:@escaping ((Bool)->())) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Certificate.certificateUploadApi let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Certificate.certificateUploadApi
...@@ -145,7 +145,7 @@ class YHCertificateViewModel: YHBaseViewModel { ...@@ -145,7 +145,7 @@ class YHCertificateViewModel: YHBaseViewModel {
YHHUD.show(.progress(message: "数据加载中...")) YHHUD.show(.progress(message: "数据加载中..."))
} }
let _ = YHNetRequest.getRequest(url: strUrl, params:params) { json, code in let _ = YHNetRequest.postRequest(url: strUrl, params:params) { json, code in
if !isSilient { if !isSilient {
YHHUD.hide() YHHUD.hide()
......
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