ChangePasswordViewController.m 3.54 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 33 34 35 36
//
//  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];
    // Do any additional setup after loading the view from its nib.
    
     [self uiConfigAction];
}

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





#pragma mark - UI
- (void)uiConfigAction
{
曹云霄's avatar
曹云霄 committed
37 38 39 40 41 42
    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;
43 44 45 46
    self.cancelButton.layer.masksToBounds = YES;
    self.cancelButton.layer.cornerRadius = kCornerRadius;
    self.sureChangeButton.layer.masksToBounds = YES;
    self.sureChangeButton.layer.cornerRadius = kCornerRadius;
曹云霄's avatar
曹云霄 committed
47
    self.userName.text = [Shoppersmanager manager].userNameString;
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    
}

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


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




/*
#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