Commit 58fe6e56 authored by Steven杜宇's avatar Steven杜宇

// 添加一键登录、苹果登录接口

parent e01318bb
...@@ -295,6 +295,8 @@ ...@@ -295,6 +295,8 @@
04F4B76B2BAA7E1E00D13284 /* YHCertificateTemplateSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F4B76A2BAA7E1E00D13284 /* YHCertificateTemplateSheetView.swift */; }; 04F4B76B2BAA7E1E00D13284 /* YHCertificateTemplateSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F4B76A2BAA7E1E00D13284 /* YHCertificateTemplateSheetView.swift */; };
04FA8B2B2C06F59D00ABE43F /* YHAppleLoginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FA8B2A2C06F59D00ABE43F /* YHAppleLoginManager.swift */; }; 04FA8B2B2C06F59D00ABE43F /* YHAppleLoginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FA8B2A2C06F59D00ABE43F /* YHAppleLoginManager.swift */; };
04FA8B2E2C084C7E00ABE43F /* ATAuthSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */; }; 04FA8B2E2C084C7E00ABE43F /* ATAuthSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */; };
04FA8B302C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FA8B2F2C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift */; };
04FA8B332C0880A100ABE43F /* YHAppleLoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FA8B322C0880A100ABE43F /* YHAppleLoginViewModel.swift */; };
6203A87EDC96313BBE789D9C /* Pods_galaxy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */; }; 6203A87EDC96313BBE789D9C /* Pods_galaxy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */; };
A51044182B493675006B60BB /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = A51044172B493675006B60BB /* README.md */; }; A51044182B493675006B60BB /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = A51044172B493675006B60BB /* README.md */; };
A510441A2B495DD0006B60BB /* UIView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51044192B495DD0006B60BB /* UIView+Extension.swift */; }; A510441A2B495DD0006B60BB /* UIView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51044192B495DD0006B60BB /* UIView+Extension.swift */; };
...@@ -766,6 +768,8 @@ ...@@ -766,6 +768,8 @@
04F4B76A2BAA7E1E00D13284 /* YHCertificateTemplateSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateTemplateSheetView.swift; sourceTree = "<group>"; }; 04F4B76A2BAA7E1E00D13284 /* YHCertificateTemplateSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateTemplateSheetView.swift; sourceTree = "<group>"; };
04FA8B2A2C06F59D00ABE43F /* YHAppleLoginManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAppleLoginManager.swift; sourceTree = "<group>"; }; 04FA8B2A2C06F59D00ABE43F /* YHAppleLoginManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAppleLoginManager.swift; sourceTree = "<group>"; };
04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = ATAuthSDK.bundle; path = "galaxy/Classes/Modules/AutoLogin(一键登录)/framework/ATAuthSDK_D.framework/ATAuthSDK.bundle"; sourceTree = "<group>"; }; 04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = ATAuthSDK.bundle; path = "galaxy/Classes/Modules/AutoLogin(一键登录)/framework/ATAuthSDK_D.framework/ATAuthSDK.bundle"; sourceTree = "<group>"; };
04FA8B2F2C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHOneKeyLoginViewModel.swift; sourceTree = "<group>"; };
04FA8B322C0880A100ABE43F /* YHAppleLoginViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAppleLoginViewModel.swift; sourceTree = "<group>"; };
19B28612265782F9DC1BE0B0 /* Pods-galaxy.testenv.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.testenv.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.testenv.xcconfig"; sourceTree = "<group>"; }; 19B28612265782F9DC1BE0B0 /* Pods-galaxy.testenv.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.testenv.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.testenv.xcconfig"; sourceTree = "<group>"; };
58C2405158A4A6632D0E7460 /* Pods-galaxy.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.debug.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.debug.xcconfig"; sourceTree = "<group>"; }; 58C2405158A4A6632D0E7460 /* Pods-galaxy.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.debug.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.debug.xcconfig"; sourceTree = "<group>"; };
987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_galaxy.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_galaxy.framework; sourceTree = BUILT_PRODUCTS_DIR; };
...@@ -1737,6 +1741,7 @@ ...@@ -1737,6 +1741,7 @@
0499E3012C05B73D0037E646 /* AppleLogin(苹果登录) */ = { 0499E3012C05B73D0037E646 /* AppleLogin(苹果登录) */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
04FA8B312C08808B00ABE43F /* V */,
0499E3022C05B7E90037E646 /* C */, 0499E3022C05B7E90037E646 /* C */,
); );
path = "AppleLogin(苹果登录)"; path = "AppleLogin(苹果登录)";
...@@ -1859,6 +1864,7 @@ ...@@ -1859,6 +1864,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
04D144752C0452E200EE3758 /* YHOneKeyLoginManager.swift */, 04D144752C0452E200EE3758 /* YHOneKeyLoginManager.swift */,
04FA8B2F2C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift */,
); );
path = M; path = M;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1886,6 +1892,14 @@ ...@@ -1886,6 +1892,14 @@
path = Server; path = Server;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
04FA8B312C08808B00ABE43F /* V */ = {
isa = PBXGroup;
children = (
04FA8B322C0880A100ABE43F /* YHAppleLoginViewModel.swift */,
);
path = V;
sourceTree = "<group>";
};
4758815B24BAF3CAA24EC6A8 /* Pods */ = { 4758815B24BAF3CAA24EC6A8 /* Pods */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -2805,6 +2819,7 @@ ...@@ -2805,6 +2819,7 @@
A5ACE94B2B4564F7002C94D2 /* YHHUDRotatingImageView.swift in Sources */, A5ACE94B2B4564F7002C94D2 /* YHHUDRotatingImageView.swift in Sources */,
A5ACE94F2B4564F7002C94D2 /* YhOverlayView.swift in Sources */, A5ACE94F2B4564F7002C94D2 /* YhOverlayView.swift in Sources */,
045EEEB92B9F171A0022A143 /* YHWorkMessageSelectTableViewCell.swift in Sources */, 045EEEB92B9F171A0022A143 /* YHWorkMessageSelectTableViewCell.swift in Sources */,
04FA8B302C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift in Sources */,
04A7BD0F2BA41C9800BD35A2 /* YHMyDocumentsModel.swift in Sources */, 04A7BD0F2BA41C9800BD35A2 /* YHMyDocumentsModel.swift in Sources */,
04174D642BCD52BD000BA46D /* YHDeviceInfoViewController.swift in Sources */, 04174D642BCD52BD000BA46D /* YHDeviceInfoViewController.swift in Sources */,
A5ACE92E2B4564F7002C94D2 /* YHValidateCodeInputView.swift in Sources */, A5ACE92E2B4564F7002C94D2 /* YHValidateCodeInputView.swift in Sources */,
...@@ -2937,6 +2952,7 @@ ...@@ -2937,6 +2952,7 @@
045EEE8E2B9F171A0022A143 /* YHPreviewInfoWorkSummaryView.swift in Sources */, 045EEE8E2B9F171A0022A143 /* YHPreviewInfoWorkSummaryView.swift in Sources */,
045EEECE2B9F171A0022A143 /* YHScoreDetailViewController.swift in Sources */, 045EEECE2B9F171A0022A143 /* YHScoreDetailViewController.swift in Sources */,
045EEE852B9F171A0022A143 /* YHPreviewFamilyMemberViewController.swift in Sources */, 045EEE852B9F171A0022A143 /* YHPreviewFamilyMemberViewController.swift in Sources */,
04FA8B332C0880A100ABE43F /* YHAppleLoginViewModel.swift in Sources */,
045EEE7F2B9F171A0022A143 /* YHWorkExpInfoPreviewModel.swift in Sources */, 045EEE7F2B9F171A0022A143 /* YHWorkExpInfoPreviewModel.swift in Sources */,
045EEEE72B9F171A0022A143 /* YHMySignatureListTableViewCell.swift in Sources */, 045EEEE72B9F171A0022A143 /* YHMySignatureListTableViewCell.swift in Sources */,
A5C382CC2B5EA11800C5E65C /* YHContractCell.swift in Sources */, A5C382CC2B5EA11800C5E65C /* YHContractCell.swift in Sources */,
......
//
// YHAppleLoginViewModel.swift
// galaxy
//
// Created by edy on 2024/5/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHAppleLoginViewModel: NSObject {
func appleLogin(params:[String: Any], callBackBlock: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Auth.appleLogin
let _ = YHNetRequest.postRequest(url: strUrl, params: params) {[weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
printLog(json)
let dic = json.data
guard let resultModel = YHUserModel.deserialize(dict: dic as? [AnyHashable : Any]) else {
let error : YHErrorModel = YHErrorModel(errorCode:-1,errorMsg: "数据解析不成功")
callBackBlock(false, error)
return
}
if json.code == 200 {
if resultModel.token?.count != 0 {
//token 正常
YHLoginManager.shared.userModel = resultModel
//数据保存到本地
YHLoginManager.shared.saveLocalUserInfo()
NotificationCenter.default.post(name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil)
callBackBlock(true,nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:-2,errorMsg: "token 不合法")
callBackBlock(false,error)
}
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false,error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
}
//
// YHOneKeyLoginViewModel.swift
// galaxy
//
// Created by edy on 2024/5/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHOneKeyLoginViewModel {
func getSecretKeyInfo(completion:((String) -> ())?) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Auth.oneKeySecretKeyInfo
let params = ["iosInfo.bundleId" : "com.intelligence.galaxy"]
let _ = YHNetRequest.getRequest(url: strUrl, params: params) { json, code in
let dic = json.data
printLog("model 是 ==> \(json)")
if json.code == 200 {
if let dic = json.data as? [String: Any], let sdkKey = dic["sdkKey"] as? String, !sdkKey.isEmpty {
completion?(sdkKey)
} else {
completion?("")
}
} else {
completion?("")
}
} failBlock: { error in
completion?("")
}
}
func oneKeyLogin(authToken: String, callBackBlock: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) {
let params: [String : Any] = ["auth_token": authToken]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Auth.oneKeyLogin
let _ = YHNetRequest.postRequest(url: strUrl, params: params) {[weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
printLog(json)
let dic = json.data
guard let resultModel = YHUserModel.deserialize(dict: dic as? [AnyHashable : Any]) else {
let error : YHErrorModel = YHErrorModel(errorCode:-1,errorMsg: "数据解析不成功")
callBackBlock(false, error)
return
}
if json.code == 200 {
if resultModel.token?.count != 0 {
//token 正常
YHLoginManager.shared.userModel = resultModel
//数据保存到本地
YHLoginManager.shared.saveLocalUserInfo()
NotificationCenter.default.post(name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil)
//回调
callBackBlock(true,nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:-2,errorMsg: "token 不合法")
callBackBlock(false,error)
}
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false,error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
}
...@@ -163,6 +163,9 @@ class YHAllApiName { ...@@ -163,6 +163,9 @@ class YHAllApiName {
struct Auth { struct Auth {
static let login = "infoflow/auth/login" static let login = "infoflow/auth/login"
static let wxlogin = "infoflow/auth/wechat-login" static let wxlogin = "infoflow/auth/wechat-login"
static let oneKeyLogin = "infoflow/auth/native-login"
static let appleLogin = "infoflow/auth/apple-login"
static let oneKeySecretKeyInfo = "infoflow/auth/sdk-info"
static let logout = "infoflow/auth/logout" static let logout = "infoflow/auth/logout"
//注销app //注销app
static let unregisterApi = "infoflow/auth/cancellation" static let unregisterApi = "infoflow/auth/cancellation"
......
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