Skip to content

Commit fe7d2ff

Browse files
committed
绑定手机号码
1 parent 4c4e177 commit fe7d2ff

File tree

12 files changed

+234
-32
lines changed

12 files changed

+234
-32
lines changed

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@
303303
4E72F8331B15B811001B6CE6 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E72F8321B15B811001B6CE6 /* [email protected] */; };
304304
4E743E6D1A88A3CC00DADDE5 /* EaseMarkdownTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E743E6C1A88A3CC00DADDE5 /* EaseMarkdownTextView.m */; };
305305
4E743E6F1A88ABF700DADDE5 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E743E6E1A88ABF700DADDE5 /* [email protected] */; };
306+
4E74EC011C311B6300EC0E1B /* SettingPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E74EC001C311B6300EC0E1B /* SettingPhoneViewController.m */; };
306307
4E753D441B8AFDEC003A00B9 /* FileEditViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E753D431B8AFDEC003A00B9 /* FileEditViewController.m */; };
307308
4E753D481B8DA099003A00B9 /* diff-ios.html in Resources */ = {isa = PBXBuildFile; fileRef = 4E753D471B8DA099003A00B9 /* diff-ios.html */; };
308309
4E76D4DE1A5A7B4A0094A35E /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E76D4DD1A5A7B4A0094A35E /* [email protected] */; };
@@ -1466,6 +1467,8 @@
14661467
4E743E6B1A88A3CC00DADDE5 /* EaseMarkdownTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EaseMarkdownTextView.h; sourceTree = "<group>"; };
14671468
4E743E6C1A88A3CC00DADDE5 /* EaseMarkdownTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EaseMarkdownTextView.m; sourceTree = "<group>"; };
14681469
4E743E6E1A88ABF700DADDE5 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
1470+
4E74EBFF1C311B6300EC0E1B /* SettingPhoneViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingPhoneViewController.h; sourceTree = "<group>"; };
1471+
4E74EC001C311B6300EC0E1B /* SettingPhoneViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingPhoneViewController.m; sourceTree = "<group>"; };
14691472
4E753D421B8AFDEC003A00B9 /* FileEditViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileEditViewController.h; sourceTree = "<group>"; };
14701473
4E753D431B8AFDEC003A00B9 /* FileEditViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FileEditViewController.m; sourceTree = "<group>"; };
14711474
4E753D471B8DA099003A00B9 /* diff-ios.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "diff-ios.html"; sourceTree = "<group>"; };
@@ -3802,6 +3805,8 @@
38023805
8E1C3E0119E8DFE300EF3032 /* SettingMineInfoViewController.m */,
38033806
8E1C3E0219E8DFE300EF3032 /* SettingPasswordViewController.h */,
38043807
8E1C3E0319E8DFE300EF3032 /* SettingPasswordViewController.m */,
3808+
4E74EBFF1C311B6300EC0E1B /* SettingPhoneViewController.h */,
3809+
4E74EC001C311B6300EC0E1B /* SettingPhoneViewController.m */,
38053810
8E1C3E0419E8DFE300EF3032 /* SettingViewController.h */,
38063811
8E1C3E0519E8DFE300EF3032 /* SettingViewController.m */,
38073812
8EF83F8819E92AA500E86DE7 /* SettingTagsViewController.h */,
@@ -5847,6 +5852,7 @@
58475852
8EA6D1AE19E240C40076D59C /* CodingTip.m in Sources */,
58485853
4E4D6A5E1B1C64C600FD2E49 /* PRDetailViewController.m in Sources */,
58495854
4E2719B81AB02F31006AE214 /* NProjectViewController.m in Sources */,
5855+
4E74EC011C311B6300EC0E1B /* SettingPhoneViewController.m in Sources */,
58505856
8EA6D1B719E240C40076D59C /* PrivateMessage.m in Sources */,
58515857
8EF643BE19FF7E2900F7EEB0 /* ProjectTaskListViewCell.m in Sources */,
58525858
4ECE8AE31A3943E80021E29C /* UIDevice+Info.m in Sources */,

Coding_iOS/Controllers/MeSetting/SettingAccountViewController.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
#import "User.h"
1212

1313
@interface SettingAccountViewController : BaseViewController<UITableViewDataSource, UITableViewDelegate>
14-
@property (strong, nonatomic) User *myUser;
1514

1615
@end

Coding_iOS/Controllers/MeSetting/SettingAccountViewController.m

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
#import "SettingAccountViewController.h"
1010
#import "TitleValueCell.h"
1111
#import "TitleDisclosureCell.h"
12+
#import "TitleValueMoreCell.h"
1213

