BindingTelAndThirdpartyViewController.m 4.46 KB
//
//  BindingTelAndThirdpartyViewController.m
//  IVTMeLiveTwo
//
//  Created by XRG on 16/8/23.
//  Copyright © 2016年 QLQ. All rights reserved.
//

#import "BindingTelAndThirdpartyViewController.h"
#import "BindingTelAndThirdpartyTableViewCell.h"

@interface BindingTelAndThirdpartyViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView *myTableView;
    UILabel *accountText;
    UILabel *accountNumber;
}
@end

@implementation BindingTelAndThirdpartyViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setNavigationBar];
    
    __weak __typeof(self)weakSelf = self;
    myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 5, kScreenWidth, 64) style:UITableViewStyleGrouped];
    myTableView.delegate = self;
    myTableView.dataSource = self;
    myTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    [self.view addSubview:myTableView];
    [myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.view.mas_left);
        make.top.equalTo(weakSelf.view.mas_top);
        make.right.equalTo(weakSelf.view.mas_right);
        make.bottom.equalTo(weakSelf.view.mas_bottom);
    }];
    
    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 50)];
    headView.backgroundColor = [UIColor whiteColor];
    myTableView.tableHeaderView = headView;
    
    accountText = [[UILabel alloc] initWithFrame:CGRectMake(16, 10, 60, 30)];
    accountText.text = @"手机号";
    accountText.textColor = [UIColor IVTMainTextColor];
    accountText.font = [UIFont IVTH3Font];
    accountText.textAlignment = 1;
    [headView addSubview:accountText];
    
    
    accountNumber = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - 110, 10, 100, 30)];
    accountNumber.text = [IVTAccountTool getUserName];
    accountNumber.textColor = [UIColor IVTMainTextColor];
    accountNumber.font = [UIFont IVTH3Font];
    accountNumber.textAlignment = 1;
    [headView addSubview:accountNumber];
}

- (void)setNavigationBar{
    self.navigationItem.title = @"绑定";
}
#pragma mark - UITableViewDelegate / UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return  36.0f;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    BindingTelAndThirdpartyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[BindingTelAndThirdpartyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    if (indexPath.row == 0) {
        cell.titleString = @"微信";
        if ([IVTAccountTool getWeChatIsBinding]) {
            cell.headerImageName = @"微信登录";
            cell.isBinding = YES;
        }
        else{
            cell.headerImageName = @"微信-未绑定";
            cell.isBinding = NO;
        }
    }
    else if (indexPath.row == 1){
        cell.titleString = @"QQ";
        if ([IVTAccountTool getQQIsBinding]) {
            cell.headerImageName = @"qq登录";
            cell.isBinding = YES;
        }
        else{
            cell.headerImageName = @"qq-未绑定";
            cell.isBinding = NO;
        }
    }
    else if (indexPath.row == 2){
        cell.titleString = @"微博";
        if ([IVTAccountTool getSinaIsBinding]) {
            cell.headerImageName = @"新浪登录";
            cell.isBinding = YES;
        }
        else{
            cell.headerImageName = @"新浪未绑定";
            cell.isBinding = NO;
        }
    }
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end