設置與幫助
修改頭像, 修改密碼, 移動客服, 幫助, 聲明, 關於我們.
代碼
//
// IndexSetting600ViewController.h
// SymptomChecker
//
// Created by wang on 2015-7-21.
//
//
#import CYTableViewController.h
@interface IndexSetting600ViewController : CYTableViewController
@end
//
// IndexSetting600ViewController.m
// SymptomChecker
//
// Created by wang on 2015-7-21.
//
//
#import IndexSetting600ViewController.h
#import UserCenter600Item.h
#import UserInfoEditingItem.h // 修改頭像
#import PortraitPickerViewController.h // 照片視圖
#import ModifyPasswordViewController.h // 修改密碼
#import LocalPasswordViewController.h
#import CYWebFromLocalViewController.h // 幫助/聲明
#import CYAboutUsViewController.h // 關於我們
#define kViewRadio viewWidth()/320
@interface IndexSetting600ViewController ()
@end
@implementation IndexSetting600ViewController {
UserFigureEditingItem *_figureItem; // 修改頭像
PortraitPickerViewController *_portraitPickerViewController; // 修改頭像視圖
Setting600Item *_changeSecret; // 修改登錄密碼
Setting600Item *_chunyuTel; // 移動客服
Setting600Item *_helpItem; // 幫助
Setting600Item *_shengMing; // 聲明
Setting600Item *_aboutUs; // 關於我們
Setting600SeparateItem *_separateItem; // 空白分割cell
FilledColorButton *_logoutButton; // 注銷按鈕
UIView *_logoutFooterView;
}
- (id) initWithQuery:(NSDictionary *)query {
self = [super initWithQuery: query];
if (self) {
self.title = @設置與幫助;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(createModel)
name:kRegisterLocalPassword
object:nil];
}
return self;
}
- (void) dealloc {
[[NSNotificationCenter defaultCenter] removeObserver: self];
}
- (void) viewDidLoad {
[super viewDidLoad];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self createTableItems]; // 確保item已經創建出來
}
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear: animated];
}
//
// 創建一次只需
//
- (void) createTableItems {
CY_DEFINE_SELF_BAR(self);
User* user = [User currentUser];
// 修改頭像
_figureItem = [[UserFigureEditingItem alloc] initWithTitle:@頭像 value:[user.matPhoto getMediaUrl]];
[self.tableViewActions attachToObject:_figureItem
tapBlock:^BOOL(id object, id target, NSIndexPath *indexPath) {
[_self editUserFigure];
return YES;
}];
// 修改登錄密碼
_changeSecret = [[Setting600Item alloc] initWithTitle: @修改登錄密碼];
_changeSecret.type = kSetting600Top;
[self.tableViewActions attachToObject: _changeSecret
tapBlock:^BOOL(id object, id target, NSIndexPath *indexPath) {
ModifyPasswordViewController *controller = [ModifyPasswordViewController new];
[_self cyPresentViewController:controller
animated:YES];
return NO;
}];
// 移動客服
_chunyuTel = [[Setting600Item alloc] initWithTitle: @移動客服];
_chunyuTel.type = kSetting600Middle;
[self.tableViewActions attachToObject: _chunyuTel
tapBlock: ^BOOL(id object, id target, NSIndexPath *indexPath) {
NSString* feedBackPhoneNumber = @4001100866;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: [NSString stringWithFormat: @tel://%@, feedBackPhoneNumber]]];
return YES;
}];
// 幫助
_helpItem = [[Setting600Item alloc] initWithTitle: @幫助];
_helpItem.type = kSetting600Middle;
[self.tableViewActions attachToObject: _helpItem
tapBlock: ^BOOL(id object, id target, NSIndexPath *indexPath) {
CYWebFromLocalViewController* controller = [[CYWebFromLocalViewController alloc] initWithQuery:@{@title : @幫助, @local_name : @help}];
[self.navigationController pushViewController:controller animated:YES];
return YES;
}];
// 聲明
_shengMing = [[Setting600Item alloc] initWithTitle: @聲明];
_shengMing.type = kSetting600Middle;
[self.tableViewActions attachToObject:_shengMing
tapBlock:^BOOL(id object, id target, NSIndexPath *indexPath) {
CYWebFromLocalViewController* controller = [[CYWebFromLocalViewController alloc] initWithQuery:@{@title : @聲明, @local_name : @statement}];
[self.navigationController pushViewController:controller animated:YES];
return YES;
}];
// 關於我們
_aboutUs = [[Setting600Item alloc] initWithTitle: @關於我們];
_aboutUs.type = kSetting600Bottom;
[self.tableViewActions attachToObject:_aboutUs
tapBlock:^BOOL(id object, id target, NSIndexPath *indexPath) {
CYAboutUsViewController* controller = [[CYAboutUsViewController alloc] initWithQuery:@{@title : @關於我們, @local_name : @about}];
[self.navigationController pushViewController:controller animated:YES];
return YES;
}];
// 分割
_separateItem = [[Setting600SeparateItem alloc] init];
// 底部視圖
_logoutFooterView = [UIView viewWithFrame:CGRectMake(0, 0, self.view.width, 92*kViewRadio)
andBkColor:[UIColor clearColor]];
self.tableView.tableFooterView = _logoutFooterView;
// 版本信息
UILabel *versionLabel = [UILabel labelWithFrame:CGRectMake(0, 8*kViewRadio, viewWidth(), 12*kViewRadio)
fontSize:11
fontColor:RGBCOLOR_HEX(0x522121)
text:[NSString stringWithFormat: @當前版本 :%@, @1.0.0]
];
[versionLabel setTextAlignment:NSTextAlignmentCenter];
[_logoutFooterView addSubview:versionLabel];
CGRect logoutRect = CGRectMake(16*kViewRadio,
versionLabel.bottom+16*kViewRadio,
viewWidth()-32*kViewRadio,
44*kViewRadio);
// 注銷按鈕
_logoutButton = [[FilledColorButton alloc] initWithFrame: logoutRect
color: RGBCOLOR_HEX(0xe85454)
highlightedColor: RGBCOLOR_HEX(0xa43939)
textColor: [UIColor whiteColor]
title: @注銷
fontSize: 16*kViewRadio
isBold: YES];
[_logoutButton addTarget: self
action: @selector(onLogOutBtnpressed:)
forControlEvents: UIControlEventTouchUpInside];
[_logoutFooterView addSubview:_logoutButton];
}
- (void)editUserFigure {
_portraitPickerViewController = [[PortraitPickerViewController alloc] initWithParent:self];
_portraitPickerViewController.delegate = self;
[_portraitPickerViewController showOptions];
}
- (void) createModel {
NSArray *dataItems;
if ([User hasLoggedIn]) {
dataItems = @[_separateItem,
_figureItem, // 修改頭像
_separateItem,
_changeSecret,// 修改登錄密碼
_chunyuTel, // 移動客服
_helpItem, // 幫助
_shengMing, // 聲明
_aboutUs, // 關於我們
_separateItem];
} else {
_logoutButton.hidden = YES;
_logoutFooterView.height = 40;
dataItems = @[_separateItem,
_chunyuTel, // 移動客服
_helpItem, // 幫助
_shengMing, // 聲明
_aboutUs, // 關於我們
_separateItem];
}
self.tableViewModel = [[NITableViewModel alloc] initWithListArray:dataItems
delegate:self.cellFactory];
}
#pragma mark - btn-selectors
// 點擊注銷
- (void) onLogOutBtnpressed:(UIButton*) sender {
NIDPRINTMETHODNAME();
// 登出
[[AutoLoginManager sharedInstance] logout];
// 更新當前的界面
[self createModel];
[self backToLastController: nil];
// 讓別的地方改變UI
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationUserLogout
object:nil];
// 獲取未登錄的badge
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationCheckBadge
object:nil];
}
@end
效果