Commit 4a0d12cd authored by pete谢兆麟's avatar pete谢兆麟

工作经验上传逻辑 工作经验step步骤逻辑 工作经验字段校验

parent 70009ba4
......@@ -92,12 +92,13 @@ class YHMainApplicantInformationViewController: YHBaseViewController {
bottom.nextblock = { [weak self] in
guard let self = self else { return }
if self.viewModel.isCanNext(self.stepView.currentIndex) {
self.stepView.currentIndex = self.stepView.currentIndex + 1
self.viewModel.mainModel.step = self.stepView.currentIndex
self.viewModel.updateMainInformation(.submit, self.orderId) {[weak self] success, error in
guard let self = self else { return }
if let error = error {
YHHUD.flash(message: error.errorMsg )
} else {
self.stepView.currentIndex = self.stepView.currentIndex + 1
self.isShowPrompt = false
self.stepView.currentIndex = self.stepView.currentIndex
if self.stepView.currentIndex == self.stepView.dataSource?.count {
......
......@@ -68,6 +68,7 @@ class YHStepView: UIScrollView {
make.left.equalTo(spaceWidth + i.cgFloat * (lineWidth + stepSpace * 2 + 14))
make.width.height.equalTo(14)
}
button.YH_clickEdgeInsets = UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50)
let label = UILabel()
label.text = array[i]
label.font = UIFont.PFSC_R(ofSize: 13)
......
......@@ -148,10 +148,14 @@ extension YHWorkExperienceListViewController: UITableViewDelegate, UITableViewDa
}
cell.newWorkBlock = {[weak self] in
guard let self = self else { return }
if self.dataSource?.count == 10 {
YHHUD.flash(message: "新增工作经历不能超过10条")
} else {
let vc = YHWorkExperienceViewController()
vc.orderID = self.orderId
self.navigationController?.pushViewController(vc, animated: true)
}
}
return cell
}
......
......@@ -9,17 +9,17 @@
import UIKit
class YHWorkExperienceViewController: YHBaseViewController {
var stepView: YHStepView!
var bottomView: YHBottomNextView!
var tableView: UITableView!
var viewModel: YHWorkExperienceViewModel!
var baseDataSource: [YHSectionWorkExperienceModel]?
var introductionDataSource: [YHWorkExperienceProjectModel]?
var fileDataSource: [String]?
var fileDataSource: [YHWorkExperienceFileModel]?
var workExperienceID: String?
var orderID: Int = 0
var isMore: Bool = false
var isShowPrompt: Bool = false
override func viewDidLoad() {
super.viewDidLoad()
......@@ -36,11 +36,18 @@ class YHWorkExperienceViewController: YHBaseViewController {
}
viewModel.requestWorkDetail(workExperienceID ?? "") {[weak self] success, error in
guard let self = self else { return }
self.stepView.currentIndex = self.viewModel.mainModel.step ?? 0
self.stepView.currentIndex = self.viewModel.mainModel.step
self.stepView.maxIndex = self.viewModel.mainModel.step
self.updateDataSource()
self.viewModel.requestWorkInfoProject("\(self.viewModel.mainModel.id ?? 0)") {[weak self] success, error in
if self.viewModel.mainModel.is_project_introduction == 1 {
self.stepView.dataSource = ["基本信息", "工作职责", "工作亮点", "项目介绍", "简历/工作总结"]
} else {
self.stepView.dataSource = ["基本信息", "工作职责", "工作亮点", "简历/工作总结"]
}
self.viewModel.requestWorkInfoProject("\(self.viewModel.mainModel.id )") {[weak self] success, error in
guard let self = self else { return }
self.introductionDataSource = success
self.fileDataSource = self.viewModel.mainModel.file
self.updateDataSource()
}
}
......@@ -49,7 +56,7 @@ class YHWorkExperienceViewController: YHBaseViewController {
func updateDataSource() {
if self.stepView.currentIndex == 0 {
self.baseDataSource = self.viewModel.getBaseDataSource()
self.baseDataSource = self.viewModel.getBaseDataSource(isShowPrompt)
}
self.tableView.reloadData()
}
......@@ -57,7 +64,7 @@ class YHWorkExperienceViewController: YHBaseViewController {
func setView() {
stepView = {
let step = YHStepView()
step.dataSource = ["基本信息", "工作职责", "工作亮点", "项目介绍", "简历/工作总结"]
step.dataSource = ["基本信息", "工作职责", "工作亮点", "简历/工作总结"]
step.contentSize = CGSize(width: KScreenWidth * 1.2, height: 104)
step.showsHorizontalScrollIndicator = false
step.showsVerticalScrollIndicator = false
......@@ -102,16 +109,37 @@ class YHWorkExperienceViewController: YHBaseViewController {
let bottom = YHBottomNextView()
bottom.nextblock = { [weak self] in
guard let self = self else { return }
self.viewModel.saveWorkDetail(1, orderID: self.orderID, callBackBlock: {[weak self] flag, model in
if self.viewModel.isCanNext(self.stepView.currentIndex) {
self.viewModel.mainModel.step = self.stepView.currentIndex
self.viewModel.saveWorkDetail(1, orderID: self.orderID, callBackBlock: {[weak self] flag, error in
guard let self = self else { return }
if let error = error {
YHHUD.flash(message: error.errorMsg )
} else {
if self.stepView.currentIndex == 4 || (self.stepView.currentIndex == 3 && self.viewModel.mainModel.is_project_introduction == 0) {
YHHUD.flash(message: "提交成功")
self.navigationController?.popViewController()
} else {
self.stepView.currentIndex = self.stepView.currentIndex + 1
self.updateDataSource()
}
}
})
} else {
self.isShowPrompt = true
self.updateDataSource()
YHHUD.flash(message: "您还有信息未填写")
}
}
bottom.saveBlock = { [weak self] in
guard let self = self else { return }
self.viewModel.saveWorkDetail(0, orderID: self.orderID, callBackBlock: {[weak self] flag, model in
self.viewModel.saveWorkDetail(0, orderID: self.orderID, callBackBlock: {[weak self] flag, error in
guard let self = self else { return }
if let error = error {
YHHUD.flash(message: error.errorMsg )
} else {
YHHUD.flash(message: "保存成功")
}
})
}
return bottom
......@@ -127,9 +155,19 @@ class YHWorkExperienceViewController: YHBaseViewController {
extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if stepView.currentIndex == 1 || stepView.currentIndex == 2 || stepView.currentIndex == 3 {
if stepView.currentIndex == 1 || stepView.currentIndex == 2 {
return 1
}
if stepView.currentIndex == 3 {
if self.viewModel.mainModel.is_project_introduction == 1 {
return 1
} else {
if viewModel.mainModel.not_need_upload_file == 1 {
return 1
}
return 2
}
}
if stepView.currentIndex == 4 {
if viewModel.mainModel.not_need_upload_file == 1 {
return 1
......@@ -160,6 +198,33 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
cell.messageBlock = {[weak self] message in
self?.viewModel.updateWduty(message)
}
cell.photoBlock = {[weak self] in
guard let self = self else { return }
YHImagePickerView.show() {[weak self] image in
guard let self = self else { return }
YHHUD.show(.progress(message: ""))
self.viewModel.uploadImage(image) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.viewModel.getPublicImageUrl(url) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.viewModel.requestFileMessage(url) {[weak self] success, model, error in
guard let self = self else { return }
if success {
YHHUD.hide()
self.viewModel.mainModel.wduty = model?.content ?? ""
cell.dataSource = viewModel.mainModel.wduty
} else {
YHHUD.hide()
YHHUD.flash(message: error?.errorMsg ?? "")
}
}
}
}
}
}
return cell
} else if stepView.currentIndex == 2 {
let cell = tableView.dequeueReusableCell(withClass: YHWorkHighlightsTableViewCell.self)
......@@ -183,9 +248,42 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
}
cell.switchBlock = {[weak self] isOn in
self?.viewModel.updateIsProjectIntroduction(isOn: isOn)
if isOn {
self?.stepView.dataSource = ["基本信息", "工作职责", "工作亮点", "项目介绍", "简历/工作总结"]
} else {
self?.stepView.dataSource = ["基本信息", "工作职责", "工作亮点", "简历/工作总结"]
}
}
cell.photoBlock = {[weak self] in
guard let self = self else { return }
YHImagePickerView.show() {[weak self] image in
guard let self = self else { return }
YHHUD.show(.progress(message: ""))
self.viewModel.uploadImage(image) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.viewModel.getPublicImageUrl(url) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.viewModel.requestFileMessage(url) {[weak self] success, model, error in
guard let self = self else { return }
if success {
YHHUD.hide()
self.viewModel.mainModel.highlights = model?.content ?? ""
cell.dataSource = viewModel.mainModel.highlights
} else {
YHHUD.hide()
YHHUD.flash(message: error?.errorMsg ?? "")
}
}
}
}
}
}
return cell
} else if stepView.currentIndex == 3 {
if self.viewModel.mainModel.is_project_introduction == 1 {
let cell = tableView.dequeueReusableCell(withClass: YHWorkIntroductionTableViewCell.self)
cell.dataSource = introductionDataSource
if isMore {
......@@ -226,6 +324,55 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
self.navigationController?.pushViewController(vc, animated: true)
}
return cell
} else {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withClass: YHWorkMessageSelectTableViewCell.self)
cell.dataSource = viewModel.mainModel.not_need_upload_file
cell.isNeedFileBlock = { [weak self] value in
guard let self = self else { return }
self.viewModel.updateNotNeedUploadFile(value: value)
self.tableView.reloadData()
}
return cell
} else {
let cell = tableView.dequeueReusableCell(withClass: YHWorkFileSyncTableViewCell.self)
cell.dataSource = fileDataSource
cell.addIntroductionBlock = { [weak self] in
guard let self = self else { return }
YHImagePickerView.show() {[weak self] image in
guard let self = self else { return }
YHHUD.show(.progress(message: ""))
self.viewModel.uploadImage(image) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
let timestamp = Date().timeIntervalSince1970
let model = YHWorkExperienceFileModel()
model.fileUrl = success ?? ""
model.fileName = "\(UInt64(timestamp))" + ".jpg"
self.fileDataSource?.append(model)
self.viewModel.mainModel.file = self.fileDataSource ?? []
self.tableView.reloadData()
YHHUD.hide()
}
}
}
cell.experienceListBlock = {[weak self] model, type in
guard let self = self else { return }
if type == .delete {
for i in 0..<(self.fileDataSource?.count ?? 0) {
let data = self.fileDataSource?[i]
if data?.fileName == model.fileName {
self.fileDataSource?.remove(at: i)
self.tableView.reloadData()
self.viewModel.mainModel.file = self.fileDataSource ?? []
return
}
}
}
}
return cell
}
}
} else if stepView.currentIndex == 4 {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withClass: YHWorkMessageSelectTableViewCell.self)
......@@ -238,6 +385,40 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
return cell
} else {
let cell = tableView.dequeueReusableCell(withClass: YHWorkFileSyncTableViewCell.self)
cell.dataSource = fileDataSource
cell.addIntroductionBlock = { [weak self] in
guard let self = self else { return }
YHImagePickerView.show() {[weak self] image in
guard let self = self else { return }
YHHUD.show(.progress(message: ""))
self.viewModel.uploadImage(image) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
let timestamp = Date().timeIntervalSince1970
let model = YHWorkExperienceFileModel()
model.fileUrl = success ?? ""
model.fileName = "\(UInt64(timestamp))" + ".jpg"
self.fileDataSource?.append(model)
self.viewModel.mainModel.file = self.fileDataSource ?? []
self.tableView.reloadData()
YHHUD.hide()
}
}
}
cell.experienceListBlock = {[weak self] model, type in
guard let self = self else { return }
if type == .delete {
for i in 0..<(self.fileDataSource?.count ?? 0) {
let data = self.fileDataSource?[i]
if data?.fileName == model.fileName {
self.fileDataSource?.remove(at: i)
self.tableView.reloadData()
self.viewModel.mainModel.file = self.fileDataSource ?? []
return
}
}
}
}
return cell
}
} else {
......@@ -256,20 +437,31 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
if stepView.currentIndex == 1 || stepView.currentIndex == 2 {
return KScreenHeight - k_Height_NavigationtBarAndStatuBar - YHStepView.height - k_Height_safeAreaInsetsBottom() - 64
} else if stepView.currentIndex == 3 {
if self.viewModel.mainModel.is_project_introduction == 1 {
let number = introductionDataSource?.count ?? 0
return CGFloat(76 * number + 161)
} else {
if indexPath.row == 0 {
return 166
} else {
let count = fileDataSource?.count ?? 0
return CGFloat(52 * count + 145)
}
}
} else if stepView.currentIndex == 4 {
if indexPath.row == 0 {
return 166
} else {
let count = fileDataSource?.count ?? 0
return CGFloat(52 * count + 138)
return CGFloat(52 * count + 145)
}
} else {
let array = baseDataSource?[indexPath.row].models ?? []
var h = 0
for i in 0..<array.count {
let data = array[i]
let message = data.message ?? ""
let isShow = data.isShowPrompts ?? false
if data.id == .id3 || data.id == .id4 || data.id == .id18 {
h = h + 132
} else if data.id == .id13 {
......@@ -277,6 +469,9 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
} else {
h = h + 52
}
if isShow && message.count == 0 {
h = h + 20
}
}
return CGFloat(h + 52 + 14)
}
......
......@@ -19,7 +19,7 @@ class YHWorkIntroductionViewController: YHBaseViewController {
var actionView: YHWorkActionView!
var bottomView: UIView!
var bottomButton: UIButton!
var viewModel: YHWorkIntroductionViewModel?
var viewModel: YHWorkIntroductionViewModel!
var workModel: YHWorkExperienceDetailModel?
var dataSource: YHWorkExperienceProjectModel = YHWorkExperienceProjectModel()
......@@ -201,6 +201,33 @@ class YHWorkIntroductionViewController: YHBaseViewController {
vc.modalPresentationStyle = .pageSheet
self.navigationController?.present(vc, animated: true)
}
view.photoBlock = {[weak self] in
guard let self = self else { return }
YHImagePickerView.show() {[weak self] image in
guard let self = self else { return }
YHHUD.show(.progress(message: "加载中"))
self.viewModel.uploadImage(image) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.viewModel.getPublicImageUrl(url) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.viewModel.requestFileMessage(url) {[weak self] success, model, error in
guard let self = self else { return }
if success {
YHHUD.hide()
self.dataSource.project_highlights = model?.content
self.messageTextField.text = model?.content
} else {
YHHUD.hide()
YHHUD.flash(message: error?.errorMsg ?? "")
}
}
}
}
}
}
return view
}()
view.addSubview(actionView)
......
......@@ -15,3 +15,7 @@ class YHWorkExampleModel: YHBaseModel {
var highlights_list: [String]?
var template: [String]?
}
class YHFileContent:YHBaseModel {
var content: String?
}
......@@ -36,7 +36,7 @@ class YHWorkExperienceDetailModel: YHBaseModel {
var is_executives: Int = 0
var wduty: String = ""
var highlights: String = ""
var file: [String] = []
var file: [YHWorkExperienceFileModel] = []
var not_need_upload_file: Int = 0
var company_member_total: Int = 0
var administrative_level: Int = 0
......@@ -59,3 +59,8 @@ class YHWorkExperienceDetailModel: YHBaseModel {
var customer_center_id: Int = 0
var projects: [String] = []
}
class YHWorkExperienceFileModel: YHBaseModel {
var fileName: String = ""
var fileUrl: String = ""
}
......@@ -58,8 +58,10 @@ struct YHWorkExperienceModel {
var rightButtonString: String?
var type: YHWorkExperienceSelectType?
var value: [String]?
var isShowPrompts: Bool?
var alertMessage: String?
init(id: YHWorkExperienceID? = nil, isNeed: Bool? = nil, title: String? = nil, isUserKeyBoard: Bool? = nil, prompts: String? = nil, message: String? = nil, leftButtonString: String? = nil, rightButtonString: String? = nil, type: YHWorkExperienceSelectType? = nil, value: [String]? = nil) {
init(id: YHWorkExperienceID? = nil, isNeed: Bool? = nil, title: String? = nil, isUserKeyBoard: Bool? = nil, prompts: String? = nil, message: String? = nil, leftButtonString: String? = nil, rightButtonString: String? = nil, type: YHWorkExperienceSelectType? = nil, value: [String]? = nil, isShowPrompts: Bool? = nil, alertMessage: String? = nil) {
self.id = id
self.isNeed = isNeed
self.title = title
......@@ -70,6 +72,8 @@ struct YHWorkExperienceModel {
self.rightButtonString = rightButtonString
self.type = type
self.value = value
self.isShowPrompts = isShowPrompts
self.alertMessage = alertMessage
}
}
......
......@@ -10,9 +10,11 @@ import UIKit
class YHWorkActionView: UIView {
typealias ExampleBlock = () -> ()
typealias PhotoBlock = () -> ()
var exampleBlock: ExampleBlock?
var photoBlock: PhotoBlock?
var photoButton: UIButton!
var wxButton: UIButton!
// var wxButton: UIButton!
var exampleButton: UIButton!
override init(frame: CGRect) {
......@@ -40,18 +42,18 @@ class YHWorkActionView: UIView {
make.height.width.equalTo(21)
}
wxButton = {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "work_experience_wx"), for: .normal)
button.addTarget(self, action: #selector(wxClick), for: .touchUpInside)
return button
}()
addSubview(wxButton)
wxButton.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalTo(49)
make.height.width.equalTo(21)
}
// wxButton = {
// let button = UIButton(type: .custom)
// button.setBackgroundImage(UIImage(named: "work_experience_wx"), for: .normal)
// button.addTarget(self, action: #selector(wxClick), for: .touchUpInside)
// return button
// }()
// addSubview(wxButton)
// wxButton.snp.makeConstraints { make in
// make.centerY.equalToSuperview()
// make.left.equalTo(49)
// make.height.width.equalTo(21)
// }
exampleButton = {
let button = UIButton(type: .custom)
......@@ -76,7 +78,9 @@ class YHWorkActionView: UIView {
}
@objc func photoClick() {
if let block = photoBlock {
block()
}
}
@objc func wxClick() {
......
......@@ -17,6 +17,7 @@ class YHWorkExperienceItemView: UIView {
var centerButton: UIButton!
var leftButton: UIButton!
var rightButton: UIButton!
var showPromptLabel: UILabel!
var dataSource: YHWorkExperienceModel? {
didSet {
......@@ -48,6 +49,8 @@ class YHWorkExperienceItemView: UIView {
messageTextField = {
let textField = UITextField()
textField.delegate = self
textField.textColor = UIColor.mainTextColor
textField.font = UIFont.PFSC_M(ofSize: 14)
return textField
}()
addSubview(messageTextField)
......@@ -56,6 +59,19 @@ class YHWorkExperienceItemView: UIView {
make.left.equalTo(112)
}
showPromptLabel = {
let label = UILabel()
label.textColor = UIColor.red
label.font = UIFont.PFSC_M(ofSize: 12)
return label
}()
addSubview(showPromptLabel)
showPromptLabel.snp.makeConstraints { make in
make.left.equalTo(messageTextField.snp.left)
make.height.equalTo(20)
make.right.bottom.equalToSuperview()
}
nextStepImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "form_right_arrow")
......@@ -115,7 +131,6 @@ class YHWorkExperienceItemView: UIView {
make.height.equalTo(32)
make.width.equalTo(74)
}
}
func updateAllViews() {
......@@ -141,6 +156,10 @@ class YHWorkExperienceItemView: UIView {
}
messageTextField.placeholder = dataSource.prompts
messageTextField.text = dataSource.message
if dataSource.message == "0" {
messageTextField.text = ""
}
showPromptLabel.text = dataSource.alertMessage
if dataSource.isUserKeyBoard ?? false {
nextStepImageView.isHidden = true
centerButton.isHidden = true
......@@ -205,6 +224,16 @@ class YHWorkExperienceItemView: UIView {
} else {
rightButton.isHidden = true
}
if dataSource.isShowPrompts ?? false {
if dataSource.message?.count != 0 && dataSource.message != "0" {
showPromptLabel.isHidden = true
} else {
showPromptLabel.isHidden = false
}
} else {
showPromptLabel.isHidden = true
}
}
func buttonState(isLeft: Bool) {
......
......@@ -99,8 +99,13 @@ class YHWorkExperienceTableViewCell: UITableViewCell {
}
y = y + 1
let data = dataSource?.models?[i]
let isShow = data?.isShowPrompts ?? false
let message = data?.message ?? ""
if data?.id == .id3 || data?.id == .id4 || data?.id == .id18 {
var h = 131
if isShow && message.count == 0 {
h = h + 20
}
let itemView = YHWorkExperienceTextItemView()
itemView.dataSource = data
itemView.block = {[weak self] model in
......@@ -113,15 +118,18 @@ class YHWorkExperienceTableViewCell: UITableViewCell {
itemView.snp.makeConstraints { make in
make.left.equalTo(18)
make.top.equalTo(y)
make.height.equalTo(131)
make.height.equalTo(h)
make.right.equalTo(-18)
}
y = y + 131
y = y + h
} else {
var h = 51
if data?.id == .id13 {
h = 71
}
if isShow && message.count == 0 {
h = h + 20
}
let itemView = YHWorkExperienceItemView()
itemView.dataSource = data
itemView.block = {[weak self] model in
......
......@@ -8,13 +8,18 @@
import UIKit
enum YHWorkFileClickType {
case delete
case click
}
class YHWorkFileItemView: UIView {
typealias ItemBlock = (_ model: YHItemModel) -> ()
typealias ItemBlock = (_ model: YHWorkExperienceFileModel, _ type: YHWorkFileClickType) -> ()
var block: ItemBlock?
var titleLabel: UILabel!
var titleLabel: UIButton!
var deleteButton: UIButton!
var dataSource: YHWorkItemListModel? {
var dataSource: YHWorkExperienceFileModel? {
didSet {
updateAllViews()
}
......@@ -31,10 +36,11 @@ class YHWorkFileItemView: UIView {
func setUpView() {
titleLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textAlignment = .left
label.textColor = UIColor.mainTextColor
let label = UIButton(type: .custom)
label.setTitleColor(UIColor.mainTextColor, for: .normal)
label.titleLabel?.font = UIFont.PFSC_M(ofSize: 14)
label.addTarget(self, action: #selector(itemClick), for: .touchUpInside)
label.contentHorizontalAlignment = .left
return label
}()
addSubview(titleLabel)
......@@ -48,11 +54,10 @@ class YHWorkFileItemView: UIView {
deleteButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_R(ofSize: 14)
button.contentHorizontalAlignment = .center
button.contentHorizontalAlignment = .right
button.setTitle("删除", for: .normal)
button.setTitleColor( UIColor(hex:0xf81d22), for: .normal)
button.setTitleColor(.red, for: .normal)
button.addTarget(self, action: #selector(deleteClick), for: .touchUpInside)
button.isHidden = true
return button
}()
addSubview(deleteButton)
......@@ -66,10 +71,18 @@ class YHWorkFileItemView: UIView {
func updateAllViews() {
guard let dataSource = dataSource else { return }
titleLabel.setTitle(dataSource.fileName, for: .normal)
}
@objc func itemClick() {
if let block = block, let dataSource = dataSource {
block(dataSource, .click)
}
}
@objc func deleteClick() {
if let block = block, let dataSource = dataSource {
block(dataSource, .delete)
}
}
}
......@@ -10,7 +10,7 @@ import UIKit
class YHWorkFileSyncTableViewCell: UITableViewCell {
typealias ExperienceListBlock = (_ model: YHItemModel) -> ()
typealias ExperienceListBlock = (_ model: YHWorkExperienceFileModel, _ type: YHWorkFileClickType) -> ()
typealias AddIntroductionBlock = () -> ()
var experienceListBlock: ExperienceListBlock?
var addIntroductionBlock: AddIntroductionBlock?
......@@ -18,7 +18,7 @@ class YHWorkFileSyncTableViewCell: UITableViewCell {
var titleLabel: UILabel!
var mainItemView: UIView!
var bottomView: YHWorkItemAddView!
var dataSource: [YHWorkItemListModel]?{
var dataSource: [YHWorkExperienceFileModel]?{
didSet {
updateAllViews()
}
......@@ -91,7 +91,7 @@ class YHWorkFileSyncTableViewCell: UITableViewCell {
mainItemView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.bottom.equalTo(-65)
make.top.equalTo(85)
make.top.equalTo(52)
}
bottomView = {
......@@ -127,10 +127,10 @@ class YHWorkFileSyncTableViewCell: UITableViewCell {
}
let itemView = YHWorkFileItemView()
itemView.dataSource = dataSource?[i]
itemView.block = {[weak self] model in
itemView.block = {[weak self] model, type in
guard let self = self else { return }
if let block = self.experienceListBlock {
block(model)
block(model, type)
}
}
mainItemView.addSubview(itemView)
......
......@@ -13,6 +13,7 @@ class YHWorkHighlightsTableViewCell: UITableViewCell {
typealias MessageBlock = (_ message: String) -> ()
typealias SwitchBlock = (_ isOn: Bool) -> ()
var exampleBlock: ExampleBlock?
var photoBlock: ExampleBlock?
var messageBlock: MessageBlock?
var switchBlock: SwitchBlock?
var centerView: UIView!
......@@ -179,6 +180,12 @@ class YHWorkHighlightsTableViewCell: UITableViewCell {
block()
}
}
view.photoBlock = {[weak self] in
guard let self = self else { return }
if let block = self.photoBlock {
block()
}
}
return view
}()
centerView.addSubview(bottomView)
......
......@@ -11,6 +11,7 @@ import UIKit
class YHWorkResponsibilitiesTableViewCell: UITableViewCell {
typealias ExampleBlock = () -> ()
typealias MessageBlock = (_ message: String) -> ()
var photoBlock: ExampleBlock?
var exampleBlock: ExampleBlock?
var messageBlock: MessageBlock?
var centerView: UIView!
......@@ -146,6 +147,13 @@ class YHWorkResponsibilitiesTableViewCell: UITableViewCell {
block()
}
}
view.photoBlock = {[weak self] in
guard let self = self else { return }
if let block = self.photoBlock {
block()
}
}
return view
}()
centerView.addSubview(bottomView)
......
......@@ -7,6 +7,7 @@
//
import UIKit
import Alamofire
class YHWorkExperienceViewModel: YHBaseViewModel {
var mainModel: YHWorkExperienceDetailModel = YHWorkExperienceDetailModel()
......@@ -16,24 +17,24 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
super.init()
}
func getBaseDataSource() -> [YHSectionWorkExperienceModel] {
let item = YHWorkExperienceModel(id: .id1, isNeed: true, title: "用人单位", isUserKeyBoard: false, prompts: "请输入", message: mainModel.company_name , type: .unit)
let item1 = YHWorkExperienceModel(id: .id2, isNeed: true, title: "用人单位性质", isUserKeyBoard: false, prompts: "请输入", message: mainModel.industry, type: .nature)
func getBaseDataSource(_ isShowPrompt: Bool) -> [YHSectionWorkExperienceModel] {
let item = YHWorkExperienceModel(id: .id1, isNeed: true, title: "用人单位", isUserKeyBoard: false, prompts: "请输入", message: mainModel.company_name , type: .unit, isShowPrompts: isShowPrompt, alertMessage:"请输入用人单位")
let item1 = YHWorkExperienceModel(id: .id2, isNeed: true, title: "用人单位性质", isUserKeyBoard: false, prompts: "请输入", message: mainModel.industry, type: .nature, isShowPrompts: isShowPrompt, alertMessage:"请选择用人单位性质")
let item2 = YHWorkExperienceModel(id: .id3, isNeed: false, title: "用人单位介绍", isUserKeyBoard: true, prompts: "如方便提供,请填写", message: mainModel.company_introduce)
let item3 = YHWorkExperienceModel(id: .id4, isNeed: false, title: "用人单位官网", isUserKeyBoard: true, prompts: "如有,请输入官网链接", message: mainModel.company_website)
let item4 = YHWorkExperienceModel(id: .id5, isNeed: true, title: "出生国家/地区", isUserKeyBoard: false, prompts: nil, message: mainModel.location.country, type: .country)
let item4 = YHWorkExperienceModel(id: .id5, isNeed: true, title: "出生国家/地区", isUserKeyBoard: false, prompts: nil, message: mainModel.location.country, type: .country, isShowPrompts: isShowPrompt, alertMessage:"请选择工作国家/地区")
var string = ""
let array = mainModel.location.area
for item in array {
string = string + item
}
let item5 = YHWorkExperienceModel(id: .id6, isNeed: true, title: "出生城市", isUserKeyBoard: false, prompts: "请选择", message: string, type: .address)
let item55 = YHWorkExperienceModel(id: .id7, isNeed: true, title: "出生城市", isUserKeyBoard: true, prompts: "请输入", message: mainModel.location.foreign)
let item6 = YHWorkExperienceModel(id: .id8, isNeed: true, title: "职位", isUserKeyBoard: true, prompts: "请输入", message: mainModel.position)
let item7 = YHWorkExperienceModel(id: .id9, isNeed: true, title: "入职年月", isUserKeyBoard: false, prompts: "请选择", message: mainModel.entry_time, type: .time)
let item8 = YHWorkExperienceModel(id: .id10, isNeed: true, title: "离职年月", isUserKeyBoard: false, prompts: "请选择", message: mainModel.departure_time, type: .time)
let item9 = YHWorkExperienceModel(id: .id11, isNeed: true, title: "工作证明文件", isUserKeyBoard: false, prompts: "请选择", message: mainModel.work_certificate, type: .certificate)
let item10 = YHWorkExperienceModel(id: .id12, isNeed: false, title: "职责性质", isUserKeyBoard: true, prompts: "请选择", message: mainModel.duty)
let item5 = YHWorkExperienceModel(id: .id6, isNeed: true, title: "出生城市", isUserKeyBoard: false, prompts: "请选择", message: string, type: .address, isShowPrompts: isShowPrompt, alertMessage:"请选择工作国家/地区")
let item55 = YHWorkExperienceModel(id: .id7, isNeed: true, title: "出生城市", isUserKeyBoard: true, prompts: "请输入", message: mainModel.location.foreign, isShowPrompts: isShowPrompt, alertMessage:"请输入工作国家/地区")
let item6 = YHWorkExperienceModel(id: .id8, isNeed: true, title: "职位", isUserKeyBoard: true, prompts: "请输入", message: mainModel.position, isShowPrompts: isShowPrompt, alertMessage:"请输入职位")
let item7 = YHWorkExperienceModel(id: .id9, isNeed: true, title: "入职年月", isUserKeyBoard: false, prompts: "请选择", message: mainModel.entry_time, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择入职年月")
let item8 = YHWorkExperienceModel(id: .id10, isNeed: true, title: "离职年月", isUserKeyBoard: false, prompts: "请选择", message: mainModel.departure_time, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择离职年月")
let item9 = YHWorkExperienceModel(id: .id11, isNeed: true, title: "工作证明文件", isUserKeyBoard: false, prompts: "请选择", message: mainModel.work_certificate, type: .certificate, isShowPrompts: isShowPrompt, alertMessage:"请选择工作证明文件")
let item10 = YHWorkExperienceModel(id: .id12, isNeed: false, title: "职责性质", isUserKeyBoard: true, prompts: "请选择", message: mainModel.duty, isShowPrompts: isShowPrompt, alertMessage:"请输入职责性质")
let item11 = YHWorkExperienceModel(id: .id13, isNeed: false, title: "相关工作经验是否属于国际工作经验", isUserKeyBoard: false, prompts: "", message: "\(mainModel.international_work_experience)", leftButtonString: "是", rightButtonString: "否")
let addressCountry = mainModel.location.country
var section = YHSectionWorkExperienceModel()
......@@ -43,15 +44,15 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
section = YHSectionWorkExperienceModel(title: "企业信息", models: [item, item1, item2, item3, item4, item55, item6, item7, item8, item9, item10, item11])
}
let item12 = YHWorkExperienceModel(id: .id14, isNeed: true, title: "企业人数规模", isUserKeyBoard: true, prompts: "请输入", message: "\(mainModel.company_member_total)")
let item12 = YHWorkExperienceModel(id: .id14, isNeed: true, title: "企业人数规模", isUserKeyBoard: true, prompts: "请输入", message: "\(mainModel.company_member_total)", isShowPrompts: isShowPrompt, alertMessage:"请输入企业人数规模")
let item13 = YHWorkExperienceModel(id: .id15, isNeed: false, title: "行政架构层级", isUserKeyBoard: false, prompts: "请输入", message: "\(mainModel.administrative_level)", type: .structure)
let item14 = YHWorkExperienceModel(id: .id16, isNeed: true, title: "下属管理人数", isUserKeyBoard: true, prompts: "请输入", message: "\(mainModel.company_manage_total)")
let item14 = YHWorkExperienceModel(id: .id16, isNeed: true, title: "下属管理人数", isUserKeyBoard: true, prompts: "请输入", message: "\(mainModel.company_manage_total)", isShowPrompts: isShowPrompt, alertMessage:"请输入下属管理人数")
let item15 = YHWorkExperienceModel(id: .id17, isNeed: false, title: "公司营业额/港元 (近一年)", isUserKeyBoard: true, prompts: "请输入具体数字", message: "\(mainModel.turnover)")
let item16 = YHWorkExperienceModel(id: .id18, isNeed: false, title: "公司业务性质/范畴/所属行业", isUserKeyBoard: true, prompts: "请输入,100字内", message: mainModel.business_nature)
let item17 = YHWorkExperienceModel(id: .id19, isNeed: true, title: "职位水平类别", isUserKeyBoard: false, prompts: "请选择", message: "\(mainModel.professional_level)", type: .level)
let item18 = YHWorkExperienceModel(id: .id20, isNeed: true, title: "高管证明文件", isUserKeyBoard: false, prompts: "请选择", message: mainModel.executives_certificate, type: .prove)
let item19 = YHWorkExperienceModel(id: .id21, isNeed: true, title: "高管在职开始时间", isUserKeyBoard: false, prompts: "请选择", message: mainModel.top_manager_start_at, type: .time)
let item20 = YHWorkExperienceModel(id: .id22, isNeed: true, title: "高管在职结束时间", isUserKeyBoard: false, prompts: "请选择", message: mainModel.top_manager_end_at, type: .time)
let item17 = YHWorkExperienceModel(id: .id19, isNeed: true, title: "职位水平类别", isUserKeyBoard: false, prompts: "请选择", message: "\(mainModel.professional_level)", type: .level, isShowPrompts: isShowPrompt, alertMessage:"请选择职位水平类别")
let item18 = YHWorkExperienceModel(id: .id20, isNeed: true, title: "高管证明文件", isUserKeyBoard: false, prompts: "请选择", message: mainModel.executives_certificate, type: .prove, isShowPrompts: isShowPrompt, alertMessage:"请选择高管证明文件")
let item19 = YHWorkExperienceModel(id: .id21, isNeed: true, title: "高管在职开始时间", isUserKeyBoard: false, prompts: "请选择", message: mainModel.top_manager_start_at, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择入职年月")
let item20 = YHWorkExperienceModel(id: .id22, isNeed: true, title: "高管在职结束时间", isUserKeyBoard: false, prompts: "请选择", message: mainModel.top_manager_end_at, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择离职年月")
var section1 = YHSectionWorkExperienceModel()
if mainModel.professional_level == 1 {
section1 = YHSectionWorkExperienceModel(title: "企业规模", models: [item12, item13, item14, item15, item16, item17, item18, item19, item20])
......@@ -174,6 +175,12 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
"country": mainModel.location.country,
"details": mainModel.location.details,
"foreign": mainModel.location.foreign] as [String : Any]
var file: [[String : Any]] = []
for item in mainModel.file {
let fileDic = ["fileName": item.fileName,
"fileUrl": item.fileUrl]
file.append(fileDic)
}
let params: [String : Any] = ["administrative_level": mainModel.administrative_level,
"business_nature": mainModel.business_nature,
"business_remark":mainModel.business_remark,
......@@ -190,7 +197,7 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
"duty": mainModel.duty,
"entry_time": mainModel.entry_time,
"executives_certificate": mainModel.executives_certificate,
"file": mainModel.file,
"file": file,
"highlights": mainModel.highlights,
"id": mainModel.id,
"order_id": orderID,
......@@ -269,4 +276,116 @@ class YHWorkExperienceViewModel: YHBaseViewModel {
}
}
// 上传方法
func uploadImage(_ image: UIImage, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
let strUrl = "https://test-comserver.galaxy-immi.com/oss/upload/storage"
let boundary = UUID().uuidString
let headers: HTTPHeaders = [
"Content-type": "multipart/form-data; boundary=\(boundary)",
"businessCode": "4001001"
]
let _ = YHNetRequest.uplaodRequest(url: strUrl, headers: headers, image: image) { [weak self] json, code in
guard let _ = self else { return }
if json.code == 200 {
callBackBlock(json.data as? String, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(nil, error)
}
} failBlock: { err in
callBackBlock(nil, err)
}
}
func getPublicImageUrl(_ url: String, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
let strUrl = "https://test-comserver.galaxy-immi.com/oss/storage/convertToPublicURL" + "?fileUrl=\(url)"
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象
guard let _ = self else { return }
if json.code == 200 {
callBackBlock(json.data as? String, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(nil, error)
}
} failBlock: { err in
callBackBlock(nil,err)
}
}
func requestFileMessage(_ url: String, callBackBlock:@escaping (_ success: Bool, _ model: YHFileContent?,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.WorkExperience.ocrFileContent + "?file_url=\(url)"
// let params: [String : Any] = ["url": url]
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
guard let result = YHFileContent.deserialize(from: dic as? Dictionary) else {
callBackBlock(false, nil, nil)
return
}
callBackBlock(true, result, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, nil,error)
}
} failBlock: { err in
callBackBlock(false, nil, err)
}
}
func isCanNext(_ step: Int) -> Bool {
if step == 0 {
let companyName = mainModel.company_name //公司名称
let industry = mainModel.industry //用人单位性质
let country = mainModel.location.country //工作国家
let area = mainModel.location.area //工作城市
let foreign = mainModel.location.foreign //工作城市 国外
let entryTime = mainModel.entry_time //入职年月
let departureTime = mainModel.departure_time //离职年月
let workCertificate = mainModel.work_certificate //工作证明文件
let duty = mainModel.duty //职责性质
let companyMemberTotal = mainModel.company_member_total //企业人数规模
let companyManageTotal = mainModel.company_manage_total //下属管理人数
let professionalLevel = mainModel.professional_level //职位水平类别
let executivesCertificate = mainModel.executives_certificate //高管证明文件
let topManagerStartAt = mainModel.top_manager_start_at //高管在职开始时间
let topManagerEndAt = mainModel.top_manager_end_at //高管在职开始时间
guard companyName.count > 0 else { return false }
guard industry.count > 0 else { return false }
guard country.count > 0 else { return false }
guard entryTime.count > 0 else { return false }
guard workCertificate.count > 0 else { return false }
guard duty.count > 0 else { return false }
guard companyMemberTotal > 0 else { return false }
guard companyManageTotal > 0 else { return false }
guard professionalLevel > 0 else { return false }
if country.contains("中国") {
guard area.count > 0 else { return false }
} else {
guard foreign.count > 0 else { return false }
}
if professionalLevel == 1 {
guard executivesCertificate.count > 0 else { return false }
guard topManagerStartAt.count > 0 else { return false }
guard topManagerEndAt.count > 0 else { return false }
}
return true
} else if step == 1 {
let message = mainModel.wduty
guard message.count > 0 else { return false }
return true
} else if step == 2 {
let message = mainModel.highlights
guard message.count > 0 else { return false }
return true
} else if step == 3 {
let message = mainModel.highlights
return true
} else {
return true
}
}
}
......@@ -7,6 +7,7 @@
//
import UIKit
import Alamofire
class YHWorkIntroductionViewModel: YHBaseViewModel {
var introducetionExampleModels: [YHWorkExampleModel]?
......@@ -52,5 +53,65 @@ class YHWorkIntroductionViewModel: YHBaseViewModel {
callBackBlock(false, err)
}
}
// 上传方法
func uploadImage(_ image: UIImage, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
let strUrl = "https://test-comserver.galaxy-immi.com/oss/upload/storage"
let boundary = UUID().uuidString
let headers: HTTPHeaders = [
"Content-type": "multipart/form-data; boundary=\(boundary)",
"businessCode": "4001001"
]
let _ = YHNetRequest.uplaodRequest(url: strUrl, headers: headers, image: image) { [weak self] json, code in
guard let _ = self else { return }
if json.code == 200 {
callBackBlock(json.data as? String, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(nil, error)
}
} failBlock: { err in
callBackBlock(nil, err)
}
}
func getPublicImageUrl(_ url: String, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
let strUrl = "https://test-comserver.galaxy-immi.com/oss/storage/convertToPublicURL" + "?fileUrl=\(url)"
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象
guard let _ = self else { return }
if json.code == 200 {
callBackBlock(json.data as? String, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(nil, error)
}
} failBlock: { err in
callBackBlock(nil,err)
}
}
func requestFileMessage(_ url: String, callBackBlock:@escaping (_ success: Bool, _ model: YHFileContent?,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.WorkExperience.ocrFileContent + "?file_url=\(url)"
// let params: [String : Any] = ["url": url]
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
guard let result = YHFileContent.deserialize(from: dic as? Dictionary) else {
callBackBlock(false, nil, nil)
return
}
callBackBlock(true, result, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, nil,error)
}
} failBlock: { err in
callBackBlock(false, nil, err)
}
}
}
......@@ -126,3 +126,35 @@ extension UIButton {
return self as! T
}
}
// 扩大点击范围
extension UIButton{
private struct RuntimeKey {
static let clickEdgeInsets = UnsafeRawPointer.init(bitPattern: "clickEdgeInsets".hashValue)
}
/// 需要扩充的点击边距
public var YH_clickEdgeInsets: UIEdgeInsets? {
set {
objc_setAssociatedObject(self, UIButton.RuntimeKey.clickEdgeInsets!, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_COPY)
}
get {
return objc_getAssociatedObject(self, UIButton.RuntimeKey.clickEdgeInsets!) as? UIEdgeInsets ?? UIEdgeInsets.zero
}
}
// 重写系统方法修改点击区域
open override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
super.point(inside: point, with: event)
var bounds = self.bounds
if (YH_clickEdgeInsets != nil) {
let x: CGFloat = -(YH_clickEdgeInsets?.left ?? 0)
let y: CGFloat = -(YH_clickEdgeInsets?.top ?? 0)
let width: CGFloat = bounds.width + (YH_clickEdgeInsets?.left ?? 0) + (YH_clickEdgeInsets?.right ?? 0)
let height: CGFloat = bounds.height + (YH_clickEdgeInsets?.top ?? 0) + (YH_clickEdgeInsets?.bottom ?? 0)
bounds = CGRect(x: x, y: y, width: width, height: height) //负值是方法响应范围
}
return bounds.contains(point)
}
}
......@@ -95,13 +95,13 @@ class YHNetRequest: NSObject {
requestHeader.add(name:"sign",value:sign)
requestHeader.add(name: "token", value: YHLoginManager.shared.userModel?.token ?? "-")
testToken(&requestHeader) //for test hjl 使用固定token
// testToken(&requestHeader) //for test hjl 使用固定token
headers = requestHeader
}
private func testToken(_ requestHeader:inout HTTPHeaders) {
//金龙的账号
requestHeader.add(name: "token", value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTE2MDcwNjQsImkiOjE0NDg0MTczMjc0MjE2LCJ1Ijoi6ZO25rKz6ZuG5ZuiIiwiciI6InN1cGVyX2FwcCJ9.KwTWdaLy5UG4LLs6i-D9ne0RflRTT5v4zvu-66yihDE")
// requestHeader.add(name: "token", value:/* "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTE2MDcwNjQsImkiOjE0NDg0MTczMjc0MjE2LCJ1Ijoi6ZO25rKz6ZuG5ZuiIiwiciI6InN1cGVyX2FwcCJ9.KwTWdaLy5UG4LLs6i-D9ne0RflRTT5v4zvu-66yihDE")*/
// requestHeader.add(name: "token", value:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTE3ODI1OTUsImkiOjEyNDMwMTA1MTY0OTA0LCJ1Ijoi6ZO25rKz6ZuG5ZuiIiwiciI6InN1cGVyX2FwcCJ9.jqWpIf3SmbetApdErmBIYh-YEhX1zF_WqgqgOq5oI2A")
}
......
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