IOS - 測試人員中樞頁面和邏輯

來源:互聯網
上載者:User

IOS - 測試人員中樞頁面和邏輯

測試人員中樞介面:
根據VIP狀態的不同, 顯示不同內容, 並設定按鈕跳轉支付頁面.

代碼

////  MemberCenterViewController.h//  SymptomChecker////  Created by C.L.Wang on 15/7/9./////** * 測試人員中樞頁面, 根據VIP狀態顯示不同. * @{link AutoLoginManager#queryUsableService}設定VIP狀態 */#import CYModelViewController.h@interface MATMemberCenterViewController : CYModelViewController@end
////  MemberCenterViewController.m//  SymptomChecker////  Created by C.L.Wang on 15/7/9.////#import MATMemberCenterViewController.h#import VIPAlipayViewController.h // 支付頁面#import UserLoginViewController.h // 登入頁面#define kViewRatio viewWidth()/320 // 寬度單位@interface MATMemberCenterViewController ()@end@implementation MATMemberCenterViewController {    UIImageView *_memberStateIcon; // 會員狀態圖片    UILabel *_memberStateText; // 會員狀態文字    UILabel *_serviceOfOwnership; // 擁有服務    UILabel *_noserviceOfOwnership; // 未擁有服務    UIView *_infiniteTimesItem; // 健康資料    UIView *_selfExaminationItem; // 自我檢查    UIView *_healthDataItem; // 無線次數    FilledColorButton *_processButton; // 處理按鈕    BOOL _needRefresh; // 是否重新整理}// 初始化類- (id) initWithNavigatorURL:(NSURL *)URL query:(NSDictionary *)query {    self = [super initWithNavigatorURL:URL query:query];    if (self) {        [self resetData];    }    return self;}// 重設資料- (void) resetData {    _needRefresh = YES;}// 頁面初始化- (void)viewDidLoad {    [super viewDidLoad];    self.title = @測試人員中樞;}// 頁面顯示- (void) viewWillAppear:(BOOL)animated {    [super viewWillAppear: animated];    if (_needRefresh && [User hasLoggedIn]) {        _needRefresh = NO;        NSMutableDictionary* access = [[NSMutableDictionary alloc] init];        if ([[User currentUser] matIsVip] == 1) { // VIP            [access setObject:@icon_mat_isvip forKey:@memberStateIcon];            [access setObject:@已開通會員包月服務 forKey:@memberStateText];            [access setObject:@1 forKey:@noserviceOfOwnership];            [access setObject:@icon_mat_checked forKey:@infiniteTimesItem];            [access setObject:@立即續約 forKey:@processButton];        } else { // 非VIP            [access setObject:@icon_mat_notvip forKey:@memberStateIcon];            [access setObject:@暫未開通會員優惠 forKey:@memberStateText];            [access setObject:@0 forKey:@noserviceOfOwnership];            [access setObject:@icon_mat_notcheck forKey:@infiniteTimesItem];            [access setObject:@立即開通 forKey:@processButton];        }        [self createModelWithDict:access];    }}/** *  建立介面, VIP不同頁面不同 * *  @param access 是否VIP */- (void) createModelWithDict:(NSMutableDictionary*)access {    [self.view setBackgroundColor:[UIColor whiteColor]];    // 會員狀態表徵圖    _memberStateIcon = [CYResource loadImageView:access[@memberStateIcon]                                        andFrame:CGRectMake(viewWidth()/2-36*kViewRatio, 36*kViewRatio, 72*kViewRatio, 72*kViewRatio)];    [self.view addSubview:_memberStateIcon];    // 會員狀態文字    _memberStateText = [UILabel labelWithFrame:CGRectMake(0, _memberStateIcon.bottom+8*kViewRatio, viewWidth(), 36*kViewRatio)                                      fontSize:20*kViewRatio                                     fontColor:[UIColor blackColor]                                          text:access[@memberStateText]];    [_memberStateText setAdjustsFontSizeToFitWidth:YES];    [_memberStateText setTextAlignment:NSTextAlignmentCenter];    [self.view addSubview:_memberStateText];    // 服務標題    _serviceOfOwnership = [UILabel labelWithFrame:CGRectMake(12*kViewRatio, _memberStateText.bottom, viewWidth(), 48*kViewRatio)                                         fontSize:18*kViewRatio                                        fontColor:[UIColor blackColor]                                             text:@已享有服務];    [_serviceOfOwnership setAdjustsFontSizeToFitWidth:YES];    [_serviceOfOwnership setTextAlignment:NSTextAlignmentLeft];    [self.view addSubview:_serviceOfOwnership];    // 健康工具項    _healthDataItem = [[UIView alloc] initWithFrame:CGRectMake(12*kViewRatio, _serviceOfOwnership.bottom, viewWidth(), 32*kViewRatio)];    [self.view addSubview:[self viewOfCombinationWithView:_healthDataItem image:@icon_mat_checked text:@健康資料追蹤記錄]];    // 自我檢查項    _selfExaminationItem = [[UIView alloc] initWithFrame:CGRectMake(12*kViewRatio, _healthDataItem.bottom, viewWidth(), 32*kViewRatio)];    [self.view addSubview:[self viewOfCombinationWithView:_selfExaminationItem image:@icon_mat_checked text:@自我檢查全面分析]];    // 未服務標題    CGRect cr = CGRectMake(12*kViewRatio, _selfExaminationItem.bottom, viewWidth(), ([access[@noserviceOfOwnership] intValue]==0)?48*kViewRatio:0);    _noserviceOfOwnership = [UILabel labelWithFrame:cr                                           fontSize:18*kViewRatio                                          fontColor:[UIColor blackColor]                                               text:([access[@noserviceOfOwnership] intValue]==0)?@開通可享有服務:@];    [_noserviceOfOwnership setAdjustsFontSizeToFitWidth:YES];    [_noserviceOfOwnership setTextAlignment:NSTextAlignmentLeft];    [self.view addSubview:_noserviceOfOwnership];    // 無線次數項    _infiniteTimesItem = [[UIView alloc] initWithFrame:CGRectMake(12*kViewRatio, _noserviceOfOwnership.bottom, viewWidth(), 32*kViewRatio)];    [self.view addSubview:[self viewOfCombinationWithView:_infiniteTimesItem image:access[@infiniteTimesItem] text:@線上問診不限次數]];    // 處理按鈕    _processButton = [[FilledColorButton alloc] initWithFrame:CGRectMake(12*kViewRatio, _infiniteTimesItem.bottom, viewWidth()-24*kViewRatio, 40*kViewRatio)                                                         type:kFilledBtnGreen                                                        title:access[@processButton]];    [_processButton addTarget: self                       action: @selector(onSubmitBtnPressedAfterLogin:)             forControlEvents: UIControlEventTouchUpInside];    [self.view addSubview:_processButton];}/** *  左圖片和右文字群組控制項 * *  @param view      父控制項 *  @param imageName 圖片本地路徑 *  @param text      文字 * *  @return 群組控制項 */- (UIView*) viewOfCombinationWithView:(UIView*)view image:(NSString*)imageName text:(NSString*)text {    // 圖片視圖    UIImageView* iv = [CYResource loadImageView:imageName                                       andFrame:CGRectMake(0, 0, 16*kViewRatio, 16*kViewRatio)];    [iv setContentMode:UIViewContentModeScaleToFill];    // 文字視圖    [view addSubview:iv];    UILabel* tv = [UILabel labelWithFrame:CGRectMake(32*kViewRatio, 0, viewWidth(), 16*kViewRatio)                                 fontSize:16*kViewRatio                                fontColor:[UIColor grayColor]                                     text:text];    [view addSubview:tv];    return view;}// 按鈕點擊事件- (void) onSubmitBtnPressedAfterLogin:(UIButton*) sender {    NIDPRINTMETHODNAME();    if (![User hasLoggedIn]) {        _needRefresh = YES;        UserLoginViewController *controller = [UserLoginViewController new];        [self cyPresentModalViewController:controller animated:YES];    } else {        NSDictionary *fakeData = @{@source: @vip,                                   @problem_id: ENSURE_NOT_NULL(@1234),                                   @ignore_tel: @(YES)};        VIPAlipayViewController* controller =        [[VIPAlipayViewController alloc]initWithNavigatorURL:nil                                                       query:fakeData];        [self.navigationController pushViewController:controller animated:YES];    }}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}@end

測試人員中樞頁面

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.