Commit 705dba9e authored by Steven杜宇's avatar Steven杜宇

// deviceToken 参数

parent 58a5ab04
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
04174D5D2BCD43F9000BA46D /* YHInformationFillCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D582BCD43F9000BA46D /* YHInformationFillCell.swift */; }; 04174D5D2BCD43F9000BA46D /* YHInformationFillCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D582BCD43F9000BA46D /* YHInformationFillCell.swift */; };
04174D5F2BCD44A5000BA46D /* YHMsgListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D5E2BCD44A5000BA46D /* YHMsgListModel.swift */; }; 04174D5F2BCD44A5000BA46D /* YHMsgListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D5E2BCD44A5000BA46D /* YHMsgListModel.swift */; };
04174D622BCD45E5000BA46D /* YHMsgViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D612BCD45E5000BA46D /* YHMsgViewModel.swift */; }; 04174D622BCD45E5000BA46D /* YHMsgViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D612BCD45E5000BA46D /* YHMsgViewModel.swift */; };
04174D642BCD52BD000BA46D /* YHTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D632BCD52BD000BA46D /* YHTestViewController.swift */; };
0425E63D2BA9345200A5E763 /* YHSchemeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E63C2BA9345200A5E763 /* YHSchemeTableViewCell.swift */; }; 0425E63D2BA9345200A5E763 /* YHSchemeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E63C2BA9345200A5E763 /* YHSchemeTableViewCell.swift */; };
0425E6402BA9357D00A5E763 /* YHScemeItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E63F2BA9357D00A5E763 /* YHScemeItemModel.swift */; }; 0425E6402BA9357D00A5E763 /* YHScemeItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E63F2BA9357D00A5E763 /* YHScemeItemModel.swift */; };
0425E6422BA95B1B00A5E763 /* YHSchemeTableFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E6412BA95B1B00A5E763 /* YHSchemeTableFooterView.swift */; }; 0425E6422BA95B1B00A5E763 /* YHSchemeTableFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0425E6412BA95B1B00A5E763 /* YHSchemeTableFooterView.swift */; };
...@@ -460,6 +461,7 @@ ...@@ -460,6 +461,7 @@
04174D582BCD43F9000BA46D /* YHInformationFillCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHInformationFillCell.swift; sourceTree = "<group>"; }; 04174D582BCD43F9000BA46D /* YHInformationFillCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHInformationFillCell.swift; sourceTree = "<group>"; };
04174D5E2BCD44A5000BA46D /* YHMsgListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = YHMsgListModel.swift; path = ../../../../../../../Desktop/YHMsgListModel.swift; sourceTree = "<group>"; }; 04174D5E2BCD44A5000BA46D /* YHMsgListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = YHMsgListModel.swift; path = ../../../../../../../Desktop/YHMsgListModel.swift; sourceTree = "<group>"; };
04174D612BCD45E5000BA46D /* YHMsgViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = YHMsgViewModel.swift; path = ../../../../../../../Desktop/YHMsgViewModel.swift; sourceTree = "<group>"; }; 04174D612BCD45E5000BA46D /* YHMsgViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = YHMsgViewModel.swift; path = ../../../../../../../Desktop/YHMsgViewModel.swift; sourceTree = "<group>"; };
04174D632BCD52BD000BA46D /* YHTestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTestViewController.swift; sourceTree = "<group>"; };
0425E63C2BA9345200A5E763 /* YHSchemeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSchemeTableViewCell.swift; sourceTree = "<group>"; }; 0425E63C2BA9345200A5E763 /* YHSchemeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSchemeTableViewCell.swift; sourceTree = "<group>"; };
0425E63F2BA9357D00A5E763 /* YHScemeItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHScemeItemModel.swift; sourceTree = "<group>"; }; 0425E63F2BA9357D00A5E763 /* YHScemeItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHScemeItemModel.swift; sourceTree = "<group>"; };
0425E6412BA95B1B00A5E763 /* YHSchemeTableFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSchemeTableFooterView.swift; sourceTree = "<group>"; }; 0425E6412BA95B1B00A5E763 /* YHSchemeTableFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSchemeTableFooterView.swift; sourceTree = "<group>"; };
...@@ -1955,6 +1957,7 @@ ...@@ -1955,6 +1957,7 @@
0414BDAC2BC7F02C00225367 /* YHMyNotifySettingVC.swift */, 0414BDAC2BC7F02C00225367 /* YHMyNotifySettingVC.swift */,
049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */, 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */,
048B2A492BC7D9DC00A93BF0 /* YHMyLikeViewController.swift */, 048B2A492BC7D9DC00A93BF0 /* YHMyLikeViewController.swift */,
04174D632BCD52BD000BA46D /* YHTestViewController.swift */,
); );
path = C; path = C;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2592,6 +2595,7 @@ ...@@ -2592,6 +2595,7 @@
045EEEB92B9F171A0022A143 /* YHWorkMessageSelectTableViewCell.swift in Sources */, 045EEEB92B9F171A0022A143 /* YHWorkMessageSelectTableViewCell.swift in Sources */,
044E1E812BC3BBC200A3B4AF /* YHSearchInfomationVC.swift in Sources */, 044E1E812BC3BBC200A3B4AF /* YHSearchInfomationVC.swift in Sources */,
04A7BD0F2BA41C9800BD35A2 /* YHMyDocumentsModel.swift in Sources */, 04A7BD0F2BA41C9800BD35A2 /* YHMyDocumentsModel.swift in Sources */,
04174D642BCD52BD000BA46D /* YHTestViewController.swift in Sources */,
A5ACE92E2B4564F7002C94D2 /* YHValidateCodeInputView.swift in Sources */, A5ACE92E2B4564F7002C94D2 /* YHValidateCodeInputView.swift in Sources */,
045EEED82B9F171A0022A143 /* YHQuestionInfo.swift in Sources */, 045EEED82B9F171A0022A143 /* YHQuestionInfo.swift in Sources */,
A5ACE94E2B4564F7002C94D2 /* AlignedCollectionViewFlowLayout.swift in Sources */, A5ACE94E2B4564F7002C94D2 /* AlignedCollectionViewFlowLayout.swift in Sources */,
......
...@@ -41,7 +41,7 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -41,7 +41,7 @@ extension AppDelegate: JPUSHRegisterDelegate {
let deviceTokenStr = deviceToken.map{String(format:"%02.2hhx", arguments: [$0]) }.joined() let deviceTokenStr = deviceToken.map{String(format:"%02.2hhx", arguments: [$0]) }.joined()
print("deviceToken:\(deviceTokenStr)") print("deviceToken:\(deviceTokenStr)")
JPUSHService.registerDeviceToken(deviceToken) JPUSHService.registerDeviceToken(deviceToken)
YHLoginManager.shared.userModel?.deviceToken = deviceTokenStr YHLoginManager.shared.deviceTokenModel.deviceToken = deviceTokenStr
} }
//获取token 失败 //获取token 失败
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { //可选 func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { //可选
......
...@@ -96,15 +96,19 @@ class YHCodeSueecssViewController: YHBaseViewController { ...@@ -96,15 +96,19 @@ class YHCodeSueecssViewController: YHBaseViewController {
guard let self = self else { return } guard let self = self else { return }
if let phone = self.phoneNumber { if let phone = self.phoneNumber {
self.viewModel?.login(phone : phone, code: code, callBackBlock: {[weak self] success,error in // 登录接口需要加一个deviceToken参数
guard let self = self else { return } YHHUD.show(.progress(message: "登录中..."))
if success == false { if YHLoginManager.shared.deviceTokenModel.registerId.isEmpty {
YHHUD.flash(message: error?.errorMsg ?? "") JPUSHService.registrationIDCompletionHandler {
} else { resCode, registrationID in
YHHUD.flash(message: "登录成功") YHHUD.hide()
self.dismiss(animated: true) YHLoginManager.shared.deviceTokenModel.registerId = registrationID ?? ""
self.requetLogin(phone: phone, code: code)
} }
}) } else {
self.requetLogin(phone: phone, code: code)
}
} else { } else {
printLog("errror : 电话号码为空") printLog("errror : 电话号码为空")
} }
...@@ -163,6 +167,20 @@ class YHCodeSueecssViewController: YHBaseViewController { ...@@ -163,6 +167,20 @@ class YHCodeSueecssViewController: YHBaseViewController {
} }
func requetLogin(phone: String, code: String) {
YHHUD.show(.progress(message: "登录中..."))
self.viewModel?.login(phone : phone, code: code, callBackBlock: {[weak self] success,error in
YHHUD.hide()
guard let self = self else { return }
if success == false {
YHHUD.flash(message: error?.errorMsg ?? "")
} else {
YHHUD.flash(message: "登录成功")
self.dismiss(animated: true)
}
})
}
func startTime() { func startTime() {
getCodeLabel.isHidden = false getCodeLabel.isHidden = false
getCodeButton.isHidden = true getCodeButton.isHidden = true
......
...@@ -17,8 +17,10 @@ struct YHUserModel: SmartCodable { ...@@ -17,8 +17,10 @@ struct YHUserModel: SmartCodable {
var sex: Int? var sex: Int?
var token: String? var token: String?
}
struct YHDeviceTokenModel {
var deviceToken: String = "" var deviceToken: String = ""
var pushUserId: String = ""
var registerId: String = "" var registerId: String = ""
} }
......
...@@ -12,6 +12,8 @@ class YHLoginManager: NSObject { ...@@ -12,6 +12,8 @@ class YHLoginManager: NSObject {
static let shared = YHLoginManager() static let shared = YHLoginManager()
var userModel: YHUserModel? var userModel: YHUserModel?
var deviceTokenModel : YHDeviceTokenModel = YHDeviceTokenModel()
private override init() {} private override init() {}
func isLogin() -> Bool { func isLogin() -> Bool {
......
//
// YHTestViewController.swift
// galaxy
//
// Created by edy on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHTestViewController: YHBaseViewController {
lazy var nameLabel: UILabel = {
let nameLabel = UILabel()
nameLabel.textColor = UIColor(hex:0x121A26)
nameLabel.textAlignment = .left
nameLabel.font = UIFont.PFSC_M(ofSize:15)
nameLabel.numberOfLines = 0
return nameLabel
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
view.addSubview(nameLabel)
nameLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalToSuperview()
}
YHHUD.show(.progress(message: "加载中..."))
JPUSHService.registrationIDCompletionHandler {
resCode, registrationID in
YHHUD.hide()
YHLoginManager.shared.deviceTokenModel.registerId = registrationID ?? ""
var info = "deviceToken: \n" + (YHLoginManager.shared.deviceTokenModel.deviceToken)
info += "\nregisterId: \n" + (YHLoginManager.shared.deviceTokenModel.registerId)
DispatchQueue.main.async {
self.nameLabel.text = info
}
}
}
}
...@@ -90,7 +90,9 @@ class YHNetRequest: NSObject { ...@@ -90,7 +90,9 @@ class YHNetRequest: NSObject {
requestHeader.add(name:"sign",value:sign) requestHeader.add(name:"sign",value:sign)
requestHeader.add(name: "token", value: YHLoginManager.shared.userModel?.token ?? "-") requestHeader.add(name: "token", value: YHLoginManager.shared.userModel?.token ?? "-")
requestHeader.add(name: "device-id", value: YHLoginManager.shared.userModel?.registerId ?? "") if !YHLoginManager.shared.deviceTokenModel.registerId.isEmpty {
requestHeader.add(name: "device-id", value: YHLoginManager.shared.deviceTokenModel.registerId)
}
// requestHeader.add(name: "token", value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTI0NjA1NzQsImkiOjk4OTcwNDI5NjA3NzI0OSwidSI6IumTtuays-mbhuWboiIsInIiOiJzdXBlcl9hcHAifQ.jyBpXSii6nlRIITdOya3GQa5eb5G42Jh9nj39Cncwl8") // requestHeader.add(name: "token", value: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTI0NjA1NzQsImkiOjk4OTcwNDI5NjA3NzI0OSwidSI6IumTtuays-mbhuWboiIsInIiOiJzdXBlcl9hcHAifQ.jyBpXSii6nlRIITdOya3GQa5eb5G42Jh9nj39Cncwl8")
......
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