杨锴
2024-11-06 63f7ed967433acee3ae8764c7a077e15c29c41f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
//  ForgotPasswordChangeVC.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/8/13.
//
 
import UIKit
import QMUIKit
import JQTools
 
class ForgotPasswordChangeVC: BaseVC {
 
                @IBOutlet weak var tf_input: QMUITextField!
                @IBOutlet weak var btn_complete: UIButton!
                @IBOutlet weak var btn_eye: UIButton!
                private let shadowView = UIView()
                var secretCode:String = ""
                var phone:String = ""
 
 
                init(phone:String,secretCode:String) {
                                super.init(nibName: nil, bundle: nil)
                                self.phone = phone
                                self.secretCode = secretCode
                }
                
                required init?(coder: NSCoder) {
                                fatalError("init(coder:) has not been implemented")
                }
                
                override func viewDidLoad() {
        super.viewDidLoad()
        title = "修改密码"
 
        yy_popBlock = {[weak self] in
            guard let weakSelf = self else { return }
            for vc in weakSelf.navigationController?.viewControllers ?? []{
                if vc is ForgotPasswordVC{
                    weakSelf.navigationController?.popToViewController(vc, animated: true);break
                }
            }
        }
    }
 
                override func setUI() {
                                btn_eye.isSelected = true
                                view.addSubview(shadowView)
                                shadowView.backgroundColor = .white
                                shadowView.snp.makeConstraints { make in
                                                make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(0)
                                                make.left.right.equalToSuperview()
                                                make.height.equalTo(30)
                                }
                }
 
                override func viewDidLayoutSubviews() {
                                super.viewDidLayoutSubviews()
 
                                btn_complete.jq_gradientNibColor(colorArr: [UIColor(hexStr: "#8EA47A").cgColor,UIColor(hexStr: "#AFCA98").cgColor], cornerRadius: 20)
 
                                shadowView.jq_gradientColor(colorArr: [UIColor(hexStr: "#F5F5F5").withAlphaComponent(0.15).cgColor,UIColor.white.cgColor], cornerRadius: 0, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW, height: 30),locations: [0.1,0.9])
 
                }
                @IBAction func eyeAction(_ sender: UIButton) {
                                btn_eye.isSelected = !btn_eye.isSelected
                                tf_input.isSecureTextEntry = btn_eye.isSelected
                }
                
                @IBAction func completeAction(_ sender: UIButton) {
                                view.endEditing(true)
                                guard !tf_input.text!.isEmpty else {alertError(msg: "请输入密码");return}
                                guard tf_input.text!.count >= 8 else {alertError(msg: "密码至少8个字符,不能全是字母或数字");return}
                                guard tf_input.text!.jq_isComplexPassword else {alertError(msg: "密码至少8个字符,不能全是字母或数字");return}
 
                                Services.updatePwd(cellPhone: phone, password: tf_input.text!, secretCode: secretCode).subscribe(onNext: {data in
            if data.code == 200{
                                                                Popup_1_View.show(state: .success, title: "修改成功", subtitle: "您的密码已修改成功,快去登录账户吧") {
                                                                                self.navigationController?.popToRootViewController(animated: true)
                                                                }
                                                }
                                }).disposed(by: disposeBag)
                }
}