Commit 69d6d19a authored by Steven杜宇's avatar Steven杜宇

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

parents 0f3df602 cab92121
......@@ -27,8 +27,20 @@ class YHInformationAuthorizationStepOneViewController: YHBaseViewController {
}
func getData() {
items = viewModel.getBaseDataSource()
tableView.reloadData()
viewModel.requestUserInfo {[weak self] success, error in
guard let self = self else { return }
self.items = viewModel.getBaseDataSource()
self.tableView.reloadData()
let url = URL(string: self.viewModel.model.avatar)
self.photoImageView.kf.setImage(with: url)
if self.viewModel.isCanNext() {
nextButton.isEnabled = true
nextButton.backgroundColor = UIColor.brandMainColor
} else {
nextButton.isEnabled = false
nextButton.backgroundColor = UIColor.brandMainColor.withAlphaComponent(0.4)
}
}
}
func setView() {
......@@ -164,17 +176,28 @@ class YHInformationAuthorizationStepOneViewController: YHBaseViewController {
YHImagePickerView.show() {[weak self] image in
guard let self = self else { return }
self.photoImageView.image = image
self.viewModel.uploadImage(image, true) {[weak self] success, error in
guard let self = self else { return }
self.viewModel.model.avatar = success ?? ""
}
}
}
@objc func changeHead() {
viewModel.requestChangeHead {[weak self] success, error in
guard let self = self else { return }
let url = URL(string: self.viewModel.model.avatar)
self.photoImageView.kf.setImage(with: url)
}
}
@objc func nextStep() {
viewModel.requestSaveUserInfo {[weak self] success, error in
guard let self = self else { return }
let vc = YHInformationAuthorizationStepTwoViewController()
self.navigationController?.pushViewController(vc)
}
}
}
extension YHInformationAuthorizationStepOneViewController: UITableViewDelegate, UITableViewDataSource {
......@@ -196,7 +219,8 @@ extension YHInformationAuthorizationStepOneViewController: UITableViewDelegate,
nextButton.backgroundColor = UIColor.brandMainColor.withAlphaComponent(0.4)
}
if model.id != .id1 && model.id != .id3 && model.id != .id5 {
self.getData()
self.items = viewModel.getBaseDataSource()
self.tableView.reloadData()
}
}
return cell
......
......@@ -24,8 +24,16 @@ class YHInformationAuthorizationStepTwoViewController: UIViewController {
}
func getData() {
if stepFlag {
items = viewModel.getBaseSetDataSource()
tableView.reloadData()
} else {
viewModel.requestUserAuthorization {[weak self] success, error in
guard let self = self else { return }
items = viewModel.getBaseSetDataSource()
tableView.reloadData()
}
}
}
func setView() {
......@@ -106,7 +114,10 @@ class YHInformationAuthorizationStepTwoViewController: UIViewController {
}
@objc func nextStep() {
viewModel.requestAuthorizationSubmit {[weak self] success, error in
guard let self = self else { return }
self.navigationController?.popViewController(animated: true)
}
}
}
......
......@@ -153,9 +153,11 @@ class YHPeopleViewController: YHBaseViewController {
return
}
let view = YHPeopleSuccessView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
// let view = YHPeopleSuccessView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
// let window = UIApplication.shared.yhKeyWindow()
// window?.addSubview(view)
let vc = YHInformationAuthorizationStepOneViewController()
self.navigationController?.pushViewController(vc)
}
func resetAnimation() {
......
......@@ -56,8 +56,26 @@ class YHMainUserInformationModel: YHBaseModel {
}
class YHMainUserInformationSetModel: YHBaseModel {
var isRea: Bool = true
var isWork: Bool = true
var isSchool: Bool = true
var uid: String = ""
var information_to_card: Int = 2
var authorization_basic_information: Int = 2
var public_education_experience: Int = 2
var public_work_experience: Int = 2
var isclick_card: Int = 2
}
class YHUserInformationDetailModel: YHBaseModel {
var username: String = ""
var avatar: String = ""
var address: YHUserInformationDetailAddressModel = YHUserInformationDetailAddressModel()
var college: String = ""
var industry: String = ""
var position: String = ""
}
class YHUserInformationDetailAddressModel: YHBaseModel {
var country: String = ""
var province: String = ""
var city: String = ""
}
......@@ -11,26 +11,23 @@ import UIKit
class YHInformationAuthorizeViewModel: YHBaseViewModel {
var mainModel: YHMainUserInformationModel = YHMainUserInformationModel()
var setModel: YHMainUserInformationSetModel = YHMainUserInformationSetModel()
var model: YHUserInformationDetailModel = YHUserInformationDetailModel()
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: .id3, title: "毕业院校", isUserKeyBoard: true, prompts: "请输入您的毕业院校", message: mainModel.school)
let item5 = YHUserInformationModel(id: .id4, title: "所属行业", isUserKeyBoard: false, prompts: "请选择您的所属行业", message: mainModel.industry, type: .id)
let item6 = YHUserInformationModel(id: .id5, title: "职位", isUserKeyBoard: true, prompts: "请输入您的职位", message: mainModel.position)
let item3 = YHUserInformationModel(id: .id2, title: "所在地-省市", isUserKeyBoard: false, prompts: "请选择您的所在地", message: string, type: .address)
let item4 = YHUserInformationModel(id: .id3, title: "毕业院校", isUserKeyBoard: true, prompts: "请输入您的毕业院校", message: model.college)
let item5 = YHUserInformationModel(id: .id4, title: "所属行业", isUserKeyBoard: false, prompts: "请选择您的所属行业", message: model.industry, type: .id)
let item6 = YHUserInformationModel(id: .id5, title: "职位", isUserKeyBoard: true, prompts: "请输入您的职位", message: model.position)
if mainModel.country.contains("中国") {
return [item1, item2, item3, item4, item5, item6]
}
......@@ -41,40 +38,47 @@ class YHInformationAuthorizeViewModel: 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 ?? ""
default:
break
}
}
func isCanNext() -> Bool {
let username = mainModel.username
let school = mainModel.school
let area = mainModel.area
let industry = mainModel.industry
let position = mainModel.position
let username = model.username
let school = model.college
let country = model.address.country
let provice = model.address.province
let city = model.address.city
let industry = model.industry
let position = model.position
guard username.count > 0 else { return false }
guard school.count > 0 else { return false }
guard industry.count > 0 else { return false }
guard position.count > 0 else { return false }
guard area.count > 0 else { return false }
guard country.count > 0 else { return false }
if mainModel.country.contains("中国") {
guard provice.count > 0 else { return false }
guard city.count > 0 else { return false }
}
return true
}
func getBaseSetDataSource() -> [YHSettingItem] {
let item1 = YHSettingItem(type: .people, title: "授权AI人脉匹配", subTitle: "开启后,您的信息将用于AI人脉匹配,为您构建高质量的人脉网络", isSelect: setModel.isRea, isShowAlert: true)
let item2 = YHSettingItem(type: .school, title: "允许向好友公开您的教育经历", subTitle: "开启后,您的教育经历将在您的个人名片上对已交换名片的好友可见", isSelect: setModel.isSchool, isShowAlert: true)
let item3 = YHSettingItem(type: .work, title: "允许向好友公开您的工作经历", subTitle: "开启后,您的工作经历将在您的个人名片上对已交换名片的好友可见", isSelect: setModel.isWork, isShowAlert: true)
let item1 = YHSettingItem(type: .people, title: "授权AI人脉匹配", subTitle: "开启后,您的信息将用于AI人脉匹配,为您构建高质量的人脉网络", isSelect: setModel.authorization_basic_information == 2 ? true : false, isShowAlert: true)
let item2 = YHSettingItem(type: .school, title: "允许向好友公开您的教育经历", subTitle: "开启后,您的教育经历将在您的个人名片上对已交换名片的好友可见", isSelect: setModel.public_education_experience == 2 ? true : false, isShowAlert: true)
let item3 = YHSettingItem(type: .work, title: "允许向好友公开您的工作经历", subTitle: "开启后,您的工作经历将在您的个人名片上对已交换名片的好友可见", isSelect: setModel.public_work_experience == 2 ? true : false, isShowAlert: true)
return [item1, item2, item3]
}
......@@ -83,11 +87,121 @@ class YHInformationAuthorizeViewModel: YHBaseViewModel {
case .normal: break
case .people:
setModel.isRea = item.isSelect
setModel.authorization_basic_information = item.isSelect ? 2 : 1
case .school:
setModel.isSchool = item.isSelect
setModel.public_education_experience = item.isSelect ? 2 : 1
case .work:
setModel.isWork = item.isSelect
setModel.public_work_experience = item.isSelect ? 2 : 1
}
}
func requestUserInfo(callBackBlock:@escaping (_ success: Bool, _ error: YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.People.userInfo
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
guard let result = YHUserInformationDetailModel.deserialize(from: dic as? Dictionary) else {
callBackBlock(false,nil)
return
}
self.model = result
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
func requestUserAuthorization(callBackBlock:@escaping (_ success: Bool, _ error: YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.People.userAuthorization
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
guard let result = YHMainUserInformationSetModel.deserialize(from: dic as? Dictionary) else {
callBackBlock(false,nil)
return
}
self.setModel = result
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
func requestSaveUserInfo(callBackBlock:@escaping (_ success: Bool, _ error: YHErrorModel?)->()) {
let address: [String: Any] = ["country": model.address.country,
"province": model.address.province,
"city": model.address.city]
let params: [String: Any] = ["avatar": model.avatar,
"username": model.username,
"college": model.college,
"industry": model.industry,
"position": model.position,
"address": address]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.People.userSubmit
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let _ = self else { return }
if json.code == 200 {
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
func requestChangeHead(callBackBlock:@escaping (_ success: Bool, _ error: YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.People.change
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
guard let result = YHChangeHeadModel.deserialize(from: dic as? Dictionary) else {
callBackBlock(false,nil)
return
}
self.model.avatar = result.avatar
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
func requestAuthorizationSubmit(callBackBlock:@escaping (_ success: Bool, _ error: YHErrorModel?)->()) {
let params: [String: Any] = ["authorization_basic_information": setModel.authorization_basic_information,
"public_education_experience": setModel.public_education_experience,
"public_work_experience": setModel.public_work_experience]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.People.authorizationSubmit
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let _ = self else { return }
if json.code == 200 {
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
}
......@@ -322,6 +322,8 @@ class YHAllApiName {
static let change = "super-app/avatar/change"
static let userSubmit = "super-app/user-base/submit"
static let authorizationSubmit = "super-app/authorization/submit"
static let userInfo = "super-app/user-base/info"
static let userAuthorization = "super-app/user/authorization"
}
}
......@@ -69,7 +69,7 @@ class YHOSSManager: NSObject, URLSessionDelegate {
}
func putObject(image: UIImage, _ isPublic: Bool = false, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
let request = OSSPutObjectRequest()
let request = OSSPutObjectACLRequest()
let size = Int(2 * 1024 * 1024)
guard let imageData = image.compressOriginalImage(size) else {
callBackBlock(nil, YHErrorModel())
......@@ -87,6 +87,7 @@ class YHOSSManager: NSObject, URLSessionDelegate {
let currentDateMMdd = dateFormatter.string(from: Date())
self.fileName.append(name)
if isPublic {
request.acl = "public-read-write"
request.objectKey = "5000000" + "/" + currentDateMMdd + "/" + "\(name)"
} else {
request.objectKey = "4001001" + "/" + currentDateMMdd + "/" + "\(name)"
......@@ -121,7 +122,7 @@ class YHOSSManager: NSObject, URLSessionDelegate {
}
func putFile(file: String, _ isPublic: Bool = false, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
let request = OSSPutObjectRequest()
let request = OSSPutObjectACLRequest()
guard let fileData = try? Data(contentsOf: URL(string: file) ?? URL(fileURLWithPath: "")) else {
callBackBlock(nil, YHErrorModel())
return
......@@ -138,6 +139,7 @@ class YHOSSManager: NSObject, URLSessionDelegate {
dateFormatter.dateFormat = "yyyyMMdd"
let currentDateMMdd = dateFormatter.string(from: Date())
if isPublic {
request.acl = "public-read-write"
request.objectKey = "5000000" + "/" + currentDateMMdd + "/" + "\(name)"
} else {
request.objectKey = "4001001" + "/" + currentDateMMdd + "/" + "\(name)"
......
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