1313
1414#import " SettingPasswordViewController.h"
1515#import " SettingPhoneViewController.h"
16-
16+ # import " Coding_NetAPIManager.h "
1717#import " Login.h"
1818
1919@interface SettingAccountViewController ()
@@ -62,36 +62,43 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
6262}
6363
6464- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
65- NSInteger row = (section == 0 ? 2 : 1 );
65+ NSInteger row = (section == 1 ? 2 : 1 );
6666 return row;
6767}
6868
6969- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
7070 if (indexPath.section == 0 ) {
7171 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];
8174 [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
8275 return cell;
8376 }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+ }
8896 }else {
8997 TitleDisclosureCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TitleDisclosure forIndexPath: indexPath];
9098 [cell setTitleStr: @" 修改密码" ];
9199 [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
92100 return cell;
93101 }
94-
95102}
96103- (UIView *)tableView : (UITableView *)tableView viewForHeaderInSection : (NSInteger )section {
97104 UIView *headerView = [[UIView alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , 20 )];
@@ -110,15 +117,37 @@ - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSIntege
110117- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
111118 [tableView deselectRowAtIndexPath: indexPath animated: YES ];
112119 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+ }
115136 }else if (indexPath.section == 2 ){
116137 SettingPasswordViewController *vc = [[SettingPasswordViewController alloc ] init ];
117138 vc.myUser = self.myUser ;
118139 [self .navigationController pushViewController: vc animated: YES ];
119140 }
120141}
121142
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+
122151- (void )dealloc
123152{
124153 _myTableView.delegate = nil ;
0 commit comments