Commit 8c821be74012d086d8a49449660078ab19f2e68d

Authored by 左丞
1 parent 092fe4e4
Exists in newLive

no message

YouerLiveVideo/YouerLiveVideo/controllers/User/Setting/ChangePassWordViewController.swift
@@ -111,24 +111,7 @@ class ChangePassWordViewController: UIViewController { @@ -111,24 +111,7 @@ class ChangePassWordViewController: UIViewController {
111 111
112 @IBAction func sendUserCodeBtnClick(_ sender: UIButton) { 112 @IBAction func sendUserCodeBtnClick(_ sender: UIButton) {
113 self.view.endEditing(true) 113 self.view.endEditing(true)
114 - var num = 0  
115 - if #available(iOS 10.0, *) {  
116 - self.timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { (timers) in  
117 - if num == 60{  
118 - sender.titleLabel?.text = "获取验证码"  
119 - sender.isUserInteractionEnabled = true  
120 - sender.backgroundColor = UIColorFromRGB(0x007aff)  
121 - self.timer.invalidate()  
122 - return  
123 - }  
124 - sender.setTitle("重新获取(\(60-num))", for: .normal)  
125 - sender.isUserInteractionEnabled = false  
126 - sender.backgroundColor = UIColor.lightGray  
127 - num += 1  
128 - })  
129 - } else {  
130 - // Fallback on earlier versions  
131 - } 114 + timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(ChangePassWordViewController.timerFire), userInfo: sender, repeats: true)
132 var phone = "" 115 var phone = ""
133 if user.isOnline(){ 116 if user.isOnline(){
134 phone = user.phone() 117 phone = user.phone()
@@ -178,9 +161,28 @@ class ChangePassWordViewController: UIViewController { @@ -178,9 +161,28 @@ class ChangePassWordViewController: UIViewController {
178 } 161 }
179 } 162 }
180 163
  164 + var num:Int = 0
  165 + func timerFire(){
  166 + let btn = timer.userInfo as! UIButton
  167 + if num == 60{
  168 + btn.setTitle("重新获取(\(60-num))", for: .normal)
  169 + btn.isUserInteractionEnabled = true
  170 + btn.backgroundColor = UIColorFromRGB(0x007aff)
  171 + self.timer.invalidate()
  172 + return
  173 + }
  174 + btn.setTitle("重新获取(\(60-num))", for: .normal)
  175 + btn.isUserInteractionEnabled = false
  176 + btn.backgroundColor = UIColor.lightGray
  177 + num += 1
  178 +
  179 + }
  180 +
181 override func viewWillDisappear(_ animated: Bool) { 181 override func viewWillDisappear(_ animated: Bool) {
182 - timer.invalidate()  
183 - timer = nil 182 + if timer != nil{
  183 + timer.invalidate()
  184 + timer = nil
  185 + }
184 } 186 }
185 // MARK: - 销毁通知 187 // MARK: - 销毁通知
186 deinit { 188 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 <device id="retina4_7" orientation="portrait"> 3 <device id="retina4_7" orientation="portrait">
4 <adaptation id="fullscreen"/> 4 <adaptation id="fullscreen"/>
5 </device> 5 </device>
@@ -584,13 +584,12 @@ @@ -584,13 +584,12 @@
584 <outlet property="delegate" destination="tCx-JF-YJm" id="xWv-of-0Wb"/> 584 <outlet property="delegate" destination="tCx-JF-YJm" id="xWv-of-0Wb"/>
585 </connections> 585 </connections>
586 </textField> 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 <color key="backgroundColor" red="0.10980392160000001" green="0.63529411759999999" blue="1" alpha="1" colorSpace="calibratedRGB"/> 589 <color key="backgroundColor" red="0.10980392160000001" green="0.63529411759999999" blue="1" alpha="1" colorSpace="calibratedRGB"/>
590 <constraints> 590 <constraints>
591 <constraint firstAttribute="width" constant="93" id="tn3-0t-fnt"/> 591 <constraint firstAttribute="width" constant="93" id="tn3-0t-fnt"/>
592 </constraints> 592 </constraints>
593 - <fontDescription key="fontDescription" type="system" pointSize="15"/>  
594 <state key="normal" title="获取验证码"> 593 <state key="normal" title="获取验证码">
595 <color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> 594 <color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
596 </state> 595 </state>
@@ -943,7 +942,7 @@ @@ -943,7 +942,7 @@
943 <color key="titleShadowColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/> 942 <color key="titleShadowColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
944 </state> 943 </state>
945 <connections> 944 <connections>
946 - <action selector="onLoginClicked:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="oVG-0D-j2T"/> 945 + <action selector="onLoginClicked:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="2mM-lR-lzR"/>
947 </connections> 946 </connections>
948 </button> 947 </button>
949 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Oee-Sm-GxU"> 948 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Oee-Sm-GxU">
@@ -957,7 +956,7 @@ @@ -957,7 +956,7 @@
957 <color key="titleColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> 956 <color key="titleColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
958 </state> 957 </state>
959 <connections> 958 <connections>
960 - <action selector="activatiAction:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="Al4-o1-Tj0"/> 959 + <action selector="activatiAction:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="U3q-J4-Ag3"/>
961 </connections> 960 </connections>
962 </button> 961 </button>
963 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vmw-Ug-eCf"> 962 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vmw-Ug-eCf">
@@ -971,7 +970,7 @@ @@ -971,7 +970,7 @@
971 <color key="titleColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> 970 <color key="titleColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
972 </state> 971 </state>
973 <connections> 972 <connections>
974 - <action selector="returnAction:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="9DX-YN-Sc1"/> 973 + <action selector="returnAction:" destination="7YD-gA-dLJ" eventType="touchUpInside" id="OEZ-Z3-zKh"/>
975 </connections> 974 </connections>
976 </button> 975 </button>
977 </subviews> 976 </subviews>
YouerLiveVideo/YouerLiveVideo/controllers/User/UserCenter/NewLoginViewController.swift
@@ -39,7 +39,8 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { @@ -39,7 +39,8 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate {
39 super.didReceiveMemoryWarning() 39 super.didReceiveMemoryWarning()
40 // Dispose of any resources that can be recreated. 40 // Dispose of any resources that can be recreated.
41 } 41 }
42 - @IBAction func onLoginClicked(sender: AnyObject) { 42 +
  43 + @IBAction func onLoginClicked(_ sender: UIButton) {
43 self.view.endEditing(true) 44 self.view.endEditing(true)
44 let account=fieldAccount.text 45 let account=fieldAccount.text
45 let pw=fieldPassword.text 46 let pw=fieldPassword.text
@@ -49,8 +50,8 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { @@ -49,8 +50,8 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate {
49 return 50 return
50 } 51 }
51 login(phone: account!, pw:pw!) 52 login(phone: account!, pw:pw!)
  53 +
52 } 54 }
53 -  
54 func login(phone:String, pw:String){ 55 func login(phone:String, pw:String){
55 if phone.isMobilePhoneNumber() { 56 if phone.isMobilePhoneNumber() {
56 SVProgressHUD.show(withStatus: "登录...") 57 SVProgressHUD.show(withStatus: "登录...")
@@ -107,19 +108,25 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { @@ -107,19 +108,25 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate {
107 } 108 }
108 } 109 }
109 func back(){ 110 func back(){
110 - self.navigationController!.popViewController(animated: true) 111 + self.navigationController!.dismiss(animated: true, completion: nil)
111 } 112 }
112 113
113 -  
114 - @IBAction func activatiAction(sender: UIButton) { 114 + func textFieldShouldReturn(_ textField: UITextField) -> Bool {
  115 + textField.resignFirstResponder()
  116 + return true
  117 + }
  118 +
  119 + @IBAction func activatiAction(_ sender: UIButton) {
115 let vc = Story.instantiateViewControllerWithIdentifier("ChangePassWordViewControllerVC", storyName: "User") as! ChangePassWordViewController 120 let vc = Story.instantiateViewControllerWithIdentifier("ChangePassWordViewControllerVC", storyName: "User") as! ChangePassWordViewController
116 - self.navigationController?.pushViewController(vc, animated: true) 121 + self.present(vc.wrapWithNavigationController(), animated: true, completion: nil)
117 } 122 }
118 - @IBAction func returnAction(sender: UIButton) { 123 +
  124 + @IBAction func returnAction(_ sender: UIButton) {
119 let vc = UIStoryboard(name: "Login", bundle: nil).instantiateViewController(withIdentifier: "RegisterViewControllerVC") as! RegisterViewController 125 let vc = UIStoryboard(name: "Login", bundle: nil).instantiateViewController(withIdentifier: "RegisterViewControllerVC") as! RegisterViewController
120 - self.navigationController!.pushViewController(vc, animated: true) 126 + self.present(vc.wrapWithNavigationController(), animated: true, completion: nil)
  127 +
121 } 128 }
122 - 129 +
123 func keyboardWillShow(){ 130 func keyboardWillShow(){
124 constraintContentOffset.constant=144 131 constraintContentOffset.constant=144
125 UIView.animate(withDuration: 2, animations: { () -> Void in 132 UIView.animate(withDuration: 2, animations: { () -> Void in
YouerLiveVideo/YouerLiveVideo/controllers/User/UserCenter/RegisterViewController.swift
@@ -22,6 +22,7 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker @@ -22,6 +22,7 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker
22 @IBOutlet weak var sendPhotoImage: UIImageView! 22 @IBOutlet weak var sendPhotoImage: UIImageView!
23 var iconImage: UIImage? 23 var iconImage: UIImage?
24 var name: String="" 24 var name: String=""
  25 + var timer :Timer!
25 override func viewDidLoad() { 26 override func viewDidLoad() {
26 super.viewDidLoad() 27 super.viewDidLoad()
27 self.configTheme() 28 self.configTheme()
@@ -39,6 +40,14 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker @@ -39,6 +40,14 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker
39 return true 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 @IBAction func sendVerificationCodeClickAction(_ sender: AnyObject) {//发验证码 51 @IBAction func sendVerificationCodeClickAction(_ sender: AnyObject) {//发验证码
43 self.view.endEditing(true) 52 self.view.endEditing(true)
44 if nikeNameTextFiled.text!.characters.count<11{ 53 if nikeNameTextFiled.text!.characters.count<11{
@@ -47,6 +56,8 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker @@ -47,6 +56,8 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker
47 if (phoneNumber.text?.isMobilePhoneNumber())! { 56 if (phoneNumber.text?.isMobilePhoneNumber())! {
48 SVProgressHUD.show(withStatus: "获取验证码...") 57 SVProgressHUD.show(withStatus: "获取验证码...")
49 SVProgressHUD.setDefaultMaskType(.black) 58 SVProgressHUD.setDefaultMaskType(.black)
  59 + timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(RegisterViewController.timerFire), userInfo: sender, repeats: true)
  60 +
50 AppDelegate.instance().httpServer.getChangePhoneCaptcha(mobile: phoneNumber.text!, completionHandler: { (str, error) in 61 AppDelegate.instance().httpServer.getChangePhoneCaptcha(mobile: phoneNumber.text!, completionHandler: { (str, error) in
51 SVProgressHUD.dismiss() 62 SVProgressHUD.dismiss()
52 if error==nil { 63 if error==nil {
@@ -114,6 +125,22 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker @@ -114,6 +125,22 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker
114 } 125 }
115 } 126 }
116 127
  128 + var num:Int = 0
  129 + func timerFire(){
  130 + let btn = timer.userInfo as! UIButton
  131 + if num == 60{
  132 + btn.setTitle("重新获取(\(60-num))", for: .normal)
  133 + btn.isUserInteractionEnabled = true
  134 + btn.backgroundColor = UIColorFromRGB(0x007aff)
  135 + self.timer.invalidate()
  136 + return
  137 + }
  138 + btn.setTitle("重新获取(\(60-num))", for: .normal)
  139 + btn.isUserInteractionEnabled = false
  140 + btn.backgroundColor = UIColor.lightGray
  141 + num += 1
  142 +
  143 + }
117 144
118 @IBAction func loginBtnClickAction(_ sender: AnyObject) { 145 @IBAction func loginBtnClickAction(_ sender: AnyObject) {
119 self.navigationController!.dismiss(animated: true, completion: nil) 146 self.navigationController!.dismiss(animated: true, completion: nil)
YouerLiveVideo/YouerLiveVideo/controllers/User/UserViewController.swift
@@ -108,7 +108,7 @@ extension UserViewController:UITableViewDelegate,UITableViewDataSource{ @@ -108,7 +108,7 @@ extension UserViewController:UITableViewDelegate,UITableViewDataSource{
108 } 108 }
109 109
110 func numberOfSections(in tableView: UITableView) -> Int { 110 func numberOfSections(in tableView: UITableView) -> Int {
111 - if user.roletype() == 3 || user.roletype() == 4 || user.roletype() == 5{ 111 + if user.roletype() == 3 || user.roletype() == 4 || user.roletype() == 5 || user.roletype() == 0 {
112 return 1 112 return 1
113 } 113 }
114 return sectionList.count 114 return sectionList.count