无故事王国
2023-10-10 a1ac0f1634ff0bd8f04259fc4cf7ebabd8c8c82d
WanPai/Root/Login/VC/LoginVC.swift
@@ -26,6 +26,9 @@
    @IBOutlet weak var cons_registerCenterX: NSLayoutConstraint!
    @IBOutlet weak var cons_loginCenterX: NSLayoutConstraint!
    @IBOutlet weak var btn_reader: UIButton!
   @IBOutlet weak var cons_stackHei: NSLayoutConstraint!
   @IBOutlet weak var stack_handleView: UIStackView!
    @IBOutlet weak var cons_loginWidth: NSLayoutConstraint!
    private let loginType = BehaviorRelay<LoginType>(value: .pwd)
@@ -43,10 +46,13 @@
        textView_treaty.isEditable = false
        let paragraphStyle = NSMutableParagraphStyle()
        paragraphStyle.lineBreakMode = NSLineBreakMode.byCharWrapping
      paragraphStyle.lineSpacing = 3
        
        let content = "我已阅读并同意《隐私协议》《用户协议》《运动安全告知书》"
        let attribute = NSMutableAttributedString(string: content)
        attribute.addAttributes([NSAttributedString.Key.link:URL(string: "tip://treaty")!], range: content.jq_subRange("《隐私协议》")!)
      attribute.addAttribute(.foregroundColor, value: UIColor.black.withAlphaComponent(0.6), range: NSRange(location: 0, length: content.count))
      attribute.addAttribute(.font, value: UIFont.systemFont(ofSize: 12, weight: .medium), range: NSRange(location: 0, length: content.count))
      attribute.addAttributes([NSAttributedString.Key.link:URL(string: "tip://treaty")!,.foregroundColor:UIColor(hexStr: "0078CD")], range: content.jq_subRange("《隐私协议》")!)
        attribute.addAttributes([NSAttributedString.Key.link:URL(string: "tip://user")!], range: content.jq_subRange("《用户协议》")!)
        attribute.addAttributes([NSAttributedString.Key.link:URL(string: "tip://sportSafety")!], range: content.jq_subRange("《运动安全告知书》")!)
        attribute.addAttributes([.paragraphStyle:paragraphStyle], range: _NSRange(location: 0, length: content.count))
@@ -66,7 +72,7 @@
            case .pwd:
                weakSelf.tf_verify.isSecureTextEntry = !weakSelf.btn_eye.isSelected
                weakSelf.tf_verify.keyboardType = .default
                weakSelf.tf_verify.maximumTextLength = 30
                weakSelf.tf_verify.maximumTextLength = 18
                weakSelf.tf_verify.placeholder = "请输入密码"
            case .smsCode:
                weakSelf.tf_verify.isSecureTextEntry = false
@@ -91,12 +97,16 @@
        
        let str = btn_pwdLogin.isSelected ? "登录":"注册/登录"
        
      self.cons_stackHei.constant = self.btn_pwdLogin.isSelected ? 25:0
        UIView.animate(withDuration: 0.4) {
            self.view.layoutIfNeeded()
            self.btn_login.setTitle(str, for: .normal)
         if self.btn_pwdLogin.isSelected{
            self.stack_handleView.alpha = 1
            self.btn_login.localGradientColor(cornerRadius: 20,bounds: CGRect(x: 0, y: 0, width: 144, height: 40))
         }else{
            self.stack_handleView.alpha = 0
            self.btn_login.localGradientColor(cornerRadius: 20,bounds: CGRect(x: 0, y: 0, width: 189, height: 40))
         }
        } completion: { _ in
@@ -117,7 +127,7 @@
        guard tf_phone.text!.jq_isPhone else {alertError(msg: "请输入正确的手机号");return}
        Services.getSMSCode(phone: tf_phone.text!, type: .login).subscribe(onNext: {data in
         if data.code == 200{
            sender.jq_openCountDown()
            sender.openCountDown()
         }else{
            alertError(msg: data.msg)
         }
@@ -130,8 +140,9 @@
        let type = loginType.value
        guard !tf_phone.text!.isEmpty else {alertError(msg: tf_phone.placeholder!);return}
      guard tf_phone.text!.jq_isPhone else {alertError(msg: "请输入正确的手机号");return}
        guard !tf_verify.text!.isEmpty else {alertError(msg: tf_verify.placeholder!);return}
        guard btn_reader.isSelected else {alert(msg: "请先仔细阅读并同意协议");return}
        guard btn_reader.isSelected else {alert(msg: "请阅读并同意《隐私协议》《用户协议》《运动安全告知书》");return}
        Services.login(phone: tf_phone.text!, verity: tf_verify.text!, type: type).subscribe(onNext: {data in
            if let token = data.data{
@@ -154,6 +165,7 @@
    }
    
    @IBAction func registerAction(_ sender: UIButton) {
      guard btn_reader.isSelected else {alert(msg: "请阅读并同意《隐私协议》《用户协议》《运动安全告知书》");return}
        let vc = LoginRegOrForgotVC(type: .register)
        push(vc: vc)
    }
@@ -164,7 +176,7 @@
    }
    
    @IBAction func wechatLoginAcion(_ sender: QMUIButton) {
      guard btn_reader.isSelected else {alert(msg: "请先仔细阅读并同意协议");return}
      guard btn_reader.isSelected else {alert(msg: "请阅读并同意《隐私协议》《用户协议》《运动安全告知书》");return}
      showHUD()
      WeChatTools.sendAuthRequest()
    }