Commit d036f520 authored by David黄金龙's avatar David黄金龙

Merge branch 'develop' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into develop

* 'develop' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS:
  长期按钮添加 时间选择器标题
  // 学历资格
  // 类名更改
  // 家庭成员
  // 家庭成员
  // 城市选择器
  主申请人国家搜索优化  字段校验优化
  // 字数限制
  主申请人相关bug处理
  // 字数限制
  图片点击放大
  相片裁剪 识别逻辑UI
parents feccbf0e 1c44327b
This diff is collapsed.
......@@ -368,7 +368,7 @@ extension YHInformationPerfectListVC : UITableViewDelegate,UITableViewDataSource
} else if indexPath.row == 1 {
//家庭程序信息
let vc = YHFamilyMemberInfoVC(orderId: orderId ?? 0)
let vc = YHFamilyMemberInfoListVC(orderId: orderId ?? 0)
vc.orderId = orderId ?? 0
navigationController?.pushViewController(vc)
......
......@@ -70,7 +70,7 @@ class YHEducationDetailVC: YHBaseViewController {
bottomView.saveBlock = {
[weak self] in
guard let self = self else { return }
saveDetailInfo(isNeedPop: true)
saveDetailInfo(isNeedPop: true, isShowToast: true)
}
bottomView.submitBlock = {
......@@ -228,7 +228,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
if isEditEnd {
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false)
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
}
}
......@@ -311,7 +311,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
}
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false)
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
}
self.navigationController?.pushViewController(vc)
......@@ -323,7 +323,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
detailInfo.teachingFormat = selectType.title
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false)
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
}
......@@ -340,7 +340,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
}
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false)
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
}
......@@ -352,7 +352,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
detailInfo.degree = selectType.title
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false)
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
}
......@@ -364,7 +364,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
detailInfo.degreeType = selectItem.title
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false)
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
}
......@@ -377,7 +377,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
detailInfo.schoolAddress.country = country
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false)
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
}
self.navigationController?.pushViewController(vc)
......@@ -390,10 +390,17 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
vc.backLocationStringController = {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
detailInfo.schoolAddress.area = [string1, string2, string3, string4]
var citys:[String] = []
if !isEmptyString(string2) {
citys.append(string2)
}
if !isEmptyString(string3) {
citys.append(string3)
}
detailInfo.schoolAddress.area = citys
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false)
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
}
self.present(vc, animated: true)
......@@ -480,7 +487,7 @@ extension YHEducationDetailVC {
YHHUD.flash(message: "资料还未填完")
return
}
saveDetailInfo(isNeedPop: true)
saveDetailInfo(isNeedPop: true, isShowToast: true)
}
// 检查填写信息完整性
......@@ -509,7 +516,7 @@ extension YHEducationDetailVC {
}
// 保存信息 isNeedPop:保存成功后是否退出该页面
func saveDetailInfo(isNeedPop:Bool) {
func saveDetailInfo(isNeedPop:Bool, isShowToast:Bool) {
// detailInfo.toDictionary() 对于值为空的字段不会添加 而后台需要 所以如下处理
// let dict:[String : Any] = [
......@@ -531,17 +538,21 @@ extension YHEducationDetailVC {
guard var dict:[String:Any] = detailInfo.toDictionary() else { return }
dict["order_id"] = self.orderId
self.educationRequest.saveEducationInfo(params: dict) {
self.educationRequest.saveEducationInfo(params: dict, isSilent: !isShowToast) {
[weak self] success, error in
guard let self = self else { return }
if success {
YHHUD.flash(message: "保存成功")
if isShowToast {
YHHUD.flash(message: "保存成功")
}
if isNeedPop {
self.navigationController?.popViewController(animated: true)
}
} else {
YHHUD.flash(message: "保存失败")
if isShowToast {
YHHUD.flash(message: "保存失败")
}
}
}
}
......
......@@ -153,7 +153,7 @@ class YHEducationInfoListVC: YHBaseViewController {
let title2 = YHFormTitleItem(type: .edutionalCertificateNameAndBirthday)
var arr2:[YHFormItemProtocol] = [title2]
// 问题集合
let questions = YHQuestionInfo.getEducationQuestion()
let questions = YHQuestionInfo.getEducationQuestion(eduList: educationInfo)
for questionInfo in questions {
if questionInfo.key == "qualification" {
questionInfo.answer = educationInfo.isNameSame
......
......@@ -308,7 +308,14 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
vc.backLocationStringController = {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
detailInfo.issuingAddr.area = [string1, string2, string3, string4]
var citys:[String] = []
if !isEmptyString(string2) {
citys.append(string2)
}
if !isEmptyString(string3) {
citys.append(string3)
}
detailInfo.issuingAddr.area = citys
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast: false)
......@@ -391,12 +398,12 @@ extension YHQualificationDetailVC {
func saveDetailInfo(isNeedPop:Bool, isShowToast:Bool) {
var dict:[String : Any] = ["orderId":self.orderId]
var quaDict:[String : Any] = detailInfo.toDictionary() ?? [:]
let quaDict:[String : Any] = detailInfo.toDictionary() ?? [:]
dict["qua_data"] = quaDict
print(dict)
self.educationRequest.saveQualificationInfo(params: dict) {
self.educationRequest.saveQualificationInfo(params: dict, isSilent:!isShowToast) {
[weak self] success, error in
guard let self = self else { return }
if success {
......
......@@ -17,6 +17,10 @@ class YHEducationListInfo: SmartCodable {
var isSpouseNameSame:Bool?
// 1=已婚,2=未婚,3=离婚,4=分居,5=丧偶,6=事实婚姻,7=鳏寡
var married: Int = 0
func isMarried() ->Bool {
return married != 2
}
enum CodingKeys: String, CodingKey {
case orderId = "order_id"
......
......@@ -71,15 +71,19 @@ class YHEducationRequestViewModel {
}
// 保存学历
func saveEducationInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
func saveEducationInfo(params:[String:Any], isSilent:Bool, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
if !isSilent {
YHHUD.show(.progress(message: "数据加载中..."))
}
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Education.saveEducationInfoApi
let _ = YHNetRequest.postRequest(url: strUrl, params:params) {[weak self] json, code in
YHHUD.hide()
if !isSilent {
YHHUD.hide()
}
guard let self = self else { return }
printLog("model 是 ==> \(json)")
if json.code == NetWorkCode.success.rawValue {
......@@ -195,15 +199,19 @@ class YHEducationRequestViewModel {
}
// 保存专业信息
func saveQualificationInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
func saveQualificationInfo(params:[String:Any], isSilent:Bool, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
if !isSilent {
YHHUD.show(.progress(message: "数据加载中..."))
}
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Qualification.saveQualificationInfoApi
let _ = YHNetRequest.postRequest(url: strUrl, params:params) {[weak self] json, code in
YHHUD.hide()
if !isSilent {
YHHUD.hide()
}
guard let self = self else { return }
printLog("model 是 ==> \(json)")
if json.code == NetWorkCode.success.rawValue {
......
......@@ -37,7 +37,7 @@ class YHQuestionInfo: SmartCodable, YHFormItemProtocol {
extension YHQuestionInfo {
// 【问题】学历证书姓名及出生日期正确性
static func getEducationQuestion() -> [YHQuestionInfo] {
static func getEducationQuestion(eduList:YHEducationListInfo) -> [YHQuestionInfo] {
let path = Bundle.main.path(forResource: "YHQuestionList", ofType: "plist")
let questions:[Dictionary] = NSArray(contentsOfFile:path!) as! [Dictionary<String, Any>]
var res:[YHQuestionInfo] = []
......@@ -45,7 +45,13 @@ extension YHQuestionInfo {
guard let questionInfo = YHQuestionInfo.deserialize(dict: dict as? [AnyHashable : Any]) else {
continue
}
res.append(questionInfo)
if questionInfo.key == "graduate" {
if eduList.isMarried() {
res.append(questionInfo)
}
} else {
res.append(questionInfo)
}
}
return res
}
......
......@@ -153,6 +153,26 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour
cell.title = detailItem.getTitle()
cell.text = detailItem.value
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
cell.textInputCondtion = {
textField in
var max = -1
if detailItem.type == .chinaIdentityCardNumber { // 身份证
max = 18
} else if detailItem.type == .certificateSignPlace { // 签发地
max = 100
} else if detailItem.type == .traverlPassportNumber ||
detailItem.type == .certificateNumber {
max = 50
}
if max > 0 {
if let textStr = textField.text {
textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr)
}
}
return true
}
cell.textChange = {
[weak self] (text, isEditEnd) in
guard let self = self else { return }
......
......@@ -263,6 +263,32 @@ extension YHChildBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
cell.title = detailItem.getTitle()
cell.text = detailItem.value
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
cell.textInputCondtion = {
textField in
if detailItem.type == .befourMarryFirstName { // 仅支持输入最多30个大写字母
let regex = "[^A-Z]+"
textField.limitInputWithPattern(pattern:regex, 30)
return true
}
var max = -1
if detailItem.type == .childName ||
detailItem.type == .everName {
max = 30
} else if detailItem.type == .birthCity ||
detailItem.type == .occupationName
{
max = 100
}
if max > 0 {
if let textStr = textField.text {
textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr)
}
}
return true
}
cell.textChange = {
[weak self] (text, isEditEnd) in
guard let self = self else { return }
......@@ -429,7 +455,14 @@ extension YHChildBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
print("\(string1)\n\(string2)\n\(string3)\n\(string4)")
self.child?.birthPlace.area = [string2, string3]
var citys:[String] = []
if !isEmptyString(string2) {
citys.append(string2)
}
if !isEmptyString(string3) {
citys.append(string3)
}
self.child?.birthPlace.area = citys
self.loadInfo()
save()
}
......
......@@ -13,6 +13,8 @@ class YHChildPrimaryInfoVC: YHBaseViewController, YHFamilyMemberProtol {
var child:YHFamilyMember?
weak var delegate:YHSpouseInfoVCProtocol?
var isNeedShowError = false
// 是否随行能编辑
var isFollowCanEdit = true
lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
......@@ -54,6 +56,7 @@ class YHChildPrimaryInfoVC: YHBaseViewController, YHFamilyMemberProtol {
items.removeAll()
isFollowCanEdit = !child.is18YearsOld()
// 随行
let title0 = YHFormTitleItem(type: .accompany)
let item00 = YHFormDetailItem(type: .ownCustody, value:String(child.isOwnCustody()))
......@@ -205,15 +208,23 @@ extension YHChildPrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
if cellType == .twoChoice {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemDoubleChoiceCell.cellReuseIdentifier, for: indexPath) as! YHFormItemDoubleChoiceCell
cell.isMust = detailItem.isNeed
cell.title = detailItem.getTitle()
cell.isCanEdit = true
var select = false
if let value = detailItem.value {
select = Bool(value)!
}
if detailItem.type == .isAccompanyToHK, let child = child, child.is18YearsOld() { // 是否随行至香港
// 年满18岁不能随行
select = false
cell.isCanEdit = isFollowCanEdit
}
let answers = [YHFormChoiceItem(title: "是".local, isSelect: select),YHFormChoiceItem(title: "否".local, isSelect: !select)]
cell.answerArr = answers
......@@ -268,10 +279,10 @@ extension YHChildPrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
cell.text = detailItem.value
cell.setTips(detailItem.tips, isShow:isNeedShowError && detailItem.isShowTips)
cell.textInputCondtion = {
text in
if let textStr = text {
textField in
if let textStr = textField.text {
let max = 100
text = textStr.count > max ? textStr[safe: ..<max] : textStr
textField.text = textStr.count > max ? textStr[safe: ..<max] : textStr
}
return true
}
......@@ -363,23 +374,37 @@ extension YHChildPrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
print("\(string1)\n\(string2)\n\(string3)\n\(string4)")
self.child?.address.area = [string2, string3]
var citys:[String] = []
if !isEmptyString(string2) {
citys.append(string2)
}
if !isEmptyString(string3) {
citys.append(string3)
}
self.child?.address.area = citys
self.loadInfo()
}
self.present(vc, animated: true)
} else if detailItem.type == .birthday { // 出生日期
// 子女选择年满18岁则【是否随行至香港】默认选择否,不可修改
// 如果未年满18岁则【是否随行至香港】可选择【是/否】,可修改
YHDatePickView.show(type: .yyyymmdd) { [weak self] date in
guard let self = self else { return }
if detailItem.type == .birthday {
self.child?.birthday = date
guard let child = child else { return }
child.birthday = date
isFollowCanEdit = !child.is18YearsOld()
}
self.loadInfo()
}
}
}
}
func createCorner(cell:UITableViewCell, arr:Array<Any>, indexPath:IndexPath) {
// 复用时需清理
......
......@@ -234,6 +234,23 @@ extension YHBrotherInfoVC : UITableViewDelegate, UITableViewDataSource {
} else {
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
}
cell.textInputCondtion = {
textField in
var max = -1
if detailItem.type == .brotherName {
max = 30
} else if detailItem.type == .birthCity {
max = 100
}
if max > 0 {
if let textStr = textField.text {
textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr)
}
}
return true
}
cell.textChange = {
[weak self] (text, isEditEnd) in
......@@ -391,7 +408,7 @@ extension YHBrotherInfoVC : UITableViewDelegate, UITableViewDataSource {
var isBirthOverSeas = false
if let brotherInfo = brotherInfo {
isBirthOverSeas = brotherInfo.isOverSeasOver1Year()
isBirthOverSeas = brotherInfo.isBirthOverSeas()
}
// 出生国外时 出生城市是输入框
if isBirthOverSeas { return }
......@@ -401,7 +418,14 @@ extension YHBrotherInfoVC : UITableViewDelegate, UITableViewDataSource {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
print("\(string1)\n\(string2)\n\(string3)\n\(string4)")
self.brotherInfo?.birthPlace.area = [string2, string3]
var citys:[String] = []
if !isEmptyString(string2) {
citys.append(string2)
}
if !isEmptyString(string3) {
citys.append(string3)
}
self.brotherInfo?.birthPlace.area = citys
self.loadInfo()
saveInfoSilent()
}
......
......@@ -276,6 +276,26 @@ extension YHParentInfoVC : UITableViewDelegate, UITableViewDataSource {
} else {
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
}
cell.textInputCondtion = {
textField in
var max = -1
if detailItem.type == .fatherName ||
detailItem.type == .motherName {
max = 30
} else if detailItem.type == .birthCity ||
detailItem.type == .occupationName
{
max = 100
}
if max > 0 {
if let textStr = textField.text {
textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr)
}
}
return true
}
cell.textChange = {
[weak self] (text, isEditEnd) in
......@@ -433,7 +453,7 @@ extension YHParentInfoVC : UITableViewDelegate, UITableViewDataSource {
var isBirthOverSeas = false
if let parentInfo = parentInfo {
isBirthOverSeas = parentInfo.isOverSeasOver1Year()
isBirthOverSeas = parentInfo.isBirthOverSeas()
}
// 出生国外时 出生城市是输入框
if isBirthOverSeas { return }
......@@ -443,7 +463,14 @@ extension YHParentInfoVC : UITableViewDelegate, UITableViewDataSource {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
print("\(string1)\n\(string2)\n\(string3)\n\(string4)")
self.parentInfo?.birthPlace.area = [string2, string3]
var citys:[String] = []
if !isEmptyString(string2) {
citys.append(string2)
}
if !isEmptyString(string3) {
citys.append(string3)
}
self.parentInfo?.birthPlace.area = citys
self.loadInfo()
saveInfoSilent()
}
......
......@@ -389,7 +389,32 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
} else {
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
}
cell.textInputCondtion = {
textField in
if detailItem.type == .befourMarryFirstName { // 仅支持输入最多30个大写字母
let regex = "[^A-Z]+"
textField.limitInputWithPattern(pattern:regex, 30)
return true
}
var max = -1
if detailItem.type == .spouseName ||
detailItem.type == .everName {
max = 30
} else if detailItem.type == .birthCity ||
detailItem.type == .occupationName
{
max = 100
}
if max > 0 {
if let textStr = textField.text {
textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr)
}
}
return true
}
cell.textChange = {
[weak self] (text, isEditEnd) in
guard let self = self else { return }
......@@ -618,7 +643,14 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
print("\(string1)\n\(string2)\n\(string3)\n\(string4)")
self.spouse?.birthPlace.area = [string2, string3]
var citys:[String] = []
if !isEmptyString(string2) {
citys.append(string2)
}
if !isEmptyString(string3) {
citys.append(string3)
}
self.spouse?.birthPlace.area = citys
loadInfo()
save()
}
......
......@@ -234,10 +234,10 @@ extension YHSpousePrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
cell.placeHolder = detailItem.placeHolder
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
cell.textInputCondtion = {
text in
if let textStr = text {
textField in
if let textStr = textField.text {
let max = 100
text = textStr.count > max ? textStr[safe: ..<max] : textStr
textField.text = textStr.count > max ? textStr[safe: ..<max] : textStr
}
return true
}
......@@ -326,7 +326,14 @@ extension YHSpousePrimaryInfoVC : UITableViewDelegate, UITableViewDataSource {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
print("\(string1)\n\(string2)\n\(string3)\n\(string4)")
self.spouse?.address.area = [string2, string3]
var citys:[String] = []
if !isEmptyString(string2) {
citys.append(string2)
}
if !isEmptyString(string3) {
citys.append(string3)
}
self.spouse?.address.area = citys
self.loadInfo()
save()
}
......
......@@ -14,7 +14,7 @@ enum YHFormTitleItemEditType:Int {
case canCancel = 3
}
class YHFamilyMemberInfoVC: YHBaseViewController {
class YHFamilyMemberInfoListVC: YHBaseViewController {
var orderId:Int
let familyRequest:YHFamilyRequestViewModel = YHFamilyRequestViewModel()
......@@ -230,7 +230,7 @@ class YHFamilyMemberInfoVC: YHBaseViewController {
}
}
extension YHFamilyMemberInfoVC {
extension YHFamilyMemberInfoListVC {
// 请求家庭成员信息
func requestFamilyInfo() {
......@@ -293,7 +293,7 @@ extension YHFamilyMemberInfoVC {
}
}
extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource {
extension YHFamilyMemberInfoListVC : UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return items.count
......@@ -368,17 +368,30 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource {
cell.detailLabel.text = "还未开始填写".local
}
if detailItem.relationType == .child || detailItem.relationType == .brother {
if detailItem.subsetName == nil || detailItem.subsetName == "" { // 姓名为空
if detailItem.relationType == .child {
cell.title = String(format: "子女%d".local, indexPath.row)
} else if detailItem.relationType == .brother {
cell.title = String(format: "兄弟姐妹%d".local, indexPath.row)
}
} else {
cell.title = detailItem.subsetName
if isEmptyString(detailItem.subsetName) { // 姓名为空
if detailItem.relationType == .child {
cell.title = String(format: "子女%d".local, indexPath.row)
} else if detailItem.relationType == .brother {
cell.title = String(format: "兄弟姐妹%d".local, indexPath.row)
}
} else {
var name = ""
if detailItem.relationType == .father {
name = "父亲"
} else if detailItem.relationType == .mother {
name = "母亲"
} else if detailItem.relationType == .spouse {
name = "配偶"
} else if detailItem.relationType == .child {
name = "子女"
} else if detailItem.relationType == .brother {
name = "兄弟姐妹"
}
name += "-"
name += detailItem.subsetName
cell.title = name
}
cell.isShowDeleteBtn = false
cell.deleteBlock = nil
if detailItem.relationType == .child || detailItem.relationType == .brother {
......@@ -462,6 +475,7 @@ extension YHFamilyMemberInfoVC : UITableViewDelegate, UITableViewDataSource {
if formItem.type == .addChild || formItem.type == .addBrother {
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemAddCell.cellReuseIdentifier, for: indexPath) as! YHFormItemAddCell
cell.title = formItem.getTitle()
cell.clickBlock = { [weak self] in
guard let self = self else { return }
if formItem.type == .addBrother {
......
......@@ -1123,6 +1123,41 @@ class YHFamilyMember: SmartCodable, YHFormItemProtocol {
self.childStepchild.has = (val ? "Y" : "N")
}
// 根据生日推算年龄
func getAge(birthday:String) ->Int {
let arr = birthday.components(separatedBy: YHDatePickView.separator)
if arr.count == 3 {
let year = Int(arr[0]) ?? 0
let month = Int(arr[1]) ?? 0
let day = Int(arr[2]) ?? 0
let now = Date()
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd"
let current = formatter.string(from: now)
let curArr = current.components(separatedBy:"-")
if curArr.count == 3 {
let cyear = Int(curArr[0]) ?? 0
let cmonth = Int(curArr[1]) ?? 0
let cday = Int(curArr[2]) ?? 0
var age = cyear - year
if cmonth < month {
age -= 1
} else if cmonth == month && cday < day {
age -= 1
}
return age
}
}
return 0
}
func is18YearsOld() -> Bool {
let age = getAge(birthday: birthday)
return age >= 18
}
var relationType:YHFamilyMemberType {
get {
......
......@@ -38,6 +38,13 @@ class YHFormItemDoubleChoiceCell: UITableViewCell {
// 是否必须字段
var isMust:Bool = false
var answerBlock:(([YHFormChoiceItem], Int)->Void)?
// 是否能点击两个按钮
var isCanEdit:Bool = true {
didSet {
answer1Btn.isUserInteractionEnabled = isCanEdit
answer2Btn.isUserInteractionEnabled = isCanEdit
}
}
var title:String? {
didSet {
......
......@@ -22,7 +22,7 @@ class YHFormItemInputTextCell: UITableViewCell {
}
// BOOL值表示编辑是否结束
var textChange:((String?, Bool)->Void)?
var textInputCondtion:((inout String?)->Bool)?
var textInputCondtion:((UITextField)->Bool)?
var title:String? {
didSet {
......@@ -165,7 +165,7 @@ class YHFormItemInputTextCell: UITableViewCell {
@objc func textFieldChanged(textField:UITextField) {
if let textChange = textChange {
if let textInputCondtion = textInputCondtion {
if textInputCondtion(&textField.text) {
if textInputCondtion(self.textField) {
textChange(textField.text, false)
}
} else {
......@@ -177,7 +177,7 @@ class YHFormItemInputTextCell: UITableViewCell {
@objc func textFieldEditEnd(textField:UITextField) {
if let textChange = textChange {
if let textInputCondtion = textInputCondtion {
if textInputCondtion(&textField.text) {
if textInputCondtion(self.textField) {
textChange(textField.text, true)
}
} else {
......
......@@ -93,7 +93,7 @@ class YHMainApplicantInformationViewController: YHBaseViewController {
guard let self = self else { return }
if self.viewModel.isCanNext(self.stepView.currentIndex) {
self.viewModel.mainModel.step = self.stepView.currentIndex
self.viewModel.updateMainInformation(.submit, self.orderId) {[weak self] success, error in
self.viewModel.updateMainInformation(.submit, self.orderId, self.stepView.currentIndex) {[weak self] success, error in
guard let self = self else { return }
if let error = error {
YHHUD.flash(message: error.errorMsg )
......@@ -117,7 +117,7 @@ class YHMainApplicantInformationViewController: YHBaseViewController {
}
bottom.saveBlock = { [weak self] in
guard let self = self else { return }
self.viewModel.updateMainInformation(.save, self.orderId) {[weak self] success, error in
self.viewModel.updateMainInformation(.save, self.orderId, self.stepView.currentIndex) {[weak self] success, error in
guard let _ = self else { return }
if let error = error {
YHHUD.flash(message: error.errorMsg )
......
......@@ -138,7 +138,7 @@ extension YHSelectCountryViewController: UITableViewDelegate, UITableViewDataSou
let cell = tableView.dequeueReusableCell(withClass: YHCountryTableViewCell.self)
let cn = searchDataSource?[indexPath.row].name_cn ?? ""
let en = searchDataSource?[indexPath.row].name_en ?? ""
cell.titleLabel.text = cn + en
cell.titleLabel.text = cn + "-" + en
return cell
}
......@@ -149,7 +149,7 @@ extension YHSelectCountryViewController: UITableViewDelegate, UITableViewDataSou
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cn = searchDataSource?[indexPath.row].name_cn ?? ""
let en = searchDataSource?[indexPath.row].name_en ?? ""
let text = cn + en
let text = cn + "-" + en
if let backLocationStringController = backLocationStringController {
backLocationStringController(text)
self.navigationController?.popViewController()
......
......@@ -62,5 +62,5 @@ class YHCertificatesModel: YHBaseModel {
var issue_date_end_at: String = ""
var img_front: String = ""
var img_back: String = ""
var passport_type: String = ""
var pass_port_type: String = ""
}
......@@ -38,7 +38,11 @@ class YHDatePickView: UIView {
// 日期分割符 eg: 2024-01-01
static let separator: String = "-"
var title: String = "" {
didSet {
titleLabel.text = title
}
}
var type: YHDateType? {
didSet {
guard let type = type else { return }
......@@ -82,7 +86,7 @@ class YHDatePickView: UIView {
titleLabel = {
let label = UILabel()
label.text = "选择出生日期"
label.text = title
label.font = UIFont.PFSC_M(ofSize: 17)
label.textColor = UIColor.mainTextColor
label.textAlignment = .center
......@@ -158,6 +162,7 @@ class YHDatePickView: UIView {
make.height.equalTo(220)
make.right.equalTo(-16)
}
pickerView.selectRow(100, inComponent: 0, animated: true)
}
@objc private func handleTap(_ sender: AnyObject?) {
......@@ -165,10 +170,11 @@ class YHDatePickView: UIView {
dismiss()
}
static func show(type:YHDateType, callBack: @escaping ((String) -> Void)) {
static func show(type:YHDateType, title: String? = nil, callBack: @escaping ((String) -> Void)) {
let view = YHDatePickView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
view.type = type
view.backDate = callBack
view.title = title ?? ""
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
}
......@@ -183,11 +189,11 @@ class YHDatePickView: UIView {
var date = ""
switch type {
case .yyyymmdd:
date = String(format: "%02ld%@%02ld%@%02ld", (self.currentDateCom.year!) - self.pickerView.selectedRow(inComponent: 0),Self.separator, self.pickerView.selectedRow(inComponent: 1) + 1,Self.separator, self.pickerView.selectedRow(inComponent: 2) + 1)
date = String(format: "%02ld%@%02ld%@%02ld", (self.currentDateCom.year!) - self.pickerView.selectedRow(inComponent: 0) + 100,Self.separator, self.pickerView.selectedRow(inComponent: 1) + 1,Self.separator, self.pickerView.selectedRow(inComponent: 2) + 1)
case .yyyymm:
date = String(format: "%02ld%@%02ld", (self.currentDateCom.year!) - self.pickerView.selectedRow(inComponent: 0),Self.separator, self.pickerView.selectedRow(inComponent: 1) + 1)
date = String(format: "%02ld%@%02ld", (self.currentDateCom.year!) - self.pickerView.selectedRow(inComponent: 0) + 100 ,Self.separator, self.pickerView.selectedRow(inComponent: 1) + 1)
case .yyyy:
date = String(format: "%02ld", (self.currentDateCom.year!) - self.pickerView.selectedRow(inComponent: 0))
date = String(format: "%02ld", (self.currentDateCom.year!) - self.pickerView.selectedRow(inComponent: 0) + 100)
}
if self.backDate != nil {
self.backDate!(date)
......@@ -219,7 +225,7 @@ extension YHDatePickView: UIPickerViewDelegate,UIPickerViewDataSource {
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
if component == 0 {
return 100
return 200
} else if component == 1 {
return 12
} else {
......@@ -267,7 +273,7 @@ extension YHDatePickView: UIPickerViewDelegate,UIPickerViewDataSource {
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
if component == 0 {
return "\((currentDateCom.year!) - row)"
return "\((currentDateCom.year!) - row + 100)"
} else if component == 1 {
return "\(row + 1)"
} else {
......
......@@ -173,8 +173,6 @@ class YHImagePickerView: UIView {
imagePicker.delegate = self
//设置来源
imagePicker.sourceType = .camera
//允许编辑
imagePicker.allowsEditing = true
//打开相机
UIViewController.current?.present(imagePicker, animated: true, completion: { () -> Void in
......@@ -190,7 +188,6 @@ class YHImagePickerView: UIView {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = true
// 这一句,开始调用图库
UIViewController.current?.present(imagePicker,animated: true)
}
......@@ -304,7 +301,7 @@ extension YHImagePickerView: UINavigationControllerDelegate, UIImagePickerContro
"businessCode": "4001001"
]
// 创建MultipartFormData对象
var multipartFormData = MultipartFormData()
let multipartFormData = MultipartFormData()
// 将图片添加到multipartFormData中
multipartFormData.append(imageData, withName: "file", fileName: "image.jpg", mimeType: "image/jpeg")
......
......@@ -18,6 +18,7 @@ class YHItemView: UIView {
var leftButton: UIButton!
var rightButton: UIButton!
var showPromptLabel: UILabel!
var longTimeButton:UIButton!
var dataSource: YHItemModel? {
didSet {
updateAllViews()
......@@ -50,6 +51,7 @@ class YHItemView: UIView {
textField.delegate = self
textField.textColor = UIColor.mainTextColor
textField.font = UIFont.PFSC_M(ofSize: 14)
textField.addTarget(self, action: #selector(textFieldDidChanged), for: .editingChanged)
return textField
}()
addSubview(messageTextField)
......@@ -130,10 +132,51 @@ class YHItemView: UIView {
make.height.equalTo(32)
make.width.equalTo(74)
}
longTimeButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "main_time_normal"), for: .normal)
button.setImage(UIImage(named: "main_time_select"), for: .selected)
button.setTitleColor(UIColor.mainTextColor, for: .normal)
button.setTitle("长期", for: .normal)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 14)
button.contentHorizontalAlignment = .right
button.addTarget(self, action: #selector(longTimeButtonClick), for: .touchUpInside)
button.imageEdgeInsets = UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 30)
button.isSelected = false
return button
}()
addSubview(longTimeButton)
longTimeButton.snp.makeConstraints { make in
make.right.equalToSuperview()
make.centerY.equalToSuperview()
make.height.equalTo(32)
make.width.equalTo(43)
}
}
@objc func longTimeButtonClick() {
longTimeButton.isSelected = !longTimeButton.isSelected
if longTimeButton.isSelected {
self.dataSource?.message = "8888-01-01"
self.updateAllViews()
if let block = self.block {
block(self.dataSource ?? YHItemModel())
}
} else {
self.dataSource?.message = ""
self.updateAllViews()
if let block = self.block {
block(self.dataSource ?? YHItemModel())
}
}
}
func updateAllViews() {
guard let dataSource = dataSource else { return }
if dataSource.id == .id23 {
messageTextField.keyboardType = .asciiCapable
}
if dataSource.isNeed ?? false {
let str = "*" + (dataSource.title ?? "")
let attributes: [NSAttributedString.Key: Any] = [
......@@ -167,6 +210,9 @@ class YHItemView: UIView {
case .time: break
case .image: break
case .id:
if dataSource.message == "0" {
messageTextField.text = ""
}
let arr = YHOtherInfoFillViewModel.arrIdType
arr.forEach { item in
if item["id"] == dataSource.message {
......@@ -175,6 +221,9 @@ class YHItemView: UIView {
}
case .country: break
case .sex:
if dataSource.message == "0" {
messageTextField.text = ""
}
let arr = YHOtherInfoFillViewModel.arrSex
arr.forEach { item in
if item["id"] == dataSource.message {
......@@ -182,6 +231,9 @@ class YHItemView: UIView {
}
}
case .marry:
if dataSource.message == "0" {
messageTextField.text = ""
}
let arr = YHOtherInfoFillViewModel.arrMarry
arr.forEach { item in
if item["id"] == dataSource.message {
......@@ -228,6 +280,33 @@ class YHItemView: UIView {
showPromptLabel.isHidden = true
}
if dataSource.id == .id11 || dataSource.id == .id15 || dataSource.id == .id20 {
longTimeButton.isHidden = false
nextStepImageView.isHidden = true
if dataSource.message == "8888-01-01" {
longTimeButton.isSelected = true
longTimeButton.snp.remakeConstraints { make in
make.left.equalTo(messageTextField.snp.left)
make.centerY.equalToSuperview()
make.height.equalTo(32)
make.width.equalTo(43)
}
centerButton.isHidden = true
messageTextField.isHidden = true
} else {
longTimeButton.isSelected = false
longTimeButton.snp.remakeConstraints { make in
make.right.equalToSuperview()
make.centerY.equalToSuperview()
make.height.equalTo(32)
make.width.equalTo(43)
}
centerButton.isHidden = false
messageTextField.isHidden = false
}
} else {
longTimeButton.isHidden = true
}
}
func buttonState(isLeft: Bool) {
......@@ -310,7 +389,17 @@ class YHItemView: UIView {
}
UIViewController.current?.present(addressPicker, animated: true, completion: nil)
case .time:
YHDatePickView.show(type: .yyyymmdd) { date in
var title = ""
if dataSource?.id == .id10 || dataSource?.id == .id14 || dataSource?.id == .id19 {
title = "请选择签发日期"
}
if dataSource?.id == .id11 || dataSource?.id == .id15 || dataSource?.id == .id20 {
title = "请选择届满日期"
}
if dataSource?.id == .id24 {
title = "请选择出生日期"
}
YHDatePickView.show(type: .yyyymmdd, title: title) { date in
// let arr = date.components(separatedBy: YHDatePickView.separator)
// [yyyy, mm, dd] eg ["2024", "01", "20"]
self.dataSource?.message = date
......@@ -372,6 +461,12 @@ class YHItemView: UIView {
}
}
}
@objc func textFieldDidChanged() {
if dataSource?.id == .id23 {
messageTextField.text = messageTextField.text?.uppercased()
}
}
}
extension YHItemView: UITextFieldDelegate {
......@@ -380,7 +475,7 @@ extension YHItemView: UITextFieldDelegate {
}
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let newText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
var newText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
if (dataSource?.id == .id9 || dataSource?.id == .id21 || dataSource?.id == .id22 || dataSource?.id == .id23) && newText.count > 30 {
return false
}
......@@ -401,6 +496,10 @@ extension YHItemView: UITextFieldDelegate {
return false
}
if dataSource?.id == .id23 {
newText = newText.uppercased()
}
var data = dataSource ?? YHItemModel()
data.message = newText
if let block = block {
......
......@@ -279,10 +279,16 @@ class YHMainInformationCardTableViewCell: UITableViewCell {
@objc func frontImageClick() {
if type == .identity {
if viewModel.mainModel.certificates.cn_identity_card.img_front.count != 0 {
let vc = YHImageViewController()
vc.imgString = viewModel.mainModel.certificates.cn_identity_card.img_front
UIViewController.current?.navigationController?.pushViewController(vc)
return
}
} else {
if viewModel.mainModel.certificates.hk_macao_pass.img_front.count != 0 {
let vc = YHImageViewController()
vc.imgString = viewModel.mainModel.certificates.hk_macao_pass.img_front
UIViewController.current?.navigationController?.pushViewController(vc)
return
}
}
......@@ -334,10 +340,16 @@ class YHMainInformationCardTableViewCell: UITableViewCell {
@objc func backSurfaceImageClick() {
if type == .identity {
if viewModel.mainModel.certificates.cn_identity_card.img_back.count != 0 {
let vc = YHImageViewController()
vc.imgString = viewModel.mainModel.certificates.cn_identity_card.img_back
UIViewController.current?.navigationController?.pushViewController(vc)
return
}
} else {
if viewModel.mainModel.certificates.hk_macao_pass.img_back.count != 0 {
let vc = YHImageViewController()
vc.imgString = viewModel.mainModel.certificates.hk_macao_pass.img_back
UIViewController.current?.navigationController?.pushViewController(vc)
return
}
}
......
......@@ -14,9 +14,9 @@ class YHSelectCountryViewModel: NSObject {
}
func requestCountry(_ key: String, callBackBlock:@escaping (_ success: [YHCountryMessage?]?, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.countryInformation + "?keyword = \(key)"
YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.countryInformation
let param: [String: Any] = ["keyword": key]
let _ = YHNetRequest.getRequest(url: strUrl, params: param) { [weak self] json, code in
guard let self = self else { return }
let dic = json.data as? [Any]
guard let resultArray = [YHCountryMessage].deserialize(from: dic) else {
......
......@@ -301,19 +301,19 @@ class YHOtherInfoFillViewModel: YHBaseViewModel {
static let arrMarry : [[String : String]] = [
["title": "已婚",
"id": "0"
"id": "1"
],
["title": "未婚",
"id": "1"
"id": "2"
],
["title": "离婚",
"id": "2"
"id": "3"
],
["title": "分居",
"id": "3"
"id": "4"
],
["title": "丧偶",
"id": "4"
"id": "5"
]
]
}
......
//
// YHImageClipperViewController.swift
// galaxy
//
// Created by EDY on 2024/3/5.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
/*
let clipperVC = YHImageClipperViewController()
clipperVC.setBaseImg(image, resultImgSize: clippedImgSize!, type: clipperType)
clipperVC.cancelClippedHandler = {
}
clipperVC.successClippedHandler = {[weak self]img in
if self?.clippedImageHandler != nil{
self?.clippedImageHandler!(img)
}
}
self.pushViewController(clipperVC, animated: true)
*/
import UIKit
class YHImageClipperViewController: YHBaseViewController {
typealias CancelClippedHandlerBlock = ()->Void
typealias SuccessClippedHandlerBlock = (_ content: String) -> Void
//MARK Public
public var cancelClippedHandler:CancelClippedHandlerBlock?
public var successClippedHandler:SuccessClippedHandlerBlock?
public func setBaseImg(_ baseImg: UIImage, resultImgSize: CGSize, type: YHClipperType) {
clipperView = YHClipperView(frame: CGRect(x: 0, y: (isIphoneX() ? 88:64), width: KScreenWidth, height: KScreenHeight - k_Height_safeAreaInsetsBottom() - 54 - (isIphoneX() ? 88:64)))
clipperView?.resultImgSize = resultImgSize
clipperView?.baseImg = baseImg
clipperView?.type = type
self.view.addSubview(clipperView!)
}
//MARK Private
private var clipperView: YHClipperView?
private var cannalButton: YHClipperButton!
private var backImageButton: YHClipperButton!
private var sureButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .black
self.hidesBottomBarWhenPushed = true
if #available(iOS 11.0, *) {
} else {
self.automaticallyAdjustsScrollViewInsets = false
}
// Do any additional setup after loading the view.
setView()
}
func setView() {
sureButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.backgroundColor = UIColor(hex: 0x2274ee)
button.contentHorizontalAlignment = .center
button.setTitle("确认", for: .normal)
button.setTitleColor( UIColor(hex:0xffffff), for: .normal)
button.layer.cornerRadius = kCornerRadius6
button.clipsToBounds = true
button.addTarget(self, action: #selector(sureBtnClick), for: .touchUpInside)
return button
}()
view.addSubview(sureButton)
sureButton.snp.makeConstraints { make in
make.right.equalTo(-16)
make.bottom.equalTo(-10 - k_Height_safeAreaInsetsBottom())
make.height.equalTo(44)
make.width.equalTo(93)
}
cannalButton = {
let button = YHClipperButton()
button.setContent("image_clipper_cannal", "取消")
button.addTarget(self, action: #selector(cannalBtnClick), for: .touchUpInside)
return button
}()
view.addSubview(cannalButton)
cannalButton.snp.makeConstraints { make in
make.centerY.equalTo(sureButton.snp.centerY)
make.left.equalTo(30)
make.height.equalTo(44)
make.width.equalTo(30)
}
backImageButton = {
let button = YHClipperButton()
button.setContent("image_clipper_back", "复原")
button.addTarget(self, action: #selector(backImageBtnClick), for: .touchUpInside)
return button
}()
view.addSubview(backImageButton)
backImageButton.snp.makeConstraints { make in
make.centerY.equalTo(sureButton.snp.centerY)
make.left.equalTo(80)
make.height.equalTo(44)
make.width.equalTo(30)
}
}
@objc private func cannalBtnClick() {
if cancelClippedHandler != nil {
cancelClippedHandler!()
}
self.navigationController?.popViewController()
}
@objc private func backImageBtnClick() {
// if cancelClippedHandler != nil {
// cancelClippedHandler!()
// }
}
@objc private func sureBtnClick() {
let clippedImg = self.clipperView?.clipImg()
let vc = YHImageResultViewController()
vc.img = clippedImg
vc.successHandlerBlock = { [weak self] result in
guard let self = self else { return }
if successClippedHandler != nil {
successClippedHandler!(result)
}
}
self.navigationController?.pushViewController(vc)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isNavigationBarHidden = false
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
//
// YHImageResultViewController.swift
// galaxy
//
// Created by EDY on 2024/3/5.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHImageResultViewController: YHBaseViewController {
typealias SuccessHandlerBlock = (_ relult: String) -> Void
var successHandlerBlock: SuccessHandlerBlock?
var resultView: UIImageView!
var bottomView: YHResultBottomView!
var img: UIImage!
var viewModel: YHWorkExperienceViewModel!
override func viewDidLoad() {
super.viewDidLoad()
viewModel = YHWorkExperienceViewModel()
gk_navTitle = "照片"
setView()
// Do any additional setup after loading the view.
}
func setView() {
resultView = {
let step = UIImageView()
step.contentMode = .scaleAspectFit
step.image = img
return step
}()
view.addSubview(resultView)
resultView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalTo(view)
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom() - 54)
}
bottomView = {
let bottom = YHResultBottomView()
bottom.nextblock = {[weak self] in
guard let self = self else { return }
YHHUD.show(.progress(message: ""))
self.viewModel.uploadImage(self.img) {[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()
if let block = self.successHandlerBlock {
block(model?.content ?? "")
let mineVC = YHWorkExperienceViewController()
var targetVC : UIViewController!
for controller in self.navigationController!.viewControllers {
if controller.isKind(of: mineVC.classForCoder) {
targetVC = controller
}
}
if targetVC != nil {
self.navigationController?.popToViewController(targetVC, animated: true)
}
}
} else {
YHHUD.hide()
YHHUD.flash(message: error?.errorMsg ?? "")
}
}
}
}
}
return bottom
}()
view.addSubview(bottomView)
bottomView.snp.makeConstraints { make in
make.left.right.bottom.equalTo(view)
make.height.equalTo(k_Height_safeAreaInsetsBottom() + 64)
}
}
}
//
// YHImageViewController.swift
// galaxy
//
// Created by EDY on 2024/3/5.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHImageViewController: YHBaseViewController {
var resultView: UIImageView!
var resultButton: UIButton!
var imgString: String!
var viewModel: YHWorkExperienceViewModel!
override func viewDidLoad() {
super.viewDidLoad()
viewModel = YHWorkExperienceViewModel()
view.backgroundColor = .black
self.hidesBottomBarWhenPushed = true
if #available(iOS 11.0, *) {
} else {
self.automaticallyAdjustsScrollViewInsets = false
}
setView()
getData()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isNavigationBarHidden = false
}
func setView() {
resultView = {
let step = UIImageView()
step.contentMode = .scaleAspectFit
return step
}()
view.addSubview(resultView)
resultView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalTo(view)
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom() - 54)
}
resultButton = {
let button = UIButton(type: .custom)
button.addTarget(self, action: #selector(back), for: .touchUpInside)
return button
}()
view.addSubview(resultButton)
resultButton.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalTo(view)
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom() - 54)
}
}
@objc func back() {
self.navigationController?.popViewController()
}
func getData() {
self.viewModel.getPublicImageUrl(imgString) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.resultView.kf.setImage(with: URL(string: success))
}
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
......@@ -238,27 +238,14 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
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
let clipperVC = YHImageClipperViewController()
clipperVC.setBaseImg(image, resultImgSize: CGSize(width: 300, height: 300), type: .Stay)
clipperVC.successClippedHandler = {[weak self] result 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 ?? "")
}
}
}
self.viewModel.mainModel.wduty = result
cell.dataSource = viewModel.mainModel.wduty
}
self.navigationController?.pushViewController(clipperVC, animated: true)
}
}
return cell
......@@ -294,27 +281,14 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
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
let clipperVC = YHImageClipperViewController()
clipperVC.setBaseImg(image, resultImgSize: CGSize(width: 300, height: 300), type: .Stay)
clipperVC.successClippedHandler = {[weak self] result 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 ?? "")
}
}
}
self.viewModel.mainModel.highlights = result
cell.dataSource = viewModel.mainModel.highlights
}
self.navigationController?.pushViewController(clipperVC, animated: true)
}
}
return cell
......@@ -455,6 +429,10 @@ extension YHWorkExperienceViewController: UITableViewDelegate, UITableViewDataSo
return
}
}
} else {
let vc = YHImageViewController()
vc.imgString = model.fileUrl
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
return cell
......
......@@ -205,27 +205,14 @@ class YHWorkIntroductionViewController: YHBaseViewController {
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
let clipperVC = YHImageClipperViewController()
clipperVC.setBaseImg(image, resultImgSize: CGSize(width: 300, height: 300), type: .Stay)
clipperVC.successClippedHandler = {[weak self] result 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 ?? "")
}
}
}
self.dataSource.project_highlights = result
self.messageTextField.text = result
}
self.navigationController?.pushViewController(clipperVC, animated: true)
}
}
return view
......
//
// YHClipperButton.swift
// galaxy
//
// Created by EDY on 2024/3/5.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHClipperButton: UIButton {
var topImageView: UIImageView!
var bottomTitleLabel: UILabel!
override init(frame: CGRect) {
super.init(frame: frame)
setView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setView() {
topImageView = {
let view = UIImageView()
return view
}()
addSubview(topImageView)
topImageView.snp.makeConstraints { make in
make.top.centerX.equalToSuperview()
make.width.height.equalTo(21)
}
bottomTitleLabel = {
let label = UILabel()
label.font = UIFont.PFSC_B(ofSize: 11)
label.textAlignment = .center
label.textColor = UIColor.white
return label
}()
addSubview(bottomTitleLabel)
bottomTitleLabel.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(15)
}
}
func setContent(_ image: String, _ title: String) {
bottomTitleLabel.text = title
topImageView.image = UIImage(named: image)
}
/*
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
// Drawing code
}
*/
}
//
// YHResultBottomView.swift
// galaxy
//
// Created by EDY on 2024/3/5.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHResultBottomView: UIView {
typealias Block = () -> ()
var nextblock: Block?
var nextButton: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
setUpView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setUpView() {
nextButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.backgroundColor = UIColor(hex: 0x2274ee)
button.contentHorizontalAlignment = .center
button.setTitle("开始识别", for: .normal)
button.setTitleColor(UIColor(hex:0xffffff), for: .normal)
button.layer.cornerRadius = kCornerRadius6
button.clipsToBounds = true
button.addTarget(self, action: #selector(goNext), for: .touchUpInside)
return button
}()
addSubview(nextButton)
nextButton.snp.makeConstraints { make in
make.right.equalTo(-16)
make.top.equalTo(10)
make.height.equalTo(44)
make.left.equalTo(16)
}
// nextButton.layoutIfNeeded()
// nextButton.backgroundGradient()
// nextButton.addYinHeGradualLayer()
}
@objc func goNext() {
if let block = nextblock {
block()
}
}
}
......@@ -187,7 +187,6 @@ extension YHWorkResponsibilitiesTableViewCell: UITextViewDelegate {
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
let newLength = (textView.text as NSString).length + text.count - range.length
return newLength <= 2000
}
}
//
// UITextField+Extension.swift
// galaxy
//
// Created by edy on 2024/3/5.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
extension UITextField {
/// 限制textField输入
public func limitInputWithPattern(pattern: String, _ limitCount: Int = -1) {
// 非markedText才继续往下处理
guard let _: UITextRange = self.markedTextRange else {
// 当前光标的位置(后面会对其做修改)
let cursorPostion = self.offset(from: self.endOfDocument, to: self.selectedTextRange!.end)
// 替换后的字符串
var str = ""
if pattern == "" {
str = self.text!
} else {
str = self.text!.regularReplace(pattern: pattern, with: "")
}
// 如果长度超过限制则直接截断
if limitCount >= 0, str.count > limitCount {
str = String(str.prefix(limitCount))
}
self.text = str
// 让光标停留在正确位置
let targetPostion = self.position(from: self.endOfDocument, offset: cursorPostion)!
self.selectedTextRange = self.textRange(from: targetPostion, to: targetPostion)
return
}
}
}
extension String {
// 使用正则表达式替换
func regularReplace(pattern: String, with: String, options: NSRegularExpression.Options = []) -> String {
let regex = try! NSRegularExpression(pattern: pattern, options: options)
return regex.stringByReplacingMatches(in: self, options: [],
range: NSMakeRange(0, self.count),
withTemplate: with)
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "main_time_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "main_time_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "main_time_select@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "main_time_select@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "image_clipper_back@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "image_clipper_back@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "image_clipper_cannal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "image_clipper_cannal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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