// // HSQMinePersonInforVC.m // YouHuiProject // // Created by liuxueli on 2018/11/20. // Copyright © 2018 kuxuan. All rights reserved. // #import "HSQMinePersonInforVC.h" #import #import"HSQCacheHttp.h" #import "HSQUserInfo.h" #import "AccountTool.h" #import "HSQMySuperViewController.h" #import "HSQMyWechatViewController.h" #import "HSQLinkAliPayViewController.h" @interface HSQMinePersonInforVC () @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) NSArray *dataArr; @property(nonatomic,strong)NSDictionary *dataDic; @property (nonatomic, strong) NSDictionary *userInfo; @property(nonatomic,strong)NSDictionary *weChatDict; @end @implementation HSQMinePersonInforVC - (void)viewDidLoad { [super viewDidLoad]; [self configNavigationBar]; } -(void)viewWillAppear:(BOOL)animated { [self loadUserInfo]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } /** 加载用户信息 */ - (void)loadUserInfo { [HSQCacheHttp post:NewUserInfo params:nil success:^(id json, BOOL isCache) { self.userInfo =[NSDictionary dictionaryWithDictionary:json[@"data"]]; [self.tableView reloadData]; } failure:^(NSError *error) { }]; } - (void)configNavigationBar { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; self.view.backgroundColor = [UIColor whiteColor]; [self.navigationBar setNavTitle:@"个人信息"]; self.navigationBar.showNavigationBarBottomLine = YES; [self.view addSubview:self.tableView]; self.navigationBar.backgroundColor = [UIColor changeColor]; self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor]; UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal]; [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; [self.navigationBar setCustomLeftButtons:@[leftBtn]]; } /** 返回 */ - (void)backAction { [self.navigationController popViewControllerAnimated:YES]; } - (UITableView *)tableView { if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain]; _tableView.estimatedSectionHeaderHeight = 0; _tableView.estimatedSectionFooterHeight = 0; _tableView.sectionFooterHeight = 0; _tableView.sectionHeaderHeight = 0; _tableView.delegate = self; _tableView.dataSource = self; _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; _tableView.backgroundColor = [UIColor yhGrayColor]; _tableView.bounces = YES; _tableView.showsVerticalScrollIndicator = NO; [_tableView setSeparatorColor:[UIColor YHColorWithHex:0xdddddd]]; } return _tableView; } -(NSDictionary *)dataDic { if (!_dataDic) { _dataDic=@{@"0":@[@{@"title":@"我的头像"}, @{@"title":@"我的昵称"}],@"1":@[@{@"title":@"我的邀请码"},@{@"title":@"我的上级"}]}; } return _dataDic; } #pragma mark ------------------ - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { [cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)]; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSArray *array =self.dataDic[self.dataDic.allKeys[section]]; return array.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0 && indexPath.row == 0) { return 60; } return 50; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return FITSIZE(5); } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.dataDic.allKeys.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"]; if ((indexPath.row == 1 && indexPath.section == 1) || (indexPath.section == 2 && indexPath.row ==2) || (indexPath.row == 1 && indexPath.section == 2)) { cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } NSArray *array =self.dataDic[self.dataDic.allKeys[indexPath.section]]; cell.textLabel.font = [UIFont systemFontOfSize:15]; cell.textLabel.text = array[indexPath.row][@"title"]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.textLabel.textColor = [UIColor YHColorWithHex:0x666666]; cell.detailTextLabel.font = [UIFont systemFontOfSize:15]; cell.detailTextLabel.textColor = [UIColor YHColorWithHex:0x999999]; cell.detailTextLabel.textAlignment=NSTextAlignmentRight; if (indexPath.section == 0 ) { if (indexPath.row == 0) { UIImageView *img =[[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-60, 10, 40, 40)]; img.layer.cornerRadius=20; img.layer.masksToBounds=YES; [cell addSubview:img]; [img sd_setImageWithURL:[NSURL URLWithString:self.userInfo[@"headimgurl"]]]; } if (indexPath.row == 1) { cell.detailTextLabel.text=self.userInfo[@"nickname"]; } } if (indexPath.section == 1 ) { if (indexPath.row == 0) {//我的邀请码 cell.detailTextLabel.text=self.userInfo[@"invite_code"]; } if (indexPath.row == 1) {//我的上级 cell.detailTextLabel.text=self.userInfo[@"parent_name"]; } } if (indexPath.section == 2 ) { if (indexPath.row == 0) {//我的手机号 cell.detailTextLabel.text=self.userInfo[@"phone"]; } if (indexPath.row == 1) {//我的微信号 if ([self.userInfo[@"weChat"] length]>0) { NSString *weixinNumber = self.userInfo[@"weChat"]; cell.detailTextLabel.text=weixinNumber; }else{ cell.detailTextLabel.text=@"未填写"; } } if (indexPath.row == 2) {//我的支付宝 if ([self.userInfo[@"alipay_account"] length]>0) { cell.detailTextLabel.text=self.userInfo[@"alipay_account"]; }else{ cell.detailTextLabel.text=@"未绑定"; } } } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 1) { if (indexPath.row == 1) {//上级 HSQMySuperViewController *superV = [[HSQMySuperViewController alloc] init]; [self.navigationController pushViewController:superV animated:YES]; } } if (indexPath.section == 2) { if (indexPath.row == 2) {//支付宝 [self alipayAccount]; } if (indexPath.row==1) {//微信 HSQMyWechatViewController *wechat = [[HSQMyWechatViewController alloc] init]; [self.navigationController pushViewController:wechat animated:YES]; } } } /** 支付宝账号 */ - (void)alipayAccount { HSQLinkAliPayViewController *alipay = [[HSQLinkAliPayViewController alloc] init]; alipay.isUpdate = [self.userModel.flag boolValue]; [self.navigationController pushViewController:alipay animated:YES]; } -(void)getWechat { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setValue:@"1" forKey:@"flag"]; [HSQHttp post:serviceWechat params:dict success:^(id json) { _weChatDict = (NSDictionary*)json; [self.tableView reloadData]; } failure:^(NSError *error) { }]; } @end