소스 검색

代码提交;

Handy_Cao 4 년 전
부모
커밋
b19dc919d0

+ 1 - 1
MTP_iOS/MTP2_iOS/Resource/PlistFiles/Address/LYB_171.plist

@@ -179,7 +179,7 @@
 			<key>bankUrl</key>
 			<string>http://192.168.31.178:20031/bank_scancode</string>
 			<key>areaUrl</key>
-			<string>http://192.168.31.171:8080/cfg?key=test_171</string>
+			<string>http://192.168.31.183:8080/cfg?key=test_183</string>
 		</dict>
 	</array>
 </dict>

+ 156 - 0
MTP_iOS/MTP2_iOS/UserInterface/Mine/Settings/PasswordUpdate/FundPasswordUpdateViewController.swift

@@ -0,0 +1,156 @@
+//
+//  FundPasswordUpdateViewController.swift
+//  MTP2_iOS
+//
+//  Created by zhongyuan on 2018/3/23.
+//  Copyright © 2018年 zhongyuan.All rights reserved.
+//
+
+import UIKit
+import NVActivityIndicatorView
+import WHToast
+
+class FundPasswordUpdateViewController: BaseViewController {
+    /// 资金账号
+    @IBOutlet weak var accountIDLabel: UILabel!
+    /// 旧密码
+    @IBOutlet weak var oldPwdTextField: UITextField!
+    /// 新密码
+    @IBOutlet weak var newPwdTextField: UITextField!
+    /// 确认新密码
+    @IBOutlet weak var confirmPwdTextField: UITextField!
+    /// 忘记密码
+    @IBOutlet weak var forgetPwdButton: UIButton! {
+        didSet {
+            /// 隐藏按钮
+            forgetPwdButton.isHidden = true
+        }
+    }
+    /// 提交按钮
+    @IBOutlet weak var submitButton: UIButton!
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        
+        /// 设置导航栏标题
+        /// 设置accountIDLabel
+        if let accountManager = MTP2BusinessCore.shared.accountManager,
+            let accountInfo = accountManager.getCurrentTAAccountInfo() {
+            accountIDLabel.text = String(accountInfo.accountId)
+        }
+        
+        buildView()
+        addLoadingView()
+    }
+    
+    /// UI界面初始化
+    func buildView() {
+        /// 设置placeholder color
+        oldPwdTextField.attributedPlaceholder = "请输入旧密码".withTextColor(Color_placeholder_text)
+        newPwdTextField.attributedPlaceholder = "请输入6-20个字符新密码".withTextColor(Color_placeholder_text)
+        confirmPwdTextField.attributedPlaceholder = "请再次确认新密码".withTextColor(Color_placeholder_text)
+        
+        /// 样式设置
+        submitButton.backgroundColor = UIColorFromHex(rgbValue: 0xFF9300)
+    }
+    
+    /// 提交表单数据
+    @IBAction func onSubmitButton(_ sender: UIButton) {
+        /// 验证数据
+        if !checkValue() {return}
+        
+        guard let accountManager = MTP2BusinessCore.shared.accountManager,
+            let accountId = accountManager.getCurrentTAAccountInfo()?.accountId else { return }
+        
+        _anim?.startAnimating()
+        
+        self.view.endEditing(true)
+        submitButton.isEnabled = false
+        
+        accountManager.modifyPwd(modifyPwdType: 2, modifyPwdID: UInt64(accountId), oldpwd: oldPwdTextField.text!, newPwd: newPwdTextField.text!) { (isSuccess, errorInfo) in
+            DispatchQueue.main.async {
+                self._anim?.stopAnimating()
+                self.submitButton.isEnabled = true
+                
+                if isSuccess {
+                    WHToast.showSuccess(withMessage: "修改成功", duration: 2.0) {
+                        self.navigationController?.popViewController(animated: true)
+                    }
+                } else {
+                    
+                    self.showErrorMessgae(error: errorInfo)
+                }
+            }
+        }
+    }
+    
+    /// 数据提交检验
+    ///
+    /// - Returns: 是否验证通过
+    func checkValue() -> Bool{
+        guard let oldPwd = oldPwdTextField.text,
+            let newPwd = newPwdTextField.text,
+            let confirmPwd = confirmPwdTextField.text
+            else { return false }
+        
+        if oldPwd.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty {
+            self.showHintController(title: "提示", message: "请输入旧密码", handler: { (_) in
+                self.oldPwdTextField.becomeFirstResponder()
+            })
+            return false
+        }
+        
+        if newPwd.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty {
+            self.showHintController(title: "提示", message: "请输入新密码", handler: { (_) in
+                self.newPwdTextField.becomeFirstResponder()
+            })
+            return false
+        } else if newPwd.count < 6 || newPwd.count > 20 {
+            self.showHintController(title: "提示", message: "请输入6-20位的字符", handler: { (_) in
+                self.newPwdTextField.becomeFirstResponder()
+            })
+            return false
+        }
+        
+        if confirmPwd.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty {
+            self.showHintController(title: "提示", message: "请再次输入新密码", handler: { (_) in
+                self.confirmPwdTextField.becomeFirstResponder()
+            })
+            return false
+        }
+        
+        if newPwd != confirmPwd {
+            self.showHintController(title: "提示", message: "两次新密码输入不一致", handler: { (_) in
+                self.confirmPwdTextField.becomeFirstResponder()
+            })
+            return false
+        }
+        
+        if oldPwd.trimmingCharacters(in: CharacterSet.whitespaces) == newPwd.trimmingCharacters(in: CharacterSet.whitespaces) {
+            self.showHintController(title: "提示", message: "新密码不可和旧密码一致")
+            return false
+        }
+        
+        return true
+    }
+    
+    @IBAction func forgetPwd(_ sender: UIButton) {
+        let nav = UIStoryboard(name: "ForgetPassword", bundle: nil).instantiateViewController(withIdentifier: "ForgetFundPassword")
+        self.present(nav, animated: true, completion: nil)
+    }
+    
+    //MARK: 键盘相关
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        
+        moveView(views: [oldPwdTextField,
+                         newPwdTextField,
+                         confirmPwdTextField])
+    }
+    
+    override func viewWillDisappear(_ animated: Bool) {
+        super.viewWillDisappear(animated)
+        
+        NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
+    }
+}