Commit c99cfcbb authored by pete谢兆麟's avatar pete谢兆麟

设置编辑传值

parent 69d6d19a
......@@ -17,7 +17,8 @@ class YHEditBaseUserInfoViewController: YHBaseViewController {
var footView: YHEditBaseInfoFootView!
var items: [YHUserInformationModel] = []
var viewModel: YHEditViewModel = YHEditViewModel()
var model: YHUserNameCardInfo = YHUserNameCardInfo()
override func viewDidLoad() {
super.viewDidLoad()
setView()
......@@ -25,6 +26,7 @@ class YHEditBaseUserInfoViewController: YHBaseViewController {
}
func getData() {
viewModel.model = model
items = viewModel.getBaseDataSource()
tableView.reloadData()
}
......
......@@ -14,6 +14,7 @@ class YHEditHonorViewController: YHBaseViewController {
var numberLabel : UILabel!
var nextButton: UIButton!
var viewModel: YHEditViewModel = YHEditViewModel()
var model: YHUserNameCardInfo = YHUserNameCardInfo()
override func viewDidLoad() {
super.viewDidLoad()
......@@ -22,7 +23,8 @@ class YHEditHonorViewController: YHBaseViewController {
}
func getData() {
viewModel.model = model
}
func setView() {
......
......@@ -15,7 +15,8 @@ class YHEditInterestViewController: YHBaseViewController {
var normalItems: [YHInterestModel] = [YHInterestModel(name: "香港子女教育", isNormal: true, isSelect: false), YHInterestModel(name: "香港房产", isNormal: true, isSelect: false), YHInterestModel(name: "香港创业", isNormal: true, isSelect: false), YHInterestModel(name: "香港就业", isNormal: true, isSelect: false), YHInterestModel(name: "香港保险", isNormal: true, isSelect: false), YHInterestModel(name: "香港商务", isNormal: true, isSelect: false), YHInterestModel(name: "企业家", isNormal: true, isSelect: false), YHInterestModel(name: "ENTJ指挥家", isNormal: true, isSelect: false), YHInterestModel(name: "ENTP辩论家", isNormal: true, isSelect: false), YHInterestModel(name: "INTJ建筑师", isNormal: true, isSelect: false)]
var likeItems: [YHInterestModel] = [YHInterestModel(name: "ENTP辩论家", isNormal: false, isSelect: false), YHInterestModel(name: "+自定义", isNormal: false, isSelect: true)]
var viewModel: YHEditViewModel = YHEditViewModel()
var model: YHUserNameCardInfo = YHUserNameCardInfo()
lazy var blackMaskView: UIView = {
let view = UIView(frame:UIScreen.main.bounds)
view.backgroundColor = UIColor(hex: 0x0F1214, alpha: 0.5)
......@@ -36,7 +37,8 @@ class YHEditInterestViewController: YHBaseViewController {
}
func getData() {
viewModel.model = model
}
func setView() {
......
......@@ -14,6 +14,7 @@ class YHEditPersonalProfileViewController: YHBaseViewController {
var numberLabel : UILabel!
var nextButton: UIButton!
var viewModel: YHEditViewModel = YHEditViewModel()
var model: YHUserNameCardInfo = YHUserNameCardInfo()
override func viewDidLoad() {
super.viewDidLoad()
......@@ -22,7 +23,8 @@ class YHEditPersonalProfileViewController: YHBaseViewController {
}
func getData() {
viewModel.model = model
}
func setView() {
......
......@@ -13,7 +13,8 @@ class YHEditSchoolViewController: YHBaseViewController {
var tableView: UITableView!
var items: [YHUserInformationModel] = []
var viewModel: YHEditViewModel = YHEditViewModel()
var model: YHUserNameCardInfo = YHUserNameCardInfo()
override func viewDidLoad() {
super.viewDidLoad()
setView()
......@@ -21,6 +22,7 @@ class YHEditSchoolViewController: YHBaseViewController {
}
func getData() {
viewModel.model = model
items = viewModel.getBaseSchoolDataSource()
tableView.reloadData()
}
......
......@@ -13,7 +13,8 @@ class YHEditWorkViewController: YHBaseViewController {
var tableView: UITableView!
var items: [YHUserInformationModel] = []
var viewModel: YHEditViewModel = YHEditViewModel()
var model: YHUserNameCardInfo = YHUserNameCardInfo()
override func viewDidLoad() {
super.viewDidLoad()
setView()
......@@ -21,6 +22,7 @@ class YHEditWorkViewController: YHBaseViewController {
}
func getData() {
viewModel.model = model
items = viewModel.getBaseWorkDataSource()
tableView.reloadData()
}
......
......@@ -9,26 +9,23 @@
import UIKit
class YHEditViewModel: YHBaseViewModel {
var mainModel: YHMainUserInformationModel = YHMainUserInformationModel()
var model: YHUserNameCardInfo = YHUserNameCardInfo()
override init() {
super.init()
}
func getBaseDataSource() -> [YHUserInformationModel] {
let item1 = YHUserInformationModel(id: .id1, title: "真实姓名", isUserKeyBoard: true, prompts: "请输入您的真实姓名", message: mainModel.username)
let item2 = YHUserInformationModel(id: .id6, title: "所在地", isUserKeyBoard: false, prompts: "请选择您的所在地", message: mainModel.country, type: .country, value: mainModel.area)
let item1 = YHUserInformationModel(id: .id1, title: "真实姓名", isUserKeyBoard: true, prompts: "请输入您的真实姓名", message: model.username)
let item2 = YHUserInformationModel(id: .id6, title: "所在地", isUserKeyBoard: false, prompts: "请选择您的所在地", message: model.address.country, type: .country)
var string = ""
let array = mainModel.area
for item in array {
if string.count != 0 {
string = string + "/" + item
} else {
string = string + item
}
if model.address.province.count != 0 {
string = model.address.province + "/" + model.address.city
}
let item3 = YHUserInformationModel(id: .id2, title: "所在地-省市", isUserKeyBoard: false, prompts: "请选择您的所在地", message: string, type: .address, value: mainModel.area)
let item4 = YHUserInformationModel(id: .id7, title: "星座", isUserKeyBoard: false, prompts: "请选择您的星座", message: mainModel.constellation, type: .constellation)
if mainModel.country.contains("中国") {
let item3 = YHUserInformationModel(id: .id2, title: "所在地-省市", isUserKeyBoard: false, prompts: "请选择您的所在地", message: string, type: .address)
let item4 = YHUserInformationModel(id: .id7, title: "星座", isUserKeyBoard: false, prompts: "请选择您的星座", message: model.zodiac, type: .constellation)
if model.address.country.contains("中国") {
return [item1, item2, item3, item4]
}
return [item1, item2, item4]
......@@ -38,40 +35,41 @@ class YHEditViewModel: YHBaseViewModel {
guard let type = item.id else { return }
switch type {
case .id1:
mainModel.username = item.message ?? ""
model.username = item.message ?? ""
case .id2:
mainModel.area = item.value ?? []
model.address.province = item.value?.first ?? ""
model.address.city = item.value?.last ?? ""
case .id3:
mainModel.school = item.message ?? ""
model.college = item.message ?? ""
case .id4:
mainModel.industry = item.message ?? ""
model.industry = item.message ?? ""
case .id5:
mainModel.position = item.message ?? ""
model.position = item.message ?? ""
case .id6:
mainModel.country = item.message ?? ""
model.address.country = item.message ?? ""
case .id7:
mainModel.constellation = item.message ?? ""
model.zodiac = item.message ?? ""
case .id8:
mainModel.major = item.message ?? ""
model.major = item.message ?? ""
case .id9:
mainModel.degree = item.message ?? ""
model.background = item.message ?? ""
case .id10:
mainModel.company = item.message ?? ""
model.companyName = item.message ?? ""
}
}
func getBaseSchoolDataSource() -> [YHUserInformationModel] {
let item1 = YHUserInformationModel(id: .id3, title: "毕业院校", isUserKeyBoard: false, prompts: "请输入您的毕业院校", message: mainModel.school, type: .school)
let item2 = YHUserInformationModel(id: .id8, title: "专业", isUserKeyBoard: true, prompts: "请输入您的专业", message: mainModel.major)
let item3 = YHUserInformationModel(id: .id9, title: "学位", isUserKeyBoard: false, prompts: "请选择您的学位", message: mainModel.degree, type: .degree)
let item1 = YHUserInformationModel(id: .id3, title: "毕业院校", isUserKeyBoard: false, prompts: "请输入您的毕业院校", message: model.college, type: .school)
let item2 = YHUserInformationModel(id: .id8, title: "专业", isUserKeyBoard: true, prompts: "请输入您的专业", message: model.major)
let item3 = YHUserInformationModel(id: .id9, title: "学位", isUserKeyBoard: false, prompts: "请选择您的学位", message: model.background, type: .degree)
return [item1, item2, item3]
}
func getBaseWorkDataSource() -> [YHUserInformationModel] {
let item1 = YHUserInformationModel(id: .id10, title: "所在企业", isUserKeyBoard: true, prompts: "请输入您的所在企业", message: mainModel.company)
let item2 = YHUserInformationModel(id: .id5, title: "职位", isUserKeyBoard: true, prompts: "请输入您的职位", message: mainModel.position)
let item3 = YHUserInformationModel(id: .id4, title: "所在行业", isUserKeyBoard: false, prompts: "请选择您的所在行业", message: mainModel.industry, type: .id)
let item1 = YHUserInformationModel(id: .id10, title: "所在企业", isUserKeyBoard: true, prompts: "请输入您的所在企业", message: model.companyName)
let item2 = YHUserInformationModel(id: .id5, title: "职位", isUserKeyBoard: true, prompts: "请输入您的职位", message: model.position)
let item3 = YHUserInformationModel(id: .id4, title: "所在行业", isUserKeyBoard: false, prompts: "请选择您的所在行业", message: model.industry, type: .id)
return [item1, item2, item3]
}
......
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