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
This diff is collapsed.
......@@ -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?()
......
//
// 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