Commit 3214f962 authored by Steven杜宇's avatar Steven杜宇

// 我的证书

parent 3f581fbd
......@@ -18,7 +18,7 @@ class YHCertificateResourceUploadVC: YHBaseViewController {
var status: YHCertificateUploadStatus = .all
var items:[YHSupplementInfo] = []
var viewModel: YHCertificateViewModel = YHCertificateViewModel()
var categoryInfo: YHCategoryData = YHCategoryData()
var categoryInfo: YHCategoryData!
lazy var tableView: UITableView = {
......@@ -97,20 +97,23 @@ extension YHCertificateResourceUploadVC: UITableViewDelegate, UITableViewDataSou
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let item = items[indexPath.section]
let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateInfoCell.cellReuseIdentifier, for: indexPath) as! YHCertificateInfoCell
cell.updateModel(item)
cell.templateBlock = {
[weak self] in
guard let self = self else { return }
let view = YHCertificateTemplateView.templateView(item.templateInfo)
view.scanTemplateBlock = {
[weak self] temlateInfo in
if 0 <= indexPath.section && indexPath.section < items.count {
let item = items[indexPath.section]
cell.updateModel(item)
cell.templateBlock = {
[weak self] in
guard let self = self else { return }
let vc = UIViewController()
self.navigationController?.pushViewController(vc)
let view = YHCertificateTemplateView.templateView(item.templateInfo)
view.scanTemplateBlock = {
[weak self] temlateInfo in
guard let self = self else { return }
let vc = UIViewController()
self.navigationController?.pushViewController(vc)
}
view.show()
}
view.show()
}
return cell
}
......@@ -122,6 +125,12 @@ extension YHCertificateResourceUploadVC: UITableViewDelegate, UITableViewDataSou
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = YHUploadContentVC()
vc.orderId = orderId
vc.categoryInfo = categoryInfo
if 0 <= indexPath.section && indexPath.section < items.count {
let item = items[indexPath.section]
vc.uploadInfo = item
}
self.navigationController?.pushViewController(vc)
}
......
......@@ -10,17 +10,16 @@ import UIKit
import IQKeyboardManagerSwift
class YHUploadContentVC: YHBaseViewController {
var orderId : Int?
var orderId : Int!
var categoryInfo: YHCategoryData!
var uploadInfo: YHSupplementInfo!
var viewModel: YHCertificateViewModel = YHCertificateViewModel()
var items:[Int] = [1,2,3,4,5]
var items:[YHContentUrl] = []
var selectEditItem: YHContentUrl?
var renameInputView: YHFileRenameInputView = {
let view = YHFileRenameInputView.inputView(defalutText:"请输入名称", editBlock: {
text in
print("\(text)")
})
let view = YHFileRenameInputView.inputView(defalutText: "请输入名称")
return view
}()
......@@ -54,29 +53,72 @@ class YHUploadContentVC: YHBaseViewController {
return tableView
}()
lazy var uploadBtn:UIButton = {
let btn = UIButton()
btn.setTitle("继续上传".local, for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
btn.setTitleColor(.white, for: .normal)
btn.backgroundColor = UIColor(hexString:"#4388FF")
btn.layer.cornerRadius = 6.0
btn.addTarget(self, action: #selector(didClickUploadBtn), for: .touchUpInside)
return btn
}()
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .white
self.gk_navTitle = "上传内容"
addKeyBoardNotify()
createUI()
items.removeAll()
items.append(contentsOf: uploadInfo.contentUrl)
tableView.reloadData()
requestList()
renameInputView.editBlock = {
[weak self] text in
guard let self = self else { return }
if let selectEditItem = selectEditItem, let text = text {
self.updateCertificateItem(selectEditItem, operation: "rename", rename: text)
}
}
}
deinit {
removeNotify()
}
@objc func didClickUploadBtn() {
}
func createUI() {
view.addSubview(uploadBtn)
view.addSubview(tableView)
view.addSubview(blackMaskView)
view.addSubview(renameInputView)
tableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalTo(view)
make.bottom.equalToSuperview().offset(-k_Height_safeAreaInsetsBottom())
if uploadInfo.checkStatus == YHCertificateUploadStatus.finish.rawValue {
make.bottom.equalToSuperview()
} else {
make.bottom.equalTo(uploadBtn.snp.top).offset(-34)
}
}
uploadBtn.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.height.equalTo(48.0)
make.bottom.equalToSuperview().offset(-8-k_Height_safeAreaInsetsBottom())
}
renameInputView.snp.makeConstraints { make in
make.left.right.equalTo(view)
make.height.equalTo(YHFileRenameInputView.height)
......@@ -90,6 +132,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 0 {
return 1
......@@ -102,19 +145,44 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
if indexPath.section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateTemplateCell.cellReuseIdentifier, for: indexPath) as! YHCertificateTemplateCell
cell.templateInfo = uploadInfo.templateInfo
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: YHCertificateNameCell.cellReuseIdentifier, for: indexPath) as! YHCertificateNameCell
if 0 <= indexPath.row && indexPath.row < items.count {
let item = items[indexPath.row]
cell.updateModel(item)
cell.editBlock = {
[weak self] contentItem in
guard let self = self else { return }
selectEditItem = contentItem
let items = [YHCertificateEditItem(type:.rename, title:"重命名"),
YHCertificateEditItem(type:.preview, title:"预览"),
YHCertificateEditItem(type:.delete, title:"删除"),
YHCertificateEditItem(type:.cancel, title:"取消")]
YHCertificateEditSheetView.sheetView(items:items) {
[weak self] editType in
guard let self = self else { return }
print("editType:\(editType.rawValue)")
if editType == .rename {
IQKeyboardManager.shared.enable = false
renameInputView.textField.text = contentItem.name
renameInputView.textField.becomeFirstResponder()
}
}.show()
}
}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 0 {
return UITableView.automaticDimension
if uploadInfo.templateInfo.isNeedShowTemplate() {
return UITableView.automaticDimension
}
return 0.0
}
return 55.0
}
......@@ -137,7 +205,8 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
titlelabel.textColor = UIColor.mainTextColor
titlelabel.textAlignment = .left
titlelabel.font = UIFont.PFSC_M(ofSize:17)
titlelabel.text = "身份证件"
titlelabel.text = uploadInfo.name
titlelabel.numberOfLines = 0
view.addSubview(titlelabel)
let statusLabel = UILabel()
......@@ -145,7 +214,7 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
statusLabel.backgroundColor = .warnColor8
statusLabel.textAlignment = .center
statusLabel.font = UIFont.PFSC_M(ofSize:10)
statusLabel.text = "审核中"
statusLabel.text = uploadInfo.getStatusName()
view.addSubview(statusLabel)
let tipsLabel = UILabel()
......@@ -153,18 +222,18 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
tipsLabel.font = UIFont.PFSC_R(ofSize:12)
tipsLabel.textAlignment = .left
tipsLabel.numberOfLines = 0
tipsLabel.text = "被驳回原因被驳回原因被驳回原因被驳回原因被驳回原因被驳回原因被驳回原因被驳回原因被驳回原因被驳回原因被驳回原因被驳回原因被驳回原因被驳回原因"
tipsLabel.text = uploadInfo.auditContent
view.addSubview(tipsLabel)
titlelabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.height.equalTo(24.0)
make.top.equalToSuperview()
}
statusLabel.snp.makeConstraints { make in
make.centerY.equalTo(titlelabel)
make.left.equalTo(titlelabel.snp.right).offset(4)
make.right.lessThanOrEqualTo(view).offset(-20)
make.height.equalTo(16)
make.width.equalTo(38)
}
......@@ -204,22 +273,6 @@ extension YHUploadContentVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if true {
let items = [YHCertificateEditItem(type:.rename, title:"重命名"),
YHCertificateEditItem(type:.preview, title:"预览"),
YHCertificateEditItem(type:.delete, title:"删除"),
YHCertificateEditItem(type:.cancel, title:"取消")]
YHCertificateEditSheetView.sheetView(items:items) {
[weak self] editType in
guard let self = self else { return }
print("editType:\(editType.rawValue)")
if editType == .rename {
IQKeyboardManager.shared.enable = false
renameInputView.textField.becomeFirstResponder()
}
}.show()
return
}
}
@objc func dismissed() {
......@@ -266,35 +319,64 @@ extension YHUploadContentVC {
func requestList() {
let params = [
"order_id" : orderId ?? 0,
"node": "1",
"state": "1",
"category_id": "20",
"status_all": "",
"keywork": "",
"template_cate_id": "",
"supplement_ids": []] as [String: Any]
// state: 3:待上传 2:已驳回 1:已通过 0:审核中
// viewModel.getCertificateList(params: params) {
//
// [weak self] listInfo, error in
// guard let self = self else { return }
//
// items.removeAll()
// if let listInfo = listInfo {
// let arr = listInfo.supplementList
// if let info = arr.first {
// let arr = info.contentUrl
// items.append(contentsOf: arr)
// }
// self.tableView.reloadData()
// }
//
// if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
// YHHUD.flash(message: errorMsg, duration:3)
// }
// }
let params:[String:Any] = [
"order_id" : orderId ?? 0,
"node": "1",
"state": "1",
"category_id": categoryInfo.categoryId,
"supplement_ids": uploadInfo.id]
print(params)
viewModel.getCertificateList(params: params) {
[weak self] listInfo, error in
guard let self = self else { return }
items.removeAll()
if let listInfo = listInfo {
let arr = listInfo.supplementList
for item in arr {
items.append(contentsOf: item.contentUrl)
}
}
self.tableView.reloadData()
if let errorMsg = error?.errorMsg, errorMsg.count > 0 {
YHHUD.flash(message: errorMsg, duration:3)
}
}
}
// 更改证件
// operation参数必填,必须是:add(上传)、del(删除)、rename(重命名)
func updateCertificateItem(_ model: YHContentUrl, operation:String, rename:String) {
var name = model.name
if operation == "rename" {
name = rename
}
let dic:[String : Any] = [
"id" : uploadInfo.id,
"content_url": [
"name": name,
"url": model.url,
"suffix": model.suffix]]
let params: [String: Any] = [
"file_info" : [dic],
"operation" : operation,
]
self.viewModel.updateCertificates(params: params) {
success in
if operation == "del" {
YHHUD.flash(message: success ? "删除成功" : "删除失败")
} else if operation == "rename" {
YHHUD.flash(message: success ? "重命名成功" : "重命名失败")
}
}
}
}
......@@ -68,7 +68,22 @@ class YHSupplementInfo: SmartCodable {
var applicantName: String = ""
var nameExtra: YHNameExtra = YHNameExtra()
var templateInfo: YHTemplateInfo = YHTemplateInfo()
var auditContent: String = ""
var uploadRequirement: String = ""
var contentUrl: [YHContentUrl] = []
func getStatusName() -> String {
if checkStatus == YHCertificateUploadStatus.review.rawValue {
return "审核中".local
} else if checkStatus == YHCertificateUploadStatus.preUpload.rawValue {
return "待上传".local
} else if checkStatus == YHCertificateUploadStatus.finish.rawValue {
return "已通过".local
} else if checkStatus == YHCertificateUploadStatus.rejected.rawValue {
return "已驳回".local
}
return ""
}
enum CodingKeys: String, CodingKey {
case id = "id"
......@@ -81,6 +96,8 @@ class YHSupplementInfo: SmartCodable {
case applicantName = "applicant_name"
case nameExtra = "name_extra"
case templateInfo = "template_info"
case auditContent = "audit_content"
case uploadRequirement = "upload_requirement"
case contentUrl = "content_url"
}
......@@ -165,6 +182,13 @@ class YHTemplateInfo: SmartCodable {
var description: String = ""
var materialPath: [YHMaterialPath] = []
func isNeedShowTemplate() -> Bool {
if self.description.isEmpty && self.materialPath.isEmpty {
return false
}
return true
}
required init() {
}
......
......@@ -12,13 +12,16 @@ class YHCertificateNameCell: UITableViewCell {
static let cellReuseIdentifier = "YHCertificateNameCell"
var editBlock:((YHContentUrl)->())?
var whiteView: UIView!
var iconImgV: UIImageView!
var nameLabel: UILabel!
var timeLabel: UILabel!
var editBtn: UIButton!
var contentItem: YHContentUrl!
required init?(coder: NSCoder) {
super.init(coder: coder)
}
......@@ -29,10 +32,49 @@ class YHCertificateNameCell: UITableViewCell {
}
func updateModel(_ model: YHContentUrl) {
contentItem = model
nameLabel.text = model.name
timeLabel.text = "上传于\(model.updatedAt)"
var suffix = ""
var iconImgName = ""
if !model.url.pathExtension.isEmpty {
suffix = model.url.pathExtension
} else {
suffix = model.suffix
}
if suffix == "jpeg" {
iconImgName = "my_cer_type_jpg"
} else if suffix == "jpg" {
iconImgName = "my_cer_type_jpg"
} else if suffix == "png" {
iconImgName = "my_cer_type_png"
} else if suffix == "pdf" {
iconImgName = "my_cer_type_pdf"
} else if suffix == "doc" || suffix == "docx" {
iconImgName = "my_cer_type_word"
} else if suffix == "ppt" || suffix == "pptx" {
iconImgName = "my_cer_type_ppt"
}
iconImgV.image = UIImage(named: iconImgName)
}
@objc func didEditBtnClicked() {
if let editBlock = editBlock {
editBlock(contentItem)
}
}
func setupUI() {
self.selectionStyle = .none
......@@ -60,6 +102,8 @@ class YHCertificateNameCell: UITableViewCell {
editBtn = UIButton()
editBtn.setImage(UIImage(named:"my_cer_btn_edit"), for:.normal)
editBtn.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
editBtn.addTarget(self, action: #selector(didEditBtnClicked), for: .touchUpInside)
whiteView.addSubview(editBtn)
whiteView.snp.makeConstraints { make in
......
......@@ -11,14 +11,46 @@ import UIKit
class YHCertificateTemplateCell: UITableViewCell {
static let cellReuseIdentifier = "YHCertificateTemplateCell"
var templateInfo: YHTemplateInfo? {
didSet {
guard let templateInfo = templateInfo else {
contentView.isHidden = true
return
}
if templateInfo.description.isEmpty && templateInfo.materialPath.isEmpty {
contentView.isHidden = true
return
}
contentView.isHidden = false
if !templateInfo.name.isEmpty {
templateTitleLabel.text = "\(templateInfo.name)示例模版"
} else {
templateTitleLabel.text = ""
}
if !templateInfo.description.isEmpty {
tipsLabel.text = "注意事项: \(templateInfo.description)"
} else {
tipsLabel.text = ""
}
let noTemplate = templateInfo.materialPath.isEmpty
templateView.isHidden = noTemplate
templateView.snp.updateConstraints { make in
make.height.equalTo(noTemplate ? 0.0 : 62.0)
make.bottom.equalToSuperview().offset(noTemplate ? 0.0 : -34.0)
}
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
lazy var tipsLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor.labelTextColor2
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize:12)
label.numberOfLines = 0
label.text = "注意事项:这里是上传应该注意的事项这里是上传应该注意的事项这里是上传应该注意的事项。"
return label
}()
......@@ -27,7 +59,8 @@ class YHCertificateTemplateCell: UITableViewCell {
label.textColor = UIColor.mainTextColor
label.textAlignment = .left
label.font = UIFont.PFSC_M(ofSize:17)
label.text = "身份证示例模版"
label.text = "示例模版"
label.numberOfLines = 0
return label
}()
......@@ -49,6 +82,8 @@ class YHCertificateTemplateCell: UITableViewCell {
func createUI() {
self.selectionStyle = .none
contentView.addSubview(templateTitleLabel)
contentView.addSubview(tipsLabel)
contentView.addSubview(templateView)
......@@ -57,7 +92,6 @@ class YHCertificateTemplateCell: UITableViewCell {
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.top.equalToSuperview().offset(16)
make.height.equalTo(24.0)
}
tipsLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
......
......@@ -53,20 +53,20 @@ class YHCertificateTemplateView: UIView {
titleLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(16)
make.left.right.equalToSuperview()
make.height.equalTo(24)
make.left.equalToSuperview().offset(64)
make.right.equalToSuperview().offset(-64)
make.bottom.equalToSuperview().offset(-12)
}
closeBtn.snp.makeConstraints { make in
make.centerY.equalTo(titleLabel)
make.top.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-20)
make.width.height.equalTo(24)
}
closeBtn.YH_clickEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
closeBtn.YH_clickEdgeInsets = UIEdgeInsets(top: 15, left: 15, bottom: 15, right: 15)
line.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(1)
make.top.equalTo(titleLabel.snp.bottom).offset(12)
make.bottom.equalToSuperview()
}
return view
......@@ -91,6 +91,7 @@ class YHCertificateTemplateView: UIView {
label.textColor = UIColor.mainTextColor
label.textAlignment = .center
label.font = UIFont.PFSC_B(ofSize:17)
label.numberOfLines = 0
label.text = "示例模版"
return label
}()
......@@ -151,9 +152,9 @@ class YHCertificateTemplateView: UIView {
if !model.description.isEmpty {
tipsLabel.text = "注意事项:\(model.description)"
}
templateView.isHidden = model.materialPath.isEmpty
let topMargin = model.description.isEmpty ? 0 : 20
templateView.snp.updateConstraints { make in
make.top.equalTo(tipsLabel.snp.bottom).offset(topMargin)
}
......
......@@ -7,10 +7,10 @@
//
/*
【Usage】
let view = YHFileRenameInputView.inputView(defalutText:"adfasfsf", editBlock: {
text in
print("\(text)")
})
let view = YHFileRenameInputView.inputView(defalutText:"adfasfsf")
view.editBlock = {
text in
}
*/
import UIKit
......@@ -18,7 +18,7 @@ import UIKit
class YHFileRenameInputView: UIView {
static let height = 217.0
var editBlock:((String?)->())?
var editBlock:((String?)->Void)?
lazy var blackMaskView: UIView = {
let view = UIView(frame:UIScreen.main.bounds)
view.backgroundColor = UIColor(hex: 0x0F1214, alpha: 0.5)
......@@ -66,7 +66,7 @@ class YHFileRenameInputView: UIView {
lazy var textField:UITextField = {
let textField = UITextField()
textField.backgroundColor = .clear
textField.placeholder = "请输入文件名称"
textField.attributedPlaceholder = NSAttributedString(string: "请输入文件名称", attributes: [NSAttributedString.Key.foregroundColor : UIColor.placeHolderColor])
textField.font = UIFont.PFSC_M(ofSize: 16)
textField.tintColor = UIColor.brandMainColor
textField.textColor = UIColor.mainTextColor
......@@ -104,10 +104,9 @@ class YHFileRenameInputView: UIView {
fatalError("init(coder:) has not been implemented")
}
static func inputView(defalutText:String?, editBlock:((String?)->())?)-> YHFileRenameInputView {
static func inputView(defalutText:String?)-> YHFileRenameInputView {
let view = YHFileRenameInputView(frame:CGRect(x: 0, y: 0, width:KScreenWidth, height:Self.height))
view.textField.text = defalutText
view.editBlock = editBlock
return view
}
......@@ -186,10 +185,15 @@ extension YHFileRenameInputView {
}
@objc func didClickConfirmBtn() {
dismiss()
if isEmptyString(textField.text) {
YHHUD.flash(message: "重命名不可为空")
return
}
if let editBlock = editBlock {
editBlock(textField.text)
}
dismiss()
}
}
......
......@@ -137,7 +137,7 @@ class YHCertificateViewModel: YHBaseViewModel {
}
func uploadCertificates(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
......
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