diff --git a/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj b/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj index e5834f3..ecdd2fa 100644 --- a/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj +++ b/ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj @@ -127,7 +127,6 @@ BF7A4C84204E338500460463 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF7A4C7E204E338400460463 /* Assets.xcassets */; }; BF7A4C85204E338500460463 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF7A4C7F204E338400460463 /* LaunchScreen.storyboard */; }; BF7A4C86204E338500460463 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF7A4C81204E338400460463 /* Main.storyboard */; }; - BF7A4C87204E338500460463 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = BF7A4C83204E338400460463 /* Info.plist */; }; BFA7443A207DB6EE00845D30 /* ActivationSchoolCardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFA74439207DB6EE00845D30 /* ActivationSchoolCardViewController.swift */; }; BFA7446C208193D300845D30 /* MessageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFA7446B208193D300845D30 /* MessageManager.swift */; }; BFBC06C52063AE8900CCFAFF /* ZLaunchAd.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBC06BB2063AE8800CCFAFF /* ZLaunchAd.swift */; }; @@ -471,6 +470,7 @@ 599364E2204E62E700C8B371 /* my */ = { isa = PBXGroup; children = ( + BF621CAB205660E90040D2C1 /* My.storyboard */, BFCED886205280B700055373 /* Controller */, BFCED889205280C900055373 /* Model */, 599364E4204E62E700C8B371 /* View */, @@ -592,6 +592,16 @@ path = ReportView; sourceTree = ""; }; + AD514759208720CD00EEABDC /* Login */ = { + isa = PBXGroup; + children = ( + BF621CAD2056663C0040D2C1 /* LoginViewController.swift */, + BFF9B7E82056852A00F39B3E /* RegisterViewController.swift */, + BFF9B7EA205772E100F39B3E /* GetBackPasswordViewController.swift */, + ); + path = Login; + sourceTree = ""; + }; ADC9AB70207C558600348EF1 /* Model */ = { isa = PBXGroup; children = ( @@ -777,17 +787,14 @@ BFCED886205280B700055373 /* Controller */ = { isa = PBXGroup; children = ( + AD514759208720CD00EEABDC /* Login */, BFCED887205280B700055373 /* MyViewController.swift */, - BFF9B7E82056852A00F39B3E /* RegisterViewController.swift */, - BF621CAD2056663C0040D2C1 /* LoginViewController.swift */, - BFF9B7EA205772E100F39B3E /* GetBackPasswordViewController.swift */, BF621CAF2056664C0040D2C1 /* CurrentInfoViewController.swift */, BF406CD52057B03A000A6681 /* MessageViewController.swift */, BF406CDB2057C110000A6681 /* OrderDetailViewController.swift */, BFF9B7EC2057776100F39B3E /* MyChildrenViewController.swift */, BFF9B7F52057A4C900F39B3E /* ChildrenDetailViewController.swift */, BFA74439207DB6EE00845D30 /* ActivationSchoolCardViewController.swift */, - BF621CAB205660E90040D2C1 /* My.storyboard */, ); path = Controller; sourceTree = ""; @@ -925,7 +932,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = HANGZHOUTEAM; TargetAttributes = { BF7A4C2F204CD55300460463 = { @@ -967,7 +974,6 @@ AD122AC220843FAF00C7D0AD /* ProgramVacateTextFieldCell.xib in Resources */, BF67F3BF20590A2F002FDC61 /* Info-watchOS.plist in Resources */, 599364EB204E62E700C8B371 /* Information.storyboard in Resources */, - BF7A4C87204E338500460463 /* Info.plist in Resources */, 599364FC204E742000C8B371 /* ChannelSelectViewCollectionViewCell.xib in Resources */, ADC9AB78207C65FC00348EF1 /* GrowSubjectCell.xib in Resources */, ADC9AB80207C672800348EF1 /* SceneTopCell.xib in Resources */, @@ -1240,6 +1246,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -1247,6 +1254,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -1297,6 +1305,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -1304,6 +1313,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate b/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate index 5010c5f..8d891c9 100644 Binary files a/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate and b/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/GetBackPasswordViewController.swift b/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/GetBackPasswordViewController.swift deleted file mode 100644 index 92899e5..0000000 --- a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/GetBackPasswordViewController.swift +++ /dev/null @@ -1,235 +0,0 @@ -// -// GetBackPasswordViewController.swift -// ParentAssistant -// -// Created by 葛建军 on 2018/3/13. -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. -// - -import UIKit -//找回密码 -class GetBackPasswordViewController: UITableViewController,UITextFieldDelegate { - @IBOutlet var rootTableView: UITableView! - @IBOutlet var personIconImageView: UIImageView!//系统头像 - @IBOutlet var phoneTextField: UITextField!//电话号码 - @IBOutlet var codeTextField: UITextField!//验证码 - @IBOutlet var passwordTextField: UITextField!//密码 - @IBOutlet var passwordTwoTextField: UITextField!//密码 - @IBOutlet var getCodeBtn: UIButton!//获取验证码按钮 - @IBOutlet var passwordHiddenBtn: UIButton!//查看密码按钮 - @IBOutlet var passwordTwoHiddenBtn: UIButton!//查看密码按钮 - - @IBOutlet var changeBtn: UIButton!//确认按钮 - - - override func viewDidLoad() { - super.viewDidLoad() - - layoutSubViews() - } - - //MARK: - 用户拖拽 关闭键盘 - override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { - phoneTextField.resignFirstResponder() - codeTextField.resignFirstResponder() - passwordTextField.resignFirstResponder() - passwordTwoTextField.resignFirstResponder() - } - //return 关闭键盘 - func textFieldShouldReturn(_ textField: UITextField) -> Bool { - return textField.resignFirstResponder() - } - - //MARK: - UITableView Delegate && DataSource - override func numberOfSections(in tableView: UITableView) -> Int { - return 1 - } - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 6 - } - override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - if indexPath.row == 0 { - return 200 - } - else{ - return 50 - } - } - - // MARK: - 设置控件属性 - func layoutSubViews(){ - self.navigationController?.navigationBar.isHidden = false - getCodeBtn.layer.borderWidth = 1.0 - getCodeBtn.layer.borderColor = UIColor.lightGray.cgColor - passwordHiddenBtn.setImage(UIImage(named: "my_password_look"), for: UIControlState.selected) - NotificationCenter.default.addObserver(self, selector: #selector(GetBackPasswordViewController.keyboardWIllChange(_:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil) - - //监听按钮状态 - phoneTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) - codeTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) - passwordTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) - passwordTwoTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) - } - //MARK: - 监听输入长度,显示登录按钮状态 - @objc func textFieldChange(){ - if (phoneTextField.text?.count)!>0 && (passwordTextField.text?.count)!>0 && (codeTextField.text?.count)!>0 && (passwordTwoTextField.text?.count)!>0 { - passwordHiddenBtn.isUserInteractionEnabled = true - passwordHiddenBtn.backgroundColor = navigationColor - }else{ - passwordHiddenBtn.isUserInteractionEnabled = false - passwordHiddenBtn.backgroundColor = UIColor.lightGray - } - } - // MARK: - 根据键盘调整高度 - @objc func keyboardWIllChange(_ noti: Notification){ - let userInfo:NSDictionary=noti.userInfo! as NSDictionary - let endFrame=(userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue - let y = navigationBarHeight! + statusBarHeight - if endFrame?.origin.y == getScreenHeight() { - UIView.animate(withDuration: 0.5) { - self.rootTableView.frame = CGRect.init(x: 0, y: y, width: screenWidth, height:screenHeight) - } - }else{ - UIView.animate(withDuration: 0.5) { - self.rootTableView.frame = CGRect.init(x: 0, y: 0, width: screenWidth, height: screenHeight) - } - } - } - // MARK: - 获取验证码 - @IBAction func getCodeAction(_ sender: UIButton) { - self.view.endEditing(true) - if isMobilePhoneNumber(phoneTextField.text!) { - HTTPServer.shared.getCaptcha(phoneTextField.text!, completionHandler: { (str, error) -> Void in - httpJsonResule(jsonString: str, error: error, successHandler: { (json) -> Void in - if !json["data"].boolValue{ - appDelegate.window!.makeToast("短信发送失败:\(json["message"].stringValue)", duration: 1, position: CSToastPositionCenter) - }else{ - appDelegate.window!.makeToast("已发送短信,请注意查收", duration: 1, position: CSToastPositionCenter) - } - }, failHandler: { (er) -> Void in - appDelegate.window!.makeToast("验证码发送失败") - }) - }) - }else{ - appDelegate.window!.makeToast("手机号格式不正确,请输入正确的手机号码", duration: 1, position: CSToastPositionCenter) - } - } - - - // MARK: - 密码显示与否 - @IBAction func passwordHiddenAction(_ sender: UIButton) { - let selected = passwordHiddenBtn.isSelected - passwordHiddenBtn.isSelected = !selected - passwordTextField.isSecureTextEntry = selected - } - @IBAction func passwordTwoHiddenAction(_ sender: UIButton) { - let selected = passwordTwoHiddenBtn.isSelected - passwordTwoHiddenBtn.isSelected = !selected - passwordTwoTextField.isSecureTextEntry = selected - } - - // MARK: - UITextFieldDelegate - func textFieldDidEndEditing(_ textField: UITextField) { - if textField==passwordTwoTextField && phoneTextField.text! != "" && codeTextField.text! != "" && passwordTextField.text! != "" && passwordTwoTextField.text! != "" && passwordTextField.text! == passwordTwoTextField.text!{ - changeBtn.isUserInteractionEnabled = true - changeBtn.backgroundColor = navigationColor - }else{ - changeBtn.isUserInteractionEnabled = false - changeBtn.backgroundColor = UIColor.lightGray - } - } - - func isMobilePhoneNumber(_ mobile:String)->Bool { - let str="^1[0-9]{10}" - return NSPredicate(format: "SELF MATCHES %@", str).evaluate(with: mobile) - } - // MARK: - 确认按钮 - @IBAction func changeAction(_ sender: UIButton) { - //登录并返回页面 - if passwordTextField.text!.count<6{ - appDelegate.window!.makeToast("为保障安全密码不得少于6位", duration: 1, position: CSToastPositionCenter) - return - } - if passwordTextField.text != passwordTwoTextField.text{ - appDelegate.window!.makeToast("密码不一致请重新输入", duration: 1, position: CSToastPositionCenter) - return - } - if passwordTextField.text!.contains(" "){ - appDelegate.window!.makeToast("密码不能含有空格请重新输入", duration: 1, position: CSToastPositionCenter) - return - } - SVProgressHUD.show() - HTTPServer.shared.resetPassWord(phoneTextField.text!, pw:passwordTextField.text!, code:codeTextField.text!) { (str, error) -> Void in - SVProgressHUD.dismiss() - httpJsonResule(jsonString: str, error: error, successHandler: { (json) -> Void in - let alertVC = UIAlertController(title: "提示", message: "密码修改成功", preferredStyle: UIAlertControllerStyle.alert) - let showBtn = UIAlertAction(title: "确认", style: UIAlertActionStyle.default) { (action) in - self.navigationController?.popToRootViewController(animated: true) - //登录 - SVProgressHUD.show(withStatus: "登录中...") - HTTPServer.shared.login(completionHandler: { (str, error) in - SVProgressHUD.dismiss() - let json=JSON.fromString(str) - if let ret=json{ - let er=ret["error"].string - if let errorStr=er{ - let Strings=errorStr.components(separatedBy: ":") - if Strings.count >= 2 { - switch Strings[1] { - //用户关联多个身份,请使用学事号登录:100 - case "101"://用户认证身份不存在:101 - appDelegate.window!.makeToast("用户认证身份不存在,请进行账号激活。") - break - //用户帐号或密码错误:102 - case "103":// 用户不存在:103 - appDelegate.window!.makeToast("该号码不存在,请联系客服400-826-2468") - break - default: - appDelegate.window!.makeToast(errorStr) - break - } - }else{ - appDelegate.window!.makeToast(errorStr) - } - }else if ret["access_token"].stringValue != ""{ - AccountManager.shared.setTokenInfo(tokenInfo: ret) - AccountManager.shared.saveToken(tokenInfo: ret) - AccountManager.shared.refreshUserInfo(self.phoneTextField.text!, completionHandler: { (finish) in - if finish{ - let ID=AccountManager.shared.rawUserInfo!.contentData()["userid"].stringValue - YXMessageManager.share.loginWithYX(account: ID, token: ID.md5()) { (success) in - SVProgressHUD.dismiss() - if !success { - AccountManager.shared.logOut() - appDelegate.window!.makeToast("聊天服务登录失败,请连接网络重试") - }else{ - //云信登录成功 - self.dismiss(animated: true, completion: nil) - } - } - }else{ - appDelegate.window!.makeToast("身份获取失败") - SVProgressHUD.dismiss() - } - }) - }else{ - SVProgressHUD.dismiss() - appDelegate.window!.makeToast("登录失败,请稍后重试") - } - }else{ - SVProgressHUD.dismiss() - appDelegate.window!.makeToast("登录失败") - } - }, phone: self.phoneTextField.text!, password: self.passwordTextField.text!) - } - alertVC.addAction(showBtn) - self.present(alertVC, animated: true, completion: nil) - }, failHandler: { (er) -> Void in - appDelegate.window!.makeToast(er.localizedDescription, duration: 1, position: CSToastPositionCenter) - }) - } - - - } - -} diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/Login/GetBackPasswordViewController.swift b/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/Login/GetBackPasswordViewController.swift new file mode 100644 index 0000000..92899e5 --- /dev/null +++ b/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/Login/GetBackPasswordViewController.swift @@ -0,0 +1,235 @@ +// +// GetBackPasswordViewController.swift +// ParentAssistant +// +// Created by 葛建军 on 2018/3/13. +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. +// + +import UIKit +//找回密码 +class GetBackPasswordViewController: UITableViewController,UITextFieldDelegate { + @IBOutlet var rootTableView: UITableView! + @IBOutlet var personIconImageView: UIImageView!//系统头像 + @IBOutlet var phoneTextField: UITextField!//电话号码 + @IBOutlet var codeTextField: UITextField!//验证码 + @IBOutlet var passwordTextField: UITextField!//密码 + @IBOutlet var passwordTwoTextField: UITextField!//密码 + @IBOutlet var getCodeBtn: UIButton!//获取验证码按钮 + @IBOutlet var passwordHiddenBtn: UIButton!//查看密码按钮 + @IBOutlet var passwordTwoHiddenBtn: UIButton!//查看密码按钮 + + @IBOutlet var changeBtn: UIButton!//确认按钮 + + + override func viewDidLoad() { + super.viewDidLoad() + + layoutSubViews() + } + + //MARK: - 用户拖拽 关闭键盘 + override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { + phoneTextField.resignFirstResponder() + codeTextField.resignFirstResponder() + passwordTextField.resignFirstResponder() + passwordTwoTextField.resignFirstResponder() + } + //return 关闭键盘 + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + return textField.resignFirstResponder() + } + + //MARK: - UITableView Delegate && DataSource + override func numberOfSections(in tableView: UITableView) -> Int { + return 1 + } + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 6 + } + override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + if indexPath.row == 0 { + return 200 + } + else{ + return 50 + } + } + + // MARK: - 设置控件属性 + func layoutSubViews(){ + self.navigationController?.navigationBar.isHidden = false + getCodeBtn.layer.borderWidth = 1.0 + getCodeBtn.layer.borderColor = UIColor.lightGray.cgColor + passwordHiddenBtn.setImage(UIImage(named: "my_password_look"), for: UIControlState.selected) + NotificationCenter.default.addObserver(self, selector: #selector(GetBackPasswordViewController.keyboardWIllChange(_:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil) + + //监听按钮状态 + phoneTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) + codeTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) + passwordTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) + passwordTwoTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) + } + //MARK: - 监听输入长度,显示登录按钮状态 + @objc func textFieldChange(){ + if (phoneTextField.text?.count)!>0 && (passwordTextField.text?.count)!>0 && (codeTextField.text?.count)!>0 && (passwordTwoTextField.text?.count)!>0 { + passwordHiddenBtn.isUserInteractionEnabled = true + passwordHiddenBtn.backgroundColor = navigationColor + }else{ + passwordHiddenBtn.isUserInteractionEnabled = false + passwordHiddenBtn.backgroundColor = UIColor.lightGray + } + } + // MARK: - 根据键盘调整高度 + @objc func keyboardWIllChange(_ noti: Notification){ + let userInfo:NSDictionary=noti.userInfo! as NSDictionary + let endFrame=(userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue + let y = navigationBarHeight! + statusBarHeight + if endFrame?.origin.y == getScreenHeight() { + UIView.animate(withDuration: 0.5) { + self.rootTableView.frame = CGRect.init(x: 0, y: y, width: screenWidth, height:screenHeight) + } + }else{ + UIView.animate(withDuration: 0.5) { + self.rootTableView.frame = CGRect.init(x: 0, y: 0, width: screenWidth, height: screenHeight) + } + } + } + // MARK: - 获取验证码 + @IBAction func getCodeAction(_ sender: UIButton) { + self.view.endEditing(true) + if isMobilePhoneNumber(phoneTextField.text!) { + HTTPServer.shared.getCaptcha(phoneTextField.text!, completionHandler: { (str, error) -> Void in + httpJsonResule(jsonString: str, error: error, successHandler: { (json) -> Void in + if !json["data"].boolValue{ + appDelegate.window!.makeToast("短信发送失败:\(json["message"].stringValue)", duration: 1, position: CSToastPositionCenter) + }else{ + appDelegate.window!.makeToast("已发送短信,请注意查收", duration: 1, position: CSToastPositionCenter) + } + }, failHandler: { (er) -> Void in + appDelegate.window!.makeToast("验证码发送失败") + }) + }) + }else{ + appDelegate.window!.makeToast("手机号格式不正确,请输入正确的手机号码", duration: 1, position: CSToastPositionCenter) + } + } + + + // MARK: - 密码显示与否 + @IBAction func passwordHiddenAction(_ sender: UIButton) { + let selected = passwordHiddenBtn.isSelected + passwordHiddenBtn.isSelected = !selected + passwordTextField.isSecureTextEntry = selected + } + @IBAction func passwordTwoHiddenAction(_ sender: UIButton) { + let selected = passwordTwoHiddenBtn.isSelected + passwordTwoHiddenBtn.isSelected = !selected + passwordTwoTextField.isSecureTextEntry = selected + } + + // MARK: - UITextFieldDelegate + func textFieldDidEndEditing(_ textField: UITextField) { + if textField==passwordTwoTextField && phoneTextField.text! != "" && codeTextField.text! != "" && passwordTextField.text! != "" && passwordTwoTextField.text! != "" && passwordTextField.text! == passwordTwoTextField.text!{ + changeBtn.isUserInteractionEnabled = true + changeBtn.backgroundColor = navigationColor + }else{ + changeBtn.isUserInteractionEnabled = false + changeBtn.backgroundColor = UIColor.lightGray + } + } + + func isMobilePhoneNumber(_ mobile:String)->Bool { + let str="^1[0-9]{10}" + return NSPredicate(format: "SELF MATCHES %@", str).evaluate(with: mobile) + } + // MARK: - 确认按钮 + @IBAction func changeAction(_ sender: UIButton) { + //登录并返回页面 + if passwordTextField.text!.count<6{ + appDelegate.window!.makeToast("为保障安全密码不得少于6位", duration: 1, position: CSToastPositionCenter) + return + } + if passwordTextField.text != passwordTwoTextField.text{ + appDelegate.window!.makeToast("密码不一致请重新输入", duration: 1, position: CSToastPositionCenter) + return + } + if passwordTextField.text!.contains(" "){ + appDelegate.window!.makeToast("密码不能含有空格请重新输入", duration: 1, position: CSToastPositionCenter) + return + } + SVProgressHUD.show() + HTTPServer.shared.resetPassWord(phoneTextField.text!, pw:passwordTextField.text!, code:codeTextField.text!) { (str, error) -> Void in + SVProgressHUD.dismiss() + httpJsonResule(jsonString: str, error: error, successHandler: { (json) -> Void in + let alertVC = UIAlertController(title: "提示", message: "密码修改成功", preferredStyle: UIAlertControllerStyle.alert) + let showBtn = UIAlertAction(title: "确认", style: UIAlertActionStyle.default) { (action) in + self.navigationController?.popToRootViewController(animated: true) + //登录 + SVProgressHUD.show(withStatus: "登录中...") + HTTPServer.shared.login(completionHandler: { (str, error) in + SVProgressHUD.dismiss() + let json=JSON.fromString(str) + if let ret=json{ + let er=ret["error"].string + if let errorStr=er{ + let Strings=errorStr.components(separatedBy: ":") + if Strings.count >= 2 { + switch Strings[1] { + //用户关联多个身份,请使用学事号登录:100 + case "101"://用户认证身份不存在:101 + appDelegate.window!.makeToast("用户认证身份不存在,请进行账号激活。") + break + //用户帐号或密码错误:102 + case "103":// 用户不存在:103 + appDelegate.window!.makeToast("该号码不存在,请联系客服400-826-2468") + break + default: + appDelegate.window!.makeToast(errorStr) + break + } + }else{ + appDelegate.window!.makeToast(errorStr) + } + }else if ret["access_token"].stringValue != ""{ + AccountManager.shared.setTokenInfo(tokenInfo: ret) + AccountManager.shared.saveToken(tokenInfo: ret) + AccountManager.shared.refreshUserInfo(self.phoneTextField.text!, completionHandler: { (finish) in + if finish{ + let ID=AccountManager.shared.rawUserInfo!.contentData()["userid"].stringValue + YXMessageManager.share.loginWithYX(account: ID, token: ID.md5()) { (success) in + SVProgressHUD.dismiss() + if !success { + AccountManager.shared.logOut() + appDelegate.window!.makeToast("聊天服务登录失败,请连接网络重试") + }else{ + //云信登录成功 + self.dismiss(animated: true, completion: nil) + } + } + }else{ + appDelegate.window!.makeToast("身份获取失败") + SVProgressHUD.dismiss() + } + }) + }else{ + SVProgressHUD.dismiss() + appDelegate.window!.makeToast("登录失败,请稍后重试") + } + }else{ + SVProgressHUD.dismiss() + appDelegate.window!.makeToast("登录失败") + } + }, phone: self.phoneTextField.text!, password: self.passwordTextField.text!) + } + alertVC.addAction(showBtn) + self.present(alertVC, animated: true, completion: nil) + }, failHandler: { (er) -> Void in + appDelegate.window!.makeToast(er.localizedDescription, duration: 1, position: CSToastPositionCenter) + }) + } + + + } + +} diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/Login/LoginViewController.swift b/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/Login/LoginViewController.swift new file mode 100644 index 0000000..57c89fb --- /dev/null +++ b/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/Login/LoginViewController.swift @@ -0,0 +1,188 @@ +// +// LoginViewController.swift +// ParentAssistant +// +// Created by 葛建军 on 2018/3/12. +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. +// + +import UIKit +//登录 +class LoginViewController: UITableViewController,UITextFieldDelegate { + + + @IBOutlet var rootTableView: UITableView! + @IBOutlet var iconImageView: UIImageView!//系统头像 + @IBOutlet var phoneTextField: UITextField!//电话号码 + @IBOutlet var passwordTextField: UITextField!//密码 + @IBOutlet var passwordHiddenBtn: UIButton!//查看密码按钮 + @IBOutlet var loginBtn: UIButton! + + var keyShow = Bool() + override func viewDidLoad() { + super.viewDidLoad() + + layoutSubViews() + + self.phoneTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) + self.passwordTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) + + } + + override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { + + phoneTextField.resignFirstResponder() + passwordTextField.resignFirstResponder() + } + + //监听输入长度,显示登录按钮状态 + @objc func textFieldChange(){ + if (phoneTextField.text?.count)!>0 && (passwordTextField.text?.count)!>0 { + loginBtn.isUserInteractionEnabled = true + loginBtn.backgroundColor = navigationColor + }else{ + loginBtn.isUserInteractionEnabled = false + loginBtn.backgroundColor = UIColor.lightGray + } + } + + + //MARK: - UITableView Delegate && DataSource + + override func numberOfSections(in tableView: UITableView) -> Int { + return 1 + } + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 5 + } + override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + if indexPath.row == 0 { + return 200 + } + else{ + return 50 + } + } + + // MARK: - 设置控件属性 + func layoutSubViews(){ + self.navigationItem.title = "登录" + + passwordHiddenBtn.setImage(UIImage(named: "my_password_look"), for: UIControlState.selected) + NotificationCenter.default.addObserver(self, selector: #selector(LoginViewController.keyboardWIllChange(_:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(LoginViewController.getPhoneNumber(_:)), name: NSNotification.Name(rawValue: MyPhoneNumberNotification.getPhoneNumber), object: nil) + } + // MARK: - 根据键盘调整高度 + @objc func keyboardWIllChange(_ noti: Notification){ + let userInfo:NSDictionary=noti.userInfo! as NSDictionary + let endFrame=(userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue + + let y = navigationBarHeight! + statusBarHeight + if endFrame?.origin.y == getScreenHeight() { + UIView.animate(withDuration: 0.5) { + self.rootTableView.frame = CGRect.init(x: 0, y: y, width: screenWidth, height: screenHeight) + } + }else{ + UIView.animate(withDuration: 0.5) { + self.rootTableView.frame = CGRect.init(x: 0, y: 0, width: screenWidth, height: screenHeight) + } + } + } + @objc func getPhoneNumber(_ noti: Notification){ + let userInfo:NSDictionary=noti.userInfo! as NSDictionary + phoneTextField.text = userInfo["phoneNumber"] as? String + } + + // MARK: - 密码显示与否 + @IBAction func passwordHiddenAction(_ sender: UIButton) { + let selected = passwordHiddenBtn.isSelected + passwordHiddenBtn.isSelected = !selected + passwordTextField.isSecureTextEntry = selected + } + // MARK: - UITextFieldDelegate + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + return textField.resignFirstResponder() + } + func isMobilePhoneNumber(_ mobile:String)->Bool { + let str="^1[0-9]{10}" + return NSPredicate(format: "SELF MATCHES %@", str).evaluate(with: mobile) + } + // MARK: - 登录按钮 + @IBAction func loginAction(_ sender: UIButton) { + self.view.endEditing(true) + SVProgressHUD.show(withStatus: "登录中...") + HTTPServer.shared.login(completionHandler: { (str, error) in + SVProgressHUD.dismiss() + let json=JSON.fromString(str) + if let ret=json{ + let er=ret["error"].string + if let errorStr=er{ + let Strings=errorStr.components(separatedBy: ":") + if Strings.count >= 2 { + switch Strings[1] { + //用户关联多个身份,请使用学事号登录:100 + case "101"://用户认证身份不存在:101 + appDelegate.window!.makeToast("用户认证身份不存在,请进行账号激活。") + break + //用户帐号或密码错误:102 + case "103":// 用户不存在:103 + appDelegate.window!.makeToast("该号码不存在,请联系客服400-826-2468") + break + default: + appDelegate.window!.makeToast(errorStr) + break + } + }else{ + appDelegate.window!.makeToast(errorStr) + } + }else if ret["access_token"].stringValue != ""{ + AccountManager.shared.setTokenInfo(tokenInfo: ret) + AccountManager.shared.saveToken(tokenInfo: ret) + AccountManager.shared.refreshUserInfo(self.phoneTextField.text!, completionHandler: { (finish) in + if finish{ + self.loadUserInfo() + }else{ + appDelegate.window!.makeToast("身份获取失败") + SVProgressHUD.dismiss() + } + }) + }else{ + SVProgressHUD.dismiss() + appDelegate.window!.makeToast("登录失败,请稍后重试") + } + }else{ + SVProgressHUD.dismiss() + appDelegate.window!.makeToast("登录失败") + } + }, phone: phoneTextField.text!, password: passwordTextField.text!) + } + func loadUserInfo(){ + let ID=AccountManager.shared.rawUserInfo!.contentData()["userid"].stringValue + YXMessageManager.share.loginWithYX(account: ID, token: ID.md5()) { (success) in + SVProgressHUD.dismiss() + if !success { + AccountManager.shared.logOut() + appDelegate.window!.makeToast("聊天服务登录失败,请连接网络重试") + }else{ + //云信登录成功 + self.navigationController?.popToRootViewController(animated: true) + } + } + } + + // MARK: - 注册页面跳转 + @IBAction func registerAction(_ sender: UIButton) { + let vc = Story.instantiateViewControllerWithIdentifier("RegisterViewController", storyName: "My") as! RegisterViewController + self.navigationController?.pushViewController(vc, animated: true) + } + // MARK: - 找回密码 + @IBAction func getPasswordAction(_ sender: UIButton) { + let vc = Story.instantiateViewControllerWithIdentifier("GetBackPasswordViewController", storyName: "My") as! GetBackPasswordViewController + self.navigationController?.pushViewController(vc, animated: true) + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + } + +} diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/Login/RegisterViewController.swift b/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/Login/RegisterViewController.swift new file mode 100644 index 0000000..c453c84 --- /dev/null +++ b/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/Login/RegisterViewController.swift @@ -0,0 +1,249 @@ +// +// RegisterViewController.swift +// ParentAssistant +// +// Created by 葛建军 on 2018/3/12. +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. +// + +import UIKit +//注册 +class RegisterViewController: UITableViewController,UITextFieldDelegate { + + @IBOutlet var rootTableView: UITableView! + @IBOutlet var personIconImageView: UIImageView!//系统头像 + @IBOutlet var phoneTextField: UITextField!//电话号码 + @IBOutlet var codeTextField: UITextField!//验证码 + @IBOutlet var passwordTextField: UITextField!//密码 + @IBOutlet var getCodeBtn: UIButton!//获取验证码按钮 + @IBOutlet var passwordHiddenBtn: UIButton!//查看密码按钮 + + @IBOutlet var registerBtn: UIButton!//注册按钮 + + override func viewDidLoad() { + super.viewDidLoad() + + layoutSubViews() + + } + // MARK: - 设置控件属性 + func layoutSubViews(){ + self.navigationController?.navigationBar.isHidden = false + self.navigationItem.title = "注册" + getCodeBtn.layer.borderWidth = 1.0 + getCodeBtn.layer.borderColor = UIColor.lightGray.cgColor + + passwordHiddenBtn.setImage(UIImage(named: "my_password_look"), for: UIControlState.selected) + //键盘监听 + NotificationCenter.default.addObserver(self, selector: #selector(RegisterViewController.keyboardWIllChange(_:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil) + //监听按钮状态 + phoneTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) + codeTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) + passwordTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) + + } + + //MARK: - 用户拖拽 关闭键盘 + override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { + phoneTextField.resignFirstResponder() + codeTextField.resignFirstResponder() + passwordTextField.resignFirstResponder() + } + + //return 关闭键盘 + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + return textField.resignFirstResponder() + } + + // MARK: - 根据键盘调整高度 + @objc func keyboardWIllChange(_ noti: Notification){ + let userInfo:NSDictionary=noti.userInfo! as NSDictionary + let endFrame=(userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue + + print(self.rootTableView.frame) + let y = navigationBarHeight! + statusBarHeight + if endFrame?.origin.y == getScreenHeight() { + UIView.animate(withDuration: 0.5) { + + self.rootTableView.frame = CGRect.init(x: 0, y: y, width: screenWidth, height:screenHeight) + } + }else{ + UIView.animate(withDuration: 0.5) { + self.rootTableView.frame = CGRect.init(x: 0, y: 0, width: screenWidth, height: screenHeight) + } + } + } + //MARK: - UITableView Delegate && DataSource + override func numberOfSections(in tableView: UITableView) -> Int { + return 1 + } + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 6 + } + override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + if indexPath.row == 0 { + return 200 + } + else{ + return 50 + } + } + //MARK: - 监听输入长度,显示登录按钮状态 + @objc func textFieldChange(){ + if (phoneTextField.text?.count)!>0 && (passwordTextField.text?.count)!>0 && (codeTextField.text?.count)!>0 { + registerBtn.isUserInteractionEnabled = true + registerBtn.backgroundColor = navigationColor + }else{ + registerBtn.isUserInteractionEnabled = false + registerBtn.backgroundColor = UIColor.lightGray + } + } + // MARK: - 获取验证码 + @IBAction func getCodeAction(_ sender: UIButton) { + self.view.endEditing(true) + if isMobilePhoneNumber(phoneTextField.text!) { + HTTPServer.shared.getCaptcha(phoneTextField.text!, completionHandler: { (str, error) -> Void in + httpJsonResule(jsonString: str, error: error, successHandler: { (json) -> Void in + if !json["data"].boolValue{ + appDelegate.window!.makeToast("短信发送失败:\(json["message"].stringValue)", duration: 1, position: CSToastPositionCenter) + }else{ + appDelegate.window!.makeToast("已发送短信,请注意查收", duration: 1, position: CSToastPositionCenter) + } + }, failHandler: { (er) -> Void in + appDelegate.window!.makeToast("验证码发送失败") + }) + }) + }else{ + appDelegate.window!.makeToast("手机号格式不正确,请输入正确的手机号码", duration: 1, position: CSToastPositionCenter) + } + } + + + // MARK: - 密码显示与否 + @IBAction func passwordHiddenAction(_ sender: UIButton) { + let selected = passwordHiddenBtn.isSelected + passwordHiddenBtn.isSelected = !selected + passwordTextField.isSecureTextEntry = selected + } + + func isMobilePhoneNumber(_ mobile:String)->Bool { + let str="^1[0-9]{10}" + return NSPredicate(format: "SELF MATCHES %@", str).evaluate(with: mobile) + } + // MARK: - 注册按钮 + @IBAction func registerAction(_ sender: UIButton) { + SVProgressHUD.show(withStatus: "注册中...") + let parameters:Dictionary=[ + "mobile": phoneTextField.text! as AnyObject,//注册手机号码 , + "captcha": codeTextField.text! as AnyObject,//手机验证码 , + "password": passwordTextField.text! as AnyObject]//设置的密码] + HTTPServer.shared.parentRegister(parameters: parameters) { (str, error) in + SVProgressHUD.dismiss() + if error == nil{ + if JSON.fromString(str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) -> Void in + //登录并返回页面 + let alertVC = UIAlertController(title: "提示", message: "您已注册成功", preferredStyle: UIAlertControllerStyle.alert) + let backBtn = UIAlertAction(title: "返回", style: UIAlertActionStyle.default) { (action) in + NotificationCenter.default.post(name: Notification.Name(rawValue: MyPhoneNumberNotification.getPhoneNumber), object: nil, userInfo: ["phoneNumber":self.phoneTextField.text!]) + self.navigationController?.popViewController(animated: true) + } + let showBtn = UIAlertAction(title: "进入首页", style: UIAlertActionStyle.default) { (action) in + //登录 + SVProgressHUD.show(withStatus: "登录中...") + HTTPServer.shared.login(completionHandler: { (str, error) in + SVProgressHUD.dismiss() + let json=JSON.fromString(str) + if let ret=json{ + let er=ret["error"].string + if let errorStr=er{ + let Strings=errorStr.components(separatedBy: ":") + if Strings.count >= 2 { + switch Strings[1] { + //用户关联多个身份,请使用学事号登录:100 + case "101"://用户认证身份不存在:101 + appDelegate.window!.makeToast("用户认证身份不存在,请进行账号激活。") + break + //用户帐号或密码错误:102 + case "103":// 用户不存在:103 + appDelegate.window!.makeToast("该号码不存在,请联系客服400-826-2468") + break + default: + appDelegate.window!.makeToast(errorStr) + break + } + }else{ + appDelegate.window!.makeToast(errorStr) + } + }else if ret["access_token"].stringValue != ""{ + AccountManager.shared.setTokenInfo(tokenInfo: ret) + AccountManager.shared.saveToken(tokenInfo: ret) + AccountManager.shared.refreshUserInfo(self.phoneTextField.text!, completionHandler: { (finish) in + if finish{ + let ID=AccountManager.shared.rawUserInfo!.contentData()["userid"].stringValue + YXMessageManager.share.loginWithYX(account: ID, token: ID.md5()) { (success) in + SVProgressHUD.dismiss() + if !success { + AccountManager.shared.logOut() + appDelegate.window!.makeToast("聊天服务登录失败,请连接网络重试") + }else{ + self.navigationController?.popToRootViewController(animated: true) + //云信登录成功 + self.dismiss(animated: true, completion: nil) + } + } + }else{ + appDelegate.window!.makeToast("身份获取失败") + SVProgressHUD.dismiss() + } + }) + }else{ + SVProgressHUD.dismiss() + appDelegate.window!.makeToast("登录失败,请稍后重试") + } + }else{ + SVProgressHUD.dismiss() + appDelegate.window!.makeToast("登录失败") + } + }, phone: self.phoneTextField.text!, password: self.passwordTextField.text!) + } + alertVC.addAction(backBtn) + alertVC.addAction(showBtn) + self.present(alertVC, animated: true, completion: nil) + }, failHandler: { (error) -> Void in + appDelegate.window!.makeToast("注册失败:\(error.localizedDescription)") + }) + }else{ + appDelegate.window!.makeToast("注册失败:\(JSON.fromString(str)!["message"].stringValue)") + } + }else{ + appDelegate.window!.makeToast("注册失败:\(String(describing: error))") + } + } + } + + + // MARK: - 登录页面跳转 + + @IBAction func loginAction(_ sender: UIButton) { + self.navigationController?.popViewController(animated: true) + } + + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/LoginViewController.swift b/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/LoginViewController.swift deleted file mode 100644 index 57c89fb..0000000 --- a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/LoginViewController.swift +++ /dev/null @@ -1,188 +0,0 @@ -// -// LoginViewController.swift -// ParentAssistant -// -// Created by 葛建军 on 2018/3/12. -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. -// - -import UIKit -//登录 -class LoginViewController: UITableViewController,UITextFieldDelegate { - - - @IBOutlet var rootTableView: UITableView! - @IBOutlet var iconImageView: UIImageView!//系统头像 - @IBOutlet var phoneTextField: UITextField!//电话号码 - @IBOutlet var passwordTextField: UITextField!//密码 - @IBOutlet var passwordHiddenBtn: UIButton!//查看密码按钮 - @IBOutlet var loginBtn: UIButton! - - var keyShow = Bool() - override func viewDidLoad() { - super.viewDidLoad() - - layoutSubViews() - - self.phoneTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) - self.passwordTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) - - } - - override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { - - phoneTextField.resignFirstResponder() - passwordTextField.resignFirstResponder() - } - - //监听输入长度,显示登录按钮状态 - @objc func textFieldChange(){ - if (phoneTextField.text?.count)!>0 && (passwordTextField.text?.count)!>0 { - loginBtn.isUserInteractionEnabled = true - loginBtn.backgroundColor = navigationColor - }else{ - loginBtn.isUserInteractionEnabled = false - loginBtn.backgroundColor = UIColor.lightGray - } - } - - - //MARK: - UITableView Delegate && DataSource - - override func numberOfSections(in tableView: UITableView) -> Int { - return 1 - } - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 5 - } - override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - if indexPath.row == 0 { - return 200 - } - else{ - return 50 - } - } - - // MARK: - 设置控件属性 - func layoutSubViews(){ - self.navigationItem.title = "登录" - - passwordHiddenBtn.setImage(UIImage(named: "my_password_look"), for: UIControlState.selected) - NotificationCenter.default.addObserver(self, selector: #selector(LoginViewController.keyboardWIllChange(_:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(LoginViewController.getPhoneNumber(_:)), name: NSNotification.Name(rawValue: MyPhoneNumberNotification.getPhoneNumber), object: nil) - } - // MARK: - 根据键盘调整高度 - @objc func keyboardWIllChange(_ noti: Notification){ - let userInfo:NSDictionary=noti.userInfo! as NSDictionary - let endFrame=(userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue - - let y = navigationBarHeight! + statusBarHeight - if endFrame?.origin.y == getScreenHeight() { - UIView.animate(withDuration: 0.5) { - self.rootTableView.frame = CGRect.init(x: 0, y: y, width: screenWidth, height: screenHeight) - } - }else{ - UIView.animate(withDuration: 0.5) { - self.rootTableView.frame = CGRect.init(x: 0, y: 0, width: screenWidth, height: screenHeight) - } - } - } - @objc func getPhoneNumber(_ noti: Notification){ - let userInfo:NSDictionary=noti.userInfo! as NSDictionary - phoneTextField.text = userInfo["phoneNumber"] as? String - } - - // MARK: - 密码显示与否 - @IBAction func passwordHiddenAction(_ sender: UIButton) { - let selected = passwordHiddenBtn.isSelected - passwordHiddenBtn.isSelected = !selected - passwordTextField.isSecureTextEntry = selected - } - // MARK: - UITextFieldDelegate - func textFieldShouldReturn(_ textField: UITextField) -> Bool { - return textField.resignFirstResponder() - } - func isMobilePhoneNumber(_ mobile:String)->Bool { - let str="^1[0-9]{10}" - return NSPredicate(format: "SELF MATCHES %@", str).evaluate(with: mobile) - } - // MARK: - 登录按钮 - @IBAction func loginAction(_ sender: UIButton) { - self.view.endEditing(true) - SVProgressHUD.show(withStatus: "登录中...") - HTTPServer.shared.login(completionHandler: { (str, error) in - SVProgressHUD.dismiss() - let json=JSON.fromString(str) - if let ret=json{ - let er=ret["error"].string - if let errorStr=er{ - let Strings=errorStr.components(separatedBy: ":") - if Strings.count >= 2 { - switch Strings[1] { - //用户关联多个身份,请使用学事号登录:100 - case "101"://用户认证身份不存在:101 - appDelegate.window!.makeToast("用户认证身份不存在,请进行账号激活。") - break - //用户帐号或密码错误:102 - case "103":// 用户不存在:103 - appDelegate.window!.makeToast("该号码不存在,请联系客服400-826-2468") - break - default: - appDelegate.window!.makeToast(errorStr) - break - } - }else{ - appDelegate.window!.makeToast(errorStr) - } - }else if ret["access_token"].stringValue != ""{ - AccountManager.shared.setTokenInfo(tokenInfo: ret) - AccountManager.shared.saveToken(tokenInfo: ret) - AccountManager.shared.refreshUserInfo(self.phoneTextField.text!, completionHandler: { (finish) in - if finish{ - self.loadUserInfo() - }else{ - appDelegate.window!.makeToast("身份获取失败") - SVProgressHUD.dismiss() - } - }) - }else{ - SVProgressHUD.dismiss() - appDelegate.window!.makeToast("登录失败,请稍后重试") - } - }else{ - SVProgressHUD.dismiss() - appDelegate.window!.makeToast("登录失败") - } - }, phone: phoneTextField.text!, password: passwordTextField.text!) - } - func loadUserInfo(){ - let ID=AccountManager.shared.rawUserInfo!.contentData()["userid"].stringValue - YXMessageManager.share.loginWithYX(account: ID, token: ID.md5()) { (success) in - SVProgressHUD.dismiss() - if !success { - AccountManager.shared.logOut() - appDelegate.window!.makeToast("聊天服务登录失败,请连接网络重试") - }else{ - //云信登录成功 - self.navigationController?.popToRootViewController(animated: true) - } - } - } - - // MARK: - 注册页面跳转 - @IBAction func registerAction(_ sender: UIButton) { - let vc = Story.instantiateViewControllerWithIdentifier("RegisterViewController", storyName: "My") as! RegisterViewController - self.navigationController?.pushViewController(vc, animated: true) - } - // MARK: - 找回密码 - @IBAction func getPasswordAction(_ sender: UIButton) { - let vc = Story.instantiateViewControllerWithIdentifier("GetBackPasswordViewController", storyName: "My") as! GetBackPasswordViewController - self.navigationController?.pushViewController(vc, animated: true) - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - } - -} diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/My.storyboard b/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/My.storyboard deleted file mode 100644 index 92fddab..0000000 --- a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/My.storyboard +++ /dev/null @@ -1,1750 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/RegisterViewController.swift b/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/RegisterViewController.swift deleted file mode 100644 index c453c84..0000000 --- a/ParentAssistant/ParentAssistant/Classes/controllers/my/Controller/RegisterViewController.swift +++ /dev/null @@ -1,249 +0,0 @@ -// -// RegisterViewController.swift -// ParentAssistant -// -// Created by 葛建军 on 2018/3/12. -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. -// - -import UIKit -//注册 -class RegisterViewController: UITableViewController,UITextFieldDelegate { - - @IBOutlet var rootTableView: UITableView! - @IBOutlet var personIconImageView: UIImageView!//系统头像 - @IBOutlet var phoneTextField: UITextField!//电话号码 - @IBOutlet var codeTextField: UITextField!//验证码 - @IBOutlet var passwordTextField: UITextField!//密码 - @IBOutlet var getCodeBtn: UIButton!//获取验证码按钮 - @IBOutlet var passwordHiddenBtn: UIButton!//查看密码按钮 - - @IBOutlet var registerBtn: UIButton!//注册按钮 - - override func viewDidLoad() { - super.viewDidLoad() - - layoutSubViews() - - } - // MARK: - 设置控件属性 - func layoutSubViews(){ - self.navigationController?.navigationBar.isHidden = false - self.navigationItem.title = "注册" - getCodeBtn.layer.borderWidth = 1.0 - getCodeBtn.layer.borderColor = UIColor.lightGray.cgColor - - passwordHiddenBtn.setImage(UIImage(named: "my_password_look"), for: UIControlState.selected) - //键盘监听 - NotificationCenter.default.addObserver(self, selector: #selector(RegisterViewController.keyboardWIllChange(_:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil) - //监听按钮状态 - phoneTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) - codeTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) - passwordTextField.addTarget(self, action: #selector(textFieldChange), for: UIControlEvents.editingChanged) - - } - - //MARK: - 用户拖拽 关闭键盘 - override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { - phoneTextField.resignFirstResponder() - codeTextField.resignFirstResponder() - passwordTextField.resignFirstResponder() - } - - //return 关闭键盘 - func textFieldShouldReturn(_ textField: UITextField) -> Bool { - return textField.resignFirstResponder() - } - - // MARK: - 根据键盘调整高度 - @objc func keyboardWIllChange(_ noti: Notification){ - let userInfo:NSDictionary=noti.userInfo! as NSDictionary - let endFrame=(userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue - - print(self.rootTableView.frame) - let y = navigationBarHeight! + statusBarHeight - if endFrame?.origin.y == getScreenHeight() { - UIView.animate(withDuration: 0.5) { - - self.rootTableView.frame = CGRect.init(x: 0, y: y, width: screenWidth, height:screenHeight) - } - }else{ - UIView.animate(withDuration: 0.5) { - self.rootTableView.frame = CGRect.init(x: 0, y: 0, width: screenWidth, height: screenHeight) - } - } - } - //MARK: - UITableView Delegate && DataSource - override func numberOfSections(in tableView: UITableView) -> Int { - return 1 - } - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 6 - } - override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - if indexPath.row == 0 { - return 200 - } - else{ - return 50 - } - } - //MARK: - 监听输入长度,显示登录按钮状态 - @objc func textFieldChange(){ - if (phoneTextField.text?.count)!>0 && (passwordTextField.text?.count)!>0 && (codeTextField.text?.count)!>0 { - registerBtn.isUserInteractionEnabled = true - registerBtn.backgroundColor = navigationColor - }else{ - registerBtn.isUserInteractionEnabled = false - registerBtn.backgroundColor = UIColor.lightGray - } - } - // MARK: - 获取验证码 - @IBAction func getCodeAction(_ sender: UIButton) { - self.view.endEditing(true) - if isMobilePhoneNumber(phoneTextField.text!) { - HTTPServer.shared.getCaptcha(phoneTextField.text!, completionHandler: { (str, error) -> Void in - httpJsonResule(jsonString: str, error: error, successHandler: { (json) -> Void in - if !json["data"].boolValue{ - appDelegate.window!.makeToast("短信发送失败:\(json["message"].stringValue)", duration: 1, position: CSToastPositionCenter) - }else{ - appDelegate.window!.makeToast("已发送短信,请注意查收", duration: 1, position: CSToastPositionCenter) - } - }, failHandler: { (er) -> Void in - appDelegate.window!.makeToast("验证码发送失败") - }) - }) - }else{ - appDelegate.window!.makeToast("手机号格式不正确,请输入正确的手机号码", duration: 1, position: CSToastPositionCenter) - } - } - - - // MARK: - 密码显示与否 - @IBAction func passwordHiddenAction(_ sender: UIButton) { - let selected = passwordHiddenBtn.isSelected - passwordHiddenBtn.isSelected = !selected - passwordTextField.isSecureTextEntry = selected - } - - func isMobilePhoneNumber(_ mobile:String)->Bool { - let str="^1[0-9]{10}" - return NSPredicate(format: "SELF MATCHES %@", str).evaluate(with: mobile) - } - // MARK: - 注册按钮 - @IBAction func registerAction(_ sender: UIButton) { - SVProgressHUD.show(withStatus: "注册中...") - let parameters:Dictionary=[ - "mobile": phoneTextField.text! as AnyObject,//注册手机号码 , - "captcha": codeTextField.text! as AnyObject,//手机验证码 , - "password": passwordTextField.text! as AnyObject]//设置的密码] - HTTPServer.shared.parentRegister(parameters: parameters) { (str, error) in - SVProgressHUD.dismiss() - if error == nil{ - if JSON.fromString(str)!["status"].intValue == 1{ - httpJsonResule(jsonString: str, error: error, successHandler: { (json) -> Void in - //登录并返回页面 - let alertVC = UIAlertController(title: "提示", message: "您已注册成功", preferredStyle: UIAlertControllerStyle.alert) - let backBtn = UIAlertAction(title: "返回", style: UIAlertActionStyle.default) { (action) in - NotificationCenter.default.post(name: Notification.Name(rawValue: MyPhoneNumberNotification.getPhoneNumber), object: nil, userInfo: ["phoneNumber":self.phoneTextField.text!]) - self.navigationController?.popViewController(animated: true) - } - let showBtn = UIAlertAction(title: "进入首页", style: UIAlertActionStyle.default) { (action) in - //登录 - SVProgressHUD.show(withStatus: "登录中...") - HTTPServer.shared.login(completionHandler: { (str, error) in - SVProgressHUD.dismiss() - let json=JSON.fromString(str) - if let ret=json{ - let er=ret["error"].string - if let errorStr=er{ - let Strings=errorStr.components(separatedBy: ":") - if Strings.count >= 2 { - switch Strings[1] { - //用户关联多个身份,请使用学事号登录:100 - case "101"://用户认证身份不存在:101 - appDelegate.window!.makeToast("用户认证身份不存在,请进行账号激活。") - break - //用户帐号或密码错误:102 - case "103":// 用户不存在:103 - appDelegate.window!.makeToast("该号码不存在,请联系客服400-826-2468") - break - default: - appDelegate.window!.makeToast(errorStr) - break - } - }else{ - appDelegate.window!.makeToast(errorStr) - } - }else if ret["access_token"].stringValue != ""{ - AccountManager.shared.setTokenInfo(tokenInfo: ret) - AccountManager.shared.saveToken(tokenInfo: ret) - AccountManager.shared.refreshUserInfo(self.phoneTextField.text!, completionHandler: { (finish) in - if finish{ - let ID=AccountManager.shared.rawUserInfo!.contentData()["userid"].stringValue - YXMessageManager.share.loginWithYX(account: ID, token: ID.md5()) { (success) in - SVProgressHUD.dismiss() - if !success { - AccountManager.shared.logOut() - appDelegate.window!.makeToast("聊天服务登录失败,请连接网络重试") - }else{ - self.navigationController?.popToRootViewController(animated: true) - //云信登录成功 - self.dismiss(animated: true, completion: nil) - } - } - }else{ - appDelegate.window!.makeToast("身份获取失败") - SVProgressHUD.dismiss() - } - }) - }else{ - SVProgressHUD.dismiss() - appDelegate.window!.makeToast("登录失败,请稍后重试") - } - }else{ - SVProgressHUD.dismiss() - appDelegate.window!.makeToast("登录失败") - } - }, phone: self.phoneTextField.text!, password: self.passwordTextField.text!) - } - alertVC.addAction(backBtn) - alertVC.addAction(showBtn) - self.present(alertVC, animated: true, completion: nil) - }, failHandler: { (error) -> Void in - appDelegate.window!.makeToast("注册失败:\(error.localizedDescription)") - }) - }else{ - appDelegate.window!.makeToast("注册失败:\(JSON.fromString(str)!["message"].stringValue)") - } - }else{ - appDelegate.window!.makeToast("注册失败:\(String(describing: error))") - } - } - } - - - // MARK: - 登录页面跳转 - - @IBAction func loginAction(_ sender: UIButton) { - self.navigationController?.popViewController(animated: true) - } - - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destinationViewController. - // Pass the selected object to the new view controller. - } - */ - -} diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/my/My.storyboard b/ParentAssistant/ParentAssistant/Classes/controllers/my/My.storyboard new file mode 100644 index 0000000..9dc8e2d --- /dev/null +++ b/ParentAssistant/ParentAssistant/Classes/controllers/my/My.storyboard @@ -0,0 +1,1749 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ParentAssistant/ParentAssistant/Supporting Files/Base.lproj/Main.storyboard b/ParentAssistant/ParentAssistant/Supporting Files/Base.lproj/Main.storyboard index 8f82c40..e300dcd 100644 --- a/ParentAssistant/ParentAssistant/Supporting Files/Base.lproj/Main.storyboard +++ b/ParentAssistant/ParentAssistant/Supporting Files/Base.lproj/Main.storyboard @@ -502,7 +502,7 @@ - + -- libgit2 0.21.0