JXSearchFileLogVC.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. //
  2. // JXSearchFileLogVC.m
  3. // shiku_im
  4. //
  5. // Created by p on 2019/4/8.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXSearchFileLogVC.h"
  9. #import "JXSearchFileLogCell.h"
  10. #import "JXShareFileObject.h"
  11. #import "JXFileDetailViewController.h"
  12. #import "webpageVC.h"
  13. #import "JXTransferDeatilVC.h"
  14. #import "JXredPacketDetailVC.h"
  15. #import "JXChatViewController.h"
  16. @interface JXSearchFileLogVC ()
  17. @property (nonatomic, strong) NSMutableArray *array;
  18. @end
  19. @implementation JXSearchFileLogVC
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. // Do any additional setup after loading the view.
  23. self.heightHeader = JX_SCREEN_TOP;
  24. self.heightFooter = 0;
  25. self.isGotoBack = YES;
  26. self.isShowFooterPull = NO;
  27. self.isShowHeaderPull = NO;
  28. [self createHeadAndFoot];
  29. _array = [NSMutableArray array];
  30. [self getServerData];
  31. }
  32. - (void)getServerData {
  33. switch (self.type) {
  34. case FileLogType_file:{
  35. _array = [[JXMessageObject sharedInstance] fetchAllMessageListWithUser:self.user.userId withTypes:@[[NSNumber numberWithInt:kWCMessageTypeFile]]];
  36. self.title = Localized(@"JX_File");
  37. }
  38. break;
  39. case FileLogType_Link:{
  40. _array = [[JXMessageObject sharedInstance] fetchAllMessageListWithUser:self.user.userId withTypes:@[[NSNumber numberWithInt:kWCMessageTypeLink],[NSNumber numberWithInt:kWCMessageTypeShare]]];
  41. self.title = Localized(@"JXLink");
  42. }
  43. break;
  44. case FileLogType_transact:{
  45. _array = [[JXMessageObject sharedInstance] fetchAllMessageListWithUser:self.user.userId withTypes:@[[NSNumber numberWithInt:kWCMessageTypeRedPacket],[NSNumber numberWithInt:kWCMessageTypeTransfer]]];
  46. self.title = Localized(@"JX_Trading");
  47. }
  48. break;
  49. default:
  50. break;
  51. }
  52. }
  53. #pragma mark ---------tableView协议----------------
  54. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  55. {
  56. JXSearchFileLogCell *cell = [tableView dequeueReusableCellWithIdentifier:@"JXSearchFileLogCell"];
  57. if (!cell) {
  58. cell = [[JXSearchFileLogCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"JXSearchFileLogCell"];
  59. }
  60. cell.type = self.type;
  61. JXMessageObject *msg = _array[indexPath.row];
  62. cell.msg = msg;
  63. return cell;
  64. }
  65. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  66. {
  67. return 1;
  68. }
  69. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  70. {
  71. return _array.count;
  72. }
  73. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  74. {
  75. return 150;
  76. }
  77. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  78. {
  79. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  80. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  81. JXMessageObject *msg = _array[indexPath.row];
  82. switch (self.type) {
  83. case FileLogType_file:{
  84. JXShareFileObject *obj = [[JXShareFileObject alloc] init];
  85. obj.fileName = [msg.fileName lastPathComponent];
  86. obj.url = msg.content;
  87. obj.size = msg.fileSize;
  88. JXFileDetailViewController *vc = [[JXFileDetailViewController alloc] init];
  89. vc.shareFile = obj;
  90. // [g_window addSubview:vc.view];
  91. [g_navigation pushViewController:vc animated:YES];
  92. }
  93. break;
  94. case FileLogType_Link:{
  95. if ([msg.type integerValue] == kWCMessageTypeShare) {
  96. NSDictionary * msgDict = [[[SBJsonParser alloc]init]objectWithString:msg.objectId];
  97. NSString *url = [msgDict objectForKey:@"url"];
  98. NSString *downloadUrl = [msgDict objectForKey:@"downloadUrl"];
  99. if ([url rangeOfString:@"http"].location == NSNotFound) {
  100. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url] options:nil completionHandler:^(BOOL success) {
  101. if (!success) {
  102. webpageVC *webVC = [webpageVC alloc];
  103. webVC.isGotoBack= YES;
  104. webVC.isSend = YES;
  105. webVC.titleString = [msgDict objectForKey:@"title"];
  106. webVC.url = downloadUrl;
  107. webVC = [webVC init];
  108. [g_navigation.navigationView addSubview:webVC.view];
  109. // [g_navigation pushViewController:webVC animated:YES];
  110. }
  111. }];
  112. }else {
  113. webpageVC *webVC = [webpageVC alloc];
  114. webVC.isGotoBack= YES;
  115. webVC.isSend = YES;
  116. webVC.titleString = [msgDict objectForKey:@"title"];
  117. webVC.url = url;
  118. webVC = [webVC init];
  119. [g_navigation.navigationView addSubview:webVC.view];
  120. // [g_navigation pushViewController:webVC animated:YES];
  121. }
  122. }else {
  123. SBJsonParser * parser = [[SBJsonParser alloc] init] ;
  124. NSDictionary *content = [parser objectWithString:msg.content];
  125. NSString *url = [content objectForKey:@"url"];
  126. webpageVC *webVC = [webpageVC alloc];
  127. webVC.isGotoBack= YES;
  128. webVC.isSend = YES;
  129. webVC.title = [content objectForKey:@"title"];
  130. webVC.url = url;
  131. webVC = [webVC init];
  132. [g_navigation.navigationView addSubview:webVC.view];
  133. }
  134. }
  135. break;
  136. case FileLogType_transact:{
  137. JXChatViewController *sendView=[JXChatViewController alloc];
  138. sendView.scrollLine = [msg getLineNumWithUserId:self.user.userId] - 1;
  139. sendView.title = self.user.remarkName.length > 0 ? self.user.remarkName : self.user.userNickname;
  140. if([self.user.roomFlag intValue] > 0 || self.user.roomId.length > 0){
  141. // if(g_xmpp.isLogined != 1){
  142. // // 掉线后点击title重连
  143. // [g_xmpp showXmppOfflineAlert];
  144. // return;
  145. // }
  146. sendView.roomJid = self.user.userId;
  147. sendView.roomId = self.user.roomId;
  148. sendView.groupStatus = self.user.groupStatus;
  149. if (self.user.roomFlag || self.user.roomId.length > 0) {
  150. NSDictionary * groupDict = [self.user toDictionary];
  151. roomData * roomdata = [[roomData alloc] init];
  152. [roomdata getDataFromDict:groupDict];
  153. sendView.room = roomdata;
  154. sendView.newMsgCount = [self.user.msgsNew intValue];
  155. self.user.isAtMe = [NSNumber numberWithInt:0];
  156. [self.user updateIsAtMe];
  157. }
  158. }
  159. sendView.rowIndex = indexPath.row;
  160. sendView.lastMsg = msg;
  161. sendView.chatPerson = self.user;
  162. sendView = [sendView init];
  163. // [g_App.window addSubview:sendView.view];
  164. [g_navigation pushViewController:sendView animated:YES];
  165. // if ([msg.type integerValue] == kWCMessageTypeRedPacket) {
  166. //
  167. // [g_server getRedPacket:msg.objectId toView:self];
  168. // }else {
  169. //
  170. // JXTransferDeatilVC *detailVC = [JXTransferDeatilVC alloc];
  171. // detailVC.msg = msg;
  172. // detailVC.onResend = @selector(onResend:);
  173. // detailVC.delegate = self;
  174. // detailVC = [detailVC init];
  175. // [g_navigation pushViewController:detailVC animated:YES];
  176. // }
  177. }
  178. break;
  179. default:
  180. break;
  181. }
  182. }
  183. // 重新发送转账消息
  184. - (void)onResend:(JXMessageObject *)msg {
  185. JXMessageObject *msg1 = [[JXMessageObject alloc]init];
  186. msg1 = [msg copy];
  187. msg1.messageId = nil;
  188. msg1.timeSend = [NSDate date];
  189. msg1.fromId = nil;
  190. msg1.isGroup = NO;
  191. msg1.isSend = [NSNumber numberWithInt:transfer_status_ing];
  192. msg1.isRead = [NSNumber numberWithBool:NO];
  193. msg1.isReadDel = [NSNumber numberWithInt:NO];
  194. [msg1 insert:nil];
  195. [g_xmpp sendMessage:msg1 roomName:nil];//发送消息
  196. }
  197. #pragma mark -------------------服务器返回数据--------------------
  198. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  199. //获取红包信息
  200. if ([aDownload.action isEqualToString:act_getRedPacket]) {
  201. }
  202. }
  203. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  204. [_wait stop];
  205. //自己查看红包或者红包已领完,resultCode =0
  206. if ([aDownload.action isEqualToString:act_getRedPacket]) {
  207. // [self changeMessageRedPacketStatus:dict[@"data"][@"packet"][@"id"]];
  208. // [self changeMessageArrFileSize:dict[@"data"][@"packet"][@"id"]];
  209. JXredPacketDetailVC * redPacketDetailVC = [[JXredPacketDetailVC alloc]init];
  210. redPacketDetailVC.dataDict = [[NSDictionary alloc]initWithDictionary:dict];
  211. // [g_window addSubview:redPacketDetailVC.view];
  212. redPacketDetailVC.isGroup = self.isGroup;
  213. [g_navigation pushViewController:redPacketDetailVC animated:YES];
  214. }
  215. return hide_error;
  216. }
  217. /*
  218. #pragma mark - Navigation
  219. // In a storyboard-based application, you will often want to do a little preparation before navigation
  220. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  221. // Get the new view controller using [segue destinationViewController].
  222. // Pass the selected object to the new view controller.
  223. }
  224. */
  225. @end