ChangePasswordViewController.m 3.31 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
        
曹云霄's avatar
曹云霄 committed
64
        [XBLoadingView showHUDViewWithText:@"账户名不能为空"];
65
    }
66
    else if ([BaseViewController isBlankString:self.oldPassWord.text])
67
    {
曹云霄's avatar
曹云霄 committed
68
        [XBLoadingView showHUDViewWithText:@"旧密码不能为空"];
69
    }
70
    else if ([BaseViewController isBlankString:self.NewPassWord.text])
71
    {
曹云霄's avatar
曹云霄 committed
72
        [XBLoadingView showHUDViewWithText:@"新密码不能为空"];
73 74
    }
    
曹云霄's avatar
曹云霄 committed
75
    [XBLoadingView showHUDViewWithDefault];
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);
曹云霄's avatar
曹云霄 committed
83
    [HTTP networkRequestWithURL:SERVERREQUESTURL(MODIFYPASSWORD)  withRequestType:ZERO withParameter:modify withReturnValueBlock:^(id returnValue) {
84
        
曹云霄's avatar
曹云霄 committed
85
        [XBLoadingView hideHUDViewWithDefault];
曹云霄's avatar
曹云霄 committed
86
        if (RESULT(returnValue)) {
勾芒's avatar
勾芒 committed
87
            //保存最新的账号信息
曹云霄's avatar
曹云霄 committed
88 89 90
            [Shoppersmanager manager].passWordString = weakSelf.NewPassWord.text;
            if ([weakSelf.delegate respondsToSelector:@selector(cancelButtonClick)]) {
                [weakSelf.delegate cancelButtonClick];
勾芒's avatar
勾芒 committed
91
            }
92
        }else{
曹云霄's avatar
曹云霄 committed
93
            [XBLoadingView showHUDViewWithText:returnValue[@"message"]];
94
        }
95
    }withFailureBlock:^(id error) {
曹云霄's avatar
曹云霄 committed
96
        NSLog(@"%@",error);
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
    }];
}




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