Commit 21616c4361d6fe38985f03e8c07c2fc41fb7b827

Authored by 葛建军
2 parents 405a45cf 3348440c
Exists in newLive

Merge branch 'newLive' of http://git.shunzhi.net/iosgroup/newlive into newLive

YouerLiveVideo/YouerLiveVideo/controllers/User/Setting/ChangePassWordViewController.swift
@@ -102,24 +102,6 @@ class ChangePassWordViewController: UIViewController { @@ -102,24 +102,6 @@ class ChangePassWordViewController: UIViewController {
102 102
103 @IBAction func sendUserCodeBtnClick(_ sender: UIButton) { 103 @IBAction func sendUserCodeBtnClick(_ sender: UIButton) {
104 self.view.endEditing(true) 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 var phone = "" 105 var phone = ""
124 if user.isOnline(){ 106 if user.isOnline(){
125 phone = user.phone() 107 phone = user.phone()
@@ -138,6 +120,7 @@ class ChangePassWordViewController: UIViewController { @@ -138,6 +120,7 @@ class ChangePassWordViewController: UIViewController {
138 if JSON.fromString(jsonString: str)!["status"].intValue == 1{ 120 if JSON.fromString(jsonString: str)!["status"].intValue == 1{
139 httpJsonResule(jsonString: str, error: error, successHandler: { (json) in 121 httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
140 self.view.makeToast("验证码发送成功") 122 self.view.makeToast("验证码发送成功")
  123 + self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(ChangePassWordViewController.timerFire), userInfo: sender, repeats: true)
141 }, failHandler: { (error) in 124 }, failHandler: { (error) in
142 self.view.makeToast("验证码发送失败:\(error.localizedDescription)") 125 self.view.makeToast("验证码发送失败:\(error.localizedDescription)")
143 }) 126 })
@@ -169,9 +152,28 @@ class ChangePassWordViewController: UIViewController { @@ -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 override func viewWillDisappear(_ animated: Bool) { 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 // MARK: - 销毁通知 178 // MARK: - 销毁通知
177 deinit { 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 <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>
@@ -937,7 +936,7 @@ @@ -937,7 +936,7 @@
937 <color key="titleShadowColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/> 936 <color key="titleShadowColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
938 </state> 937 </state>
939 <connections> 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 </connections> 940 </connections>
942 </button> 941 </button>
943 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Oee-Sm-GxU"> 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,7 +950,7 @@
951 <color key="titleColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> 950 <color key="titleColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
952 </state> 951 </state>
953 <connections> 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 </connections> 954 </connections>
956 </button> 955 </button>
957 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vmw-Ug-eCf"> 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,7 +964,7 @@
965 <color key="titleColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> 964 <color key="titleColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
966 </state> 965 </state>
967 <connections> 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 </connections> 968 </connections>
970 </button> 969 </button>
971 </subviews> 970 </subviews>
YouerLiveVideo/YouerLiveVideo/controllers/User/UserCenter/NewLoginViewController.swift
@@ -37,6 +37,7 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { @@ -37,6 +37,7 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate {
37 super.didReceiveMemoryWarning() 37 super.didReceiveMemoryWarning()
38 // Dispose of any resources that can be recreated. 38 // Dispose of any resources that can be recreated.
39 } 39 }
  40 +
40 @IBAction func onLoginClicked(_ sender: UIButton) { 41 @IBAction func onLoginClicked(_ sender: UIButton) {
41 self.view.endEditing(true) 42 self.view.endEditing(true)
42 let account=fieldAccount.text 43 let account=fieldAccount.text
@@ -47,8 +48,8 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { @@ -47,8 +48,8 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate {
47 return 48 return
48 } 49 }
49 login(phone: account!, pw:pw!) 50 login(phone: account!, pw:pw!)
  51 +
50 } 52 }
51 -  
52 func login(phone:String, pw:String){ 53 func login(phone:String, pw:String){
53 if phone.isMobilePhoneNumber() { 54 if phone.isMobilePhoneNumber() {
54 SVProgressHUD.show(withStatus: "登录...") 55 SVProgressHUD.show(withStatus: "登录...")
@@ -105,18 +106,23 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate { @@ -105,18 +106,23 @@ class NewLoginViewController: UIViewController,UITextFieldDelegate {
105 } 106 }
106 } 107 }
107 func back(){ 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 @IBAction func forgetPassword(_ sender: UIButton) { 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 self.navigationController?.pushViewController(vc, animated: true) 119 self.navigationController?.pushViewController(vc, animated: true)
114 } 120 }
115 @IBAction func registerAccount(_ sender: UIButton) { 121 @IBAction func registerAccount(_ sender: UIButton) {
116 let vc = UIStoryboard(name: "Login", bundle: nil).instantiateViewController(withIdentifier: "RegisterViewControllerVC") as! RegisterViewController 122 let vc = UIStoryboard(name: "Login", bundle: nil).instantiateViewController(withIdentifier: "RegisterViewControllerVC") as! RegisterViewController
117 self.navigationController!.pushViewController(vc, animated: true) 123 self.navigationController!.pushViewController(vc, animated: true)
118 } 124 }
119 - 125 +
120 func keyboardWillShow(){ 126 func keyboardWillShow(){
121 constraintContentOffset.constant=144 127 constraintContentOffset.constant=144
122 UIView.animate(withDuration: 2, animations: { () -> Void in 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,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,12 +56,15 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker @@ -47,12 +56,15 @@ 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 +
50 AppDelegate.instance().httpServer.getChangePhoneCaptcha(mobile: phoneNumber.text!, completionHandler: { (str, error) in 60 AppDelegate.instance().httpServer.getChangePhoneCaptcha(mobile: phoneNumber.text!, completionHandler: { (str, error) in
51 SVProgressHUD.dismiss() 61 SVProgressHUD.dismiss()
52 if error==nil { 62 if error==nil {
53 if JSON.fromString(jsonString: str)!["status"].intValue == 1{ 63 if JSON.fromString(jsonString: str)!["status"].intValue == 1{
54 httpJsonResule(jsonString: str, error: error, successHandler: { (json) in 64 httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
55 self.view.makeToast("验证码发送成功") 65 self.view.makeToast("验证码发送成功")
  66 + self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(RegisterViewController.timerFire), userInfo: sender, repeats: true)
  67 +
56 self.nikeNameTextFiled.isUserInteractionEnabled=false 68 self.nikeNameTextFiled.isUserInteractionEnabled=false
57 self.phoneNumber.isUserInteractionEnabled=false 69 self.phoneNumber.isUserInteractionEnabled=false
58 self.passwordTextField.isUserInteractionEnabled=false 70 self.passwordTextField.isUserInteractionEnabled=false
@@ -114,6 +126,22 @@ class RegisterViewController: UIViewController,UIAlertViewDelegate,UIImagePicker @@ -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 @IBAction func loginBtnClickAction(_ sender: AnyObject) { 146 @IBAction func loginBtnClickAction(_ sender: AnyObject) {
119 self.navigationController!.popViewController(animated: true) 147 self.navigationController!.popViewController(animated: true)
YouerLiveVideo/YouerLiveVideo/controllers/User/UserViewController.swift
@@ -51,7 +51,6 @@ class UserViewController: UIViewController { @@ -51,7 +51,6 @@ class UserViewController: UIViewController {
51 let vc=Story.instantiateViewControllerWithIdentifier("NewLoginViewControllerVC", storyName: "Login") as! NewLoginViewController 51 let vc=Story.instantiateViewControllerWithIdentifier("NewLoginViewControllerVC", storyName: "Login") as! NewLoginViewController
52 self.navigationController?.pushViewController(vc, animated: true) 52 self.navigationController?.pushViewController(vc, animated: true)
53 } 53 }
54 -  
55 } 54 }
56 55
57 func editBtnClick(){ 56 func editBtnClick(){
@@ -108,7 +107,7 @@ extension UserViewController:UITableViewDelegate,UITableViewDataSource{ @@ -108,7 +107,7 @@ extension UserViewController:UITableViewDelegate,UITableViewDataSource{
108 } 107 }
109 108
110 func numberOfSections(in tableView: UITableView) -> Int { 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 return 1 111 return 1
113 } 112 }
114 return sectionList.count 113 return sectionList.count