| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- //
- // PersonalCenterViewModel.m
- // HappyWork
- //
- // Created by 张晓光 on 2019/9/24.
- // Copyright © 2019 张晓光. All rights reserved.
- //
- #import "PersonalCenterViewModel.h"
- #import "PersonalCenterHeaderCell.h"
- #import "PersonalCenterCell.h"
- #import "PersonalCenterModel.h"
- @interface PersonalCenterViewModel ()
- @end
- @implementation PersonalCenterViewModel
- - (instancetype)init {
-
- if ([super init])
- {
-
- }
- return self;
- }
- - (void)requestPersonalCenterData{
-
- __weak typeof(self) weakSelf = self;
- [HWAFHttpTool getRequestWithURLStr:get_HwUserInfo params:@{@"user_id":[HWAppUserProfile sharedInstance].userId,@"user_token":[HWAppUserProfile sharedInstance].oauthToken} success:^(NSDictionary *responseDic) {
-
- if ([responseDic[@"errcode"] integerValue] == 0)
- {
- weakSelf.userDict = responseDic[@"data"][@"hwUser"];
- weakSelf.successBlock(weakSelf.userDict);
- }
- else
- {
- weakSelf.failBlock(responseDic[@"errmsg"]);
- }
- } failure:^(NSString *error) {
-
- weakSelf.failBlock(error);
- }];
- }
- #pragma mark - event response
- /* 设置 */
- - (void)setButtonClick:(UIButton *)btn {
-
- self.setBlock();
- }
- #pragma mark - UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
-
- return 4;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-
- if (section == 0 || section == 3)
- {
- return 1;
- }
- else
- {
- return 2;
- }
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- if (indexPath.section == 0)
- {
- static NSString *headerCell = @"headerCell";
- PersonalCenterHeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:headerCell];
- if (cell == nil)
- {
- cell = [[PersonalCenterHeaderCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:headerCell];
- }
- [cell.setBtn addTarget:self action:@selector(setButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- [cell.headerBtn addTarget:self action:@selector(setButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- PersonalCenterModel *model = [PersonalCenterModel mj_objectWithKeyValues:self.userDict];
-
- cell.nameLabel.text = model.name ;
- [cell.headerBtn sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",model.avatar]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"personalCenter_icon"]];
- if ([model.authenticationStatus integerValue] == 0)
- {
- cell.authLabel.text = @"未认证";
- }
- if ([model.authenticationStatus integerValue] == 1)
- {
- cell.authLabel.text = @"已认证";
- }
- if ([model.authenticationStatus integerValue] == 2)
- {
- cell.authLabel.text = @"认证不通过";
- }
- return cell;
- }
- else
- {
- static NSString *listCell = @"listCell";
- PersonalCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:listCell];
- if (cell == nil)
- {
- cell = [[PersonalCenterCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:listCell];
- }
- if (indexPath.section == 1 && indexPath.row == 0)
- {
- cell.leftImageV.image = [UIImage imageNamed:@"personalCenter_signup"];
- cell.titleLabel.text = @"我的报名";
- }
- if (indexPath.section == 1 && indexPath.row == 1)
- {
- cell.leftImageV.image = [UIImage imageNamed:@"personalCenter_myorder"];
- cell.titleLabel.text = @"我的订单";
- }
-
- if (indexPath.section == 2 && indexPath.row == 0)
- {
- cell.leftImageV.image = [UIImage imageNamed:@"personalCenter_paymentRecord"];
- cell.titleLabel.text = @"收款记录";
- }
- if (indexPath.section == 2 && indexPath.row == 1)
- {
- cell.leftImageV.image = [UIImage imageNamed:@"personalCenter_tax"];
- cell.titleLabel.text = @"完税证明";
- }
- if (indexPath.section == 3 && indexPath.row == 0)
- {
- cell.leftImageV.image = [UIImage imageNamed:@"general_Set"];
- cell.titleLabel.text = @"通用设置";
- }
- return cell;
- }
- }
- @end
|