JXRecordCodeVC.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //
  2. // JXRecordCodeVC.m
  3. // shiku_im
  4. //
  5. // Created by Apple on 16/9/18.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. #import "JXRecordCodeVC.h"
  9. #import "JXRecordTBCell.h"
  10. @interface JXRecordCodeVC ()
  11. @end
  12. @implementation JXRecordCodeVC
  13. - (instancetype)init
  14. {
  15. self = [super init];
  16. if (self) {
  17. //self.view.frame = CGRectMake(JX_SCREEN_WIDTH, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  18. self.heightHeader = JX_SCREEN_TOP;
  19. self.heightFooter = 0;
  20. self.isGotoBack = YES;
  21. _dataArr = [NSMutableArray array];
  22. }
  23. return self;
  24. }
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. // Do any additional setup after loading the view.
  28. [self customView];
  29. [self getServerData];
  30. }
  31. -(void)getServerData{
  32. [_wait start];
  33. [g_server getConsumeRecord:_page toView:self];
  34. }
  35. - (void)customView{
  36. self.title =@"账单";// Localized(@"JXRecordCodeVC_Title");
  37. [self createHeadAndFoot];
  38. _table.delegate = self;
  39. _table.dataSource = self;
  40. _table.separatorStyle = UITableViewCellSeparatorStyleNone;
  41. _table.allowsSelection = NO;
  42. if (@available(iOS 11.0, *)) {
  43. _table.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  44. } else {
  45. self.automaticallyAdjustsScrollViewInsets = NO;
  46. }
  47. }
  48. -(void)getDataObjFromArr:(NSMutableArray*)arr{
  49. [_table reloadData];
  50. }
  51. - (void)viewWillAppear:(BOOL)animated{
  52. [super viewWillAppear:animated];
  53. // [UIView animateWithDuration:0.3 animations:^{
  54. // self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  55. // }];
  56. }
  57. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  58. return 1;
  59. }
  60. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  61. return [_dataArr count];
  62. }
  63. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  64. JXRecordTBCell * cell = [tableView dequeueReusableCellWithIdentifier:@"JXRecordTBCell"];
  65. NSDictionary * cellModel = _dataArr[indexPath.row];
  66. if (cell == nil) {
  67. cell = [[NSBundle mainBundle] loadNibNamed:@"JXRecordTBCell" owner:self options:nil][0];
  68. }
  69. //描述
  70. cell.titleLabel.text = cellModel[@"desc"];
  71. //转换为日期
  72. NSTimeInterval creatTime = [cellModel[@"time"] doubleValue];
  73. NSDate * date = [NSDate dateWithTimeIntervalSince1970:creatTime]; //1000
  74. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  75. [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
  76. [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:8*60*60]];//中国专用
  77. cell.timeLabel.text = [dateFormatter stringFromDate:date];
  78. NSString *symbolStr;
  79. int type = [cellModel[@"type"] intValue];
  80. if (type == 2 || type == 4 || type == 7 || type == 10 || type == 12 || type == 14) {
  81. symbolStr = @"-";
  82. cell.moneyLabel.textColor = [UIColor blackColor];
  83. }else {
  84. symbolStr = @"+";
  85. cell.moneyLabel.textColor = THEMECOLOR;
  86. }
  87. //交易金额
  88. cell.moneyLabel.text = [NSString stringWithFormat:@"%@%@ %@",symbolStr,cellModel[@"money"],Localized(@"JX_ChinaMoney")];
  89. //是否退款
  90. cell.refundLabel.text = @"";
  91. return cell;
  92. }
  93. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  94. return 68;
  95. }
  96. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  97. [_wait stop];
  98. [self stopLoading];
  99. //消费记录
  100. if ([aDownload.action isEqualToString:act_consumeRecord]) {
  101. //添加到数据源
  102. if (dict == nil) {
  103. return;
  104. }
  105. // if ([dict[@"pageIndex"] intValue] == 0) {
  106. // _dataArr = [[NSMutableArray alloc]initWithArray:dict[@"pageData"]];
  107. // // self.dataDict = [[NSMutableDictionary alloc]initWithDictionary:dict];
  108. // }else if([dict[@"pageIndex"] intValue] <= [dict[@"pageCount"] intValue]){
  109. // [_dataArr addObjectsFromArray:dict[@"pageData"]];
  110. // }else{
  111. // //没有更多数据
  112. // }
  113. _footer.hidden = [(NSArray *)dict[@"pageData"] count] < 20;
  114. if(_page == 0){
  115. [_dataArr removeAllObjects];
  116. [_dataArr addObjectsFromArray:dict[@"pageData"]];
  117. }else{
  118. if([(NSArray *)dict[@"pageData"] count]>0){
  119. [_dataArr addObjectsFromArray:dict[@"pageData"]];
  120. }
  121. }
  122. _page ++;
  123. [self getDataObjFromArr:_dataArr];
  124. }
  125. }
  126. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  127. [_wait stop];
  128. [self stopLoading];
  129. return hide_error;
  130. }
  131. - (void)didReceiveMemoryWarning {
  132. [super didReceiveMemoryWarning];
  133. // Dispose of any resources that can be recreated.
  134. }
  135. @end