JXMyFeedVc.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. //
  2. // JXMyFeedVc.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/5/23.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #define insert_photo_tag -100000
  9. #import "JXMyFeedVc.h"
  10. #import "JXMyFeedCell.h"
  11. #import "addMsgVC.h"
  12. #import "RITLPhotosViewController.h"
  13. #import "GWLPhotoLibrayController.h"
  14. #import "UIView+LK.h"
  15. #import "JXFeedShowView.h"
  16. #import "JXCameraVC.h"
  17. #import "JXMediaObject.h"
  18. #import "addMsgVC.h"
  19. #import "AppDelegate.h"
  20. #import "JXImageView.h"
  21. #import "JXServer.h"
  22. #import "JXConnection.h"
  23. #import "ImageResize.h"
  24. #import "UIFactory.h"
  25. #import "JXTableView.h"
  26. #import "QBImagePickerController.h"
  27. #import "SBJsonWriter.h"
  28. #import "recordVideoViewController.h"
  29. #import "JXTextView.h"
  30. #import "JXMediaObject.h"
  31. #import "LXActionSheet.h"
  32. #import "myMediaVC.h"
  33. #import "JXLocationVC.h"
  34. #import "JXMapData.h"
  35. #import "WhoCanSeeViewController.h"
  36. #import "JXSelFriendVC.h"
  37. #import "JXSelectFriendsVC.h"
  38. #import "RITLPhotosViewController.h"
  39. #import "RITLPhotosDataManager.h"
  40. #import "JXMyFile.h"
  41. #import "UIImageView+FileType.h"
  42. #import "JXFileDetailViewController.h"
  43. #import "JXShareFileObject.h"
  44. #import "webpageVC.h"
  45. #import "JXSelectorVC.h"
  46. #ifdef Meeting_Version
  47. #ifdef Live_Version
  48. #import "JXSmallVideoViewController.h"
  49. #endif
  50. #endif
  51. #import "JXActionSheetVC.h"
  52. #import "JXCameraVC.h"
  53. #import "QCheckBox.h"
  54. #import "JXSelectCoverVC.h"
  55. @interface JXMyFeedVc ()<UITableViewDelegate,UITableViewDataSource,VisibelDelegate,RITLPhotosViewControllerDelegate,JXSelectorVCDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate, JXActionSheetVCDelegate, JXCameraVCDelegate,JXSelectCoverVCDelegate,JXImageViewPanDelegate,JXActionSheetVCDelegate,UITextViewDelegate>
  56. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  57. @property (nonatomic,strong) NSMutableArray *dataArr;
  58. @property (nonatomic,strong) JXMyModel *strURL;
  59. @property (nonatomic, strong) NSMutableArray* imageViewArray;
  60. @property (nonatomic, assign) CGPoint startPoint;
  61. @property (nonatomic, assign) CGPoint oraginPoint;
  62. @property (nonatomic, assign) CGPoint newPoint;
  63. @property (nonatomic, assign) CGPoint lastPoint;
  64. @property (nonatomic, assign) NSTimeInterval intoBorderTime;
  65. @property (nonatomic, assign) NSTimeInterval stayBorderTime;
  66. @property (nonatomic, assign) BOOL inBorder;
  67. @property (nonatomic, assign) BOOL isUpdateImage;
  68. @property (nonatomic, strong) NSMutableDictionary *gifDataDic;
  69. @property (weak, nonatomic) IBOutlet UILabel *placeholdL;
  70. @property (weak, nonatomic) IBOutlet UITextView *textView;
  71. @property (weak, nonatomic) IBOutlet UILabel *addIMGLb;
  72. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *textViewH;
  73. @property (nonatomic,strong) UIImagePickerController *picker;
  74. @property (nonatomic,weak) JXFeedShowView *feedShowView;
  75. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *topViewH;
  76. @end
  77. @implementation JXMyFeedVc
  78. - (void)viewWillAppear:(BOOL)animated{
  79. [super viewWillAppear:animated];
  80. [self.navigationController setNavigationBarHidden:NO];
  81. // [self defineNavBar:@"排行榜" andRinghtBtnImg:@""];
  82. }
  83. - (IBAction)goBack:(id)sender {
  84. [g_navigation dismissViewController:self animated:NO];
  85. }
  86. - (void)touchAtlasButtonReturnCover:(UIImage *)img{
  87. }
  88. - (void)selectImage:(UIImage *)img toView:(JXSelectCoverVC *)view{
  89. }
  90. - (void) selector:(JXSelectorVC*)selector selectorAction:(NSInteger)selectIndex{
  91. }
  92. - (void)viewDidLoad {
  93. [super viewDidLoad];
  94. self.topViewH.constant=JX_SCREEN_HEIGHT>=812?88:64;
  95. //self.view.backgroundColor=kRGBColor246;
  96. _dataArr=[NSMutableArray array];
  97. _images = [NSMutableArray array];
  98. _tableView.tableFooterView=[UIView new];
  99. _picker=[UIImagePickerController new];
  100. _textView.delegate=self;
  101. CGFloat imagesHH=0;
  102. imagesHH=JX_SCREEN_HEIGHT>=812?90:10;
  103. svImages = [[UIScrollView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_addIMGLb.frame)+imagesHH, JX_SCREEN_WIDTH,80)];
  104. svImages.pagingEnabled = YES;
  105. svImages.delegate = self;
  106. svImages.showsVerticalScrollIndicator = NO;
  107. svImages.showsHorizontalScrollIndicator = NO;
  108. svImages.backgroundColor = [UIColor whiteColor];
  109. svImages.userInteractionEnabled = YES;
  110. [self.view addSubview:svImages];
  111. [self showImages];
  112. self.textView.delegate=self;
  113. self.textViewH.constant=JX_SCREEN_HEIGHT>=812?200:140;
  114. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardAction:) name:UIKeyboardWillShowNotification object:nil];
  115. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardAction:) name:UIKeyboardWillHideNotification object:nil];
  116. [self loadData];
  117. JXFeedShowView *show=[JXFeedShowView XIBJXFeedShowView];
  118. show.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.4];
  119. show.frame=[UIScreen mainScreen].bounds;
  120. [[UIApplication sharedApplication].keyWindow addSubview:show];
  121. self.feedShowView=show;
  122. show.hidden=YES;
  123. [show.konwBtn22 addTarget:self action:@selector(goBckBtn) forControlEvents:UIControlEventTouchUpInside];
  124. }
  125. - (void)goBckBtn{
  126. [_feedShowView removeFromSuperview];
  127. [g_navigation dismissViewController:self animated:YES];
  128. }
  129. - (void)textViewDidChange:(UITextView *)textView{
  130. if (textView.text.length>0) {
  131. self.placeholdL.hidden=YES;
  132. }else{
  133. self.placeholdL.hidden=NO;
  134. }
  135. }
  136. /**
  137. * 加载最新数据
  138. */
  139. - (void)loadData{
  140. long time = (long)[[NSDate date] timeIntervalSince1970];
  141. time = (time *1000 + g_server.timeDifference);
  142. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  143. [SVProgressHUD show];
  144. [g_server getact_usermyfeedbacktypes:salt andType:@"" andToView:self];
  145. // [g_server getact_act_usermyfeedSubmit:salt andType:@"1" andToView:self];
  146. }
  147. -(void)showImages{
  148. int i;
  149. [g_factory removeAllChild:svImages];
  150. NSInteger n = [_images count];
  151. _sendBtn.enabled = n > 1 || _remark.text.length > 0;
  152. svImages.contentSize = CGSizeMake((n+1) * 80, svImages.frame.size.height);
  153. for(i=0;i<n&&i<9;i++){
  154. JXImageView* iv = [[JXImageView alloc]initWithFrame:CGRectMake(i*78+15, 10, 63,63)];
  155. iv.delegate = self;
  156. iv.panDelegate = self;
  157. iv.userInteractionEnabled = YES;
  158. iv.layer.cornerRadius = 6;
  159. iv.layer.masksToBounds = YES;
  160. iv.animationType = JXImageView_Animation_Line;
  161. iv.tag = i;
  162. [iv addLongPressGesture];
  163. [iv addTapGesture];
  164. iv.image = [_images objectAtIndex:i];
  165. [svImages addSubview:iv];
  166. // [iv release];
  167. }
  168. _imageViewArray = [NSMutableArray arrayWithArray:svImages.subviews];
  169. UIButton* btn = [self createButton:nil icon:@"add_picture" action:@selector(actionImage:) parent:svImages];
  170. btn.frame = CGRectMake(i*78+15, 10, 63, 63);
  171. btn.tag = insert_photo_tag;
  172. }
  173. -(UIButton*)createButton:(NSString*)title icon:(NSString*)icon action:(SEL)action parent:(UIView*)parent{
  174. UIButton* btn = [UIFactory createButtonWithImage:icon
  175. highlight:nil
  176. target:self
  177. selector:action];
  178. btn.titleEdgeInsets = UIEdgeInsetsMake(45, -60, 0, 0);
  179. [btn setTitle:title forState:UIControlStateNormal];
  180. [btn setTitleColor:HEXCOLOR(0x999999) forState:UIControlStateNormal];
  181. btn.titleLabel.font = g_factory.font10;
  182. [parent addSubview:btn];
  183. return btn;
  184. }
  185. - (void)tapImageView:(JXImageView *)imageView{
  186. [self actionImage:imageView];
  187. }
  188. -(void)actionImage:(JXImageView*)sender{
  189. _photoIndex = sender.tag;
  190. if(_photoIndex==insert_photo_tag&&[_images count]>8){
  191. [g_App showAlert:Localized(@"addMsgVC_SelNinePhoto")];
  192. return;
  193. }else if(_photoIndex==insert_photo_tag){
  194. JXActionSheetVC *actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JX_ChoosePhoto"),Localized(@"JX_TakePhoto")]];
  195. actionVC.delegate = self;
  196. actionVC.tag = 111;
  197. [self presentViewController:actionVC animated:NO completion:nil];
  198. return;
  199. }
  200. LXActionSheet* _menu = [[LXActionSheet alloc]
  201. initWithTitle:nil delegate:self
  202. cancelButtonTitle:Localized(@"JX_Cencal")
  203. destructiveButtonTitle:Localized(@"JX_Update")
  204. otherButtonTitles:@[Localized(@"JX_Delete")]];
  205. [g_window addSubview:_menu];
  206. // [_menu release];
  207. }
  208. - (void)didClickOnButtonIndex:(LXActionSheet*)sender buttonIndex:(int)buttonIndex{
  209. if(buttonIndex<0)
  210. return;
  211. _nSelMenu = buttonIndex;
  212. [self doOutputMenu];
  213. }
  214. -(void)doOutputMenu{
  215. if(_nSelMenu==0){
  216. self.isUpdateImage = YES;
  217. [self pickImages:NO];
  218. }
  219. if(_nSelMenu==1){
  220. [_images removeObjectAtIndex:_photoIndex];
  221. [self showImages];
  222. }
  223. }
  224. -(void)pickImages:(BOOL)Multi{
  225. RITLPhotosViewController *photoController = RITLPhotosViewController.photosViewController;
  226. if (!self.isUpdateImage) {
  227. photoController.configuration.maxCount = 9 - _images.count;//最大的选择数目
  228. }else {
  229. photoController.configuration.maxCount = 1;//最大的选择数目
  230. }
  231. photoController.configuration.containVideo = NO;//选择类型,目前只选择图片不选择视频
  232. photoController.photo_delegate = self;
  233. photoController.thumbnailSize = CGSizeMake(320, 320);//缩略图的尺寸
  234. // photoController.defaultIdentifers = self.saveAssetIds;//记录已经选择过的资源
  235. [self presentViewController:photoController animated:true completion:^{}];
  236. }
  237. - (void)displayImages:(NSArray *)images {
  238. for (UIImageView *imageView in self.imageViewArray) {
  239. [imageView removeFromSuperview];
  240. }
  241. if (self.isUpdateImage) {
  242. _images[_photoIndex] = images.firstObject;
  243. }else {
  244. [_images addObjectsFromArray:images.mutableCopy];
  245. }
  246. self.gifDataDic = nil;
  247. self.gifDataDic = [NSMutableDictionary dictionary];
  248. for (int i = 0; i < images.count; i++) {
  249. UIImage *image = images[i];
  250. if (image.images.count > 0) {
  251. //NSDictionary *dic = [infos objectAtIndex:i];
  252. //NSData *data = [dic objectForKey:@"gifData"];
  253. //[self.gifDataDic setValue:data forKey:[NSString stringWithFormat:@"%d",i]];
  254. }
  255. }
  256. [self showImages];
  257. }
  258. - (void)actionSheet:(JXActionSheetVC *)actionSheet didButtonWithIndex:(NSInteger)index{
  259. // __weak typeof (self)weakSelf = self;
  260. // GWLPhotoLibrayController *photoSelector = [GWLPhotoLibrayController photoLibrayControllerWithBlock:^(NSArray *images) {
  261. // [weakSelf displayImages:images];
  262. // }];
  263. // photoSelector.maxCount = 10;
  264. // photoSelector.multiAlbumSelect = YES;
  265. // [self presentViewController:photoSelector animated:YES completion:nil];
  266. if (index == 0) {
  267. RITLPhotosViewController *photoController = RITLPhotosViewController.photosViewController;
  268. if (!self.isUpdateImage) {
  269. photoController.configuration.maxCount = 9 - _images.count;//最大的选择数目
  270. }else {
  271. photoController.configuration.maxCount = 1;//最大的选择数目
  272. }
  273. photoController.configuration.containVideo = NO;//选择类型,目前只选择图片不选择视频
  274. photoController.photo_delegate = self;
  275. photoController.thumbnailSize = CGSizeMake(320, 320);//缩略图的尺寸
  276. // photoController.defaultIdentifers = self.saveAssetIds;//记录已经选择过的资源
  277. [self presentViewController:photoController animated:YES completion:nil];
  278. self.maxImageCount = self.maxImageCount - (int)[_images count];
  279. self.isUpdateImage = NO;
  280. [self pickImages:YES];
  281. }else {
  282. JXCameraVC *vc = [JXCameraVC alloc];
  283. vc.cameraDelegate = self;
  284. vc.isVideo = NO;
  285. vc = [vc init];
  286. [self presentViewController:vc animated:YES completion:nil];
  287. //将sourceType设为UIImagePickerControllerSourceTypeCamera代表拍照或拍视频
  288. // _picker.sourceType=UIImagePickerControllerSourceTypeCamera;
  289. //
  290. // //设置拍摄照片
  291. //
  292. // _picker.cameraCaptureMode=UIImagePickerControllerCameraCaptureModePhoto;
  293. //
  294. // //设置使用手机的后置摄像头(默认使用后置摄像头)
  295. //
  296. // _picker.cameraDevice=UIImagePickerControllerCameraDeviceRear;
  297. //
  298. // //设置使用手机的前置摄像头。
  299. //
  300. // //picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
  301. //
  302. // //设置拍摄的照片允许编辑
  303. //
  304. // _picker.allowsEditing=YES;
  305. //
  306. //
  307. // //显示picker视图控制器
  308. //
  309. // [self presentViewController:_picker animated:YES completion:nil];
  310. }
  311. }
  312. - (void)cameraVC:(JXCameraVC *)vc didFinishWithImage:(UIImage *)image {
  313. [_images addObject:image];
  314. [self showImages];
  315. }
  316. - (void)cameraVC:(JXCameraVC *)vc didFinishWithVideoPath:(NSString *)filePath timeLen:(NSInteger)timeLen {
  317. [_images removeAllObjects];
  318. JXMediaObject* media = [[JXMediaObject alloc] init];
  319. media.userId = MY_USER_ID;
  320. media.fileName = filePath;
  321. media.isVideo = [NSNumber numberWithBool:YES];
  322. media.timeLen = [NSNumber numberWithInteger:timeLen];
  323. media.createTime = [NSDate date];
  324. // media.photoPath = filePath.absoluteString;
  325. [media insert];
  326. NSString* file = media.fileName;
  327. UIImage *image = [FileInfo getFirstImageFromVideo:file];
  328. // videoFile = [file copy];
  329. // // file = [NSString stringWithFormat:@"%@.jpg",[file stringByDeletingPathExtension]];
  330. // // [_images addObject:[UIImage imageWithContentsOfFile:file]];
  331. // [_images addObject:image];
  332. //
  333. // JXSelectCoverVC *Vc = [[JXSelectCoverVC alloc] initWithVideo:videoFile];
  334. // Vc.delegate = self;
  335. // [g_navigation pushViewController:Vc animated:YES];
  336. //
  337. // [self showVideos];
  338. }
  339. #pragma mark - 发送原图
  340. - (void)photosViewController:(UIViewController *)viewController images:(NSArray<UIImage *> *)images infos:(NSArray<NSDictionary *> *)infos {
  341. if (self.isUpdateImage) {
  342. _images[_photoIndex] = images.firstObject;
  343. }else {
  344. [_images addObjectsFromArray:images.mutableCopy];
  345. }
  346. self.gifDataDic = nil;
  347. self.gifDataDic = [NSMutableDictionary dictionary];
  348. for (int i = 0; i < images.count; i++) {
  349. UIImage *image = images[i];
  350. if (image.images.count > 0) {
  351. NSDictionary *dic = [infos objectAtIndex:i];
  352. NSData *data = [dic objectForKey:@"gifData"];
  353. [self.gifDataDic setValue:data forKey:[NSString stringWithFormat:@"%d",i]];
  354. }
  355. }
  356. [self showImages];
  357. }
  358. #pragma mark - 发送缩略图
  359. - (void)photosViewController:(UIViewController *)viewController thumbnailImages:(NSArray *)thumbnailImages infos:(NSArray<NSDictionary *> *)infos {
  360. if (self.isUpdateImage) {
  361. _images[_photoIndex] = thumbnailImages.firstObject;
  362. }else {
  363. [_images addObjectsFromArray:thumbnailImages.mutableCopy];
  364. }
  365. [self showImages];
  366. }
  367. - (void)getTouchWhenMove:(JXImageView *)imageView withTouch:(NSSet *)touch withEvent:(UIEvent *)event withLongPressGes:(UILongPressGestureRecognizer *)lpGes{
  368. UITouch *mytouch = touch.allObjects.lastObject;
  369. CGPoint inWindow = [mytouch locationInView:nil];
  370. if ((inWindow.x > JX_SCREEN_WIDTH - 30 && inWindow.x < JX_SCREEN_WIDTH && svImages.contentOffset.x == 0) || (inWindow.x < 30 && svImages.contentOffset.x > 0)) {
  371. if (_inBorder) {
  372. _stayBorderTime = mytouch.timestamp - _intoBorderTime;
  373. if (_stayBorderTime > 0.3) {
  374. [self changeWhenPan:imageView gesture:lpGes];
  375. }
  376. }else{
  377. _inBorder = YES;
  378. _intoBorderTime = mytouch.timestamp;
  379. }
  380. }else{
  381. _inBorder = NO;
  382. _intoBorderTime = 0;
  383. }
  384. }
  385. - (void)changeWhenPan:(JXImageView *)sender gesture:(UILongPressGestureRecognizer *)sender2{
  386. BOOL isBorderStart = NO;
  387. if (sender2.state == UIGestureRecognizerStateBegan) {
  388. [svImages setScrollEnabled:NO];
  389. sender.alpha = 0.5;
  390. self.startPoint = [sender2 locationInView:svImages];
  391. CGPoint inWindow = [sender2 locationInView:nil];
  392. if ((inWindow.x > JX_SCREEN_WIDTH - 30 && inWindow.x < JX_SCREEN_WIDTH && svImages.contentOffset.x == 0) || (inWindow.x < 30 && svImages.contentOffset.x > 0)) {
  393. isBorderStart = YES;
  394. }else{
  395. isBorderStart = NO;
  396. }
  397. self.oraginPoint = sender.center;
  398. _lastPoint = _oraginPoint;
  399. [self.view bringSubviewToFront:svImages];
  400. [svImages bringSubviewToFront:sender];
  401. }else if (sender2.state == UIGestureRecognizerStateChanged) {
  402. self.newPoint = [sender2 locationInView:svImages];
  403. CGFloat xChange = _newPoint.x - _startPoint.x;
  404. CGFloat yChange = _newPoint.y - _startPoint.y;
  405. sender.center = CGPointMake(_oraginPoint.x + xChange, _oraginPoint.y + yChange);
  406. CGPoint inWindow = [sender2 locationInView:nil];
  407. if (isBorderStart) {
  408. if ((inWindow.x < JX_SCREEN_WIDTH - 30 && svImages.contentOffset.x == 0) && (inWindow.x > 30 && svImages.contentOffset.x > 0)){
  409. isBorderStart = NO;
  410. }
  411. }
  412. if (inWindow.x < 30 && svImages.contentOffset.x > 0 && !isBorderStart && _stayBorderTime > 0.3) {
  413. for (int num = 0; num <_imageViewArray.count; num++) {
  414. JXImageView *imgView = _imageViewArray[num];
  415. if (imgView.tag != num) {
  416. [_imageViewArray exchangeObjectAtIndex:num withObjectAtIndex:imgView.tag];
  417. }
  418. }
  419. [UIView animateWithDuration:0.3 animations:^{
  420. [svImages setContentOffset:CGPointMake(0, 0)];
  421. }];
  422. _stayBorderTime = 0;
  423. _inBorder = NO;
  424. NSInteger index = sender.tag;
  425. for (NSInteger i = index - 1; i > -1; i--) {
  426. JXImageView *imgView = _imageViewArray[i];
  427. [_images exchangeObjectAtIndex:imgView.tag withObjectAtIndex:imgView.tag + 1];
  428. [UIView animateWithDuration:0.5 animations:^{
  429. imgView.tag = imgView.tag + 1;
  430. CGPoint center = imgView.center;
  431. imgView.center = _lastPoint;
  432. _lastPoint = center;
  433. }];
  434. }
  435. sender.tag = 0;
  436. }else if (inWindow.x > g_window.frame.size.width - 30 && _newPoint.x < svImages.contentSize.width && !isBorderStart && _stayBorderTime > 0.3) {
  437. for (int num = 0; num <_imageViewArray.count; num++) {
  438. JXImageView *imgView = _imageViewArray[num];
  439. if (imgView.tag != num) {
  440. [_imageViewArray exchangeObjectAtIndex:num withObjectAtIndex:imgView.tag];
  441. }
  442. }
  443. [UIView animateWithDuration:0.3 animations:^{
  444. [svImages setContentOffset:CGPointMake(svImages.contentSize.width - JX_SCREEN_WIDTH, 0)];
  445. }];
  446. _stayBorderTime = 0;
  447. _inBorder = NO;
  448. NSInteger index = sender.tag;
  449. for (NSInteger i = index + 1; i < _imageViewArray.count; i++) {
  450. JXImageView *imgView = _imageViewArray[i];
  451. [_images exchangeObjectAtIndex:imgView.tag withObjectAtIndex:imgView.tag - 1];
  452. [UIView animateWithDuration:0.5 animations:^{
  453. imgView.tag = imgView.tag - 1;
  454. CGPoint center = imgView.center;
  455. imgView.center = _lastPoint;
  456. _lastPoint = center;
  457. }];
  458. }
  459. sender.tag = _imageViewArray.count - 1;
  460. }else{
  461. for (int num = 0; num <_imageViewArray.count; num++) {
  462. JXImageView *imgView = _imageViewArray[num];
  463. if (imgView.tag != num) {
  464. [_imageViewArray exchangeObjectAtIndex:num withObjectAtIndex:imgView.tag];
  465. }
  466. }
  467. for (NSInteger i = 0;i < _imageViewArray.count; i++) {
  468. JXImageView * imgView = _imageViewArray[i];
  469. if (CGRectContainsPoint(imgView.frame, _newPoint)) {
  470. if (imgView == sender) {
  471. continue;
  472. }
  473. [UIView animateWithDuration:0.3 animations:^{
  474. CGPoint point = imgView.center;
  475. imgView.center = _lastPoint;
  476. _lastPoint = point;
  477. }];
  478. [_images exchangeObjectAtIndex:imgView.tag withObjectAtIndex:sender.tag];
  479. NSInteger l = imgView.tag;
  480. imgView.tag = sender.tag;
  481. sender.tag = l;
  482. }
  483. }
  484. if (!CGRectContainsPoint(svImages.bounds, _newPoint)) {
  485. [sender2 setState:UIGestureRecognizerStateEnded];
  486. }
  487. }
  488. }else if(sender2.state == UIGestureRecognizerStateEnded) {
  489. sender.alpha = 1;
  490. [UIView animateWithDuration:0.3 animations:^{
  491. sender.center = _lastPoint;
  492. }];
  493. [svImages setScrollEnabled:YES];
  494. }
  495. }
  496. /**
  497. * 提交
  498. */
  499. - (IBAction)tijiaoBtn:(id)sender {
  500. if (_strURL.name.length==0) {
  501. [SVProgressHUD showWithStatus:@"请选择您的反馈类型"];
  502. [SVProgressHUD dismissWithDelay:1.0];
  503. return;
  504. }
  505. [SVProgressHUD show];
  506. if(_images.count){
  507. [g_server uploadFile:_images audio:@"" video:@"" file:@"fileFile" type:2+1 validTime:@"-1" timeLen:0 toView:self gifDic:self.gifDataDic];
  508. }else{
  509. JXMyModel *model=_strURL;
  510. long time = (long)[[NSDate date] timeIntervalSince1970];
  511. time = (time *1000 + g_server.timeDifference);
  512. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  513. [g_server getMyFeedSubmit:salt type:model.id desc:_textView.text img:@"" targetUserId:g_server.myself.userId andToView:self];
  514. }
  515. }
  516. #pragma mark --- 请求成功
  517. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  518. [SVProgressHUD dismiss];
  519. //NSLog(@"dict: %@ --- arry: %@",dict ,array1 );
  520. if([aDownload.action isEqualToString:act_usermyfeedbacktypes])
  521. {
  522. _dataArr=[JXMyModel mj_objectArrayWithKeyValuesArray:array1];
  523. [_tableView reloadData];
  524. if (_dataArr.count>0) {
  525. [_tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
  526. }
  527. }
  528. else if([aDownload.action isEqualToString:act_feedbacksubmit])
  529. {
  530. _feedShowView.hidden=NO;
  531. }
  532. else if([aDownload.action isEqualToString:act_UploadFile]) //上传图片
  533. {
  534. NSDictionary *dataD;
  535. NSMutableArray *array = [NSMutableArray arrayWithArray:[dict objectForKey:@"images"]];
  536. dataD = dict;
  537. NSMutableString *stringM=[NSMutableString string];
  538. [array enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  539. [stringM appendFormat:@",%@",obj[@"tUrl"]];
  540. }];
  541. [stringM deleteCharactersInRange:NSMakeRange(0,1)];
  542. // [g_server addMessage:@"text" type:3 data:dataD flag:3 visible:_visible lookArray:@[] coor:_coor location:nil remindArray:@[] lable:[UILabel new] isAllowComment:YES toView:self];
  543. JXMyModel *model=_strURL;
  544. long time = (long)[[NSDate date] timeIntervalSince1970];
  545. time = (time *1000 + g_server.timeDifference);
  546. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  547. [g_server getMyFeedSubmit:salt type:model.id desc:_textView.text img:[stringM copy] targetUserId:g_server.myself.userId andToView:self];
  548. }
  549. }
  550. - (NSString *)getNumberFromStr:(NSString *)str
  551. {
  552. NSCharacterSet *nonDigitCharacterSet = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
  553. return[[str componentsSeparatedByCharactersInSet:nonDigitCharacterSet] componentsJoinedByString:@""];
  554. }
  555. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  556. [SVProgressHUD dismiss];
  557. NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]];
  558. if([errorCode isEqualToString:@"权限验证失败"])
  559. {
  560. if ([aDownload.action isEqualToString:act_GetBalanceRedTimes])
  561. {
  562. }else{
  563. }
  564. }
  565. return [errorCode intValue];
  566. }
  567. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  568. return _dataArr.count;
  569. }
  570. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  571. JXMyFeedCell *cell=[JXMyFeedCell cellWithTableView:tableView];
  572. JXMyModel *nameStr=_dataArr[indexPath.row];
  573. _strURL=[_dataArr firstObject];
  574. cell.model=nameStr;
  575. return cell;
  576. }
  577. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  578. JXMyModel *nameStr=_dataArr[indexPath.row];
  579. _strURL=nameStr;
  580. }
  581. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  582. [self.view endEditing:YES];
  583. }
  584. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  585. [self.view endEditing:YES];
  586. }
  587. // 键盘监听事件
  588. - (void)keyboardAction:(NSNotification*)sender{
  589. // 通过通知对象获取键盘frame: [value CGRectValue]
  590. NSDictionary *useInfo = [sender userInfo];
  591. NSValue *value = [useInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
  592. if([sender.name isEqualToString:UIKeyboardWillShowNotification]){
  593. int aa = [value CGRectValue].size.height;
  594. self.view.xmg_y=-120;
  595. }else{
  596. self.view.xmg_y=0;
  597. //self.view.frame = CGRectMake(0, 44, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-JX_SCREEN_TOP-44);
  598. }
  599. }
  600. @end