Skip to content

Commit d008a08

Browse files
committed
设置邮箱
1 parent 5ce0049 commit d008a08

File tree

4 files changed

+182
-12
lines changed

4 files changed

+182
-12
lines changed

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@
377377
4E76D4DE1A5A7B4A0094A35E /* text_clear_btn@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E76D4DD1A5A7B4A0094A35E /* text_clear_btn@2x.png */; };
378378
4E787DE21B0329B300F06E83 /* ProjectLineNote.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E787DE11B0329B300F06E83 /* ProjectLineNote.m */; };
379379
4E787DE51B03342000F06E83 /* ProjectActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E787DE41B03342000F06E83 /* ProjectActivity.m */; };
380+
4E83AE7B1CF30F1A006BA3BB /* SettingEmailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E83AE7A1CF30F1A006BA3BB /* SettingEmailViewController.m */; };
380381
4E86FEE51BB556D6005E53F3 /* tipIcon_ProjectFileComment@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E86FEE41BB556D6005E53F3 /* tipIcon_ProjectFileComment@2x.png */; };
381382
4E8765651A22E5B40090CFB9 /* NSMutableArray+SWUtilityButtons.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E87655A1A22E5B40090CFB9 /* NSMutableArray+SWUtilityButtons.m */; };
382383
4E8765661A22E5B40090CFB9 /* SWCellScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E87655C1A22E5B40090CFB9 /* SWCellScrollView.m */; };
@@ -1673,6 +1674,8 @@
16731674
4E787DE11B0329B300F06E83 /* ProjectLineNote.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectLineNote.m; sourceTree = "<group>"; };
16741675
4E787DE31B03342000F06E83 /* ProjectActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectActivity.h; sourceTree = "<group>"; };
16751676
4E787DE41B03342000F06E83 /* ProjectActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectActivity.m; sourceTree = "<group>"; };
1677+
4E83AE791CF30F1A006BA3BB /* SettingEmailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingEmailViewController.h; sourceTree = "<group>"; };
1678+
4E83AE7A1CF30F1A006BA3BB /* SettingEmailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingEmailViewController.m; sourceTree = "<group>"; };
16761679
4E86FEE41BB556D6005E53F3 /* tipIcon_ProjectFileComment@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_ProjectFileComment@2x.png"; sourceTree = "<group>"; };
16771680
4E8765591A22E5B40090CFB9 /* NSMutableArray+SWUtilityButtons.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+SWUtilityButtons.h"; sourceTree = "<group>"; };
16781681
4E87655A1A22E5B40090CFB9 /* NSMutableArray+SWUtilityButtons.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableArray+SWUtilityButtons.m"; sourceTree = "<group>"; };
@@ -4238,6 +4241,8 @@
42384241
8E1C3E0319E8DFE300EF3032 /* SettingPasswordViewController.m */,
42394242
4E74EBFF1C311B6300EC0E1B /* SettingPhoneViewController.h */,
42404243
4E74EC001C311B6300EC0E1B /* SettingPhoneViewController.m */,
4244+
4E83AE791CF30F1A006BA3BB /* SettingEmailViewController.h */,
4245+
4E83AE7A1CF30F1A006BA3BB /* SettingEmailViewController.m */,
42414246
8E1C3E0419E8DFE300EF3032 /* SettingViewController.h */,
42424247
8E1C3E0519E8DFE300EF3032 /* SettingViewController.m */,
42434248
8EF83F8819E92AA500E86DE7 /* SettingTagsViewController.h */,
@@ -6348,6 +6353,7 @@
63486353
8E59F1001A01133C009A905F /* CodeTree.m in Sources */,
63496354
4E93F2331B84243D00017916 /* KxMenu.m in Sources */,
63506355
D0C447B91C02C63000DC1C4B /* UserSearchCell.m in Sources */,
6356+
4E83AE7B1CF30F1A006BA3BB /* SettingEmailViewController.m in Sources */,
63516357
8EF643BA19FF7E2900F7EEB0 /* MemberCell.m in Sources */,
63526358
4ECE8B021A3946C10021E29C /* JobManager.m in Sources */,
63536359
4E0BD8561B6C7DFD0061CAA6 /* UIView+Frame.m in Sources */,

