IOS-member center page and logic
Member Center interface:
Different content is displayed based on the VIP status, and the button is set to jump to the payment page.
Code
/// MemberCenterViewController. h // SymptomChecker /// Created by C. l. wang on 15/7/9. //// *** the member center page is displayed according to the VIP status. * @ {link AutoLoginManager # queryUsableService} sets the VIP status */# 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 // payment page # import UserLoginViewController. h // login page # define kViewRatio viewWidth ()/320 // width unit @ interface MATMemberCenterViewController () @ end @ implementation MATMemberCenterViewController {UIImageView * _ memberStateIcon; // member status image UILabel * _ mem BerStateText; // member status text UILabel * _ serviceOfOwnership; // The owner service UILabel * _ noserviceOfOwnership; // The owner service UIView * _ infiniteTimesItem; // The health data UIView * _ selfExaminationItem; // self-check UIView * _ healthDataItem; // number of wireless requests FilledColorButton * _ processButton; // processing button BOOL _ needRefresh; // whether to refresh} // initialization class-(id) initWithNavigatorURL :( NSURL *) URL query :( NSDictionary *) query {self = [super initWithNavigatorURL: URL que Ry: query]; if (self) {[self resetData];} return self;} // reset data-(void) resetData {_ needRefresh = YES ;} // page initialization-(void) viewDidLoad {[super viewDidLoad]; self. title = @ member center;} // The page displays-(void) viewWillAppear :( BOOL) animated {[super viewWillAppear: animated]; if (_ needRefresh & [User hasLoggedIn]) {_ needRefresh = NO; NSMutableDictionary * access = [[NSMutableDictionary alloc] init]; if ([User curre NtUser] matIsVip] = 1) {// VIP [access setObject: @ icon_mat_isvip forKey: @ memberStateIcon]; [access setObject: @ subscribed membership service forKey: @ memberStateText]; [access setObject: @ 1 forKey: @ noserviceOfOwnership]; [access setObject: @ icon_mat_checked forKey: @ infiniteTimesItem]; [access setObject: @ forKey: @ processButton];} else {// non-VIP [access setObject: @ icon_mat_notvip forKey: @ memberStateIcon]; [access se TObject: @ forKey: @ memberStateText]; [access setObject: @ 0 forKey: @ noserviceOfOwnership]; [access setObject: @ icon_mat_notcheck forKey: @ infiniteTimesItem]; [access setObject: @ activate now forKey: @ processButton];} [self createModelWithDict: access] ;}/ *** create interface, different VIP pages ** @ param access whether VIP */-(void) createModelWithDict :( NSMutableDictionary *) access {[self. view setBackgroundColor: [UIColor white Color]; // member status icon _ memberStateIcon = [CYResource loadImageView: access [@ memberStateIcon] andFrame: CGRectMake (viewWidth ()/2-36 * kViewRatio, 36 * kViewRatio, 72 * kViewRatio, 72 * kViewRatio)]; [self. view addSubview: _ memberStateIcon]; // member status text _ 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]; // service title _ serviceOfOwnership = [UILabel labelWithFrame: CGRectMake (12 * kViewRatio, _ memberStateText. bottom, viewWidth (), 48 * kViewRatio) fontSize: 18 * kViewRatio fontColor: [UIColor blackColor] text: @ Already available services]; [_ ServiceOfOwnership setAdjustsFontSizeToFitWidth: YES]; [_ serviceOfOwnership setTextAlignment: NSTextAlignmentLeft]; [self. view addSubview: _ serviceOfOwnership]; // health tool Item _ healthDataItem = [[UIView alloc] initWithFrame: CGRectMake (12 * kViewRatio, _ serviceOfOwnership. bottom, viewWidth (), 32 * kViewRatio)]; [self. view addSubview: [self viewOfCombinationWithView: _ healthDataItem image: @ icon_mat_checked text :@ Health data tracking record]; // self-check item _ selfExaminationItem = [[UIView alloc] initWithFrame: CGRectMake (12 * kViewRatio, _ healthDataItem. bottom, viewWidth (), 32 * kViewRatio)]; [self. view addSubview: [self check: _ selfExaminationItem image: @ icon_mat_checked text: @ Comprehensive Analysis of self check]; // unserved title 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 )? @ Activate the service: @]; [_ noserviceOfOwnership setAdjustsFontSizeToFitWidth: YES]; [_ noserviceOfOwnership setTextAlignment: NSTextAlignmentLeft]; [self. view addSubview: _ noserviceOfOwnership]; // number of wireless items _ infiniteTimesItem = [[UIView alloc] initWithFrame: CGRectMake (12 * kViewRatio, _ noserviceOfOwnership. bottom, viewWidth (), 32 * kViewRatio)]; [self. view addSubview: [self viewOfCombinationWithView: _ infiniteTimesItem ima Ge: access [@ infiniteTimesItem] text: @ unlimited number of online queries]; // processing button _ 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];} /*** left image and right text combination control ** @ param view parent control * @ param imageName local path of the image * @ param text ** @ return combination control */-( UIView *) viewOfCombinationWithView :( UIView *) view image :( NSString *) imageName text :( NSString *) text {// image view UIImageView * iv = [CYResource loadImageView: imageName andFrame: CGRectMake (0, 0, 0, 16 * kViewRatio, 16 * kViewRatio)]; [iv setContentMode: UIViewContentModeScaleToFill]; // Text view [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 ;}// click the event-(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 didreceivemorywarning]; // Dispose of any resources that can be recreated .} @ end
Member Center page