|
//
// editEmailController.m
// ThePaperHD
//
// Created by scar1900 on 15/3/27.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "editEmailController.h"
#define TEXTFIELDTAG 2000
@interface editEmailController (){
NSString *email;
NSString *inviteCode;
}
@end
@implementation editEmailController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.titleLabel.text = @"修改邮箱";
[self.getInviteCodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
NSAttributedString* atrString = [[NSAttributedString alloc] initWithString:@"请输入新邮箱" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:LINECOLOR]}];
self.phoneTextField.attributedPlaceholder = atrString;
NSAttributedString* atrString1 = [[NSAttributedString alloc] initWithString:@"请输入邮箱中的验证码" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:LINECOLOR]}];
self.inviteCodeField.attributedPlaceholder = atrString1;
self.phoneTextField.text = @"";
self.inviteCodeField.text = @"";
}
- (void)addTextFieldImage {
UIImageView *phoneImageView = [[UIImageView alloc]initWithFrame:CGRectMake(17,
CGRectGetMinY(self.phoneTextField.frame)+10,
20,
15)];
phoneImageView.image = Image(@"login/emailIcon.png");
[self.keyboardView addSubview:phoneImageView];
//
UIImageView *inviteCodeImageView = [[UIImageView alloc]initWithFrame:CGRectMake(17,
CGRectGetMinY(self.inviteCodeField.frame)+10,
20,
15)];
inviteCodeImageView.image = Image(@"login/inviteCodeIcon.png");
[self.keyboardView addSubview:inviteCodeImageView];
}
- (void)textFieldDidChange:(UITextField *)textField {
if (textField.tag == TEXTFIELDTAG) {
email = textField.text;
}else if (textField.tag == TEXTFIELDTAG+1) {
inviteCode = textField.text;
}
}
- (void)getInviteCode:(UIButton*)btn {
[self closeKeyBoard];
if (isBlankString(email)) {
ShowTextMessage(@"请输入邮箱地址");
return;
}
NSDictionary *dic = @{@"verType":@"2",@"mail":email};
[Remote doJsonActionWithBlock:0 requestUrl:getVerCodeURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) {
if (success) {
if ([responseData[@"resultCode"] intValue] == 1) {
ShowTextMessage(responseData[@"resultMsg"]);
}
}else {
ShowTextMessage(message);
}
}];
}
- (void)confirmEvent:(UIButton*)btn {
[self closeKeyBoard];
if (isBlankString(email)) {
ShowTextMessage(@"请输入邮箱地址");
return;
}
if (isBlankString(inviteCode)) {
ShowTextMessage(@"请输入验证码");
return;
}
NSDictionary *dic = @{@"verType":@"2",@"mail":email,@"verCode":inviteCode};
[Remote doJsonActionWithBlock:0 requestUrl:checkVerCodeURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) {
if (success) {
if ([responseData[@"resultCode"] intValue] == 1) {
userBO *user = [TPUserDefault instance].userBO;
user.mail= email;
userBO *oriUser = [TPUserDefault instance].userBO;
user.loginType = oriUser.loginType;
[TPUserDefault instance].userBO = user;
[(MLNavigationController*)self.navigationController popViewControllerWithFlip];
}
}else {
ShowTextMessage(message);
}
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#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
|