123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- //
- // HSQMinePersonInforVC.m
- // YouHuiProject
- //
- // Created by liuxueli on 2018/11/20.
- // Copyright © 2018 kuxuan. All rights reserved.
- //
- #import "HSQMinePersonInforVC.h"
- #import <UIKit/UIKit.h>
- #import"HSQCacheHttp.h"
- #import "HSQUserInfo.h"
- #import "AccountTool.h"
- #import "HSQMySuperViewController.h"
- #import "HSQMyWechatViewController.h"
- #import "HSQLinkAliPayViewController.h"
- @interface HSQMinePersonInforVC ()<UITableViewDelegate,UITableViewDataSource>
- @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
|