ChangePasswordViewController.m 3.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
//
//  ChangePasswordViewController.m
//  Lighting
//
//  Created by 曹云霄 on 16/5/9.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "ChangePasswordViewController.h"

@interface ChangePasswordViewController ()

@end

@implementation ChangePasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
     [self uiConfigAction];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    
}


#pragma mark - UI
- (void)uiConfigAction
{
曹云霄's avatar
曹云霄 committed
33 34 35 36 37 38
    self.userNameBack.layer.masksToBounds = YES;
    self.userNameBack.layer.cornerRadius = kCornerRadius;
    self.oldPasswordBack.layer.masksToBounds = YES;
    self.oldPasswordBack.layer.cornerRadius = kCornerRadius;
    self.NewPasswrodBack.layer.masksToBounds = YES;
    self.NewPasswrodBack.layer.cornerRadius = kCornerRadius;
39 40 41 42
    self.cancelButton.layer.masksToBounds = YES;
    self.cancelButton.layer.cornerRadius = kCornerRadius;
    self.sureChangeButton.layer.masksToBounds = YES;
    self.sureChangeButton.layer.cornerRadius = kCornerRadius;
曹云霄's avatar
曹云霄 committed
43
    self.userName.text = [Shoppersmanager manager].userNameString;
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    
}

#pragma mark -取消按钮
- (IBAction)cancelButtonClick:(UIButton *)sender {
    
    if ([self.delegate respondsToSelector:@selector(cancelButtonClick)]) {
        
        [self.delegate cancelButtonClick];
    }
    
}


#pragma amrk -确认修改按钮
- (IBAction)sureChangeButtonClick:(UIButton *)sender {
    
勾芒's avatar
勾芒 committed
61
    [self.view endEditing:YES];
62
    if ([BaseViewController isBlankString:self.userName.text]) {
63 64 65
        
        [self ErrorMBProgressView:@"账户名不能为空"];
    }
66
    else if ([BaseViewController isBlankString:self.oldPassWord.text])
67 68 69
    {
        [self ErrorMBProgressView:@"旧密码不能为空"];
    }
70
    else if ([BaseViewController isBlankString:self.NewPassWord.text])
71 72 73 74
    {
        [self ErrorMBProgressView:@"新密码不能为空"];
    }
    
曹云霄's avatar
曹云霄 committed
75
    [self CreateMBProgressHUDLoding];
76 77
    ModifyPasswordRequest *modify = [[ModifyPasswordRequest alloc]init];
    modify.oldPassword = self.oldPassWord.text;
曹云霄's avatar
曹云霄 committed
78 79
    modify.fnewPassword = self.NewPassWord.text;
    modify.employeeId = [Shoppersmanager manager].Shoppers.employee.fid;
80 81
    
    //修改密码
曹云霄's avatar
曹云霄 committed
82
    WS(weakSelf);
83
    [[NetworkRequestClassManager Manager] NetworkRequestWithURL:SERVERREQUESTURL(MODIFYPASSWORD) WithCallClass:weakSelf WithRequestType:0 WithParameter:modify WithReturnValueBlock:^(id returnValue) {
84
        
曹云霄's avatar
曹云霄 committed
85
        [weakSelf RemoveMBProgressHUDLoding];
86 87
        if ([returnValue[@"code"] isEqualToNumber:@0]) {
            
勾芒's avatar
勾芒 committed
88
            //保存最新的账号信息
曹云霄's avatar
曹云霄 committed
89 90 91
            [Shoppersmanager manager].passWordString = weakSelf.NewPassWord.text;
            [weakSelf SuccessMBProgressView:returnValue[@"message"]];
            if ([weakSelf.delegate respondsToSelector:@selector(cancelButtonClick)]) {
勾芒's avatar
勾芒 committed
92
                
曹云霄's avatar
曹云霄 committed
93
                [weakSelf.delegate cancelButtonClick];
勾芒's avatar
勾芒 committed
94
            }
95 96
        }else
        {
曹云霄's avatar
曹云霄 committed
97
            [weakSelf ErrorMBProgressView:returnValue[@"message"]];
98 99 100 101
        }
        
    } WithErrorCodeBlock:^(id errorCodeValue) {
        
曹云霄's avatar
曹云霄 committed
102
        [weakSelf RemoveMBProgressHUDLoding];
103
        [weakSelf ErrorMBProgressView:NETWORK];
104
    } WithFailureBlock:^(id error) {
曹云霄's avatar
曹云霄 committed
105
        NSLog(@"%@",error);
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
    }];
}




/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end