PersonalCenterViewModel.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //
  2. // PersonalCenterViewModel.m
  3. // HappyWork
  4. //
  5. // Created by 张晓光 on 2019/9/24.
  6. // Copyright © 2019 张晓光. All rights reserved.
  7. //
  8. #import "PersonalCenterViewModel.h"
  9. #import "PersonalCenterHeaderCell.h"
  10. #import "PersonalCenterCell.h"
  11. #import "PersonalCenterModel.h"
  12. @interface PersonalCenterViewModel ()
  13. @end
  14. @implementation PersonalCenterViewModel
  15. - (instancetype)init {
  16. if ([super init])
  17. {
  18. }
  19. return self;
  20. }
  21. - (void)requestPersonalCenterData{
  22. __weak typeof(self) weakSelf = self;
  23. [HWAFHttpTool getRequestWithURLStr:get_HwUserInfo params:@{@"user_id":[HWAppUserProfile sharedInstance].userId,@"user_token":[HWAppUserProfile sharedInstance].oauthToken} success:^(NSDictionary *responseDic) {
  24. if ([responseDic[@"errcode"] integerValue] == 0)
  25. {
  26. weakSelf.userDict = responseDic[@"data"][@"hwUser"];
  27. weakSelf.successBlock(weakSelf.userDict);
  28. }
  29. else
  30. {
  31. weakSelf.failBlock(responseDic[@"errmsg"]);
  32. }
  33. } failure:^(NSString *error) {
  34. weakSelf.failBlock(error);
  35. }];
  36. }
  37. #pragma mark - event response
  38. /* 设置 */
  39. - (void)setButtonClick:(UIButton *)btn {
  40. self.setBlock();
  41. }
  42. #pragma mark - UITableViewDataSource
  43. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  44. return 4;
  45. }
  46. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  47. if (section == 0 || section == 3)
  48. {
  49. return 1;
  50. }
  51. else
  52. {
  53. return 2;
  54. }
  55. }
  56. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  57. if (indexPath.section == 0)
  58. {
  59. static NSString *headerCell = @"headerCell";
  60. PersonalCenterHeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:headerCell];
  61. if (cell == nil)
  62. {
  63. cell = [[PersonalCenterHeaderCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:headerCell];
  64. }
  65. [cell.setBtn addTarget:self action:@selector(setButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  66. [cell.headerBtn addTarget:self action:@selector(setButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  67. PersonalCenterModel *model = [PersonalCenterModel mj_objectWithKeyValues:self.userDict];
  68. cell.nameLabel.text = model.name ;
  69. [cell.headerBtn sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",model.avatar]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"personalCenter_icon"]];
  70. if ([model.authenticationStatus integerValue] == 0)
  71. {
  72. cell.authLabel.text = @"未认证";
  73. }
  74. if ([model.authenticationStatus integerValue] == 1)
  75. {
  76. cell.authLabel.text = @"已认证";
  77. }
  78. if ([model.authenticationStatus integerValue] == 2)
  79. {
  80. cell.authLabel.text = @"认证不通过";
  81. }
  82. return cell;
  83. }
  84. else
  85. {
  86. static NSString *listCell = @"listCell";
  87. PersonalCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:listCell];
  88. if (cell == nil)
  89. {
  90. cell = [[PersonalCenterCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:listCell];
  91. }
  92. if (indexPath.section == 1 && indexPath.row == 0)
  93. {
  94. cell.leftImageV.image = [UIImage imageNamed:@"personalCenter_signup"];
  95. cell.titleLabel.text = @"我的报名";
  96. }
  97. if (indexPath.section == 1 && indexPath.row == 1)
  98. {
  99. cell.leftImageV.image = [UIImage imageNamed:@"personalCenter_myorder"];
  100. cell.titleLabel.text = @"我的订单";
  101. }
  102. if (indexPath.section == 2 && indexPath.row == 0)
  103. {
  104. cell.leftImageV.image = [UIImage imageNamed:@"personalCenter_paymentRecord"];
  105. cell.titleLabel.text = @"收款记录";
  106. }
  107. if (indexPath.section == 2 && indexPath.row == 1)
  108. {
  109. cell.leftImageV.image = [UIImage imageNamed:@"personalCenter_tax"];
  110. cell.titleLabel.text = @"完税证明";
  111. }
  112. if (indexPath.section == 3 && indexPath.row == 0)
  113. {
  114. cell.leftImageV.image = [UIImage imageNamed:@"general_Set"];
  115. cell.titleLabel.text = @"通用设置";
  116. }
  117. return cell;
  118. }
  119. }
  120. @end