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

// 我的证件

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