JXTransferNoticeVC.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // JXTransferNoticeVC.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 2019/3/8.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXTransferNoticeVC.h"
  9. #import "JXTransferNoticeCell.h"
  10. #import "JXTransferNoticeModel.h"
  11. #import "JXTransferModel.h"
  12. #import "JXTransferOpenPayModel.h"
  13. @interface JXTransferNoticeVC ()
  14. @property (nonatomic, strong) NSArray *array;
  15. @end
  16. @implementation JXTransferNoticeVC
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. self.title = Localized(@"JX_PaymentNo.");
  20. self.heightHeader = JX_SCREEN_TOP;
  21. self.heightFooter = 0;
  22. self.isGotoBack = YES;
  23. [self createHeadAndFoot];
  24. self.isShowFooterPull = NO;
  25. self.isShowHeaderPull = NO;
  26. _table.backgroundColor = HEXCOLOR(0xF2F2F2);
  27. [self getData];
  28. }
  29. - (void)getData {
  30. // 获取所有聊天记录
  31. _array = [[JXMessageObject sharedInstance] fetchAllMessageListWithUser:SHIKU_TRANSFER];
  32. if (_array.count > 0) {
  33. [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:_array.count-1 inSection:0]
  34. animated:NO
  35. scrollPosition:UITableViewScrollPositionMiddle];
  36. }
  37. }
  38. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  39. return 1;
  40. }
  41. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  42. return _array.count;
  43. }
  44. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  45. JXMessageObject *msg=[_array objectAtIndex:indexPath.row];
  46. return [JXTransferNoticeCell getChatCellHeight:msg];
  47. // return 215;
  48. }
  49. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  50. static NSString *cellIdentifier = @"JXTransferNoticeCell";
  51. JXTransferNoticeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  52. if (!cell) {
  53. cell = [[JXTransferNoticeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  54. }
  55. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  56. JXMessageObject *msg = _array[indexPath.row];
  57. // SBJsonParser * OderJsonwriter = [SBJsonParser new];
  58. NSDictionary *dict = [self dictionaryWithJsonString:msg.content];
  59. if ([msg.type intValue] == kWCMessageTypeTransferBack) {
  60. JXTransferModel *model = [[JXTransferModel alloc] init];
  61. [model getTransferDataWithDict:dict];
  62. [cell setDataWithMsg:msg model:model];
  63. }
  64. else if ([msg.type intValue] == kWCMessageTypeOpenPaySuccess) {
  65. JXTransferOpenPayModel *model = [[JXTransferOpenPayModel alloc] init];
  66. [model getTransferDataWithDict:dict];
  67. [cell setDataWithMsg:msg model:model];
  68. }
  69. else {
  70. JXTransferNoticeModel *model = [[JXTransferNoticeModel alloc]init];
  71. [model getTransferNoticeWithDict:dict];
  72. [cell setDataWithMsg:msg model:model];
  73. }
  74. return cell;
  75. }
  76. - (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString
  77. {
  78. if (jsonString == nil) {
  79. return nil;
  80. }
  81. NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
  82. NSError *err;
  83. NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
  84. options:NSJSONReadingMutableContainers
  85. error:&err];
  86. if(err)
  87. {
  88. NSLog(@"json解析失败:%@",err);
  89. return nil;
  90. }
  91. return dic;
  92. }
  93. @end