Commit 9d82c9cc 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:
  //  请求错误显示优化
parents 6a9cf162 0fdb0e11
...@@ -70,7 +70,7 @@ class YHEducationDetailVC: YHBaseViewController { ...@@ -70,7 +70,7 @@ class YHEducationDetailVC: YHBaseViewController {
bottomView.saveBlock = { bottomView.saveBlock = {
[weak self] in [weak self] in
guard let self = self else { return } guard let self = self else { return }
saveDetailInfo(isNeedPop: true, isShowToast: true) saveDetailInfo(isSubmit:false, isNeedPop: true, isShowToast: true)
} }
bottomView.submitBlock = { bottomView.submitBlock = {
...@@ -227,9 +227,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -227,9 +227,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
} }
if isEditEnd { if isEditEnd {
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
} }
} }
return cell return cell
...@@ -310,9 +308,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -310,9 +308,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
detailInfo.college = "" detailInfo.college = ""
} }
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
} }
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
...@@ -323,9 +319,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -323,9 +319,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return } guard let self = self else { return }
detailInfo.teachingFormat = item.title detailInfo.teachingFormat = item.title
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
} }
} else if detailItem.type == .educationTime || detailItem.type == .graduateTime { // 入学及毕业年月 } else if detailItem.type == .educationTime || detailItem.type == .graduateTime { // 入学及毕业年月
...@@ -340,9 +334,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -340,9 +334,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
detailInfo.graduateTime = date detailInfo.graduateTime = date
} }
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
} }
} else if detailItem.type == .educationDegree { // 学位 } else if detailItem.type == .educationDegree { // 学位
...@@ -352,9 +344,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -352,9 +344,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return } guard let self = self else { return }
detailInfo.degree = item.title detailInfo.degree = item.title
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
} }
} else if detailItem.type == .degreeType { // 学位类型 } else if detailItem.type == .degreeType { // 学位类型
...@@ -364,9 +354,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -364,9 +354,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return } guard let self = self else { return }
detailInfo.degreeType = selectItem.title detailInfo.degreeType = selectItem.title
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
} }
} else if detailItem.type == .educationCountry { // 上课国家/地区 } else if detailItem.type == .educationCountry { // 上课国家/地区
...@@ -377,9 +365,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -377,9 +365,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return } guard let self = self else { return }
detailInfo.schoolAddress.country = country detailInfo.schoolAddress.country = country
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
} }
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
...@@ -400,9 +386,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -400,9 +386,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
} }
detailInfo.schoolAddress.area = citys detailInfo.schoolAddress.area = citys
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
} }
self.present(vc, animated: true) self.present(vc, animated: true)
} }
...@@ -488,7 +472,7 @@ extension YHEducationDetailVC { ...@@ -488,7 +472,7 @@ extension YHEducationDetailVC {
YHHUD.flash(message: "资料还未填完") YHHUD.flash(message: "资料还未填完")
return return
} }
saveDetailInfo(isNeedPop: true, isShowToast: true) saveDetailInfo(isSubmit:true, isNeedPop: true, isShowToast: true)
} }
// 检查填写信息完整性 // 检查填写信息完整性
...@@ -516,25 +500,14 @@ extension YHEducationDetailVC { ...@@ -516,25 +500,14 @@ extension YHEducationDetailVC {
return true return true
} }
func saveInfoSilent() {
if detailId != 0 {
saveDetailInfo(isSubmit:false, isNeedPop: false, isShowToast: false)
}
}
// 保存信息 isNeedPop:保存成功后是否退出该页面 // 保存信息 isNeedPop:保存成功后是否退出该页面
func saveDetailInfo(isNeedPop:Bool, isShowToast:Bool) { func saveDetailInfo(isSubmit:Bool, isNeedPop:Bool, isShowToast:Bool) {
// detailInfo.toDictionary() 对于值为空的字段不会添加 而后台需要 所以如下处理
// let dict:[String : Any] = [
// "order_id":
// "id": detailInfo.id,
// "admission_time": detailInfo.admissionTime,
// "background": detailInfo.major,
// "college": detailInfo.college,
// "degree_type": detailInfo.degreeType,
// "graduate_time": detailInfo.graduateTime,
// "professional": detailInfo.major,
// "school_address_aboard": "",
// "type": detailInfo.teachingFormat,
// "school_address": ["country": detailInfo.schoolAddress.country,
// "area": detailInfo.schoolAddress.area,
// "foreign": detailInfo.schoolAddress.foreign],
// ]
guard var dict:[String:Any] = detailInfo.toDictionary() else { return } guard var dict:[String:Any] = detailInfo.toDictionary() else { return }
dict["order_id"] = self.orderId dict["order_id"] = self.orderId
...@@ -542,9 +515,10 @@ extension YHEducationDetailVC { ...@@ -542,9 +515,10 @@ extension YHEducationDetailVC {
self.educationRequest.saveEducationInfo(params: dict, isSilent: !isShowToast) { self.educationRequest.saveEducationInfo(params: dict, isSilent: !isShowToast) {
[weak self] success, error in [weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
if success { if success {
if isShowToast { if isShowToast {
YHHUD.flash(message: "保存成功") YHHUD.flash(message: isSubmit ? "提交成功":"保存成功" )
} }
if isNeedPop { if isNeedPop {
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
...@@ -552,7 +526,11 @@ extension YHEducationDetailVC { ...@@ -552,7 +526,11 @@ extension YHEducationDetailVC {
} else { } else {
if isShowToast { if isShowToast {
YHHUD.flash(message: "保存失败") var errorMsg = isSubmit ? "提交失败" : "保存失败"
if let errMsg = error?.errorMsg, errMsg.count > 0 {
errorMsg = errMsg
}
YHHUD.flash(message: errorMsg)
} }
} }
} }
......
...@@ -494,6 +494,12 @@ extension YHEducationInfoListVC { ...@@ -494,6 +494,12 @@ extension YHEducationInfoListVC {
guard let self = self else { return } guard let self = self else { return }
if success { if success {
requestEducationInfo() requestEducationInfo()
} else {
var errorMsg = "删除失败"
if let errMsg = error?.errorMsg, errMsg.count > 0 {
errorMsg = errMsg
}
YHHUD.flash(message: errorMsg)
} }
} }
} }
...@@ -506,6 +512,12 @@ extension YHEducationInfoListVC { ...@@ -506,6 +512,12 @@ extension YHEducationInfoListVC {
guard let self = self else { return } guard let self = self else { return }
if success { if success {
requestEducationInfo() requestEducationInfo()
} else {
var errorMsg = "删除失败"
if let errMsg = error?.errorMsg, errMsg.count > 0 {
errorMsg = errMsg
}
YHHUD.flash(message: errorMsg)
} }
} }
} }
...@@ -525,6 +537,12 @@ extension YHEducationInfoListVC { ...@@ -525,6 +537,12 @@ extension YHEducationInfoListVC {
if success { if success {
requestEducationInfo() requestEducationInfo()
self.navigationController?.popViewController() self.navigationController?.popViewController()
} else {
var errorMsg = isSubmit ? "提交失败" : "保存失败"
if let errMsg = error?.errorMsg, errMsg.count > 0 {
errorMsg = errMsg
}
YHHUD.flash(message: errorMsg)
} }
} }
} }
......
...@@ -68,7 +68,7 @@ class YHQualificationDetailVC: YHBaseViewController { ...@@ -68,7 +68,7 @@ class YHQualificationDetailVC: YHBaseViewController {
bottomView.saveBlock = { bottomView.saveBlock = {
[weak self] in [weak self] in
guard let self = self else { return } guard let self = self else { return }
saveDetailInfo(isNeedPop: true, isShowToast: true) saveDetailInfo(isSubmit:false, isNeedPop: true, isShowToast: true)
} }
bottomView.submitBlock = { bottomView.submitBlock = {
[weak self] in [weak self] in
...@@ -201,9 +201,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -201,9 +201,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
} }
if isEditEnd { if isEditEnd {
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast: false)
}
} }
} }
return cell return cell
...@@ -269,9 +267,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -269,9 +267,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return } guard let self = self else { return }
detailInfo.certName = selectItem.title detailInfo.certName = selectItem.title
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast: false)
}
} }
} else if detailItem.type == .conferTime { // 授权年份 } else if detailItem.type == .conferTime { // 授权年份
...@@ -281,9 +277,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -281,9 +277,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return } guard let self = self else { return }
detailInfo.issuingYear = Int(date) ?? 2024 detailInfo.issuingYear = Int(date) ?? 2024
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast: false)
}
} }
} else if detailItem.type == .conferCountry { // 授权国家/地区 } else if detailItem.type == .conferCountry { // 授权国家/地区
...@@ -294,9 +288,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -294,9 +288,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return } guard let self = self else { return }
detailInfo.issuingAddr.country = country detailInfo.issuingAddr.country = country
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast: false)
}
} }
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
...@@ -317,9 +309,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -317,9 +309,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
} }
detailInfo.issuingAddr.area = citys detailInfo.issuingAddr.area = citys
loadInfo() loadInfo()
if detailId != 0 { saveInfoSilent()
saveDetailInfo(isNeedPop: false, isShowToast: false)
}
} }
self.present(vc, animated: true) self.present(vc, animated: true)
} }
...@@ -392,10 +382,16 @@ extension YHQualificationDetailVC { ...@@ -392,10 +382,16 @@ extension YHQualificationDetailVC {
} }
} }
func saveInfoSilent() {
if detailId != 0 {
saveDetailInfo(isSubmit:false, isNeedPop: false, isShowToast: false)
}
}
// 保存数据 // 保存数据
// @param isNeedPop:保存成功后是否需要退出该页面 // @param isNeedPop:保存成功后是否需要退出该页面
// @param isShowToast: 请求完成后是否弹Toast // @param isShowToast: 请求完成后是否弹Toast
func saveDetailInfo(isNeedPop:Bool, isShowToast:Bool) { func saveDetailInfo(isSubmit:Bool, isNeedPop:Bool, isShowToast:Bool) {
var dict:[String : Any] = ["orderId":self.orderId] var dict:[String : Any] = ["orderId":self.orderId]
let quaDict:[String : Any] = detailInfo.toDictionary() ?? [:] let quaDict:[String : Any] = detailInfo.toDictionary() ?? [:]
...@@ -408,7 +404,7 @@ extension YHQualificationDetailVC { ...@@ -408,7 +404,7 @@ extension YHQualificationDetailVC {
guard let self = self else { return } guard let self = self else { return }
if success { if success {
if isShowToast { if isShowToast {
YHHUD.flash(message: "保存成功") YHHUD.flash(message: isSubmit ? "提交成功":"保存成功" )
} }
if isNeedPop { if isNeedPop {
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
...@@ -416,7 +412,11 @@ extension YHQualificationDetailVC { ...@@ -416,7 +412,11 @@ extension YHQualificationDetailVC {
} else { } else {
if isShowToast { if isShowToast {
YHHUD.flash(message: "保存失败") var errorMsg = isSubmit ? "提交失败" : "保存失败"
if let errMsg = error?.errorMsg, errMsg.count > 0 {
errorMsg = errMsg
}
YHHUD.flash(message: errorMsg)
} }
} }
} }
...@@ -433,7 +433,7 @@ extension YHQualificationDetailVC { ...@@ -433,7 +433,7 @@ extension YHQualificationDetailVC {
return return
} }
saveDetailInfo(isNeedPop: true, isShowToast: true) saveDetailInfo(isSubmit:true, isNeedPop: true, isShowToast: true)
} }
......
...@@ -184,7 +184,7 @@ class YHChildInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol { ...@@ -184,7 +184,7 @@ class YHChildInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol {
if let targetVC = getCurrentStepViewController() { if let targetVC = getCurrentStepViewController() {
if targetVC.nextStep() { if targetVC.nextStep() {
saveInfo(isSubmit: true, isShowLoading: true) { saveInfo(isSubmit: true, isShowLoading: true) {
[weak self] success, error in [weak self] success in
guard let self = self else { return } guard let self = self else { return }
if success { if success {
// 当前步骤已是最后一步 // 当前步骤已是最后一步
...@@ -239,7 +239,7 @@ extension YHChildInfoContainerVC { ...@@ -239,7 +239,7 @@ extension YHChildInfoContainerVC {
// @param isSubmit:是否为提交 false为保存 true为提交 // @param isSubmit:是否为提交 false为保存 true为提交
// @param isShowLoading: 是否展示loading和toast // @param isShowLoading: 是否展示loading和toast
func saveInfo(isSubmit:Bool, isShowLoading:Bool, callBack:((Bool, String?)->Void)?) { func saveInfo(isSubmit:Bool, isShowLoading:Bool, callBack:((Bool)->Void)?) {
guard let child = child else { return } guard let child = child else { return }
guard let info = child.toDictionary() else { return } guard let info = child.toDictionary() else { return }
...@@ -265,7 +265,7 @@ extension YHChildInfoContainerVC { ...@@ -265,7 +265,7 @@ extension YHChildInfoContainerVC {
} }
} }
if let callBack = callBack { if let callBack = callBack {
callBack(success, error?.errorMsg) callBack(success)
} }
} }
} }
......
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