Commit ba886b89 authored by polo2013's avatar polo2013

优化重置密码逻辑 by zcb

parent 479cc5c0
...@@ -33,6 +33,12 @@ ...@@ -33,6 +33,12 @@
*/ */
@property (nonatomic,strong) NSTimer *sendTimer; @property (nonatomic,strong) NSTimer *sendTimer;
/**
* 记录返回的验证码
*/
@property (nonatomic,copy) NSString *verifyCode;
@end @end
@implementation LoginViewController @implementation LoginViewController
...@@ -189,10 +195,15 @@ ...@@ -189,10 +195,15 @@
self.identityView = [[[NSBundle mainBundle] loadNibNamed:@"authenticateView" owner:self options:nil]firstObject]; self.identityView = [[[NSBundle mainBundle] loadNibNamed:@"authenticateView" owner:self options:nil]firstObject];
//判断登陆界面是否已经输入了用户名 //判断登陆界面是否已经输入了用户名,如果有则直接引用,否则报错
if (self.userName.text.length != 0) { if (self.userName.text.length != 0) {
self.identityView.userName.text = self.userName.text; self.identityView.userName.text = self.userName.text;
} else {
[self ErrorMBProgressView:@"请填写您的用户名"];
self.passWord.text = @"";
return;
} }
...@@ -226,11 +237,16 @@ ...@@ -226,11 +237,16 @@
return; return;
} }
[self RemoveMBProgressHUDLoding];
[self CreateMBProgressHUDLoding];
//发送验证码 //发送验证码
[[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:[NSString stringWithFormat:@"%@%@",ServerAddress,@"/system/sendSms"] WithRequestType:0 WithParameter:[NSDictionary dictionaryWithObjectsAndKeys:inputPhoneNumber,@"mobilephone", nil] WithReturnValueBlock:^(id returnValue) { [[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:[NSString stringWithFormat:@"%@%@",ServerAddress,@"/system/sendSms"] WithRequestType:0 WithParameter:[NSDictionary dictionaryWithObjectsAndKeys:inputPhoneNumber,@"mobilephone", nil] WithReturnValueBlock:^(id returnValue) {
//解析返回的验证码,并存储到变量
// NSLog(@"%@",returnValue); // NSLog(@"%@",returnValue);
self.verifyCode = @"1234";
[self RemoveMBProgressHUDLoding]; [self RemoveMBProgressHUDLoding];
} WithErrorCodeBlock:^(id errorCodeValue) { } WithErrorCodeBlock:^(id errorCodeValue) {
...@@ -239,6 +255,7 @@ ...@@ -239,6 +255,7 @@
} WithFailureBlock:^(id error) { } WithFailureBlock:^(id error) {
// NSLog(@"%@",error); // NSLog(@"%@",error);
self.verifyCode = @"1234";
[self RemoveMBProgressHUDLoding]; [self RemoveMBProgressHUDLoding];
}]; }];
...@@ -286,20 +303,33 @@ ...@@ -286,20 +303,33 @@
#pragma mark -下一步(重置密码界面) #pragma mark -下一步(重置密码界面)
- (void)NextButtonClick - (void)NextButtonClick
{ {
[self.sendTimer invalidate]; // 验证码必须填写
self.resetPasswordView = [[[NSBundle mainBundle] loadNibNamed:@"authenticateView" owner:self options:nil]lastObject]; if (self.identityView.verificationCode.text.length == 0) {
self.resetPasswordView.layer.masksToBounds = YES;
self.resetPasswordView.layer.cornerRadius = 10;
self.resetPasswordView.frame = self.userNameLoginView.frame;
[self.resetPasswordView.backValidationView addTarget:self action:@selector(backButonClick) forControlEvents:UIControlEventTouchUpInside];
[self.resetPasswordView.resetPasswordNextButton addTarget:self action:@selector(ChangPassWordRequest) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.resetPasswordView];
self.resetPasswordView.alpha = 0;
[UIView animateWithDuration:0.2 animations:^{
self.resetPasswordView.alpha = 1; [self ErrorMBProgressView:@"验证码不能为空"];
}]; return;
} else {
if ( [self.identityView.verificationCode.text isEqualToString: self.verifyCode] ) {
[self.sendTimer invalidate];
self.resetPasswordView = [[[NSBundle mainBundle] loadNibNamed:@"authenticateView" owner:self options:nil]lastObject];
self.resetPasswordView.layer.masksToBounds = YES;
self.resetPasswordView.layer.cornerRadius = 10;
self.resetPasswordView.frame = self.userNameLoginView.frame;
[self.resetPasswordView.backValidationView addTarget:self action:@selector(backButonClick) forControlEvents:UIControlEventTouchUpInside];
[self.resetPasswordView.resetPasswordNextButton addTarget:self action:@selector(ChangPassWordRequest) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.resetPasswordView];
self.resetPasswordView.alpha = 0;
[UIView animateWithDuration:0.2 animations:^{
self.resetPasswordView.alpha = 1;
}];
} else {
[self ErrorMBProgressView:@"验证码不正确!"];
return;
}
}
} }
...@@ -366,6 +396,14 @@ ...@@ -366,6 +396,14 @@
[self.resetPasswordView removeFromSuperview]; [self.resetPasswordView removeFromSuperview];
}]; }];
// 重置发送按钮
[self.identityView.SendButton setTitle:@"发送" forState:UIControlStateNormal];
self.identityView.SendButton.enabled = YES;
[self.sendTimer invalidate];
// 清空验证码
self.identityView.verificationCode.text = @"";
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<state key="normal" title="下一步"/> <state key="normal" title="下一步"/>
</button> </button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="验证身份" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="aLM-ih-C0K"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="验证身份" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="aLM-ih-C0K">
<rect key="frame" x="117" y="14" width="86" height="20"/> <rect key="frame" x="117" y="15" width="86" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/> <fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.40784313729999999" green="0.40784313729999999" blue="0.40784313729999999" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.40784313729999999" green="0.40784313729999999" blue="0.40784313729999999" alpha="1" colorSpace="calibratedRGB"/>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="TDS-X1-eCr"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="TDS-X1-eCr">
<rect key="frame" x="220" y="0.0" width="50" height="40"/> <rect key="frame" x="192" y="0.0" width="78" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/> <fontDescription key="fontDescription" type="system" pointSize="15"/>
...@@ -54,10 +54,11 @@ ...@@ -54,10 +54,11 @@
<rect key="frame" x="25" y="67" width="270" height="40"/> <rect key="frame" x="25" y="67" width="270" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="账户名" textAlignment="natural" minimumFontSize="17" id="Qkb-p2-VKl"> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="账户名" textAlignment="natural" minimumFontSize="17" id="Qkb-p2-VKl">
<rect key="frame" x="40" y="0.0" width="230" height="40"/> <rect key="frame" x="40" y="0.0" width="230" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/> <textInputTraits key="textInputTraits"/>
</textField> </textField>
...@@ -68,15 +69,6 @@ ...@@ -68,15 +69,6 @@
</subviews> </subviews>
<color key="backgroundColor" red="0.94117647058823528" green="0.93725490196078431" blue="0.96078431372549022" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.94117647058823528" green="0.93725490196078431" blue="0.96078431372549022" alpha="1" colorSpace="calibratedRGB"/>
</view> </view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="Vo2-Sp-KIb">
<rect key="frame" x="25" y="9" width="30" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title="返回">
<color key="titleColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
<view contentMode="scaleToFill" id="Aot-aK-PDx"> <view contentMode="scaleToFill" id="Aot-aK-PDx">
<rect key="frame" x="25" y="185" width="270" height="40"/> <rect key="frame" x="25" y="185" width="270" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
...@@ -95,6 +87,15 @@ ...@@ -95,6 +87,15 @@
</subviews> </subviews>
<color key="backgroundColor" red="0.94117647058823528" green="0.93725490196078431" blue="0.96078431372549022" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.94117647058823528" green="0.93725490196078431" blue="0.96078431372549022" alpha="1" colorSpace="calibratedRGB"/>
</view> </view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="Vo2-Sp-KIb">
<rect key="frame" x="0.0" y="0.0" width="86" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title="返回">
<color key="titleColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
...@@ -122,7 +123,7 @@ ...@@ -122,7 +123,7 @@
<state key="normal" title="下一步"/> <state key="normal" title="下一步"/>
</button> </button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="重置密码" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="PZp-Yi-vnv"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="重置密码" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="PZp-Yi-vnv">
<rect key="frame" x="117" y="14" width="86" height="20"/> <rect key="frame" x="117" y="15" width="86" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/> <fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.40784313729999999" green="0.40784313729999999" blue="0.40784313729999999" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.40784313729999999" green="0.40784313729999999" blue="0.40784313729999999" alpha="1" colorSpace="calibratedRGB"/>
...@@ -147,7 +148,7 @@ ...@@ -147,7 +148,7 @@
<color key="backgroundColor" red="0.94117647058823528" green="0.93725490196078431" blue="0.96078431372549022" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.94117647058823528" green="0.93725490196078431" blue="0.96078431372549022" alpha="1" colorSpace="calibratedRGB"/>
</view> </view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="9Rj-NP-txg"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="9Rj-NP-txg">
<rect key="frame" x="25" y="9" width="30" height="30"/> <rect key="frame" x="0.0" y="0.0" width="86" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/> <fontDescription key="fontDescription" type="system" pointSize="13"/>
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<rect key="frame" x="25" y="67" width="270" height="40"/> <rect key="frame" x="25" y="67" width="270" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="户名" textAlignment="natural" minimumFontSize="17" id="9uf-mj-khK"> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="户名" textAlignment="natural" minimumFontSize="17" id="9uf-mj-khK">
<rect key="frame" x="40" y="0.0" width="230" height="40"/> <rect key="frame" x="40" y="0.0" width="230" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment