mirror of
https://github.com/wu736139669/ManagerDemo.git
synced 2026-08-05 05:55:42 +00:00
set password
This commit is contained in:
BIN
Binary file not shown.
@@ -61,6 +61,8 @@
|
||||
[dic setObject:@"15e6c60bbdfa5d62dc7baab09cca5d19d1f32d11" forKey:@"token"];
|
||||
[dic setObject:@"2.5.0" forKey:@"ver"];
|
||||
[dic setObject:@"IOS" forKey:@"vjson"];
|
||||
[dic setObject:@"8201408070536905" forKey:@"userId"];
|
||||
[dic setObject:@"15e6c60bbdfa5d62dc7baab09cca5d19d1f32d11" forKey:@"token"];
|
||||
return [self operationWithPath:path params:dic httpMethod:@"POST" ssl:YES];
|
||||
}
|
||||
-(MKNetworkOperation*)getApiWithParam:(NSDictionary *)param withApiType:(NSString *)apiType completionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
if ([ManagerUser shareInstance].token.length > 0) {
|
||||
[dic setObject:[ManagerUser shareInstance].token forKey:@"token"];
|
||||
}
|
||||
if ([ManagerUser shareInstance].userId.length > 0) {
|
||||
[dic setObject:[ManagerUser shareInstance].userId forKey:@"userid"];
|
||||
}
|
||||
NSError *parseError = nil;
|
||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];
|
||||
NSString* tempStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
|
||||
@@ -56,17 +56,32 @@
|
||||
|
||||
- (IBAction)login:(id)sender {
|
||||
if (_passwordTextField.text.length>0 && _phoneNum.length>0) {
|
||||
DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance];
|
||||
[daiDaiTongApi loginWithPhone:_phoneNum withPassWord:_passwordTextField.text withCompletionBlock:^(id jsonRes) {
|
||||
if ([[jsonRes objectForKey:@"succ"] integerValue] != 1) {
|
||||
// DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance];
|
||||
// [daiDaiTongApi loginWithPhone:_phoneNum withPassWord:_passwordTextField.text withCompletionBlock:^(id jsonRes) {
|
||||
// if ([[jsonRes objectForKey:@"succ"] integerValue] != 1) {
|
||||
// }else{
|
||||
// }
|
||||
// [ManagerUser shareInstance].isLogin = YES;
|
||||
// [self.navigationController dismissViewControllerAnimated:YES completion:nil];
|
||||
//
|
||||
// } failedBlock:^(NSError *error) {
|
||||
// [MBProgressHUD errorHudWithView:nil label:@"网络出错" hidesAfter:1.0];
|
||||
// }];
|
||||
|
||||
[MBProgressHUD hudWithView:self.view label:@"安全加载中"];
|
||||
DaiDaiTongTestApi* daiDaiTongTestApi = [DaiDaiTongTestApi shareInstance];
|
||||
[daiDaiTongTestApi getApiWithParam:[NSDictionary dictionaryWithObjectsAndKeys:_phoneNum,@"phoneNum",_passwordTextField.text, @"loginPsw", nil] withApiType:@"loginByPsw" completionBlock:^(id jsonRes) {
|
||||
if (!([[jsonRes objectForKey:@"resultflag"] integerValue] == 0)) {
|
||||
[MBProgressHUD errorHudWithView:self.view label:[jsonRes objectForKey:@"resultMsg"] hidesAfter:0.5];
|
||||
}else{
|
||||
[ManagerUser shareInstance].isLogin = YES;
|
||||
[ManagerUser shareInstance].userId = [jsonRes objectForKey:@"userid"];
|
||||
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
|
||||
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
[ManagerUser shareInstance].isLogin = YES;
|
||||
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
} failedBlock:^(NSError *error) {
|
||||
DLog(@"失败");
|
||||
[MBProgressHUD errorHudWithView:nil label:@"网络出错" hidesAfter:1.0];
|
||||
|
||||
[MBProgressHUD errorHudWithView:self.view label:@"网络出错" hidesAfter:0.5];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#import "ViewController.h"
|
||||
|
||||
@interface SetPassWordViewController : ViewController
|
||||
@interface SetPassWordViewController : ViewController<UITextFieldDelegate>
|
||||
@property (weak, nonatomic) IBOutlet UITextField *passWordTextField;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *surePassWordTextField;
|
||||
- (IBAction)completeBtnClick:(id)sender;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *completeBtn;
|
||||
|
||||
@end
|
||||
|
||||
@@ -27,6 +27,66 @@
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view from its nib.
|
||||
self.navigationItem.title = @"设置登录密码";
|
||||
_passWordTextField.leftViewMode = UITextFieldViewModeAlways;
|
||||
_passWordTextField.layer.masksToBounds=YES;
|
||||
_passWordTextField.layer.borderColor = [[UIColor lightGrayColor]CGColor];
|
||||
_passWordTextField.layer.borderWidth= 1.0f;
|
||||
_passWordTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldTextDidChange:) name:UITextFieldTextDidChangeNotification object:_passWordTextField];
|
||||
_passWordTextField.delegate = self;
|
||||
|
||||
_surePassWordTextField.leftViewMode = UITextFieldViewModeAlways;
|
||||
_surePassWordTextField.layer.masksToBounds=YES;
|
||||
_surePassWordTextField.layer.borderColor = [[UIColor lightGrayColor]CGColor];
|
||||
_surePassWordTextField.layer.borderWidth= 1.0f;
|
||||
_surePassWordTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldTextDidChange:) name:UITextFieldTextDidChangeNotification object:_surePassWordTextField];
|
||||
_surePassWordTextField.delegate = self;
|
||||
|
||||
_completeBtn.enabled = NO;
|
||||
[_completeBtn setBackgroundImage:[ManagerUtil buttonImageFromColor:[UIColor lightGrayColor] withFrame:_completeBtn.frame] forState:UIControlStateDisabled];
|
||||
}
|
||||
|
||||
|
||||
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
|
||||
[super touchesMoved:touches withEvent:event];
|
||||
[_surePassWordTextField resignFirstResponder];
|
||||
[_passWordTextField resignFirstResponder];
|
||||
|
||||
}
|
||||
#pragma mark UITextFieldDelegate
|
||||
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
|
||||
{
|
||||
textField.layer.borderColor = [[UIColor orangeColor]CGColor];
|
||||
return YES;
|
||||
}
|
||||
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
|
||||
{
|
||||
|
||||
if (range.location >= 12)
|
||||
return NO; // return NO to not change text
|
||||
|
||||
return YES;
|
||||
}
|
||||
-(void)textFieldTextDidChange:(NSNotification *)sender
|
||||
{
|
||||
|
||||
if ([_passWordTextField.text isEqualToString:@""] || [_surePassWordTextField.text isEqualToString:@""] ) {
|
||||
_completeBtn.enabled = NO;
|
||||
|
||||
}else{
|
||||
_completeBtn.enabled = YES;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField
|
||||
{
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
@@ -35,4 +95,28 @@
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
- (IBAction)completeBtnClick:(id)sender {
|
||||
|
||||
if (![_passWordTextField.text isEqualToString:_surePassWordTextField.text]) {
|
||||
[MBProgressHUD errorHudWithView:self.view label:@"两次密码不同" hidesAfter:0.5];
|
||||
}
|
||||
if (_passWordTextField.text.length<6 || _passWordTextField.text.length>11) {
|
||||
[MBProgressHUD errorHudWithView:self.view label:@"密码不规范" hidesAfter:0.5];
|
||||
}
|
||||
[MBProgressHUD hudWithView:self.view label:@"安全加载中"];
|
||||
DaiDaiTongTestApi* daiDaiTongTestApi = [DaiDaiTongTestApi shareInstance];
|
||||
[daiDaiTongTestApi getApiWithParam:[NSDictionary dictionaryWithObjectsAndKeys:_passWordTextField.text,@"loginPsw", nil] withApiType:@"setLoginPsw" completionBlock:^(id jsonRes) {
|
||||
if (!([[jsonRes objectForKey:@"resultflag"] integerValue] == 0)) {
|
||||
[MBProgressHUD errorHudWithView:self.view label:[jsonRes objectForKey:@"resultMsg"] hidesAfter:0.5];
|
||||
}else{
|
||||
[self.navigationController dismissViewControllerAnimated:YES completion:^{
|
||||
|
||||
}];
|
||||
}
|
||||
} failedBlock:^(NSError *error) {
|
||||
|
||||
[MBProgressHUD errorHudWithView:self.view label:@"网络出错" hidesAfter:0.5];
|
||||
}];
|
||||
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SetPassWordViewController">
|
||||
<connections>
|
||||
<outlet property="completeBtn" destination="mWs-sA-ia8" id="JhR-s2-Kwo"/>
|
||||
<outlet property="passWordTextField" destination="qes-Vw-q4F" id="gix-lK-yM2"/>
|
||||
<outlet property="surePassWordTextField" destination="s3w-SU-YZd" id="rjh-Hp-2FU"/>
|
||||
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
@@ -14,12 +17,37 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="line" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="qes-Vw-q4F">
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="line" placeholder="登录密码" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="qes-Vw-q4F">
|
||||
<rect key="frame" x="20" y="75" width="280" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<textInputTraits key="textInputTraits" secureTextEntry="YES"/>
|
||||
</textField>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="line" placeholder="登录密码确认" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="s3w-SU-YZd">
|
||||
<rect key="frame" x="20" y="156" width="280" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" secureTextEntry="YES"/>
|
||||
</textField>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="密码由6-16个字符组成,字母区分大小写" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="280" translatesAutoresizingMaskIntoConstraints="NO" id="0Ee-ib-6T6">
|
||||
<rect key="frame" x="20" y="127" width="280" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mWs-sA-ia8">
|
||||
<rect key="frame" x="20" y="232" width="280" height="42"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<state key="normal" title="完成">
|
||||
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="completeBtnClick:" destination="-1" eventType="touchUpInside" id="Jz6-WB-xyN"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
_myMoreNavigationController = [[UINavigationController alloc] initWithRootViewController:[[MoreViewController alloc] init]];
|
||||
if (IOS7_OR_LATER) {
|
||||
[_homeNavigationController setTabBarItem:[[UITabBarItem alloc] initWithTitle:@"首页" image:[UIImage imageNamed:@"icon_dock_home"] selectedImage:[UIImage imageNamed:@"icon_dock_home_actived"]]];
|
||||
// [_homeNavigationController.tabBarItem setBadgeValue:@"新"];
|
||||
|
||||
[_produciListNavigationController setTabBarItem:[[UITabBarItem alloc] initWithTitle:@"产品列表" image:[UIImage imageNamed:@"icon_dock_session"] selectedImage:[UIImage imageNamed:@"icon_dock_session_actived"]]];
|
||||
|
||||
@@ -56,8 +55,8 @@
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view from its nib.
|
||||
|
||||
[ManagerUser shareInstance].userId = @"8201408070536905";
|
||||
[ManagerUser shareInstance].token = @"15e6c60bbdfa5d62dc7baab09cca5d19d1f32d11";
|
||||
// [ManagerUser shareInstance].userId = @"8201408070536905";
|
||||
// [ManagerUser shareInstance].token = @"15e6c60bbdfa5d62dc7baab09cca5d19d1f32d11";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user