绑定手机 设置密码
This commit is contained in:
@@ -49,6 +49,9 @@
|
||||
E89F19472B9197090098E797 /* ChatTimeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E89F19462B9197090098E797 /* ChatTimeCell.swift */; };
|
||||
E89F19492B919EB80098E797 /* ChatVoiceCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E89F19482B919EB80098E797 /* ChatVoiceCell.swift */; };
|
||||
E89F194B2B919ECB0098E797 /* ChatImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E89F194A2B919ECB0098E797 /* ChatImageCell.swift */; };
|
||||
E89F19AF2B91C00F0098E797 /* BindMobileVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = E89F19AE2B91C00F0098E797 /* BindMobileVC.swift */; };
|
||||
E89F19B32B91E2C00098E797 /* PasswordSetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = E89F19B22B91E2C00098E797 /* PasswordSetVC.swift */; };
|
||||
E89F19B52B91E3A50098E797 /* PasswordSetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E89F19B42B91E3A50098E797 /* PasswordSetView.swift */; };
|
||||
E8D15A9D2B899E1500369467 /* YMNetworkHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D15A9C2B899E1500369467 /* YMNetworkHelper.swift */; };
|
||||
E8D15A9F2B89AED600369467 /* AuthManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D15A9E2B89AED500369467 /* AuthManager.swift */; };
|
||||
E8D15AA12B89AF4F00369467 /* UserTokenObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D15AA02B89AF4F00369467 /* UserTokenObject.swift */; };
|
||||
@@ -130,6 +133,9 @@
|
||||
E89F19462B9197090098E797 /* ChatTimeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatTimeCell.swift; sourceTree = "<group>"; };
|
||||
E89F19482B919EB80098E797 /* ChatVoiceCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatVoiceCell.swift; sourceTree = "<group>"; };
|
||||
E89F194A2B919ECB0098E797 /* ChatImageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatImageCell.swift; sourceTree = "<group>"; };
|
||||
E89F19AE2B91C00F0098E797 /* BindMobileVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BindMobileVC.swift; sourceTree = "<group>"; };
|
||||
E89F19B22B91E2C00098E797 /* PasswordSetVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordSetVC.swift; sourceTree = "<group>"; };
|
||||
E89F19B42B91E3A50098E797 /* PasswordSetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordSetView.swift; sourceTree = "<group>"; };
|
||||
E8D15A9C2B899E1500369467 /* YMNetworkHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YMNetworkHelper.swift; sourceTree = "<group>"; };
|
||||
E8D15A9E2B89AED500369467 /* AuthManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthManager.swift; sourceTree = "<group>"; };
|
||||
E8D15AA02B89AF4F00369467 /* UserTokenObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserTokenObject.swift; sourceTree = "<group>"; };
|
||||
@@ -492,6 +498,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E8D15AC12B8C703C00369467 /* UserFunctionView.swift */,
|
||||
E89F19B42B91E3A50098E797 /* PasswordSetView.swift */,
|
||||
);
|
||||
path = View;
|
||||
sourceTree = "<group>";
|
||||
@@ -501,6 +508,8 @@
|
||||
children = (
|
||||
E8D15AB72B8B003C00369467 /* UserInfoVC.swift */,
|
||||
E8D15AC42B8C90D400369467 /* AboutUsVC.swift */,
|
||||
E89F19AE2B91C00F0098E797 /* BindMobileVC.swift */,
|
||||
E89F19B22B91E2C00098E797 /* PasswordSetVC.swift */,
|
||||
);
|
||||
path = VC;
|
||||
sourceTree = "<group>";
|
||||
@@ -678,6 +687,7 @@
|
||||
E8479E482B8DD6E1009AF878 /* ChatTextCell.swift in Sources */,
|
||||
E8D15A9F2B89AED600369467 /* AuthManager.swift in Sources */,
|
||||
E8479E382B8DC5CD009AF878 /* ChatListVC.swift in Sources */,
|
||||
E89F19AF2B91C00F0098E797 /* BindMobileVC.swift in Sources */,
|
||||
E86A43B02B85E11B0084C04D /* BaseNavigationViewController.swift in Sources */,
|
||||
E86A43E82B884C5E0084C04D /* String+.swift in Sources */,
|
||||
E8D15AA32B89B03D00369467 /* Deserialized.swift in Sources */,
|
||||
@@ -710,6 +720,7 @@
|
||||
233E515B2B8C849600582F9C /* PlanetStarClickItemView.swift in Sources */,
|
||||
E8FF28B42B90ADBE005D2BE7 /* AppKeys.swift in Sources */,
|
||||
2311D6A92B8F405F001C70AB /* HomeVoiceChooseTypeView.swift in Sources */,
|
||||
E89F19B52B91E3A50098E797 /* PasswordSetView.swift in Sources */,
|
||||
E89F19492B919EB80098E797 /* ChatVoiceCell.swift in Sources */,
|
||||
E8D15AB62B8B002700369467 /* ChatVC.swift in Sources */,
|
||||
E8E4AB182B9019E50096D77C /* ChatKeyboardView.swift in Sources */,
|
||||
@@ -738,6 +749,7 @@
|
||||
E8D15A9D2B899E1500369467 /* YMNetworkHelper.swift in Sources */,
|
||||
E8E4AB1B2B901AF50096D77C /* UIView+.swift in Sources */,
|
||||
2311D69D2B8DC311001C70AB /* PlanetStarModel.swift in Sources */,
|
||||
E89F19B32B91E2C00098E797 /* PasswordSetVC.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
Binary file not shown.
@@ -34,7 +34,8 @@ var window: UIWindow?
|
||||
if result == true {
|
||||
///如果登录成功显示tabbar
|
||||
self.window?.rootViewController = BaseTabBarViewController()
|
||||
if let uid = LoginTokenConfig.config.getAccountInfo()?.uid {
|
||||
let uid = AuthManager.userUid
|
||||
if uid > 0 {
|
||||
UserViewModel.userVM.getUserInfo(uid: uid)
|
||||
}
|
||||
if NIMSDK.shared().loginManager.isLogined() == false {
|
||||
@@ -54,7 +55,7 @@ var window: UIWindow?
|
||||
}
|
||||
}).disposed(by: rx.disposeBag)
|
||||
|
||||
UserViewModel.userVM.userInfo.subscribe(onNext: { result in
|
||||
UserViewModel.userVM.selfInfo.subscribe(onNext: { result in
|
||||
if result.nick?.count ?? 0 <= 0 || result.avatar?.count ?? 0 <= 0 {
|
||||
let fillVC = AuthFillDataVC()
|
||||
fillVC.modalPresentationStyle = .fullScreen
|
||||
|
22
yinmeng-ios/Assets.xcassets/user/user_eye.imageset/Contents.json
vendored
Normal file
22
yinmeng-ios/Assets.xcassets/user/user_eye.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "user_eye@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "user_eye@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
yinmeng-ios/Assets.xcassets/user/user_eye.imageset/user_eye@2x.png
vendored
Normal file
BIN
yinmeng-ios/Assets.xcassets/user/user_eye.imageset/user_eye@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 385 B |
BIN
yinmeng-ios/Assets.xcassets/user/user_eye.imageset/user_eye@3x.png
vendored
Normal file
BIN
yinmeng-ios/Assets.xcassets/user/user_eye.imageset/user_eye@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 610 B |
22
yinmeng-ios/Assets.xcassets/user/user_eye_open.imageset/Contents.json
vendored
Normal file
22
yinmeng-ios/Assets.xcassets/user/user_eye_open.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "user_eye_open@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "user_eye_open@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
yinmeng-ios/Assets.xcassets/user/user_eye_open.imageset/user_eye_open@2x.png
vendored
Normal file
BIN
yinmeng-ios/Assets.xcassets/user/user_eye_open.imageset/user_eye_open@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 288 B |
BIN
yinmeng-ios/Assets.xcassets/user/user_eye_open.imageset/user_eye_open@3x.png
vendored
Normal file
BIN
yinmeng-ios/Assets.xcassets/user/user_eye_open.imageset/user_eye_open@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 486 B |
@@ -149,7 +149,7 @@ extension ChatVC {
|
||||
}
|
||||
|
||||
let par:[String : Any] = ["uid": AuthManager.userUid, "isLikeUid": vm.session.sessionId]
|
||||
RequestGet(path: "fans/islike", parma: par) { data in
|
||||
RequestGet(path: "fans/isLike", parma: par) { data in
|
||||
if let isLike = data as? Bool {
|
||||
self.navView.isLike = isLike
|
||||
}
|
||||
|
283
yinmeng-ios/Modules/User/VC/BindMobileVC.swift
Normal file
283
yinmeng-ios/Modules/User/VC/BindMobileVC.swift
Normal file
@@ -0,0 +1,283 @@
|
||||
//
|
||||
// BindMobileVC.swift
|
||||
// yinmeng-ios
|
||||
//
|
||||
// Created by MaiMang on 2024/3/1.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class BindMobileVC: BaseViewController, HiddenNavigationBarProtocol {
|
||||
var phone:String = ""
|
||||
var code:String = ""
|
||||
var countdownSeconds = 60
|
||||
var timer: Timer?
|
||||
var vm = AuthViewModel.authVM
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
title = "绑定手机号"
|
||||
vm.data.subscribe(onNext: { [weak self] success in
|
||||
if success {
|
||||
HUDTool.show(with: "验证码已发送\n+86\(self?.phone ?? "")")
|
||||
self?.startCountdown()
|
||||
}
|
||||
}).disposed(by: rx.disposeBag)
|
||||
view.addSubview(backImgView)
|
||||
view.addSubview(phoneNumView)
|
||||
view.addSubview(backBtn)
|
||||
view.addSubview(titleLb)
|
||||
phoneNumView.addSubview(areaLb)
|
||||
phoneNumView.addSubview(phonetextFiled)
|
||||
|
||||
codeView.addSubview(codetextFiled)
|
||||
codeView.addSubview(sepView)
|
||||
codeView.addSubview(getCodeBtn)
|
||||
|
||||
backImgView.snp.makeConstraints { make in
|
||||
make.edges.equalTo(view)
|
||||
}
|
||||
|
||||
backBtn.snp.makeConstraints { make in
|
||||
make.size.equalTo(CGSize(width: 20, height: 20))
|
||||
make.left.equalTo(view).offset(16)
|
||||
make.top.equalTo(view).offset(StatusBarHeight + 12)
|
||||
}
|
||||
|
||||
titleLb.snp.makeConstraints { make in
|
||||
make.centerX.equalToSuperview()
|
||||
make.centerY.equalTo(backBtn)
|
||||
}
|
||||
|
||||
phoneNumView.snp.makeConstraints { make in
|
||||
make.left.right.equalToSuperview().inset(36)
|
||||
make.height.equalTo(52)
|
||||
make.top.equalToSuperview().offset(60)
|
||||
}
|
||||
|
||||
areaLb.snp.makeConstraints { make in
|
||||
make.centerY.equalTo(phoneNumView)
|
||||
make.left.equalTo(phoneNumView).offset(20)
|
||||
}
|
||||
|
||||
phonetextFiled.snp.makeConstraints { make in
|
||||
make.top.bottom.equalTo(phoneNumView)
|
||||
make.left.equalTo(phoneNumView).offset(82)
|
||||
}
|
||||
|
||||
codeView.snp.makeConstraints { make in
|
||||
make.left.right.height.equalTo(phoneNumView)
|
||||
make.top.equalTo(phoneNumView.snp.bottom).offset(20)
|
||||
}
|
||||
|
||||
codetextFiled.snp.makeConstraints { make in
|
||||
make.left.equalTo(codeView).offset(20)
|
||||
make.top.bottom.equalTo(codeView)
|
||||
|
||||
}
|
||||
|
||||
sepView.snp.makeConstraints { make in
|
||||
make.size.equalTo(CGSize(width: 1, height: 20))
|
||||
make.centerY.equalTo(codeView)
|
||||
make.right.equalTo(getCodeBtn.snp.left).offset(-16)
|
||||
}
|
||||
|
||||
getCodeBtn.snp.makeConstraints { make in
|
||||
make.top.bottom.equalTo(codeView)
|
||||
make.right.equalTo(codeView).offset(-18)
|
||||
}
|
||||
|
||||
confirmBtn.snp.makeConstraints { make in
|
||||
make.left.right.equalToSuperview().inset(36)
|
||||
make.top.equalTo(codeView.snp.bottom).offset(30)
|
||||
make.height.equalTo(52)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@objc func backBtnAction() {
|
||||
self.navigationController?.popViewController(animated: true)
|
||||
}
|
||||
|
||||
@objc func confirmBtnAction() {
|
||||
if phone.count > 0 {
|
||||
if code.count > 0 {
|
||||
if let phoneDes = phone.encrypt() {
|
||||
let params = ["phone": phoneDes, "code":code, "ticket": AuthManager.ticket]
|
||||
RequestPost(path: "withDraw/phone", parma: params) { _ in
|
||||
HUDTool.show(with: "绑定成功")
|
||||
self.navigationController?.popViewController(animated: true)
|
||||
} fail: { _, msg in
|
||||
HUDTool.show(with: msg)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
HUDTool.show(with: "请输入正确的手机号")
|
||||
}
|
||||
} else {
|
||||
HUDTool.show(with: "请输入正确的手机号")
|
||||
}
|
||||
}
|
||||
|
||||
@objc func getCodeBtnAction() {
|
||||
if phone.count > 0 {
|
||||
vm.getSmsCode(phone: phone, type: 4)
|
||||
} else {
|
||||
HUDTool.show(with: "请输入正确的手机号码")
|
||||
}
|
||||
}
|
||||
|
||||
@objc func phoneTextFiledDidChange(_ textField: UITextField) {
|
||||
if let text = textField.text {
|
||||
if text.count > 11 {
|
||||
textField.text = text.substring(start: 0, 11)
|
||||
}
|
||||
}
|
||||
phone = textField.text ?? ""
|
||||
}
|
||||
|
||||
@objc func codeTextFiledDidChange(_ textField: UITextField) {
|
||||
if let text = textField.text {
|
||||
if text.count > 11 {
|
||||
textField.text = text.substring(start: 0, 11)
|
||||
}
|
||||
}
|
||||
code = textField.text ?? ""
|
||||
}
|
||||
|
||||
private lazy var backImgView: UIImageView = {
|
||||
let imageView = UIImageView()
|
||||
imageView.image = UIImage(named: "auth_login_bg")
|
||||
imageView.isUserInteractionEnabled = true
|
||||
imageView.layer.masksToBounds = true
|
||||
imageView.contentMode = .scaleAspectFill
|
||||
return imageView
|
||||
}()
|
||||
|
||||
private lazy var backBtn: UIButton = {
|
||||
let button = UIButton(type: .custom)
|
||||
button.setImage(UIImage(named: "public_back_white"), for: .normal)
|
||||
button.setImage(UIImage(named: "public_back_white"), for: .selected)
|
||||
button.addTarget(self, action: #selector(backBtnAction), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
private lazy var titleLb: UILabel = {
|
||||
let label = UILabel()
|
||||
label.textColor = .white
|
||||
label.text = "绑定手机号"
|
||||
label.font = UIFont.systemFont(ofSize: 18, weight: .medium)
|
||||
return label
|
||||
}()
|
||||
|
||||
private lazy var phoneNumView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .white
|
||||
view.layer.masksToBounds = true
|
||||
view.layer.cornerRadius = 26
|
||||
return view
|
||||
}()
|
||||
|
||||
private lazy var areaLb: UILabel = {
|
||||
let label = UILabel()
|
||||
label.textColor = .firstText
|
||||
label.text = "+86"
|
||||
label.font = UIFont.systemFont(ofSize: 16)
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var phonetextFiled:UITextField = {
|
||||
let view = UITextField()
|
||||
view.textColor = .firstText
|
||||
view.font = UIFont.systemFont(ofSize: 16)
|
||||
let attribute = NSMutableAttributedString(string: "请输入手机号码", attributes: [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 16), NSAttributedString.Key.foregroundColor:UIColor.placeholderText])
|
||||
view.attributedPlaceholder = attribute
|
||||
view.keyboardType = .numberPad
|
||||
view.tintColor = ThemeColor(hexStr: "#282828")
|
||||
view.addTarget(self, action: #selector(phoneTextFiledDidChange), for: .editingChanged)
|
||||
return view
|
||||
}()
|
||||
|
||||
private lazy var codeView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .white
|
||||
view.layer.masksToBounds = true
|
||||
view.layer.cornerRadius = 26
|
||||
return view
|
||||
}()
|
||||
|
||||
|
||||
lazy var codetextFiled:UITextField = {
|
||||
let view = UITextField()
|
||||
view.textColor = .firstText
|
||||
view.font = UIFont.systemFont(ofSize: 16)
|
||||
let attribute = NSMutableAttributedString(string: "请输入验证码", attributes: [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 16), NSAttributedString.Key.foregroundColor: UIColor.placeholderText])
|
||||
view.attributedPlaceholder = attribute
|
||||
view.keyboardType = .numberPad
|
||||
view.tintColor = ThemeColor(hexStr: "#282828")
|
||||
view.addTarget(self, action: #selector(codeTextFiledDidChange), for: .editingChanged)
|
||||
return view
|
||||
}()
|
||||
|
||||
private lazy var sepView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .clear
|
||||
return view
|
||||
}()
|
||||
|
||||
private lazy var getCodeBtn: UIButton = {
|
||||
let button = UIButton(type: .custom)
|
||||
button.setTitle("获取验证码", for: .normal)
|
||||
button.setTitleColor(ThemeColor(hexStr: "#9552FF"), for: .normal)
|
||||
button.setTitleColor(ThemeColor(hexStr: "#878B9C"), for: .disabled)
|
||||
button.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .regular)
|
||||
button.addTarget(self, action: #selector(getCodeBtnAction), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
private lazy var confirmBtn: UIButton = {
|
||||
let button = UIButton(type: .custom)
|
||||
button.setBackgroundImage(UIImage.gradient(hexsString: ["#FF60FD", "#8974FF", "#69EBFF"]), for: .normal)
|
||||
button.setImage(UIImage(named: "auth_login_confirm"), for: .normal)
|
||||
button.layer.masksToBounds = true
|
||||
button.layer.cornerRadius = 26
|
||||
button.addTarget(self, action: #selector(confirmBtnAction), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
extension BindMobileVC {
|
||||
|
||||
func startCountdown() {
|
||||
if timer != nil {
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
}
|
||||
countdownSeconds = 60
|
||||
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(updateCountdown), userInfo: nil, repeats: true)
|
||||
timer!.fire()
|
||||
}
|
||||
|
||||
@objc func updateCountdown() {
|
||||
countdownSeconds -= 1
|
||||
|
||||
if countdownSeconds <= 0 {
|
||||
getCodeBtn.setTitle("获取验证码", for: .normal)
|
||||
getCodeBtn.isEnabled = true
|
||||
stopCountdown()
|
||||
return
|
||||
}
|
||||
getCodeBtn.isHidden = false
|
||||
let seconds = countdownSeconds % 60
|
||||
getCodeBtn.setTitle("\(seconds)s", for: .disabled)
|
||||
getCodeBtn.isEnabled = false
|
||||
}
|
||||
|
||||
func stopCountdown() {
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
214
yinmeng-ios/Modules/User/VC/PasswordSetVC.swift
Normal file
214
yinmeng-ios/Modules/User/VC/PasswordSetVC.swift
Normal file
@@ -0,0 +1,214 @@
|
||||
//
|
||||
// PasswordSetVC.swift
|
||||
// yinmeng-ios
|
||||
//
|
||||
// Created by MaiMang on 2024/3/1.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class PasswordSetVC: BaseViewController, HiddenNavigationBarProtocol {
|
||||
|
||||
var isSet:Bool?
|
||||
var phone:String?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
view.addSubview(backImgView)
|
||||
view.addSubview(backBtn)
|
||||
view.addSubview(titleLb)
|
||||
view.addSubview(stackView)
|
||||
view.addSubview(tipsLb)
|
||||
view.addSubview(forgetBtn)
|
||||
view.addSubview(confirmBtn)
|
||||
|
||||
stackView.addArrangedSubview(oneView)
|
||||
stackView.addArrangedSubview(twoView)
|
||||
stackView.addArrangedSubview(threeView)
|
||||
|
||||
|
||||
backImgView.snp.makeConstraints { make in
|
||||
make.edges.equalTo(view)
|
||||
}
|
||||
|
||||
backBtn.snp.makeConstraints { make in
|
||||
make.size.equalTo(CGSize(width: 20, height: 20))
|
||||
make.left.equalTo(view).offset(16)
|
||||
make.top.equalTo(view).offset(StatusBarHeight + 12)
|
||||
}
|
||||
|
||||
titleLb.snp.makeConstraints { make in
|
||||
make.centerX.equalToSuperview()
|
||||
make.centerY.equalTo(backBtn)
|
||||
}
|
||||
|
||||
stackView.snp.makeConstraints { make in
|
||||
make.top.equalTo(view).offset(NavHeight + 60)
|
||||
make.left.right.equalTo(view).inset(36)
|
||||
}
|
||||
|
||||
oneView.snp.makeConstraints { make in
|
||||
make.height.equalTo(50)
|
||||
}
|
||||
|
||||
twoView.snp.makeConstraints { make in
|
||||
make.height.equalTo(50)
|
||||
}
|
||||
|
||||
threeView.snp.makeConstraints { make in
|
||||
make.height.equalTo(50)
|
||||
}
|
||||
|
||||
tipsLb.snp.makeConstraints { make in
|
||||
make.centerX.equalTo(view)
|
||||
make.top.equalTo(stackView.snp.bottom).offset(40)
|
||||
}
|
||||
|
||||
forgetBtn.snp.makeConstraints { make in
|
||||
make.height.equalTo(20)
|
||||
make.right.equalTo(stackView)
|
||||
make.top.equalTo(stackView.snp.bottom).offset(8)
|
||||
}
|
||||
|
||||
confirmBtn.snp.makeConstraints { make in
|
||||
make.left.right.equalToSuperview().inset(36)
|
||||
make.top.equalTo(stackView.snp.bottom).offset(70)
|
||||
make.height.equalTo(52)
|
||||
}
|
||||
|
||||
self.oneView.isHidden = isSet == true
|
||||
self.forgetBtn.isHidden = isSet == true
|
||||
}
|
||||
|
||||
private lazy var backImgView: UIImageView = {
|
||||
let imageView = UIImageView()
|
||||
imageView.image = UIImage(named: "auth_login_bg")
|
||||
imageView.isUserInteractionEnabled = true
|
||||
imageView.layer.masksToBounds = true
|
||||
imageView.contentMode = .scaleAspectFill
|
||||
return imageView
|
||||
}()
|
||||
|
||||
private lazy var backBtn: UIButton = {
|
||||
let button = UIButton(type: .custom)
|
||||
button.setImage(UIImage(named: "public_back_white"), for: .normal)
|
||||
button.setImage(UIImage(named: "public_back_white"), for: .selected)
|
||||
button.addTarget(self, action: #selector(backBtnAction), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
private lazy var titleLb: UILabel = {
|
||||
let label = UILabel()
|
||||
label.textColor = .white
|
||||
label.text = "设置密码"
|
||||
label.font = UIFont.systemFont(ofSize: 18, weight: .medium)
|
||||
return label
|
||||
}()
|
||||
|
||||
private lazy var stackView: UIStackView = {
|
||||
let stackView = UIStackView()
|
||||
stackView.distribution = .fill
|
||||
stackView.axis = .vertical
|
||||
stackView.alignment = .fill
|
||||
stackView.spacing = 20
|
||||
return stackView
|
||||
}()
|
||||
|
||||
private lazy var oneView: PasswordSetView = {
|
||||
let view = PasswordSetView()
|
||||
view.placeHolder = "请输入旧密码"
|
||||
return view
|
||||
}()
|
||||
|
||||
private lazy var twoView: PasswordSetView = {
|
||||
let view = PasswordSetView()
|
||||
view.placeHolder = "请设置新密码"
|
||||
return view
|
||||
}()
|
||||
|
||||
private lazy var threeView: PasswordSetView = {
|
||||
let view = PasswordSetView()
|
||||
view.placeHolder = "请确认新密码"
|
||||
return view
|
||||
}()
|
||||
|
||||
private lazy var tipsLb: UILabel = {
|
||||
let label = UILabel()
|
||||
label.textColor = .white
|
||||
label.text = "密码必须使用6-16个字符内的数字和英文字母组合哦!"
|
||||
label.font = UIFont.systemFont(ofSize: 13)
|
||||
return label
|
||||
}()
|
||||
|
||||
private lazy var confirmBtn: UIButton = {
|
||||
let button = UIButton(type: .custom)
|
||||
button.setBackgroundImage(UIImage.gradient(hexsString: ["#FF60FD", "#8974FF", "#69EBFF"]), for: .normal)
|
||||
button.setImage(UIImage(named: "auth_login_confirm"), for: .normal)
|
||||
button.layer.masksToBounds = true
|
||||
button.layer.cornerRadius = 26
|
||||
button.addTarget(self, action: #selector(confirmBtnAction), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
|
||||
private lazy var forgetBtn: UIButton = {
|
||||
let button = UIButton(type: .custom)
|
||||
button.setTitle("忘记密码?", for: .normal)
|
||||
button.setTitleColor(ThemeColor(hexStr: "#FFFFFF", alpha: 0.8), for: .normal)
|
||||
button.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .medium)
|
||||
button.addTarget(self, action: #selector(forgetBtnAction), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
extension PasswordSetVC {
|
||||
@objc func backBtnAction() {
|
||||
self.navigationController?.popViewController(animated:true)
|
||||
}
|
||||
|
||||
@objc func confirmBtnAction() {
|
||||
let old = self.oneView.textFiled.text
|
||||
let newPwd = self.twoView.textFiled.text
|
||||
let secondPwd = self.threeView.textFiled.text
|
||||
if isSet == true {
|
||||
if newPwd == secondPwd {
|
||||
let params = ["phone":phone, "newPwd": newPwd]
|
||||
RequestPost(path: "acc/pwd/set", parma: params) { _ in
|
||||
HUDTool.show(with: "密码设置成功")
|
||||
self.navigationController?.popViewController(animated: true)
|
||||
} fail: { _, msg in
|
||||
HUDTool.show(with:msg)
|
||||
self.navigationController?.popViewController(animated: true)
|
||||
}
|
||||
} else {
|
||||
HUDTool.show(with: "输入的两次密码不一致")
|
||||
}
|
||||
} else {
|
||||
if old?.count ?? 0 > 0 && newPwd?.count ?? 0 > 0 && secondPwd?.count ?? 0 > 0 {
|
||||
if newPwd == secondPwd {
|
||||
let params = ["phone":phone, "newPwd": newPwd, "pwd": old]
|
||||
RequestPost(path: "acc/pwd/modify", parma: params) { _ in
|
||||
HUDTool.show(with: "密码修改成功")
|
||||
self.navigationController?.popViewController(animated: true)
|
||||
} fail: { _, msg in
|
||||
HUDTool.show(with:msg)
|
||||
self.navigationController?.popViewController(animated: true)
|
||||
}
|
||||
} else {
|
||||
HUDTool.show(with: "输入的两次密码不一致")
|
||||
}
|
||||
} else {
|
||||
HUDTool.show(with: "请输入密码")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func forgetBtnAction() {
|
||||
self.navigationController?.pushViewController(AuthForgetVC(), animated: true)
|
||||
}
|
||||
|
||||
}
|
@@ -9,9 +9,22 @@ import UIKit
|
||||
|
||||
class UserInfoVC: BaseViewController, HiddenNavigationBarProtocol {
|
||||
|
||||
var vm = UserViewModel.userVM
|
||||
|
||||
var info:UserObject?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
loadSubView()
|
||||
|
||||
vm.selfInfo.subscribe(onNext: { [weak self] info in
|
||||
self?.info = info
|
||||
}).disposed(by: rx.disposeBag)
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
vm.getUserInfo(uid: AuthManager.userUid)
|
||||
}
|
||||
|
||||
private func loadSubView() {
|
||||
@@ -155,10 +168,20 @@ extension UserInfoVC: UserFunctionViewProtocol{
|
||||
//TODO: 充值
|
||||
print("aaa")
|
||||
case .mobile:
|
||||
//TODO: 手机号
|
||||
print("aaa")
|
||||
if self.info?.isBindPhone == true {
|
||||
HUDTool.show(with: "您已绑定手机号")
|
||||
} else {
|
||||
self.navigationController?.pushViewController(BindMobileVC(), animated: true)
|
||||
}
|
||||
case .password:
|
||||
//TODO: 修改密码
|
||||
if self.info?.isBindPhone == true {
|
||||
let vc = PasswordSetVC()
|
||||
vc.isSet = !(self.info?.isBindPasswd ?? false)
|
||||
vc.phone = self.info?.phone
|
||||
self.navigationController?.pushViewController(vc, animated: true)
|
||||
} else {
|
||||
self.navigationController?.pushViewController(BindMobileVC(), animated: true)
|
||||
}
|
||||
print("aaa")
|
||||
case .logoff:
|
||||
let web = WebViewController(url: "yinmeng/\(H5Utils.logoff.rawValue)")
|
||||
|
@@ -27,6 +27,9 @@ struct UserObject: HandyJSON {
|
||||
var avatar:String? = ""
|
||||
var nick:String? = ""
|
||||
var gender:GenderEnum? = .male
|
||||
var isBindPhone:Bool? = false
|
||||
var isBindPasswd:Bool? = false
|
||||
var phone:String? = ""
|
||||
}
|
||||
|
||||
enum GenderEnum:Int,HandyJSONEnum {
|
||||
|
@@ -9,13 +9,17 @@ import Foundation
|
||||
import RxSwift
|
||||
class UserViewModel: NSObject {
|
||||
static let userVM = UserViewModel.init()
|
||||
|
||||
let selfInfo = PublishSubject<UserObject>()
|
||||
let userInfo = PublishSubject<UserObject>()
|
||||
func getUserInfo(uid:Int) {
|
||||
let params = ["uid":uid]
|
||||
RequestGet(path: "user/get", parma: params) { data in
|
||||
if var info = Deserialized<UserObject>.toModel(with: data) {
|
||||
self.userInfo.onNext(info)
|
||||
if let info = Deserialized<UserObject>.toModel(with: data) {
|
||||
if uid == AuthManager.userUid {
|
||||
self.selfInfo.onNext(info)
|
||||
} else {
|
||||
self.userInfo.onNext(info)
|
||||
}
|
||||
}
|
||||
} fail: { code, message in
|
||||
|
||||
|
78
yinmeng-ios/Modules/User/View/PasswordSetView.swift
Normal file
78
yinmeng-ios/Modules/User/View/PasswordSetView.swift
Normal file
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// PasswordSetView.swift
|
||||
// yinmeng-ios
|
||||
//
|
||||
// Created by MaiMang on 2024/3/1.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class PasswordSetView: UIView {
|
||||
|
||||
|
||||
var placeHolder:String? {
|
||||
didSet {
|
||||
let attribute = NSMutableAttributedString(string: placeHolder ?? "", attributes: [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 16), NSAttributedString.Key.foregroundColor:UIColor.placeholderText])
|
||||
textFiled.attributedPlaceholder = attribute
|
||||
}
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
backgroundColor = .white
|
||||
layer.masksToBounds = true
|
||||
layer.cornerRadius = 25
|
||||
addSubview(textFiled)
|
||||
addSubview(eyeBtn)
|
||||
|
||||
textFiled.snp.makeConstraints { make in
|
||||
make.left.equalToSuperview().offset(15)
|
||||
make.top.bottom.equalToSuperview()
|
||||
make.right.equalTo(eyeBtn.snp.left).offset(-10)
|
||||
}
|
||||
|
||||
eyeBtn.snp.makeConstraints { make in
|
||||
make.size.equalTo(CGSize(width: 18, height: 18))
|
||||
make.centerY.equalToSuperview()
|
||||
make.right.equalTo(self).offset(-15)
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
lazy var textFiled:UITextField = {
|
||||
let view = UITextField()
|
||||
view.textColor = .firstText
|
||||
view.font = UIFont.systemFont(ofSize: 16)
|
||||
view.tintColor = ThemeColor(hexStr: "#282828")
|
||||
view.isSecureTextEntry = true
|
||||
view.addTarget(self, action: #selector(phoneTextFiledDidChange), for: .editingChanged)
|
||||
return view
|
||||
}()
|
||||
|
||||
private lazy var eyeBtn: UIButton = {
|
||||
let button = UIButton(type: .custom)
|
||||
button.setImage(UIImage(named: "user_eye"), for: .normal)
|
||||
button.setImage(UIImage(named: "user_eye_open"), for: .selected)
|
||||
button.addTarget(self, action: #selector(eyeClick), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
@objc func eyeClick() {
|
||||
eyeBtn.isSelected = !eyeBtn.isSelected
|
||||
textFiled.isSecureTextEntry = !textFiled.isSecureTextEntry
|
||||
}
|
||||
|
||||
|
||||
@objc func phoneTextFiledDidChange(_ textField: UITextField) {
|
||||
if let text = textField.text {
|
||||
if text.count > 16 {
|
||||
textField.text = text.substring(start: 0, 16)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user