Commit 746ed517 authored by pete谢兆麟's avatar pete谢兆麟

红点逻辑

parent ae4756da
...@@ -29,8 +29,9 @@ struct YHUserInformationModel { ...@@ -29,8 +29,9 @@ struct YHUserInformationModel {
var message: String? var message: String?
var type: YHItemSelectType? var type: YHItemSelectType?
var value: [String]? var value: [String]?
var isNeed: Bool?
init(id: YHUserInformationID? = nil, title: String? = nil, isUserKeyBoard: Bool? = nil, prompts: String? = nil, message: String? = nil, type: YHItemSelectType? = nil, value: [String]? = nil) { init(id: YHUserInformationID? = nil, title: String? = nil, isUserKeyBoard: Bool? = nil, prompts: String? = nil, message: String? = nil, type: YHItemSelectType? = nil, value: [String]? = nil, isNeed: Bool? = nil) {
self.id = id self.id = id
self.title = title self.title = title
self.isUserKeyBoard = isUserKeyBoard self.isUserKeyBoard = isUserKeyBoard
...@@ -38,6 +39,7 @@ struct YHUserInformationModel { ...@@ -38,6 +39,7 @@ struct YHUserInformationModel {
self.message = message self.message = message
self.type = type self.type = type
self.value = value self.value = value
self.isNeed = isNeed
} }
} }
......
...@@ -107,13 +107,25 @@ class YHMyInformationItemCell: UITableViewCell { ...@@ -107,13 +107,25 @@ class YHMyInformationItemCell: UITableViewCell {
func updateAllViews() { func updateAllViews() {
guard let dataSource = dataSource else { return } guard let dataSource = dataSource else { return }
let str = dataSource.title ?? "" if dataSource.isNeed ?? false {
let attributes: [NSAttributedString.Key: Any] = [ let str = "*" + (dataSource.title ?? "")
.font: UIFont.PFSC_R(ofSize: 14), let attributes: [NSAttributedString.Key: Any] = [
.foregroundColor: UIColor.mainTextColor .font: UIFont.PFSC_R(ofSize: 14),
] .foregroundColor: UIColor.mainTextColor
let questionAttrStr = NSMutableAttributedString(string: str, attributes: attributes) ]
titleLabel.attributedText = questionAttrStr let questionAttrStr = NSMutableAttributedString(string: str, attributes: attributes)
let starRange = NSRange(location: 0, length: 1)
questionAttrStr.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.failColor, range: starRange)
titleLabel.attributedText = questionAttrStr
} else {
let str = dataSource.title ?? ""
let attributes: [NSAttributedString.Key: Any] = [
.font: UIFont.PFSC_R(ofSize: 14),
.foregroundColor: UIColor.mainTextColor
]
let questionAttrStr = NSMutableAttributedString(string: str, attributes: attributes)
titleLabel.attributedText = questionAttrStr
}
messageTextField.placeholder = dataSource.prompts messageTextField.placeholder = dataSource.prompts
messageTextField.text = dataSource.message messageTextField.text = dataSource.message
if dataSource.isUserKeyBoard ?? false { if dataSource.isUserKeyBoard ?? false {
......
...@@ -16,17 +16,17 @@ class YHInformationAuthorizeViewModel: YHBaseViewModel { ...@@ -16,17 +16,17 @@ class YHInformationAuthorizeViewModel: YHBaseViewModel {
} }
func getBaseDataSource() -> [YHUserInformationModel] { func getBaseDataSource() -> [YHUserInformationModel] {
let item1 = YHUserInformationModel(id: .id1, title: "真实姓名", isUserKeyBoard: true, prompts: "请输入您的真实姓名", message: model.username) let item1 = YHUserInformationModel(id: .id1, title: "真实姓名", isUserKeyBoard: true, prompts: "请输入您的真实姓名", message: model.username, isNeed: false)
let item2 = YHUserInformationModel(id: .id6, title: "所在地", isUserKeyBoard: false, prompts: "请选择您的所在地", message: model.address.country, type: .country) let item2 = YHUserInformationModel(id: .id6, title: "所在地", isUserKeyBoard: false, prompts: "请选择您的所在地", message: model.address.country, type: .country, isNeed: false)
var string = "" var string = ""
if model.address.province.count != 0 { if model.address.province.count != 0 {
string = model.address.province + "/" + model.address.city string = model.address.province + "/" + model.address.city
} }
let item3 = YHUserInformationModel(id: .id2, title: "所在地-省市", isUserKeyBoard: false, prompts: "请选择您的所在地", message: string, type: .address) let item3 = YHUserInformationModel(id: .id2, title: "所在地-省市", isUserKeyBoard: false, prompts: "请选择您的所在地", message: string, type: .address, isNeed: false)
let item4 = YHUserInformationModel(id: .id3, title: "毕业院校", isUserKeyBoard: true, prompts: "请输入您的毕业院校", message: model.college) let item4 = YHUserInformationModel(id: .id3, title: "毕业院校", isUserKeyBoard: true, prompts: "请输入您的毕业院校", message: model.college, isNeed: false)
let item5 = YHUserInformationModel(id: .id4, title: "所属行业", isUserKeyBoard: false, prompts: "请选择您的所属行业", message: model.industry, type: .id) let item5 = YHUserInformationModel(id: .id4, title: "所属行业", isUserKeyBoard: false, prompts: "请选择您的所属行业", message: model.industry, type: .id, isNeed: false)
let item6 = YHUserInformationModel(id: .id5, title: "职位", isUserKeyBoard: true, prompts: "请输入您的职位", message: model.position) let item6 = YHUserInformationModel(id: .id5, title: "职位", isUserKeyBoard: true, prompts: "请输入您的职位", message: model.position, isNeed: false)
if model.address.country.contains("中国") { if model.address.country.contains("中国") {
return [item1, item2, item3, item4, item5, item6] return [item1, item2, item3, item4, item5, item6]
} }
......
...@@ -38,15 +38,15 @@ class YHEditViewModel: YHBaseViewModel { ...@@ -38,15 +38,15 @@ class YHEditViewModel: YHBaseViewModel {
} }
func getBaseDataSource() -> [YHUserInformationModel] { func getBaseDataSource() -> [YHUserInformationModel] {
let item1 = YHUserInformationModel(id: .id1, title: "真实姓名", isUserKeyBoard: true, prompts: "请输入您的真实姓名", message: model.username) let item1 = YHUserInformationModel(id: .id1, title: "真实姓名", isUserKeyBoard: true, prompts: "请输入您的真实姓名", message: model.username, isNeed: true)
let item2 = YHUserInformationModel(id: .id6, title: "所在地", isUserKeyBoard: false, prompts: "请选择您的所在地", message: model.address.country, type: .country) let item2 = YHUserInformationModel(id: .id6, title: "所在地", isUserKeyBoard: false, prompts: "请选择您的所在地", message: model.address.country, type: .country, isNeed: true)
var string = "" var string = ""
if model.address.province.count != 0 { if model.address.province.count != 0 {
string = model.address.province + "/" + model.address.city string = model.address.province + "/" + model.address.city
} }
let item3 = YHUserInformationModel(id: .id2, title: "所在地-省市", isUserKeyBoard: false, prompts: "请选择您的所在地", message: string, type: .address) let item3 = YHUserInformationModel(id: .id2, title: "所在地-省市", isUserKeyBoard: false, prompts: "请选择您的所在地", message: string, type: .address, isNeed: true)
let item4 = YHUserInformationModel(id: .id7, title: "星座", isUserKeyBoard: false, prompts: "请选择您的星座", message: model.zodiac, type: .constellation) let item4 = YHUserInformationModel(id: .id7, title: "星座", isUserKeyBoard: false, prompts: "请选择您的星座", message: model.zodiac, type: .constellation, isNeed: false)
if model.address.country.contains("中国") { if model.address.country.contains("中国") {
return [item1, item2, item3, item4] return [item1, item2, item3, item4]
} }
...@@ -82,17 +82,17 @@ class YHEditViewModel: YHBaseViewModel { ...@@ -82,17 +82,17 @@ class YHEditViewModel: YHBaseViewModel {
} }
func getBaseSchoolDataSource() -> [YHUserInformationModel] { func getBaseSchoolDataSource() -> [YHUserInformationModel] {
let item1 = YHUserInformationModel(id: .id3, title: "毕业院校", isUserKeyBoard: true, prompts: "请输入您的毕业院校", message: model.college) let item1 = YHUserInformationModel(id: .id3, title: "毕业院校", isUserKeyBoard: true, prompts: "请输入您的毕业院校", message: model.college, isNeed: true)
let item2 = YHUserInformationModel(id: .id8, title: "专业", isUserKeyBoard: true, prompts: "请输入您的专业", message: model.major) let item2 = YHUserInformationModel(id: .id8, title: "专业", isUserKeyBoard: true, prompts: "请输入您的专业", message: model.major, isNeed: false)
let item3 = YHUserInformationModel(id: .id9, title: "学位", isUserKeyBoard: false, prompts: "请选择您的学位", message: model.background, type: .degree) let item3 = YHUserInformationModel(id: .id9, title: "学位", isUserKeyBoard: false, prompts: "请选择您的学位", message: model.background, type: .degree, isNeed: false)
return [item1, item2, item3] return [item1, item2, item3]
} }
func getBaseWorkDataSource() -> [YHUserInformationModel] { func getBaseWorkDataSource() -> [YHUserInformationModel] {
let item1 = YHUserInformationModel(id: .id10, title: "所在企业", isUserKeyBoard: true, prompts: "请输入您的所在企业", message: model.companyName) let item1 = YHUserInformationModel(id: .id10, title: "所在企业", isUserKeyBoard: true, prompts: "请输入您的所在企业", message: model.companyName, isNeed: false)
let item2 = YHUserInformationModel(id: .id5, title: "职位", isUserKeyBoard: true, prompts: "请输入您的职位", message: model.position) let item2 = YHUserInformationModel(id: .id5, title: "职位", isUserKeyBoard: true, prompts: "请输入您的职位", message: model.position, isNeed: true)
let item3 = YHUserInformationModel(id: .id4, title: "所在行业", isUserKeyBoard: false, prompts: "请选择您的所在行业", message: model.industry, type: .id) let item3 = YHUserInformationModel(id: .id4, title: "所在行业", isUserKeyBoard: false, prompts: "请选择您的所在行业", message: model.industry, type: .id, isNeed: true)
return [item1, item2, item3] 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