Commit 21616c4361d6fe38985f03e8c07c2fc41fb7b827
Exists in
newLive
Merge branch 'newLive' of http://git.shunzhi.net/iosgroup/newlive into newLive
Showing
5 changed files
with
68 additions
and
34 deletions
Show diff stats
YouerLiveVideo/YouerLiveVideo/controllers/User/Setting/ChangePassWordViewController.swift
| ... | ... | @@ -102,24 +102,6 @@ class ChangePassWordViewController: UIViewController { |
| 102 | 102 | |
| 103 | 103 | @IBAction func sendUserCodeBtnClick(_ sender: UIButton) { |
| 104 | 104 | self.view.endEditing(true) |
| 105 | - var num = 0 | |
| 106 | - if #available(iOS 10.0, *) { | |
| 107 | - self.timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { (timers) in | |
| 108 | - if num == 60{ | |
| 109 | - sender.titleLabel?.text = "获取验证码" | |
| 110 | - sender.isUserInteractionEnabled = true | |
| 111 | - sender.backgroundColor = UIColorFromRGB(0x007aff) | |
| 112 | - self.timer.invalidate() | |
| 113 | - return | |
| 114 | - } | |
| 115 | - sender.setTitle("重新获取(\(60-num))", for: .normal) | |
| 116 | - sender.isUserInteractionEnabled = false | |
| 117 | - sender.backgroundColor = UIColor.lightGray | |
| 118 | - num += 1 | |
| 119 | - }) | |
| 120 | - } else { | |
| 121 | - // Fallback on earlier versions | |
| 122 | - } | |
| 123 | 105 | var phone = "" |
| 124 | 106 | if user.isOnline(){ |
| 125 | 107 | phone = user.phone() |
| ... | ... | @@ -138,6 +120,7 @@ class ChangePassWordViewController: UIViewController { |
| 138 | 120 | if JSON.fromString(jsonString: str)!["status"].intValue == 1{ |
| 139 | 121 | httpJsonResule(jsonString: str, error: error, successHandler: { (json) in |
| 140 | 122 | self.view.makeToast("验证码发送成功") |
| 123 | + self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(ChangePassWordViewController.timerFire), userInfo: sender, repeats: true) | |
| 141 | 124 | }, failHandler: { (error) in |
| 142 | 125 | self.view.makeToast("验证码发送失败:\(error.localizedDescription)") |
| 143 | 126 | }) |
| ... | ... | @@ -169,9 +152,28 @@ class ChangePassWordViewController: UIViewController { |
| 169 | 152 | } |
| 170 | 153 | } |
| 171 | 154 | |
| 155 | + var num:Int = 0 | |
| 156 | + func timerFire(){ | |
| 157 | + let btn = timer.userInfo as! UIButton | |
| 158 | + if num == 60{ | |
| 159 | + btn.setTitle("重新获取(\(60-num))", for: .normal) | |
| 160 | + btn.isUserInteractionEnabled = true | |
| 161 | + btn.backgroundColor = UIColorFromRGB(0x007aff) | |
| 162 | + self.timer.invalidate() | |
| 163 | + return | |
| 164 | + } | |
| 165 | + btn.setTitle("重新获取(\(60-num))", for: .normal) | |
| 166 | + btn.isUserInteractionEnabled = false | |
| 167 | + btn.backgroundColor = UIColor.lightGray | |
| 168 | + num += 1 | |
| 169 | + | |
| 170 | + } | |
| 171 | + | |
| 172 | 172 | override func viewWillDisappear(_ animated: Bool) { |
| 173 | - timer.invalidate() | |
| 174 | - timer = nil | |
| 173 | + if timer != nil{ | |
| 174 | + timer.invalidate() | |
| 175 | + timer = nil | |
| 176 | + } | |
| 175 | 177 | } |
| 176 | 178 | // MARK: - 销毁通知 |
| 177 | 179 | deinit { | ... | ... |
YouerLiveVideo/YouerLiveVideo/controllers/User/UserCenter/Login.storyboard
| 1 | -<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
| 2 | -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1217" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> | |
| 3 | 3 | <device id="retina4_7" orientation="portrait"> |
| 4 | 4 | <adaptation id="fullscreen"/> |
| 5 | 5 | </device> |
| ... | ... | @@ -584,13 +584,12 @@ |
| 584 | 584 | <outlet property="delegate" destination="tCx-JF-YJm" id="xWv-of-0Wb"/> |
| 585 | 585 | </connections> |
| 586 | 586 | </textField> |
| 587 | - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hwv-0n-dsf"> | |
| 588 | - <rect key="frame" x="274" y="13" width="93" height="30"/> | |
| 587 | + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hwv-0n-dsf"> | |
| 588 | + <rect key="frame" x="274" y="11" width="93" height="34"/> | |
| 589 | 589 | <color key="backgroundColor" red="0.10980392160000001" green="0.63529411759999999" blue="1" alpha="1" colorSpace="calibratedRGB"/> |
| 590 | 590 | <constraints> |
| 591 | 591 | <constraint firstAttribute="width" constant="93" id="tn3-0t-fnt"/> |
| 592 | 592 | </constraints> |
| 593 | - <fontDescription key="fontDescription" type="system" pointSize="15"/> | |
| 594 | 593 | <state key="normal" title="获取验证码"> |
| 595 | 594 | <color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> |
| 596 | 595 | </state> |
| ... | ... | @@ -937,7 +936,7 @@ |
| 937 | 936 | <color key="titleShadowColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/> |
| 938 | 937 | </state> |
| 939 | 938 | <connections> |
| 940 | - <action selector="onLoginClicked:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="K5c-Pu-mOx"/> | |
| 939 | + <action selector="onLoginClicked:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="2mM-lR-lzR"/> | |
| 941 | 940 | </connections> |
| 942 | 941 | </button> |
| 943 | 942 | <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Oee-Sm-GxU"> |
| ... | ... | @@ -951,7 +950,7 @@ |
| 951 | 950 | <color key="titleColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> |
| 952 | 951 | </state> |
| 953 | 952 | <connections> |
| 954 | - <action selector="forgetPassword:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="vNy-vF-mrx"/> | |
| 953 | + <action selector="forgetPassword:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="y4v-x3-3Yo"/> | |
| 955 | 954 | </connections> |
| 956 | 955 | </button> |
| 957 | 956 | <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vmw-Ug-eCf"> |
| ... | ... | @@ -965,7 +964,7 @@ |
| 965 | 964 | <color key="titleColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> |
| 966 | 965 | </state> |
| 967 | 966 | <connections> |
| 968 | - <action selector="registerAccount:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="SPU-2J-UeI"/> | |
| 967 | + <action selector="registerAccount:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="1N1-9k-yxY"/> | |
| 969 | 968 | </connections> |
| 970 | 969 | </button> |
| 971 | 970 | </subviews> | ... | ... |
YouerLiveVideo/YouerLiveVideo/controllers/User/UserCenter/NewLoginViewController.swift
| ... | ... | @@ -37,6 +37,7 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { |
| 37 | 37 | super.didReceiveMemoryWarning() |
| 38 | 38 | // Dispose of any resources that can be recreated. |
| 39 | 39 | } |
| 40 | + | |
| 40 | 41 | @IBAction func onLoginClicked(_ sender: UIButton) { |
| 41 | 42 | self.view.endEditing(true) |
| 42 | 43 | let account=fieldAccount.text |
| ... | ... | @@ -47,8 +48,8 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { |
| 47 | 48 | return |
| 48 | 49 | } |
| 49 | 50 | login(phone: account!, pw:pw!) |
| 51 | + | |
| 50 | 52 | } |
| 51 | - | |
| 52 | 53 | func login(phone:String, pw:String){ |
| 53 | 54 | if phone.isMobilePhoneNumber() { |
| 54 | 55 | SVProgressHUD.show(withStatus: "登录...") |
| ... | ... | @@ -105,18 +106,23 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { |
| 105 | 106 | } |
| 106 | 107 | } |
| 107 | 108 | func back(){ |
| 108 | - self.navigationController!.popViewController(animated: true) | |
| 109 | + self.navigationController!.dismiss(animated: true, completion: nil) | |
| 110 | + } | |
| 111 | + | |
| 112 | + func textFieldShouldReturn(_ textField: UITextField) -> Bool { | |
| 113 | + textField.resignFirstResponder() | |
| 114 | + return true | |
| 109 | 115 | } |
| 110 | 116 | |
| 111 | 117 | @IBAction func forgetPassword(_ sender: UIButton) { |
| 112 | - let vc = Story.instantiateViewControllerWithIdentifier("ChangePassWordViewControllerVC", storyName: "User") as! ChangePassWordViewController | |
| 118 | + let vc = Story.instantiateViewControllerWithIdentifier("ChangePassWordViewControllerVC", storyName: "User") as! ChangePassWordViewController | |
| 113 | 119 | self.navigationController?.pushViewController(vc, animated: true) |
| 114 | 120 | } |
| 115 | 121 | @IBAction func registerAccount(_ sender: UIButton) { |
| 116 | 122 | let vc = UIStoryboard(name: "Login", bundle: nil).instantiateViewController(withIdentifier: "RegisterViewControllerVC") as! RegisterViewController |
| 117 | 123 | self.navigationController!.pushViewController(vc, animated: true) |
| 118 | 124 | } |
| 119 | - | |
| 125 | + | |
| 120 | 126 | func keyboardWillShow(){ |
| 121 | 127 | constraintContentOffset.constant=144 |
| 122 | 128 | UIView.animate(withDuration: 2, animations: { () -> Void in | ... | ... |
YouerLiveVideo/YouerLiveVideo/controllers/User/UserCenter/RegisterViewController.swift
| ... | ... | @@ -22,6 +22,7 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker |
| 22 | 22 | @IBOutlet weak var sendPhotoImage: UIImageView! |
| 23 | 23 | var iconImage: UIImage? |
| 24 | 24 | var name: String="" |
| 25 | + var timer :Timer! | |
| 25 | 26 | override func viewDidLoad() { |
| 26 | 27 | super.viewDidLoad() |
| 27 | 28 | self.configTheme() |
| ... | ... | @@ -39,6 +40,14 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker |
| 39 | 40 | return true |
| 40 | 41 | } |
| 41 | 42 | |
| 43 | + override func viewWillDisappear(_ animated: Bool) { | |
| 44 | + super.viewWillDisappear(animated) | |
| 45 | + if timer != nil{ | |
| 46 | + timer.invalidate() | |
| 47 | + timer = nil | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 42 | 51 | @IBAction func sendVerificationCodeClickAction(_ sender: AnyObject) {//发验证码 |
| 43 | 52 | self.view.endEditing(true) |
| 44 | 53 | if nikeNameTextFiled.text!.characters.count<11{ |
| ... | ... | @@ -47,12 +56,15 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker |
| 47 | 56 | if (phoneNumber.text?.isMobilePhoneNumber())! { |
| 48 | 57 | SVProgressHUD.show(withStatus: "获取验证码...") |
| 49 | 58 | SVProgressHUD.setDefaultMaskType(.black) |
| 59 | + | |
| 50 | 60 | AppDelegate.instance().httpServer.getChangePhoneCaptcha(mobile: phoneNumber.text!, completionHandler: { (str, error) in |
| 51 | 61 | SVProgressHUD.dismiss() |
| 52 | 62 | if error==nil { |
| 53 | 63 | if JSON.fromString(jsonString: str)!["status"].intValue == 1{ |
| 54 | 64 | httpJsonResule(jsonString: str, error: error, successHandler: { (json) in |
| 55 | 65 | self.view.makeToast("验证码发送成功") |
| 66 | + self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(RegisterViewController.timerFire), userInfo: sender, repeats: true) | |
| 67 | + | |
| 56 | 68 | self.nikeNameTextFiled.isUserInteractionEnabled=false |
| 57 | 69 | self.phoneNumber.isUserInteractionEnabled=false |
| 58 | 70 | self.passwordTextField.isUserInteractionEnabled=false |
| ... | ... | @@ -114,6 +126,22 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker |
| 114 | 126 | } |
| 115 | 127 | } |
| 116 | 128 | |
| 129 | + var num:Int = 0 | |
| 130 | + func timerFire(){ | |
| 131 | + let btn = timer.userInfo as! UIButton | |
| 132 | + if num == 60{ | |
| 133 | + btn.setTitle("重新获取(\(60-num))", for: .normal) | |
| 134 | + btn.isUserInteractionEnabled = true | |
| 135 | + btn.backgroundColor = UIColorFromRGB(0x007aff) | |
| 136 | + self.timer.invalidate() | |
| 137 | + return | |
| 138 | + } | |
| 139 | + btn.setTitle("重新获取(\(60-num))", for: .normal) | |
| 140 | + btn.isUserInteractionEnabled = false | |
| 141 | + btn.backgroundColor = UIColor.lightGray | |
| 142 | + num += 1 | |
| 143 | + | |
| 144 | + } | |
| 117 | 145 | |
| 118 | 146 | @IBAction func loginBtnClickAction(_ sender: AnyObject) { |
| 119 | 147 | self.navigationController!.popViewController(animated: true) | ... | ... |
YouerLiveVideo/YouerLiveVideo/controllers/User/UserViewController.swift
| ... | ... | @@ -51,7 +51,6 @@ class UserViewController: UIViewController { |
| 51 | 51 | let vc=Story.instantiateViewControllerWithIdentifier("NewLoginViewControllerVC", storyName: "Login") as! NewLoginViewController |
| 52 | 52 | self.navigationController?.pushViewController(vc, animated: true) |
| 53 | 53 | } |
| 54 | - | |
| 55 | 54 | } |
| 56 | 55 | |
| 57 | 56 | func editBtnClick(){ |
| ... | ... | @@ -108,7 +107,7 @@ extension UserViewController:UITableViewDelegate,UITableViewDataSource{ |
| 108 | 107 | } |
| 109 | 108 | |
| 110 | 109 | func numberOfSections(in tableView: UITableView) -> Int { |
| 111 | - if user.roletype() == 3 || user.roletype() == 4 || user.roletype() == 5{ | |
| 110 | + if user.roletype() == 3 || user.roletype() == 4 || user.roletype() == 5 || user.roletype() == 0 { | |
| 112 | 111 | return 1 |
| 113 | 112 | } |
| 114 | 113 | return sectionList.count | ... | ... |