线上所有马甲包模板,与《猎豆》同UI。域名zhuadd

HSQMinePersonInforVC.m 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. //
  2. // HSQMinePersonInforVC.m
  3. // YouHuiProject
  4. //
  5. // Created by liuxueli on 2018/11/20.
  6. // Copyright © 2018 kuxuan. All rights reserved.
  7. //
  8. #import "HSQMinePersonInforVC.h"
  9. #import <UIKit/UIKit.h>
  10. #import"HSQCacheHttp.h"
  11. #import "HSQUserInfo.h"
  12. #import "AccountTool.h"
  13. #import "HSQMySuperViewController.h"
  14. #import "HSQMyWechatViewController.h"
  15. #import "HSQLinkAliPayViewController.h"
  16. @interface HSQMinePersonInforVC ()<UITableViewDelegate,UITableViewDataSource>
  17. @property (nonatomic, strong) UITableView *tableView;
  18. @property (nonatomic, strong) NSArray *dataArr;
  19. @property(nonatomic,strong)NSDictionary *dataDic;
  20. @property (nonatomic, strong) NSDictionary *userInfo;
  21. @property(nonatomic,strong)NSDictionary *weChatDict;
  22. @end
  23. @implementation HSQMinePersonInforVC
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. [self configNavigationBar];
  27. }
  28. -(void)viewWillAppear:(BOOL)animated
  29. {
  30. [self loadUserInfo];
  31. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  32. }
  33. /**
  34. 加载用户信息
  35. */
  36. - (void)loadUserInfo {
  37. [HSQCacheHttp post:NewUserInfo params:nil success:^(id json, BOOL isCache) {
  38. self.userInfo =[NSDictionary dictionaryWithDictionary:json[@"data"]];
  39. [self.tableView reloadData];
  40. } failure:^(NSError *error) {
  41. }];
  42. }
  43. - (void)configNavigationBar {
  44. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  45. self.view.backgroundColor = [UIColor whiteColor];
  46. [self.navigationBar setNavTitle:@"个人信息"];
  47. self.navigationBar.showNavigationBarBottomLine = YES;
  48. [self.view addSubview:self.tableView];
  49. self.navigationBar.backgroundColor = [UIColor changeColor];
  50. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  51. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  52. [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
  53. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  54. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  55. }
  56. /**
  57. 返回
  58. */
  59. - (void)backAction {
  60. [self.navigationController popViewControllerAnimated:YES];
  61. }
  62. - (UITableView *)tableView {
  63. if (!_tableView) {
  64. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
  65. _tableView.estimatedSectionHeaderHeight = 0;
  66. _tableView.estimatedSectionFooterHeight = 0;
  67. _tableView.sectionFooterHeight = 0;
  68. _tableView.sectionHeaderHeight = 0;
  69. _tableView.delegate = self;
  70. _tableView.dataSource = self;
  71. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  72. _tableView.backgroundColor = [UIColor yhGrayColor];
  73. _tableView.bounces = YES;
  74. _tableView.showsVerticalScrollIndicator = NO;
  75. [_tableView setSeparatorColor:[UIColor YHColorWithHex:0xdddddd]];
  76. }
  77. return _tableView;
  78. }
  79. -(NSDictionary *)dataDic
  80. {
  81. if (!_dataDic) {
  82. _dataDic=@{@"0":@[@{@"title":@"我的头像"},
  83. @{@"title":@"我的昵称"}],@"1":@[@{@"title":@"我的邀请码"},@{@"title":@"我的上级"}]};
  84. }
  85. return _dataDic;
  86. }
  87. #pragma mark ------------------
  88. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  89. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  90. [cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
  91. }
  92. }
  93. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  94. NSArray *array =self.dataDic[self.dataDic.allKeys[section]];
  95. return array.count;
  96. }
  97. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  98. if (indexPath.section == 0 && indexPath.row == 0) {
  99. return 60;
  100. }
  101. return 50;
  102. }
  103. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  104. return FITSIZE(5);
  105. }
  106. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  107. {
  108. return self.dataDic.allKeys.count;
  109. }
  110. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  111. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"];
  112. if ((indexPath.row == 1 && indexPath.section == 1) || (indexPath.section == 2 && indexPath.row ==2) || (indexPath.row == 1 && indexPath.section == 2)) {
  113. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  114. }
  115. NSArray *array =self.dataDic[self.dataDic.allKeys[indexPath.section]];
  116. cell.textLabel.font = [UIFont systemFontOfSize:15];
  117. cell.textLabel.text = array[indexPath.row][@"title"];
  118. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  119. cell.textLabel.textColor = [UIColor YHColorWithHex:0x666666];
  120. cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
  121. cell.detailTextLabel.textColor = [UIColor YHColorWithHex:0x999999];
  122. cell.detailTextLabel.textAlignment=NSTextAlignmentRight;
  123. if (indexPath.section == 0 ) {
  124. if (indexPath.row == 0) {
  125. UIImageView *img =[[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-60, 10, 40, 40)];
  126. img.layer.cornerRadius=20;
  127. img.layer.masksToBounds=YES;
  128. [cell addSubview:img];
  129. [img sd_setImageWithURL:[NSURL URLWithString:self.userInfo[@"headimgurl"]]];
  130. }
  131. if (indexPath.row == 1) {
  132. cell.detailTextLabel.text=self.userInfo[@"nickname"];
  133. }
  134. }
  135. if (indexPath.section == 1 ) {
  136. if (indexPath.row == 0) {//我的邀请码
  137. cell.detailTextLabel.text=self.userInfo[@"invite_code"];
  138. }
  139. if (indexPath.row == 1) {//我的上级
  140. cell.detailTextLabel.text=self.userInfo[@"parent_name"];
  141. }
  142. }
  143. if (indexPath.section == 2 ) {
  144. if (indexPath.row == 0) {//我的手机号
  145. cell.detailTextLabel.text=self.userInfo[@"phone"];
  146. }
  147. if (indexPath.row == 1) {//我的微信号
  148. if ([self.userInfo[@"weChat"] length]>0) {
  149. NSString *weixinNumber = self.userInfo[@"weChat"];
  150. cell.detailTextLabel.text=weixinNumber;
  151. }else{
  152. cell.detailTextLabel.text=@"未填写";
  153. }
  154. }
  155. if (indexPath.row == 2) {//我的支付宝
  156. if ([self.userInfo[@"alipay_account"] length]>0) {
  157. cell.detailTextLabel.text=self.userInfo[@"alipay_account"];
  158. }else{
  159. cell.detailTextLabel.text=@"未绑定";
  160. }
  161. }
  162. }
  163. return cell;
  164. }
  165. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  166. if (indexPath.section == 1) {
  167. if (indexPath.row == 1) {//上级
  168. HSQMySuperViewController *superV = [[HSQMySuperViewController alloc] init];
  169. [self.navigationController pushViewController:superV animated:YES];
  170. }
  171. }
  172. if (indexPath.section == 2) {
  173. if (indexPath.row == 2) {//支付宝
  174. [self alipayAccount];
  175. }
  176. if (indexPath.row==1) {//微信
  177. HSQMyWechatViewController *wechat = [[HSQMyWechatViewController alloc] init];
  178. [self.navigationController pushViewController:wechat animated:YES];
  179. }
  180. }
  181. }
  182. /**
  183. 支付宝账号
  184. */
  185. - (void)alipayAccount {
  186. HSQLinkAliPayViewController *alipay = [[HSQLinkAliPayViewController alloc] init];
  187. alipay.isUpdate = [self.userModel.flag boolValue];
  188. [self.navigationController pushViewController:alipay animated:YES];
  189. }
  190. -(void)getWechat
  191. {
  192. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  193. [dict setValue:@"1" forKey:@"flag"];
  194. [HSQHttp post:serviceWechat params:dict success:^(id json) {
  195. _weChatDict = (NSDictionary*)json;
  196. [self.tableView reloadData];
  197. } failure:^(NSError *error) {
  198. }];
  199. }
  200. @end