1314
#import "SettingPasswordViewController.h"
15+
#import "SettingPhoneViewController.h"
16+
17+
#import "Login.h"
1418

1519
@interface SettingAccountViewController ()
16-
@property (strong, nonatomic) UITableView *myTableView;
20+
@property (strong, nonatomic) User *myUser;
1721

22+
@property (strong, nonatomic) UITableView *myTableView;
1823
@end
1924

2025
@implementation SettingAccountViewController
@@ -35,6 +40,7 @@ - (void)viewDidLoad
3540
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
3641
[tableView registerClass:[TitleValueCell class] forCellReuseIdentifier:kCellIdentifier_TitleValue];
3742
[tableView registerClass:[TitleDisclosureCell class] forCellReuseIdentifier:kCellIdentifier_TitleDisclosure];
43+
[tableView registerClass:[TitleValueMoreCell class] forCellReuseIdentifier:kCellIdentifier_TitleValueMore];
3844
[self.view addSubview:tableView];
3945
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
4046
make.edges.equalTo(self.view);
@@ -43,20 +49,20 @@ - (void)viewDidLoad
4349
});
4450
}
4551

46-
- (void)didReceiveMemoryWarning
47-
{
48-
[super didReceiveMemoryWarning];
49-
// Dispose of any resources that can be recreated.
52+
- (void)viewWillAppear:(BOOL)animated{
53+
[super viewWillAppear:animated];
54+
self.myUser = [Login curLoginUser];
55+
[self.myTableView reloadData];
5056
}
5157

5258
#pragma mark TableM
5359

5460
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
55-
return 2;
61+
return 3;
5662
}
5763

5864
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
59-
NSInteger row = section == 0? 2: 1;
65+
NSInteger row = (section == 0? 2: 1);
6066
return row;
6167
}
6268

@@ -74,6 +80,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
7480
}
7581
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
7682
return cell;
83+
}else if (indexPath.section == 1){
84+
TitleValueMoreCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleValueMore forIndexPath:indexPath];
85+
[cell setTitleStr:@"手机号码" valueStr:self.myUser.phone.length > 0? self.myUser.phone: @"未验证"];
86+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
87+
return cell;
7788
}else{
7889
TitleDisclosureCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleDisclosure forIndexPath:indexPath];
7990
[cell setTitleStr:@"修改密码"];
@@ -98,7 +109,10 @@ - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSIntege
98109