Coding_iOS/Controllers/MeSetting/SettingAccountViewController.m

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#import "Coding_NetAPIManager.h"
1717
#import "Login.h"
1818
#import "Close2FAViewController.h"
19+
#import "SettingEmailViewController.h"
1920

2021
@interface SettingAccountViewController ()
2122
@property (strong, nonatomic) User *myUser;
@@ -87,18 +88,27 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
8788
return cell;
8889
}else if (indexPath.section == 1){
8990
if (indexPath.row == 0) {
90-
if (self.myUser.email_validation.boolValue || self.myUser.email.length <= 0) {
91-
TitleValueCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleValue forIndexPath:indexPath];
92-
cell.selectionStyle = UITableViewCellSelectionStyleNone;
93-
[cell setTitleStr:@"邮箱" valueStr:self.myUser.email.length > 0 ? self.myUser.email: @"未绑定"];
94-
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
95-
return cell;
96-
}else{
97-
TitleValueMoreCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleValueMore forIndexPath:indexPath];
98-
[cell setTitleStr:@"邮箱" valueStr:[NSString stringWithFormat:@"%@ 未验证",self.myUser.email]];
99-
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
100-
return cell;
101-
}
91+
92+
TitleValueMoreCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleValueMore forIndexPath:indexPath];
93+
94+
NSString *valueStr = (self.myUser.email.length <= 0? @"未绑定":
95+
self.myUser.email_validation.boolValue? self.myUser.email:
96+
[NSString stringWithFormat:@"%@ 未验证",self.myUser.email]);
97+
[cell setTitleStr:@"邮箱" valueStr:valueStr];
98+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
99+
return cell;
100+
// if (self.myUser.email_validation.boolValue || self.myUser.email.length <= 0) {
101+
// TitleValueCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleValue forIndexPath:indexPath];
102+
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
103+
// [cell setTitleStr:@"邮箱" valueStr:self.myUser.email.length > 0 ? self.myUser.email: @"未绑定"];
104+
// [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
105+
// return cell;
106+
// }else{
107+
// TitleValueMoreCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleValueMore forIndexPath:indexPath];
108+
// [cell setTitleStr:@"邮箱" valueStr:[NSString stringWithFormat:@"%@ 未验证",self.myUser.email]];
109+
// [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
110+
// return cell;
111+
// }
102112
}else{
103113
TitleValueMoreCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleValueMore forIndexPath:indexPath];
104114
[cell setTitleStr:@"手机号码" valueStr:self.myUser.phone.length > 0 ? self.myUser.phone: @"未绑定"];
@@ -140,6 +150,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
140150
}
141151
}];
142152
[alertView show];
153+
}else{
154+
SettingEmailViewController *vc = [SettingEmailViewController new];
155+
[self.navigationController pushViewController:vc animated:YES];
143156
}
144157
}else{
145158
SettingPhoneViewController *vc = [[SettingPhoneViewController alloc] init];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// SettingEmailViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 16/5/23.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "BaseViewController.h"
10+
11+
@interface SettingEmailViewController : BaseViewController
12+
13+
@end
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
//
2+
// SettingEmailViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 16/5/23.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "SettingEmailViewController.h"
10+
#import "Input_OnlyText_Cell.h"
11+
#import "TPKeyboardAvoidingTableView.h"
12+
#import "Coding_NetAPIManager.h"
13+
#import "Login.h"
14+
15+
@interface SettingEmailViewController ()<UITableViewDataSource, UITableViewDelegate>
16+
@property (strong, nonatomic) TPKeyboardAvoidingTableView *myTableView;
17+
@property (assign, nonatomic) BOOL is2FAOpen;
18+
@property (strong, nonatomic) NSString *email, *j_captcha, *two_factor_code;
19+
@end
20+
21+
@implementation SettingEmailViewController
22+
23+
- (void)viewDidLoad{
24+
[super viewDidLoad];
25+
self.title = @"绑定邮箱";
26+
self.email = [Login curLoginUser].email;
27+
_myTableView = ({
28+
TPKeyboardAvoidingTableView *tableView = [[TPKeyboardAvoidingTableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
29+
tableView.backgroundColor = kColorTableSectionBg;
30+
tableView.dataSource = self;
31+
tableView.delegate = self;
32+
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
33+
[tableView registerClass:[Input_OnlyText_Cell class] forCellReuseIdentifier:kCellIdentifier_Input_OnlyText_Cell_Text];
34+
[tableView registerClass:[Input_OnlyText_Cell class] forCellReuseIdentifier:kCellIdentifier_Input_OnlyText_Cell_Captcha];
35+
[tableView registerClass:[Input_OnlyText_Cell class] forCellReuseIdentifier:kCellIdentifier_Input_OnlyText_Cell_Password];
36+
[self.view addSubview:tableView];
37+
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
38+
make.edges.equalTo(self.view);
39+
}];
40+
tableView;
41+
});
42+
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(doneBtnClicked:)];
43+
}
44+
45+
- (void)viewWillAppear:(BOOL)animated{
46+
[super viewWillAppear:animated];
47+
[self refresh2FA];
48+
}
49+
50+
- (void)refresh2FA{
51+
__weak typeof(self) weakSelf = self;
52+
[[Coding_NetAPIManager sharedManager] get_is2FAOpenBlock:^(BOOL data, NSError *error) {
53+
if (!error) {
54+
weakSelf.is2FAOpen = data;
55+
[weakSelf.myTableView reloadData];
56+
}
57+
}];
58+
}
59+
60+
#pragma mark TableM
61+
62+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
63+
return 3;
64+
}
65+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
66+
NSString *identifier = (indexPath.row == 0? kCellIdentifier_Input_OnlyText_Cell_Text:
67+
indexPath.row == 1? (!_is2FAOpen? kCellIdentifier_Input_OnlyText_Cell_Password:
68+
kCellIdentifier_Input_OnlyText_Cell_Text):
69+
kCellIdentifier_Input_OnlyText_Cell_Captcha);
70+
Input_OnlyText_Cell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
71+
72+
__weak typeof(self) weakSelf = self;
73+
if (indexPath.row == 0) {
74+
cell.textField.keyboardType = UIKeyboardTypeEmailAddress;
75+
[cell setPlaceholder:@" 邮箱" value:self.email];
76+
cell.textValueChangedBlock = ^(NSString *valueStr){
77+
weakSelf.email = valueStr;
78+
};
79+
}else if (indexPath.row == 1){
80+
[cell setPlaceholder:!_is2FAOpen? @" 输入密码": @" 输入两步验证码" value:_two_factor_code];
81+
cell.textValueChangedBlock = ^(NSString *valueStr){
82+
weakSelf.two_factor_code = valueStr;
83+
};
84+
}else{
85+
[cell setPlaceholder:@" 验证码" value:self.j_captcha];
86+
cell.textValueChangedBlock = ^(NSString *valueStr){
87+
weakSelf.j_captcha = valueStr;
88+
};
89+
}
90+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
91+
return cell;
92+
}
93+
94+
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
95+
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 20)];
96+
headerView.backgroundColor = kColorTableSectionBg;
97+
return headerView;
98+
}
99+
100+
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
101+
return 20.0;
102+
}
103+
104+
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
105+
return 0.5;
106+
}
107+
108+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
109+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
110+
}
111+
112+
#pragma mark DoneBtn Clicked
113+
- (void)doneBtnClicked:(id)sender{
114+
NSString *tipStr;
115+
if (![_email isEmail]) {
116+
tipStr = @"邮箱格式有误";
117+
}else if (_two_factor_code.length <= 0){
118+
tipStr = !_is2FAOpen? @"请填写密码": @"请填写两步验证码";
119+
}else if (_j_captcha.length <= 0){
120+
tipStr = @"请填写验证码";
121+
}
122+
if (tipStr.length > 0) {
123+
[NSObject showHudTipStr:tipStr];
124+
return;
125+
}
126+
NSDictionary *params = @{@"email": _email,
127+
@"j_captcha": _j_captcha,
128+
@"two_factor_code": !_is2FAOpen? [_two_factor_code sha1Str]: _two_factor_code};
129+
__weak typeof(self) weakSelf = self;
130+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:@"api/account/email/change/send" withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
131+
if (data) {
132+
[NSObject showHudTipStr:@"发送验证邮件成功"];
133+
[weakSelf.navigationController popViewControllerAnimated:YES];
134+
}
135+
}];
136+
}
137+
138+
@end

0 commit comments

Comments
 (0)