13
13
14
14
#import " SettingPasswordViewController.h"
15
15
#import " SettingPhoneViewController.h"
16
-
16
+ # import " Coding_NetAPIManager.h "
17
17
#import " Login.h"
18
18
19
19
@interface SettingAccountViewController ()
@@ -62,36 +62,43 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
62
62
}
63
63
64
64
- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
65
- NSInteger row = (section == 0 ? 2 : 1 );
65
+ NSInteger row = (section == 1 ? 2 : 1 );
66
66
return row;
67
67
}
68
68
69
69
- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
70
70
if (indexPath.section == 0 ) {
71
71
TitleValueCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TitleValue forIndexPath: indexPath];
72
-
73
- switch (indexPath.row ) {
74
- case 0 :
75
- [cell setTitleStr: @" 邮箱" valueStr: self .myUser.email];
76
- break ;
77
- default :
78
- [cell setTitleStr: @" 个性后缀" valueStr: self .myUser.global_key];
79
- break ;
80
- }
72
+ cell.selectionStyle = UITableViewCellSelectionStyleNone;
73
+ [cell setTitleStr: @" 个性后缀" valueStr: self .myUser.global_key];
81
74
[tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
82
75
return cell;
83
76
}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;
77
+ if (indexPath.row == 0 ) {
78
+ if (self.myUser .email_validation .boolValue || self.myUser .email .length <= 0 ) {
79
+ TitleValueCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TitleValue forIndexPath: indexPath];
80
+ cell.selectionStyle = UITableViewCellSelectionStyleNone;
81
+ [cell setTitleStr: @" 邮箱" valueStr: self .myUser.email ?: @" 未绑定" ];
82
+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
83
+ return cell;
84
+ }else {
85
+ TitleValueMoreCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TitleValueMore forIndexPath: indexPath];
86
+ [cell setTitleStr: @" 邮箱" valueStr: [NSString stringWithFormat: @" %@ (未验证)" ,self .myUser.email]];
87
+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
88
+ return cell;
89
+ }
90
+ }else {
91
+ TitleValueMoreCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TitleValueMore forIndexPath: indexPath];
92
+ [cell setTitleStr: @" 手机号码" valueStr: self .myUser.phone ?: @" 未绑定" ];
93
+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
94
+ return cell;
95
+ }
88
96
}else {
89
97
TitleDisclosureCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TitleDisclosure forIndexPath: indexPath];
90
98
[cell setTitleStr: @" 修改密码" ];
91
99
[tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
92
100
return cell;
93
101
}
94
-
95
102
}
96
103
- (UIView *)tableView : (UITableView *)tableView viewForHeaderInSection : (NSInteger )section {
97
104
UIView *headerView = [[UIView alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , 20 )];
@@ -110,15 +117,37 @@ - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSIntege
110
117
- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
111
118
[tableView deselectRowAtIndexPath: indexPath animated: YES ];
112
119
if (indexPath.section == 1 ) {
113
- SettingPhoneViewController *vc = [[SettingPhoneViewController alloc ] init ];
114
- [self .navigationController pushViewController: vc animated: YES ];
120
+ if (indexPath.row == 0 ) {
121
+ if (!self.myUser .email_validation .boolValue && self.myUser .email .length > 0 ) {
122
+ UIAlertView *alertView = [UIAlertView bk_alertViewWithTitle: @" 激活邮箱" message: @" 该邮箱尚未激活,请尽快去邮箱查收邮件并激活账号。如果在收件箱中没有看到,请留意一下垃圾邮件箱子(T_T)" ];
123
+ [alertView bk_setCancelButtonWithTitle: @" 取消" handler: nil ];
124
+ [alertView bk_addButtonWithTitle: @" 重发激活邮件" handler: nil ];
125
+ [alertView bk_setDidDismissBlock: ^(UIAlertView *alert, NSInteger index) {
126
+ if (index == 1 ) {
127
+ [self sendActivateEmail ];
128
+ }
129
+ }];
130
+ [alertView show ];
131
+ }
132
+ }else {
133
+ SettingPhoneViewController *vc = [[SettingPhoneViewController alloc ] init ];
134
+ [self .navigationController pushViewController: vc animated: YES ];
135
+ }
115
136
}else if (indexPath.section == 2 ){
116
137
SettingPasswordViewController *vc = [[SettingPasswordViewController alloc ] init ];
117
138
vc.myUser = self.myUser ;
118
139
[self .navigationController pushViewController: vc animated: YES ];
119
140
}
120
141
}
121
142
143
+ - (void )sendActivateEmail {
144
+ [[Coding_NetAPIManager sharedManager ] request_SendActivateEmail: self .myUser.email block: ^(id data, NSError *error) {
145
+ if (data) {
146
+ [NSObject showHudTipStr: @" 邮件已发送" ];
147
+ }
148
+ }];
149
+ }
150
+
122
151
- (void )dealloc
123
152
{
124
153
_myTableView.delegate = nil ;
0 commit comments