99110
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
100111
[tableView deselectRowAtIndexPath:indexPath animated:YES];
101-
if (indexPath.section != 0) {
112+
if (indexPath.section == 1) {
113+
SettingPhoneViewController *vc = [[SettingPhoneViewController alloc] init];
114+
[self.navigationController pushViewController:vc animated:YES];
115+
}else if (indexPath.section == 2){
102116
SettingPasswordViewController *vc = [[SettingPasswordViewController alloc] init];
103117
vc.myUser = self.myUser;
104118
[self.navigationController pushViewController:vc animated:YES];
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// SettingPhoneViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/12/28.
6+
// Copyright © 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "BaseViewController.h"
10+
#import "User.h"
11+
12+
@interface SettingPhoneViewController : BaseViewController
13+
14+
@end
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
//
2+
// SettingPhoneViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/12/28.
6+
// Copyright © 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "SettingPhoneViewController.h"
10+
#import "Input_OnlyText_Cell.h"
11+
#import "TPKeyboardAvoidingTableView.h"
12+
#import "Coding_NetAPIManager.h"
13+
#import "Login.h"
14+
15+
@interface SettingPhoneViewController ()<UITableViewDataSource, UITableViewDelegate>
16+
@property (strong, nonatomic) TPKeyboardAvoidingTableView *myTableView;
17+
@property (strong, nonatomic) NSString *phone, *code;
18+
@property (strong, nonatomic) NSString *phoneCodeCellIdentifier;
19+
20+
@end
21+
22+
@implementation SettingPhoneViewController
23+
24+
- (void)viewDidLoad {
25+
[super viewDidLoad];
26+
// Do any additional setup after loading the view.
27+
self.title = @"绑定手机号码";
28+
self.phone = [Login curLoginUser].phone;
29+
30+
// 添加myTableView
31+
self.phoneCodeCellIdentifier = [Input_OnlyText_Cell randomCellIdentifierOfPhoneCodeType];
32+
_myTableView = ({
33+
TPKeyboardAvoidingTableView *tableView = [[TPKeyboardAvoidingTableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
34+
tableView.backgroundColor = kColorTableSectionBg;
35+
tableView.dataSource = self;
36+
tableView.delegate = self;
37+
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
38+
[tableView registerClass:[Input_OnlyText_Cell class] forCellReuseIdentifier:kCellIdentifier_Input_OnlyText_Cell_Text];
39+
[tableView registerClass:[Input_OnlyText_Cell class] forCellReuseIdentifier:self.phoneCodeCellIdentifier];
40+
[self.view addSubview:tableView];
41+
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
42+
make.edges.equalTo(self.view);
43+
}];
44+
tableView;
45+
});
46+
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(doneBtnClicked:)];
47+
48+
}
49+
#pragma mark TableM
50+
51+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
52+
return 2;
53+
}
54+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
55+
Input_OnlyText_Cell *cell = [tableView dequeueReusableCellWithIdentifier:indexPath.row == 0? self.phoneCodeCellIdentifier: kCellIdentifier_Input_OnlyText_Cell_Text forIndexPath:indexPath];
56+
57+
__weak typeof(self) weakSelf = self;
58+
if (indexPath.row == 0) {
59+
cell.textField.keyboardType = UIKeyboardTypeNumberPad;
60+
[cell setPlaceholder:@" 手机号码" value:self.phone];
61+
cell.textValueChangedBlock = ^(NSString *valueStr){
62+
weakSelf.phone = valueStr;
63+
};
64+
cell.phoneCodeBtnClckedBlock = ^(PhoneCodeButton *btn){
65+
[weakSelf phoneCodeBtnClicked:btn];
66+
};
67+
}else{
68+
cell.textField.keyboardType = UIKeyboardTypeNumberPad;
69+
[cell setPlaceholder:@" 手机验证码" value:self.code];
70+
cell.textValueChangedBlock = ^(NSString *valueStr){
71+
weakSelf.code = valueStr;
72+
};
73+
}
74+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
75+
return cell;
76+
}
77+
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
78+
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 20)];
79+
headerView.backgroundColor = kColorTableSectionBg;
80+
return headerView;
81+
}
82+
83+
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
84+
return 20.0;
85+
}
86+
87+
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
88+
return 0.5;
89+
}
90+
91+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
92+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
93+
}
94+
95+
#pragma mark CodeBtn
96+
- (void)phoneCodeBtnClicked:(PhoneCodeButton *)sender{
97+
if (![_phone isPhoneNo]) {
98+
[NSObject showHudTipStr:@"手机号码格式有误"];
99+
return;
100+
}
101+
sender.enabled = NO;
102+
[[Coding_NetAPIManager sharedManager] request_GeneratePhoneCodeToResetPhone:_phone block:^(id data, NSError *error) {
103+
if (data) {
104+
[sender startUpTimer];
105+
}else{
106+
[sender invalidateTimer];
107+
}
108+
}];
109+
}
110+
111+
#pragma mark DoneBtn Clicked
112+
- (void)doneBtnClicked:(id)sender{
113+
NSString *tipStr;
114+
if (![_phone isPhoneNo]) {
115+
tipStr = @"手机号码格式有误";
116+
}else if (_code.length <= 0){
117+
tipStr = @"请填写手机验证码";
118+
}
119+
if (tipStr.length > 0) {
120+
[NSObject showHudTipStr:tipStr];
121+
return;
122+
}
123+
__weak typeof(self) weakSelf = self;
124+
[[Coding_NetAPIManager sharedManager] request_ResetPhone:_phone code:_code andBlock:^(id data, NSError *error) {
125+
weakSelf.navigationItem.rightBarButtonItem.enabled = YES;
126+
if (data) {
127+
[NSObject showHudTipStr:@"手机号码绑定成功"];
128+
[weakSelf.navigationController popViewControllerAnimated:YES];
129+
}
130+
}];
131+
}
132+
133+
@end

Coding_iOS/Controllers/MeSetting/SettingViewController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,13 @@ - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSIntege
109109
return 0.5;
110110
}
111111

112+
#pragma mark -
113+
112114
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
113115
[tableView deselectRowAtIndexPath:indexPath animated:YES];
114116
switch (indexPath.section) {
115117
case 0:{//账号设置
116118
SettingAccountViewController *vc = [[SettingAccountViewController alloc] init];
117-
vc.myUser = self.myUser;
118119
[self.navigationController pushViewController:vc animated:YES];
119120
}
120121
break;

0 commit comments

Comments
 (0)