Commit ecfc017a authored by Steven杜宇's avatar Steven杜宇

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

# Conflicts:
#	galaxy/galaxy.xcodeproj/project.pbxproj
parents 5b2421ab c4c543ba
......@@ -1193,6 +1193,8 @@
04AFEF452D5DDCCB0007A011 /* YHMyFunctionGroup2Cell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AFEF442D5DDCCB0007A011 /* YHMyFunctionGroup2Cell.swift */; };
04AFEF492D5DDE180007A011 /* YHMyFunctionGroupItem2Cell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AFEF482D5DDE180007A011 /* YHMyFunctionGroupItem2Cell.swift */; };
04AFEF4B2D5DF3710007A011 /* YHMyUserInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AFEF4A2D5DF3710007A011 /* YHMyUserInfoView.swift */; };
04E4CF3E2D5C6D32004D4013 /* YHCountryMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E4CF3D2D5C6D32004D4013 /* YHCountryMessageView.swift */; };
04E4CF402D5C83AE004D4013 /* YHSelectPhoneCountryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E4CF3F2D5C83AE004D4013 /* YHSelectPhoneCountryViewController.swift */; };
04EA376D2BEA06EF00DBAF64 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04EA376C2BEA06EF00DBAF64 /* WebKit.framework */; };
04EA376F2BEA071600DBAF64 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 04EA376E2BEA070500DBAF64 /* libc++.tbd */; };
6203A87EDC96313BBE789D9C /* Pods_galaxy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */; };
......@@ -2188,7 +2190,6 @@
045C0E7A2D12CA5E00BD2DC0 /* YHH5WebViewVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHH5WebViewVC.swift; sourceTree = "<group>"; };
045C0E7B2D12CA5E00BD2DC0 /* YHJsApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHJsApi.swift; sourceTree = "<group>"; };
045C0E7D2D12CA5E00BD2DC0 /* YHBasePlayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBasePlayerViewController.swift; sourceTree = "<group>"; };
045C0E7E2D12CA5E00BD2DC0 /* YHFloatingWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFloatingWindow.swift; sourceTree = "<group>"; };
045C0E7F2D12CA5E00BD2DC0 /* YHLivePlayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLivePlayerViewController.swift; sourceTree = "<group>"; };
045C0E802D12CA5E00BD2DC0 /* YHLivePlayerViewController+Api.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "YHLivePlayerViewController+Api.swift"; sourceTree = "<group>"; };
045C0E812D12CA5E00BD2DC0 /* YHLiveStateViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLiveStateViewController.swift; sourceTree = "<group>"; };
......@@ -2423,6 +2424,8 @@
04AFEF442D5DDCCB0007A011 /* YHMyFunctionGroup2Cell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyFunctionGroup2Cell.swift; sourceTree = "<group>"; };
04AFEF482D5DDE180007A011 /* YHMyFunctionGroupItem2Cell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyFunctionGroupItem2Cell.swift; sourceTree = "<group>"; };
04AFEF4A2D5DF3710007A011 /* YHMyUserInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyUserInfoView.swift; sourceTree = "<group>"; };
04E4CF3D2D5C6D32004D4013 /* YHCountryMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCountryMessageView.swift; sourceTree = "<group>"; };
04E4CF3F2D5C83AE004D4013 /* YHSelectPhoneCountryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSelectPhoneCountryViewController.swift; sourceTree = "<group>"; };
04EA376C2BEA06EF00DBAF64 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
04EA376E2BEA070500DBAF64 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
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>"; };
......@@ -5440,7 +5443,6 @@
children = (
045C0E7D2D12CA5E00BD2DC0 /* YHBasePlayerViewController.swift */,
04307BAD2D1FFEA200ED8E8D /* YHLiveAppointmentViewController.swift */,
045C0E7E2D12CA5E00BD2DC0 /* YHFloatingWindow.swift */,
045C0E7F2D12CA5E00BD2DC0 /* YHLivePlayerViewController.swift */,
045C0E802D12CA5E00BD2DC0 /* YHLivePlayerViewController+Api.swift */,
045C0E812D12CA5E00BD2DC0 /* YHLiveStateViewController.swift */,
......@@ -5530,6 +5532,7 @@
045C0EA82D12CA5E00BD2DC0 /* YHPickPhoneAddressViewController.swift */,
045C0EA92D12CA5E00BD2DC0 /* YHUserInfoSettingViewController.swift */,
045C0EAA2D12CA5E00BD2DC0 /* YHWebViewViewController.swift */,
04E4CF3F2D5C83AE004D4013 /* YHSelectPhoneCountryViewController.swift */,
);
path = C;
sourceTree = "<group>";
......@@ -5570,6 +5573,7 @@
045C0EB72D12CA5E00BD2DC0 /* YHLoginPrivacyView.swift */,
045C0EB82D12CA5E00BD2DC0 /* YHLoginStyleButton.swift */,
045C0EB92D12CA5E00BD2DC0 /* YHPhoneMessageView.swift */,
04E4CF3D2D5C6D32004D4013 /* YHCountryMessageView.swift */,
045C0EBA2D12CA5E00BD2DC0 /* YHPrivacyAlertView.swift */,
045C0EBB2D12CA5E00BD2DC0 /* YHValidateCodeInputView.swift */,
);
......@@ -7242,6 +7246,7 @@
045C112F2D12CA5F00BD2DC0 /* YHAboutUsAdvantageCell.swift in Sources */,
045C11302D12CA5F00BD2DC0 /* YHQuestionAndAnswerModel.swift in Sources */,
045C11312D12CA5F00BD2DC0 /* YHAdopterIncomeDetailViewController.swift in Sources */,
04E4CF3E2D5C6D32004D4013 /* YHCountryMessageView.swift in Sources */,
045C11322D12CA5F00BD2DC0 /* YHAdopterBirthViewController.swift in Sources */,
045C11332D12CA5F00BD2DC0 /* YHFormItemEnterDetailCell.swift in Sources */,
045C11342D12CA5F00BD2DC0 /* YHHomeWebViewModel.swift in Sources */,
......@@ -7812,6 +7817,7 @@
045C13332D12CA5F00BD2DC0 /* YHResignCertificateDetailViewController.swift in Sources */,
045C13342D12CA5F00BD2DC0 /* YHDeviceInfoViewController.swift in Sources */,
045C13352D12CA5F00BD2DC0 /* YHScoreOptionsView.swift in Sources */,
04E4CF402D5C83AE004D4013 /* YHSelectPhoneCountryViewController.swift in Sources */,
045C13362D12CA5F00BD2DC0 /* YHQualificationDetailVC.swift in Sources */,
045C13372D12CA5F00BD2DC0 /* YHResignFamilyInfoListCell.swift in Sources */,
045C13382D12CA5F00BD2DC0 /* YHButlerMessageReportHandler.swift in Sources */,
......@@ -8053,11 +8059,9 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = galaxy/galaxyTestEnv.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
DEVELOPMENT_TEAM = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
......@@ -8087,7 +8091,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = com.dev.profile;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = TESTENV;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/$(TARGET_NAME)/Res/galaxy-Bridge-Header.h";
......@@ -8202,11 +8205,9 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = galaxy/galaxy.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
DEVELOPMENT_TEAM = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
......@@ -8236,7 +8237,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = com.dev.profile;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = UATENV;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/$(TARGET_NAME)/Res/galaxy-Bridge-Header.h";
......@@ -8413,11 +8413,9 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = galaxy/galaxyDebug.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
DEVELOPMENT_TEAM = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
......@@ -8447,7 +8445,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = com.dev.profile;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/$(TARGET_NAME)/Res/galaxy-Bridge-Header.h";
SWIFT_VERSION = 5.0;
......@@ -8464,11 +8461,9 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = galaxy/galaxy.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RXHYW88XR7;
DEVELOPMENT_TEAM = RXHYW88XR7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
......@@ -8498,7 +8493,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.intelligence.galaxy;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = com.dev.profile;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/$(TARGET_NAME)/Res/galaxy-Bridge-Header.h";
SWIFT_VERSION = 5.0;
......
......@@ -303,6 +303,10 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
}
getData()
updateNetWorkStatusUI(needReload: false)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)),
name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)),
name: UIResponder.keyboardWillHideNotification, object: nil)
}
......@@ -423,6 +427,22 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
previewFileTool.openXLSXRemoteFile(urlString: urlString, fileName: "")
}
@objc func keyboardWillShow(_ notification: Notification) {
guard let userInfo = notification.userInfo,
let keyboardFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
let keyboardHeight = keyboardFrame.height
// 调用 H5 的 onKeyboardShow 方法,传递高度
let dict = ["height": "\(keyboardHeight)"]
webview.callHandler("onKeyboardHeightChanged", arguments: [dict])
}
@objc func keyboardWillHide(_ notification: Notification) {
// 调用 H5 的 onKeyboardHide 方法
let dict = ["height": "\(0)"]
webview.callHandler("onKeyboardHeightChanged", arguments: [dict])
}
// MARK: - WKNavigationDelegate
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
// if vcTitle == nil {
......
......@@ -158,7 +158,7 @@ extension YHSelectCountryViewController: UITableViewDelegate, UITableViewDataSou
class YHCountryTableViewCell: UITableViewCell {
var titleLabel: UILabel!
var messagelabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
......@@ -193,6 +193,20 @@ class YHCountryTableViewCell: UITableViewCell {
make.centerY.equalToSuperview()
make.height.equalTo(20)
}
messagelabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 13)
label.textColor = UIColor.mainTextColor
label.textAlignment = .right
return label
}()
contentView.addSubview(messagelabel)
messagelabel.snp.makeConstraints { make in
make.right.equalTo(-22)
make.centerY.equalToSuperview()
make.height.equalTo(20)
}
}
}
......@@ -13,6 +13,13 @@ class YHCountryMessage: SmartCodable {
var name_cn: String?
var name_en: String?
var code: String?
required init() {
}
init(name_cn: String? = nil, name_en: String? = nil, code: String? = nil) {
self.name_cn = name_cn
self.name_en = name_en
self.code = code
}
}
......@@ -77,6 +77,10 @@ class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)),
name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)),
name: UIResponder.keyboardWillHideNotification, object: nil)
}
override func viewWillAppear(_ animated: Bool) {
......@@ -456,6 +460,22 @@ private extension YHH5WebViewVC {
func navigationShouldPopOnGesture() -> Bool {
return !disableFullScreenGestureFlag
}
@objc func keyboardWillShow(_ notification: Notification) {
guard let userInfo = notification.userInfo,
let keyboardFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
let keyboardHeight = keyboardFrame.height
// 调用 H5 的 onKeyboardShow 方法,传递高度
let dict = ["height": "\(keyboardHeight)"]
webview.callHandler("onKeyboardHeightChanged", arguments: [dict])
}
@objc func keyboardWillHide(_ notification: Notification) {
// 调用 H5 的 onKeyboardHide 方法
let dict = ["height": "\(0)"]
webview.callHandler("onKeyboardHeightChanged", arguments: [dict])
}
}
......@@ -646,6 +666,16 @@ extension YHH5WebViewVC {
// supportFullScreenSyn("1")
}
gk_navigationBar.isHidden = isHideNavigationBar
if isHideNavigationBar {
webview.snp.remakeConstraints { make in
make.edges.equalToSuperview()
}
} else if !isFullScreenFlag {
webview.snp.remakeConstraints { make in
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.left.right.bottom.equalToSuperview()
}
}
}
//是否支持通屏
......
//
// YHFloatingWindow.swift
// galaxy
//
// Created by alexzzw on 2024/11/29.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
......@@ -23,6 +23,7 @@ class YHCodeSueecssViewController: YHBaseViewController {
var viewModel: YHLoginViewModel?
let appleLoginViewModel = YHAppleLoginViewModel()
var token: String = ""
var country: Country = Country(name: "中国大陆", code: "86", index: "")
var appleLoginParams: [String : Any] = [:]
private var isRequestFlag : Bool = false
......@@ -167,7 +168,7 @@ class YHCodeSueecssViewController: YHBaseViewController {
if type == .phone {
YHHUD.show(.progress(message: "登录中..."))
self.viewModel?.login(phone : phone, code: code, callBackBlock: {[weak self] success,error in
self.viewModel?.login(phone : phone, code: code, countryCode: self.country.code, callBackBlock: {[weak self] success,error in
YHHUD.hide()
self?.isRequestFlag = false
guard let self = self else { return }
......@@ -194,7 +195,7 @@ class YHCodeSueecssViewController: YHBaseViewController {
}
if type == .wechat {
self.viewModel?.wxlogin(unionId: self.token, phone: phone, code: code, callBackBlock: {[weak self] success, error in
self.viewModel?.wxlogin(unionId: self.token, phone: phone, code: code, countryCode: self.country.code, callBackBlock: {[weak self] success, error in
self?.isRequestFlag = false
guard let self = self else { return }
if success == false {
......@@ -219,6 +220,7 @@ class YHCodeSueecssViewController: YHBaseViewController {
var params = self.appleLoginParams
params["sms_code"] = code
params["mobile"] = phone
params["mobile_area_code"] = "+" + self.country.code
printLog("Apple login parmas: \(params)")
YHHUD.show(.progress(message: ""))
self.appleLoginViewModel.appleLogin(params: params) {[weak self] success, error in
......@@ -270,7 +272,7 @@ class YHCodeSueecssViewController: YHBaseViewController {
@objc func startClicked() {
YHHUD.show(.progress(message: ""))
viewModel?.getLoginCode(phoneNumber ?? "", callBackBlock: {[weak self] success,error in
viewModel?.getLoginCode(phoneNumber ?? "", code: self.country.code, callBackBlock: {[weak self] success,error in
YHHUD.hide()
guard let self = self else { return }
......
......@@ -28,6 +28,7 @@ class YHOtherLoginViewController: YHBaseViewController {
var loginTitleLabel: UILabel!
var loginSubTitleLabel: UILabel!
var phoneMessageView: YHPhoneMessageView!
var countryMessageView: YHCountryMessageView!
var getCodeButton: UIButton!
var wechatButton: UIButton!
var appleButton: UIButton!
......@@ -37,6 +38,7 @@ class YHOtherLoginViewController: YHBaseViewController {
var type: YHLoginType = .phone
var token: String = ""
var appleLoginParams: [String : Any] = [:]
var country: Country = Country(name: "中国大陆", code: "86", index: "")
override func viewDidLoad() {
super.viewDidLoad()
......@@ -118,6 +120,28 @@ class YHOtherLoginViewController: YHBaseViewController {
}()
view.addSubview(phoneMessageView)
phoneMessageView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.top.equalTo(356)
make.height.equalTo(56)
}
countryMessageView = {
let view = YHCountryMessageView()
view.block = {[weak self] in
guard let self = self else { return }
let vc = YHSelectPhoneCountryViewController()
vc.backLocationStringController = { (country) in
self.country = country
self.countryMessageView.messageButton.setTitle(country.name, for: .normal)
self.phoneMessageView.messageButton.setTitle("+\(country.code)", for: .normal)
}
UIViewController.current?.navigationController?.pushViewController(vc)
}
return view
}()
view.addSubview(countryMessageView)
countryMessageView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.top.equalTo(300)
......@@ -140,7 +164,7 @@ class YHOtherLoginViewController: YHBaseViewController {
getCodeButton.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.top.equalTo(373)
make.top.equalTo(431)
make.height.equalTo(48)
}
......@@ -150,7 +174,7 @@ class YHOtherLoginViewController: YHBaseViewController {
}()
view.addSubview(privacyView)
privacyView.snp.makeConstraints { make in
make.top.equalTo(442)
make.top.equalTo(503)
make.left.equalTo(25)
make.height.equalTo(20)
make.width.equalTo(260)
......@@ -237,13 +261,16 @@ class YHOtherLoginViewController: YHBaseViewController {
IQKeyboardManager.shared.resignFirstResponder()
if type == .phone {
let phoneNumer = phoneMessageView.phoneTextField.text ?? ""
if self.country.code == "86" {
guard phoneNumer.isMobile() == true else {
YHHUD.flash(message: "请输入正确的手机号")
return
}
}
if privacyView.isAgree {
YHHUD.show(.progress(message: ""))
viewModel?.getLoginCode(phoneNumer, callBackBlock: {[weak self] success,error in
viewModel?.getLoginCode(phoneNumer, code: self.country.code, callBackBlock: {[weak self] success,error in
YHHUD.hide()
guard let self = self else { return }
......@@ -251,6 +278,7 @@ class YHOtherLoginViewController: YHBaseViewController {
if success == true {
let vc = YHCodeSueecssViewController()
vc.phoneNumber = self.phoneMessageView.phoneTextField.text
vc.country = self.country
vc.type = self.type
vc.token = self.token
self.navigationController?.pushViewController(vc)
......@@ -286,12 +314,14 @@ class YHOtherLoginViewController: YHBaseViewController {
}
if type == .wechat {
let phoneNumer = phoneMessageView.phoneTextField.text ?? ""
if self.country.code == "86" {
guard phoneNumer.isMobile() == true else {
YHHUD.flash(message: "请输入正确的手机号")
return
}
}
YHHUD.show(.progress(message: ""))
viewModel?.getLoginCode(phoneNumer, callBackBlock: {[weak self] success,error in
viewModel?.getLoginCode(phoneNumer, code: self.country.code, callBackBlock: {[weak self] success,error in
YHHUD.hide()
guard let self = self else { return }
......@@ -299,6 +329,7 @@ class YHOtherLoginViewController: YHBaseViewController {
if success == true {
let vc = YHCodeSueecssViewController()
vc.phoneNumber = self.phoneMessageView.phoneTextField.text
vc.country = self.country
vc.type = self.type
vc.token = self.token
self.navigationController?.pushViewController(vc)
......@@ -313,12 +344,14 @@ class YHOtherLoginViewController: YHBaseViewController {
}
if type == .apple {
let phoneNumer = phoneMessageView.phoneTextField.text ?? ""
if self.country.code == "86" {
guard phoneNumer.isMobile() == true else {
YHHUD.flash(message: "请输入正确的手机号")
return
}
}
YHHUD.show(.progress(message: ""))
viewModel?.getLoginCode(phoneNumer, callBackBlock: {[weak self] success,error in
viewModel?.getLoginCode(phoneNumer, code: self.country.code, callBackBlock: {[weak self] success,error in
YHHUD.hide()
guard let self = self else { return }
......@@ -326,6 +359,7 @@ class YHOtherLoginViewController: YHBaseViewController {
if success == true {
let vc = YHCodeSueecssViewController()
vc.phoneNumber = self.phoneMessageView.phoneTextField.text
vc.country = self.country
vc.type = self.type
vc.token = self.token
vc.appleLoginParams = self.appleLoginParams
......@@ -347,7 +381,7 @@ class YHOtherLoginViewController: YHBaseViewController {
login.sendLogin()
login.success = { [weak self] unionId in
guard let self = self else { return }
self.viewModel.wxlogin(unionId: unionId, phone: "", code: "") {[weak self] success, error in
self.viewModel.wxlogin(unionId: unionId, phone: "", code: "", countryCode: self.country.code) {[weak self] success, error in
guard let self = self else { return }
if success {
YHLoginManager.shared.loginSuccessActionBlock?()
......
//
// YHSelectPhoneCountryViewController.swift
// galaxy
//
// Created by EDY on 2025/2/12.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
struct Country {
let name: String
let code: String
let index: String // 字符索引
}
class YHSelectPhoneCountryViewController: YHBaseViewController {
public var backLocationStringController: ((Country) -> Void)?
var searchView: UITextField!
var tableView: UITableView!
var searchTableView: UITableView!
var filteredCountries: [Country] = []
let countries: [Country] = [
Country(name: "阿富汗", code: "93", index: "A"),
Country(name: "阿尔巴尼亚", code: "355", index: "A"),
Country(name: "阿尔及利亚", code: "213", index: "A"),
Country(name: "美属萨摩亚", code: "1684", index: "M"),
Country(name: "安道尔", code: "376", index: "A"),
Country(name: "安哥拉", code: "244", index: "A"),
Country(name: "安圭拉", code: "1264", index: "A"),
Country(name: "安提瓜和巴布达", code: "1268", index: "A"),
Country(name: "阿根廷", code: "54", index: "A"),
Country(name: "亚美尼亚", code: "374", index: "Y"),
Country(name: "阿鲁巴", code: "297", index: "A"),
Country(name: "澳大利亚", code: "61", index: "A"),
Country(name: "奥地利", code: "43", index: "A"),
Country(name: "阿塞拜疆", code: "994", index: "A"),
Country(name: "巴哈马", code: "1242", index: "B"),
Country(name: "巴林", code: "973", index: "B"),
Country(name: "孟加拉国", code: "880", index: "M"),
Country(name: "巴巴多斯", code: "1246", index: "B"),
Country(name: "白俄罗斯", code: "375", index: "B"),
Country(name: "比利时", code: "32", index: "B"),
Country(name: "伯利兹", code: "501", index: "B"),
Country(name: "贝宁", code: "229", index: "B"),
Country(name: "百慕大群岛", code: "1441", index: "B"),
Country(name: "不丹", code: "975", index: "B"),
Country(name: "玻利维亚", code: "591", index: "B"),
Country(name: "波斯尼亚和黑塞哥维那", code: "387", index: "B"),
Country(name: "博茨瓦纳", code: "267", index: "B"),
Country(name: "巴西", code: "55", index: "B"),
Country(name: "文莱", code: "673", index: "W"),
Country(name: "保加利亚", code: "359", index: "B"),
Country(name: "布基纳法索", code: "226", index: "B"),
Country(name: "布隆迪", code: "257", index: "B"),
Country(name: "柬埔寨", code: "855", index: "J"),
Country(name: "喀麦隆", code: "237", index: "K"),
Country(name: "加拿大", code: "1", index: "J"),
Country(name: "开普", code: "238", index: "K"),
Country(name: "开曼群岛", code: "1345", index: "K"),
Country(name: "中非共和国", code: "236", index: "Z"),
Country(name: "乍得", code: "235", index: "Z"),
Country(name: "智利", code: "56", index: "Z"),
Country(name: "中国", code: "86", index: "Z"),
Country(name: "哥伦比亚", code: "57", index: "G"),
Country(name: "科摩罗", code: "269", index: "K"),
Country(name: "库克群岛", code: "682", index: "K"),
Country(name: "哥斯达黎加", code: "506", index: "G"),
Country(name: "克罗地亚", code: "385", index: "K"),
Country(name: "库拉索", code: "599", index: "K"),
Country(name: "塞浦路斯", code: "357", index: "S"),
Country(name: "捷克", code: "420", index: "J"),
Country(name: "刚果民主共和国", code: "243", index: "G"),
Country(name: "丹麦", code: "45", index: "D"),
Country(name: "吉布提", code: "253", index: "J"),
Country(name: "多米尼克", code: "1767", index: "D"),
Country(name: "多米尼加共和国", code: "1809", index: "D"),
Country(name: "东帝汶", code: "670", index: "D"),
Country(name: "厄瓜多尔", code: "593", index: "E"),
Country(name: "埃及", code: "20", index: "E"),
Country(name: "萨尔瓦多", code: "503", index: "S"),
Country(name: "赤道几内亚", code: "240", index: "C"),
Country(name: "厄立特里亚", code: "291", index: "E"),
Country(name: "爱沙尼亚", code: "372", index: "A"),
Country(name: "埃塞俄比亚", code: "251", index: "A"),
Country(name: "法罗群岛", code: "298", index: "F"),
Country(name: "斐济", code: "679", index: "F"),
Country(name: "芬兰", code: "358", index: "F"),
Country(name: "法国", code: "33", index: "F"),
Country(name: "法属圭亚那", code: "594", index: "F"),
Country(name: "法属波利尼西亚", code: "689", index: "F"),
Country(name: "加蓬", code: "241", index: "J"),
Country(name: "冈比亚", code: "220", index: "G"),
Country(name: "格鲁吉亚", code: "995", index: "G"),
Country(name: "德国", code: "49", index: "D"),
Country(name: "加纳", code: "233", index: "J"),
Country(name: "直布罗陀", code: "350", index: "Z"),
Country(name: "希腊", code: "30", index: "X"),
Country(name: "格陵兰岛", code: "299", index: "G"),
Country(name: "格林纳达", code: "1473", index: "G"),
Country(name: "瓜德罗普岛", code: "590", index: "G"),
Country(name: "关岛", code: "1671", index: "G"),
Country(name: "瓜地马拉", code: "502", index: "G"),
Country(name: "几内亚", code: "224", index: "J"),
Country(name: "几内亚比绍共和国", code: "245", index: "J"),
Country(name: "圭亚那", code: "592", index: "J"),
Country(name: "海地", code: "509", index: "H"),
Country(name: "洪都拉斯", code: "504", index: "H"),
Country(name: "中国香港", code: "852", index: "Z"),
Country(name: "匈牙利", code: "36", index: "H"),
Country(name: "冰岛", code: "354", index: "B"),
Country(name: "印度", code: "91", index: "Y"),
Country(name: "印度尼西亚", code: "62", index: "Y"),
Country(name: "伊拉克", code: "964", index: "Y"),
Country(name: "爱尔兰", code: "353", index: "Y"),
Country(name: "以色列", code: "972", index: "Y"),
Country(name: "意大利", code: "39", index: "Y"),
Country(name: "象牙海岸", code: "225", index: "X"),
Country(name: "牙买加", code: "1876", index: "Y"),
Country(name: "日本", code: "81", index: "R"),
Country(name: "约旦", code: "962", index: "Y"),
Country(name: "哈萨克斯坦", code: "7", index: "H"),
Country(name: "肯尼亚", code: "254", index: "K"),
Country(name: "基里巴斯", code: "686", index: "J"),
Country(name: "科威特", code: "965", index: "K"),
Country(name: "吉尔吉斯斯坦", code: "996", index: "J"),
Country(name: "老挝", code: "856", index: "L"),
Country(name: "拉脱维亚", code: "371", index: "L"),
Country(name: "黎巴嫩", code: "961", index: "L"),
Country(name: "莱索托", code: "266", index: "L"),
Country(name: "利比里亚", code: "231", index: "L"),
Country(name: "利比亚", code: "218", index: "L"),
Country(name: "列支敦士登", code: "423", index: "L"),
Country(name: "立陶宛", code: "370", index: "L"),
Country(name: "卢森堡", code: "352", index: "L"),
Country(name: "中国澳门", code: "853", index: "Z"),
Country(name: "马其顿", code: "389", index: "M"),
Country(name: "马达加斯加", code: "261", index: "M"),
Country(name: "马拉维", code: "265", index: "M"),
Country(name: "马来西亚", code: "60", index: "M"),
Country(name: "马尔代夫", code: "960", index: "M"),
Country(name: "马里", code: "223", index: "M"),
Country(name: "马耳他", code: "356", index: "M"),
Country(name: "马提尼克", code: "596", index: "M"),
Country(name: "毛里塔尼亚", code: "222", index: "M"),
Country(name: "毛里求斯", code: "230", index: "M"),
Country(name: "马约特", code: "269", index: "M"),
Country(name: "墨西哥", code: "52", index: "M"),
Country(name: "摩尔多瓦", code: "373", index: "M"),
Country(name: "摩纳哥", code: "377", index: "M"),
Country(name: "蒙古", code: "976", index: "M"),
Country(name: "黑山", code: "382", index: "H"),
Country(name: "蒙特塞拉特岛", code: "1664", index: "M"),
Country(name: "摩洛哥", code: "212", index: "M"),
Country(name: "莫桑比克", code: "258", index: "M"),
Country(name: "缅甸", code: "95", index: "M"),
Country(name: "纳米比亚", code: "264", index: "N"),
Country(name: "尼泊尔", code: "977", index: "N"),
Country(name: "荷兰", code: "31", index: "H"),
Country(name: "新喀里多尼亚", code: "687", index: "X"),
Country(name: "新西兰", code: "64", index: "X"),
Country(name: "尼加拉瓜", code: "505", index: "N"),
Country(name: "尼日尔", code: "227", index: "N"),
Country(name: "尼日利亚", code: "234", index: "N"),
Country(name: "挪威", code: "47", index: "N"),
Country(name: "阿曼", code: "968", index: "A"),
Country(name: "巴基斯坦", code: "92", index: "B"),
Country(name: "帕劳", code: "680", index: "P"),
Country(name: "巴勒斯坦", code: "970", index: "B"),
Country(name: "巴拿马", code: "507", index: "B"),
Country(name: "巴布亚新几内亚", code: "675", index: "B"),
Country(name: "巴拉圭", code: "595", index: "B"),
Country(name: "秘鲁", code: "51", index: "B"),
Country(name: "菲律宾", code: "63", index: "P"),
Country(name: "波兰", code: "48", index: "P"),
Country(name: "葡萄牙", code: "351", index: "P"),
Country(name: "波多黎各", code: "1787", index: "P"),
Country(name: "卡塔尔", code: "974", index: "Q"),
Country(name: "刚果共和国", code: "242", index: "G"),
Country(name: "留尼汪", code: "262", index: "L"),
Country(name: "罗马尼亚", code: "40", index: "L"),
Country(name: "俄罗斯", code: "7", index: "L"),
Country(name: "卢旺达", code: "250", index: "L"),
Country(name: "圣基茨和尼维斯", code: "1869", index: "S"),
Country(name: "圣露西亚", code: "1758", index: "S"),
Country(name: "圣彼埃尔和密克隆岛", code: "508", index: "S"),
Country(name: "圣文森特和格林纳丁斯", code: "1784", index: "S"),
Country(name: "萨摩亚", code: "685", index: "S"),
Country(name: "圣马力诺", code: "378", index: "S"),
Country(name: "圣多美和普林西比", code: "239", index: "S"),
Country(name: "沙特阿拉伯", code: "966", index: "S"),
Country(name: "塞内加尔", code: "221", index: "S"),
Country(name: "塞尔维亚", code: "381", index: "S"),
Country(name: "塞舌尔", code: "248", index: "S"),
Country(name: "塞拉利昂", code: "232", index: "S"),
Country(name: "新加坡", code: "65", index: "X"),
Country(name: "圣马丁岛(荷兰部分)", code: "1721", index: "S"),
Country(name: "斯洛伐克", code: "421", index: "S"),
Country(name: "斯洛文尼亚", code: "386", index: "S"),
Country(name: "所罗门群岛", code: "677", index: "S"),
Country(name: "索马里", code: "252", index: "S"),
Country(name: "南非", code: "27", index: "N"),
Country(name: "韩国", code: "82", index: "H"),
Country(name: "西班牙", code: "34", index: "X"),
Country(name: "斯里兰卡", code: "94", index: "S"),
Country(name: "苏丹", code: "249", index: "S"),
Country(name: "苏里南", code: "597", index: "S"),
Country(name: "斯威士兰", code: "268", index: "S"),
Country(name: "瑞典", code: "46", index: "R"),
Country(name: "瑞士", code: "41", index: "R"),
Country(name: "中国台湾", code: "886", index: "Z"),
Country(name: "塔吉克斯坦", code: "992", index: "T"),
Country(name: "坦桑尼亚", code: "255", index: "T"),
Country(name: "泰国", code: "66", index: "T"),
Country(name: "东帝汶", code: "670", index: "D"),
Country(name: "多哥", code: "228", index: "D"),
Country(name: "汤加", code: "676", index: "T"),
Country(name: "特立尼达和多巴哥", code: "1868", index: "T"),
Country(name: "突尼斯", code: "216", index: "T"),
Country(name: "土耳其", code: "90", index: "T"),
Country(name: "土库曼斯坦", code: "993", index: "T"),
Country(name: "特克斯和凯科斯群岛", code: "1649", index: "T"),
Country(name: "乌干达", code: "256", index: "W"),
Country(name: "乌克兰", code: "380", index: "W"),
Country(name: "阿拉伯联合酋长国", code: "971", index: "A"),
Country(name: "英国", code: "44", index: "Y"),
Country(name: "美国", code: "1", index: "M"),
Country(name: "乌拉圭", code: "598", index: "W"),
Country(name: "乌兹别克斯坦", code: "998", index: "W"),
Country(name: "瓦努阿图", code: "678", index: "W"),
Country(name: "委内瑞拉", code: "58", index: "W"),
Country(name: "越南", code: "84", index: "Y"),
Country(name: "英属处女群岛", code: "1340", index: "Y"),
Country(name: "美属维尔京群岛", code: "1284", index: "M"),
Country(name: "也门", code: "967", index: "Y"),
Country(name: "赞比亚", code: "260", index: "Z"),
Country(name: "津巴布韦", code: "263", index: "Z"),
]
var sections: [String] = []
var countryGroups: [String: [Country]] = [:]
var searchDataSource: [YHCountryMessage]?
var viewModel: YHSelectCountryViewModel?
override func viewDidLoad() {
super.viewDidLoad()
gk_navTitle = "国家地区"
viewModel = YHSelectCountryViewModel()
setView()
getData()
}
func getData() {
countryGroups = getIndexedCountries()
sections = sortedIndices()
tableView.reloadData()
}
func sortedIndices() -> [String] {
return getIndexedCountries().keys.sorted()
}
func getIndexedCountries() -> [String: [Country]] {
var indexedCountries = [String: [Country]]()
for country in countries {
if indexedCountries[country.index] == nil {
indexedCountries[country.index] = []
}
indexedCountries[country.index]?.append(country)
}
return indexedCountries
}
func setView() {
view.backgroundColor = .white
searchView = {
let searchBar = UITextField()
searchBar.font = .PFSC_R(ofSize: 14)
searchBar.placeholder = "请输入国家地区"
searchBar.backgroundColor = UIColor.contentBkgColor
searchBar.keyboardType = .default
searchBar.delegate = self
searchBar.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 16, height: 42))
searchBar.leftViewMode = .always
return searchBar
}()
view.addSubview(searchView)
searchView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 16)
make.height.equalTo(42)
make.left.equalTo(16)
make.right.equalTo(-16)
}
tableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.register(cellWithClass: YHCountryTableViewCell.self)
return tableView
}()
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 78)
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom())
make.left.right.equalTo(view)
}
searchTableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.register(cellWithClass: YHCountryTableViewCell.self)
tableView.isHidden = true
return tableView
}()
view.addSubview(searchTableView)
searchTableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + 78)
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom())
make.left.right.equalTo(view)
}
}
}
extension YHSelectPhoneCountryViewController: UITextFieldDelegate {
func textFieldDidChangeSelection(_ textField: UITextField) {
if textField.text == "" {
filteredCountries = []
tableView.isHidden = false
searchTableView.isHidden = true
} else {
// 匹配逻辑
filteredCountries = countries.filter { $0.name.contains(textField.text ?? "") }
tableView.isHidden = true
searchTableView.isHidden = false
}
self.tableView.reloadData()
self.searchTableView.reloadData()
}
}
extension YHSelectPhoneCountryViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
if tableView == searchTableView {
return 1
}
return sections.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if tableView == searchTableView {
return filteredCountries.count
}
let index = sections[section]
return countryGroups[index]?.count ?? 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withClass: YHCountryTableViewCell.self)
let index = sections[indexPath.section]
if tableView == searchTableView {
let country = filteredCountries[indexPath.row]
cell.titleLabel.text = "\(country.name)"
cell.messagelabel.text = "+\(country.code)"
} else {
if let country = countryGroups[index]?[indexPath.row] {
cell.titleLabel.text = "\(country.name)"
cell.messagelabel.text = "+\(country.code)"
}
}
return cell
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if tableView == searchTableView {
return nil
}
return sections[section]
}
// MARK: - Section Index
func sectionIndexTitles(for tableView: UITableView) -> [String]? {
if tableView == searchTableView {
return nil
}
return sections
}
func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
return index
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if tableView == searchTableView {
let country = filteredCountries[indexPath.row]
if let backLocationStringController = backLocationStringController {
backLocationStringController(country)
self.navigationController?.popViewController()
}
} else {
let index = sections[indexPath.section]
let country = countryGroups[index]?[indexPath.row] ?? Country(name: "", code: "", index: "")
if let backLocationStringController = backLocationStringController {
backLocationStringController(country)
self.navigationController?.popViewController()
}
}
}
}
//
// YHCountryMessageView.swift
// galaxy
//
// Created by EDY on 2025/2/12.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHCountryMessageView: UIView {
typealias PhoneBlock = (_ count: Int) -> ()
typealias Block = () -> ()
var block: Block?
var messageButton: UIButton!
var titleButton: UIButton!
var allowButton: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
setView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setView() {
titleButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.setTitle("国家/地区", for: .normal)
button.setTitleColor(UIColor.mainTextColor, for: .normal)
button.addTarget(self, action: #selector(messageClick), for: .touchUpInside)
button.contentHorizontalAlignment = .left
return button
}()
addSubview(titleButton)
titleButton.snp.makeConstraints { make in
make.top.bottom.equalToSuperview()
make.left.equalToSuperview()
make.width.equalTo(85)
make.height.equalTo(20)
}
messageButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.setTitle("中国大陆", for: .normal)
button.setTitleColor(UIColor.mainTextColor, for: .normal)
button.addTarget(self, action: #selector(messageClick), for: .touchUpInside)
button.contentHorizontalAlignment = .left
return button
}()
addSubview(messageButton)
messageButton.snp.makeConstraints { make in
make.top.bottom.equalToSuperview()
make.left.equalTo(105)
make.right.equalToSuperview()
make.height.equalTo(20)
}
allowButton = {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "form_right_arrow"), for: .normal)
button.addTarget(self, action: #selector(messageClick), for: .touchUpInside)
return button
}()
addSubview(allowButton)
allowButton.snp.makeConstraints { make in
make.centerY.right.equalToSuperview()
make.width.height.equalTo(16)
}
let lineone = UIView()
lineone.backgroundColor = UIColor(hex: 0xf0f3f7, alpha: 0.8)
addSubview(lineone)
lineone.snp.makeConstraints { make in
make.left.equalTo(89)
make.height.equalTo(20)
make.width.equalTo(0.5)
make.centerY.equalToSuperview()
}
let line = UIView()
line.backgroundColor = UIColor(hex: 0xf0f3f7, alpha: 0.8)
addSubview(line)
line.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.height.equalTo(0.5)
}
}
@objc func messageClick() {
if let block = block {
block()
}
}
}
......@@ -14,7 +14,9 @@ class YHPhoneMessageView: UIView {
var block: Block?
var phoneBlock: PhoneBlock?
var messageButton: UIButton!
var titleButton: UIButton!
var phoneTextField: UITextField!
override init(frame: CGRect) {
super.init(frame: frame)
setView()
......@@ -25,20 +27,37 @@ class YHPhoneMessageView: UIView {
}
func setView() {
titleButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.setTitle("手机号", for: .normal)
button.setTitleColor(UIColor.mainTextColor, for: .normal)
button.addTarget(self, action: #selector(messageClick), for: .touchUpInside)
button.contentHorizontalAlignment = .left
return button
}()
addSubview(titleButton)
titleButton.snp.makeConstraints { make in
make.top.bottom.equalToSuperview()
make.left.equalToSuperview()
make.width.equalTo(85)
make.height.equalTo(20)
}
messageButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont(name: "DINAlternate-Bold", size: 18)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 16)
button.setTitle("+86", for: .normal)
button.setTitleColor(UIColor.mainTextColor, for: .normal)
button.setTitleColor(UIColor(hex: 0x8993a2), for: .normal)
button.addTarget(self, action: #selector(messageClick), for: .touchUpInside)
button.titleLabel?.textAlignment = .left
button.contentHorizontalAlignment = .left
return button
}()
addSubview(messageButton)
messageButton.snp.makeConstraints { make in
make.top.bottom.equalToSuperview()
make.left.equalToSuperview()
make.width.equalTo(30)
make.left.equalTo(105)
make.width.equalTo(40)
make.height.equalTo(20)
}
......@@ -61,7 +80,15 @@ class YHPhoneMessageView: UIView {
make.height.equalTo(20)
make.right.equalToSuperview()
}
let lineone = UIView()
lineone.backgroundColor = UIColor(hex: 0xf0f3f7, alpha: 0.8)
addSubview(lineone)
lineone.snp.makeConstraints { make in
make.left.equalTo(89)
make.height.equalTo(20)
make.width.equalTo(0.5)
make.centerY.equalToSuperview()
}
let line = UIView()
line.backgroundColor = UIColor(hex: 0xf0f3f7, alpha: 0.8)
......
......@@ -21,10 +21,11 @@ class YHLoginViewModel: YHBaseViewModel {
//接口
extension YHLoginViewModel {
//发送验证码
func getLoginCode(_ phone: String, callBackBlock: @escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
func getLoginCode(_ phone: String, code: String, callBackBlock: @escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["type": "Phone",
"value": XXTEA.encryptString(toBase64String: phone, stringKey: "galaxyapps") ?? phone,
"extend":"register"]
"extend":"register",
"code": "+" + code]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.User.verifyCode
let _ = YHNetRequest.postRequest(url: strUrl, params: params) {[weak self] json, code in
......@@ -48,13 +49,14 @@ extension YHLoginViewModel {
}
}
func login(phone: String, code: String,callBackBlock: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) {
func login(phone: String, code: String, countryCode: String, callBackBlock: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) {
let timestamp = Int(Date().timeIntervalSince1970)
print(timestamp)
let params: [String : Any] = ["mobile": XXTEA.encryptString(toBase64String: phone, stringKey: "galaxyapps") ?? phone,
"sms_code": code,
"client": "super_app",
"mobile_area_code": "+" + countryCode,
"testTimestamp":timestamp]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Auth.login
let _ = YHNetRequest.postRequest(url: strUrl, params: params) {[weak self] json, code in
......@@ -135,18 +137,20 @@ extension YHLoginViewModel {
}
}
func wxlogin(unionId: String, phone: String, code: String, callBackBlock: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) {
func wxlogin(unionId: String, phone: String, code: String, countryCode: String, callBackBlock: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) {
let timestamp = Int(Date().timeIntervalSince1970)
print(timestamp)
var params: [String : Any] = ["union_id": unionId,
"client": "super_app",
"mobile_area_code": "+" + countryCode,
"testTimestamp":timestamp]
if phone.count != 0 {
params = ["union_id": unionId,
"mobile": phone,
"sms_code": code,
"client": "super_app",
"mobile_area_code": "+" + countryCode,
"testTimestamp":timestamp]
}
......
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