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 {
bottomView.saveBlock = {
[weak self] in
guard let self = self else { return }
saveDetailInfo(isNeedPop: true, isShowToast: true)
saveDetailInfo(isSubmit:false, isNeedPop: true, isShowToast: true)
}
bottomView.submitBlock = {
......@@ -227,9 +227,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
}
if isEditEnd {
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
saveInfoSilent()
}
}
return cell
......@@ -310,9 +308,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
detailInfo.college = ""
}
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
saveInfoSilent()
}
self.navigationController?.pushViewController(vc)
......@@ -323,9 +319,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return }
detailInfo.teachingFormat = item.title
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
saveInfoSilent()
}
} else if detailItem.type == .educationTime || detailItem.type == .graduateTime { // 入学及毕业年月
......@@ -340,9 +334,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
detailInfo.graduateTime = date
}
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
saveInfoSilent()
}
} else if detailItem.type == .educationDegree { // 学位
......@@ -352,9 +344,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return }
detailInfo.degree = item.title
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
saveInfoSilent()
}
} else if detailItem.type == .degreeType { // 学位类型
......@@ -364,9 +354,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return }
detailInfo.degreeType = selectItem.title
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
saveInfoSilent()
}
} else if detailItem.type == .educationCountry { // 上课国家/地区
......@@ -377,9 +365,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return }
detailInfo.schoolAddress.country = country
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
saveInfoSilent()
}
self.navigationController?.pushViewController(vc)
......@@ -400,9 +386,7 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
}
detailInfo.schoolAddress.area = citys
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast:false)
}
saveInfoSilent()
}
self.present(vc, animated: true)
}
......@@ -488,7 +472,7 @@ extension YHEducationDetailVC {
YHHUD.flash(message: "资料还未填完")
return
}
saveDetailInfo(isNeedPop: true, isShowToast: true)
saveDetailInfo(isSubmit:true, isNeedPop: true, isShowToast: true)
}
// 检查填写信息完整性
......@@ -516,25 +500,14 @@ extension YHEducationDetailVC {
return true
}
func saveInfoSilent() {
if detailId != 0 {
saveDetailInfo(isSubmit:false, isNeedPop: false, isShowToast: false)
}
}
// 保存信息 isNeedPop:保存成功后是否退出该页面
func saveDetailInfo(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],
// ]
func saveDetailInfo(isSubmit:Bool, isNeedPop:Bool, isShowToast:Bool) {
guard var dict:[String:Any] = detailInfo.toDictionary() else { return }
dict["order_id"] = self.orderId
......@@ -542,9 +515,10 @@ extension YHEducationDetailVC {
self.educationRequest.saveEducationInfo(params: dict, isSilent: !isShowToast) {
[weak self] success, error in
guard let self = self else { return }
if success {
if isShowToast {
YHHUD.flash(message: "保存成功")
YHHUD.flash(message: isSubmit ? "提交成功":"保存成功" )
}
if isNeedPop {
self.navigationController?.popViewController(animated: true)
......@@ -552,7 +526,11 @@ extension YHEducationDetailVC {
} else {
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 {
guard let self = self else { return }
if success {
requestEducationInfo()
} else {
var errorMsg = "删除失败"
if let errMsg = error?.errorMsg, errMsg.count > 0 {
errorMsg = errMsg
}
YHHUD.flash(message: errorMsg)
}
}
}
......@@ -506,6 +512,12 @@ extension YHEducationInfoListVC {
guard let self = self else { return }
if success {
requestEducationInfo()
} else {
var errorMsg = "删除失败"
if let errMsg = error?.errorMsg, errMsg.count > 0 {
errorMsg = errMsg
}
YHHUD.flash(message: errorMsg)
}
}
}
......@@ -525,6 +537,12 @@ extension YHEducationInfoListVC {
if success {
requestEducationInfo()
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 {
bottomView.saveBlock = {
[weak self] in
guard let self = self else { return }
saveDetailInfo(isNeedPop: true, isShowToast: true)
saveDetailInfo(isSubmit:false, isNeedPop: true, isShowToast: true)
}
bottomView.submitBlock = {
[weak self] in
......@@ -201,9 +201,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
}
if isEditEnd {
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast: false)
}
saveInfoSilent()
}
}
return cell
......@@ -269,9 +267,7 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return }
detailInfo.certName = selectItem.title
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast: false)
}
saveInfoSilent()
}
} else if detailItem.type == .conferTime { // 授权年份
......@@ -281,33 +277,29 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
guard let self = self else { return }
detailInfo.issuingYear = Int(date) ?? 2024
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast: false)
}
saveInfoSilent()
}
} else if detailItem.type == .conferCountry { // 授权国家/地区
let vc = YHSelectCountryViewController()
vc.backLocationStringController = {
[weak self] country in
guard let self = self else { return }
detailInfo.issuingAddr.country = country
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast: false)
}
}
self.navigationController?.pushViewController(vc)
vc.backLocationStringController = {
[weak self] country in
guard let self = self else { return }
detailInfo.issuingAddr.country = country
loadInfo()
saveInfoSilent()
}
self.navigationController?.pushViewController(vc)
} else if detailItem.type == .conferCity { // 授权城市
if detailInfo.isCollegeInAboard() { return }
let vc = YHAddressViewController()
vc.backLocationStringController = {
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
[weak self] (string1, string2, string3, string4) in
guard let self = self else { return }
var citys:[String] = []
if !isEmptyString(string2) {
citys.append(string2)
......@@ -315,12 +307,10 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
if !isEmptyString(string3) {
citys.append(string3)
}
detailInfo.issuingAddr.area = citys
loadInfo()
if detailId != 0 {
saveDetailInfo(isNeedPop: false, isShowToast: false)
}
}
detailInfo.issuingAddr.area = citys
loadInfo()
saveInfoSilent()
}
self.present(vc, animated: true)
}
}
......@@ -392,10 +382,16 @@ extension YHQualificationDetailVC {
}
}
func saveInfoSilent() {
if detailId != 0 {
saveDetailInfo(isSubmit:false, isNeedPop: false, isShowToast: false)
}
}
// 保存数据
// @param isNeedPop:保存成功后是否需要退出该页面
// @param isShowToast: 请求完成后是否弹Toast
func saveDetailInfo(isNeedPop:Bool, isShowToast:Bool) {
func saveDetailInfo(isSubmit:Bool, isNeedPop:Bool, isShowToast:Bool) {
var dict:[String : Any] = ["orderId":self.orderId]
let quaDict:[String : Any] = detailInfo.toDictionary() ?? [:]
......@@ -408,7 +404,7 @@ extension YHQualificationDetailVC {
guard let self = self else { return }
if success {
if isShowToast {
YHHUD.flash(message: "保存成功")
YHHUD.flash(message: isSubmit ? "提交成功":"保存成功" )
}
if isNeedPop {
self.navigationController?.popViewController(animated: true)
......@@ -416,7 +412,11 @@ extension YHQualificationDetailVC {
} else {
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 {
return
}
saveDetailInfo(isNeedPop: true, isShowToast: true)
saveDetailInfo(isSubmit:true, isNeedPop: true, isShowToast: true)
}
......
......@@ -184,7 +184,7 @@ class YHChildInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol {
if let targetVC = getCurrentStepViewController() {
if targetVC.nextStep() {
saveInfo(isSubmit: true, isShowLoading: true) {
[weak self] success, error in
[weak self] success in
guard let self = self else { return }
if success {
// 当前步骤已是最后一步
......@@ -239,7 +239,7 @@ extension YHChildInfoContainerVC {
// @param isSubmit:是否为提交 false为保存 true为提交
// @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 info = child.toDictionary() else { return }
......@@ -265,7 +265,7 @@ extension YHChildInfoContainerVC {
}
}
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