YOUPAILCSendImageDynamicVC.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. //
  2. // YOUPAILCSendImageDynamicVC.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/9/6.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCSendImageDynamicVC.h"
  9. #import "TZImagePickerController.h"
  10. #import "YOUPAILCImageCollectionCell.h"
  11. #import "YOUPAILCImageDeleteView.h"
  12. #import "UIViewController+TFPresent.h"
  13. #import "LZAlertWindow.h"
  14. #import "YOUPAILPChatTipView.h"
  15. #import "YOUPAILZTextView.h"
  16. @interface YOUPAILCSendImageDynamicVC () <UICollectionViewDelegate,UICollectionViewDataSource,TZImagePickerControllerDelegate,UIGestureRecognizerDelegate,UIScrollViewDelegate>
  17. @property (nonatomic, strong) NSMutableArray *youpaipcellAttributesArray;
  18. @property (nonatomic, assign) CGPoint youpaiplastPressPoint;
  19. @property(nonatomic,strong)UIScrollView* youpaipscrollView;
  20. @property (nonatomic,strong)UICollectionView *youpaipcollectionView;
  21. @property (nonatomic,strong)YOUPAILZTextView* youpaipliveView;
  22. @property(nonatomic,strong)YOUPAILCImageDeleteView* youpaipdeleteView;
  23. @property(nonatomic,strong)UIButton *youpaipsendImageDynamicBtn;//发布动态
  24. @end
  25. @implementation YOUPAILCSendImageDynamicVC
  26. - (YOUPAILCImageDeleteView*)youpaipdeleteView{
  27. if (!_youpaipdeleteView) {
  28. _youpaipdeleteView = [[YOUPAILCImageDeleteView alloc]initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, 50)];
  29. [self.view addSubview:_youpaipdeleteView];
  30. }
  31. return _youpaipdeleteView;
  32. }
  33. - (NSMutableArray *)youpaipcellAttributesArray{
  34. if (!_youpaipcellAttributesArray) {
  35. self.youpaipcellAttributesArray = [NSMutableArray arrayWithCapacity:0];
  36. }
  37. return _youpaipcellAttributesArray;
  38. }
  39. - (void)viewWillAppear:(BOOL)animated{
  40. [super viewWillAppear:animated];
  41. // [self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:LCBkgColor size:CGSizeMake(KScreenWidth, 0.0)]];
  42. // [self youpaifaddTip];
  43. }
  44. - (void)youpaifaddTip{
  45. NSString *tip = @"请勿涉及色情,广告等违规内容,违者将永久封号";
  46. YOUPAILPChatTipView* chatTip = [[YOUPAILPChatTipView alloc]initWithFrame:CGRectMake(0,NavBarHeight-40, KScreenWidth, 40)];
  47. chatTip.tipLabel.text = tip;
  48. [self.view addSubview:chatTip];
  49. [UIView animateWithDuration:1 animations:^{
  50. chatTip.frame = CGRectMake(0,NavBarHeight, KScreenWidth, 40);
  51. }completion:^(BOOL finished) {
  52. if (finished) {
  53. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  54. [UIView animateWithDuration:1 animations:^{
  55. chatTip.frame = CGRectMake(0,NavBarHeight-40, KScreenWidth, 40);
  56. }completion:^(BOOL finished) {
  57. if (finished) {
  58. [chatTip removeFromSuperview];
  59. }
  60. }];
  61. });
  62. }
  63. }];
  64. }
  65. - (void)viewWillDisappear:(BOOL)animated{
  66. [super viewWillDisappear:animated];
  67. [self.navigationController.navigationBar setShadowImage:nil];
  68. }
  69. - (void)viewDidLoad {
  70. [super viewDidLoad];
  71. self.title = @"发布动态";
  72. self.sx_disableInteractivePop = YES;
  73. // self.view.backgroundColor = [UIColor whiteColor];
  74. [self youpaifrightClick];
  75. // self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifcancelClick) title:@"取消" font:LCFont15 titleColor:LCTextGray highlightedColor:LCTextGray titleEdgeInsets:UIEdgeInsetsZero];
  76. // self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifsendClick) title:@"发布" font:LCFont15 titleColor:LCBlueColor highlightedColor:LCBlueColorHighit titleEdgeInsets:UIEdgeInsetsZero];
  77. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifcancelClick) image:[UIImage imageNamed:@"vqu_images_navigation_back_black"]];
  78. UIButton *rightBgV = [UIButton buttonWithType:UIButtonTypeCustom];
  79. rightBgV.frame = CGRectMake(0, 0, 44.0f, 44.0f);
  80. [rightBgV addTarget:self action:@selector(youpaifrightClick) forControlEvents:UIControlEventTouchUpInside];
  81. UIImageView *rightImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_D_senddynamic_right"]];
  82. rightImgV.frame = CGRectMake(44.0f - 16.0f, (44.0f - 16.0f) / 2.0f, 16.0f, 16.0f);
  83. [rightBgV addSubview:rightImgV];
  84. UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithCustomView:rightBgV];
  85. self.navigationItem.rightBarButtonItem = rightBarItem;//[UIBarButtonItem itemWithTarget:self action:@selector(youpaifrightClick) image:[UIImage imageNamed:@"ic_senddynamic_right"]];
  86. UIButton* btn = (UIButton*)self.navigationItem.rightBarButtonItem.customView;
  87. btn.uxy_acceptEventInterval = 3.0;
  88. [self youpaifsetupView];
  89. self.youpaipliveView.youpaiptextView.text = self.youpaipsendModel.youpaiptit;
  90. [self.youpaipcollectionView reloadData];
  91. [self youpaifupdateFrame];
  92. // self.liveView.textView.delegate = self;
  93. // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifhideTheKeyboard)];
  94. // [self.navigationController.navigationBar addGestureRecognizer:tap];
  95. }
  96. - (void)youpaifsetupView{
  97. UIScrollView* scrollV = [[UIScrollView alloc]initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight)];
  98. scrollV.backgroundColor = [UIColor whiteColor];
  99. scrollV.delegate = self;
  100. scrollV.contentSize = CGSizeMake(KScreenWidth, KScreenHeight-NavBarHeight+1);
  101. self.youpaipscrollView = scrollV;
  102. [self.view addSubview:scrollV];
  103. YOUPAILZTextView *textView = [[YOUPAILZTextView alloc] initWithMaxCount:140];
  104. textView.frame = CGRectMake(14.0f, 25.0f, KScreenWidth-28, 148.0f);
  105. textView.youpaiptextViewPadding = UIEdgeInsetsMake(14.0f, 14.0f, 10.0f, 14.0f);
  106. textView.youpaiptextLengthDefaultColor = LZD3D1D7Color;
  107. textView.youpaiptextLengthHigtColor = LZ7C69FEColor;
  108. textView.youpaiptextLengthFont = LCFont(14.0f);
  109. textView.youpaiptextLengthRight = 14.0f;
  110. textView.youpaiptextLengthBottom = 14.0f;
  111. textView.youpaiptextView.placeholderFont = LCFont(14.0f);
  112. textView.youpaiptextView.placeholderTextColor = LZD3D1D7Color;
  113. textView.youpaiptextView.placeholderText = @"这一刻你想说点什么…";
  114. textView.youpaiptextView.font = LCFont(14.0f);
  115. textView.layer.cornerRadius = 5.0f;
  116. textView.clipsToBounds = YES;
  117. textView.tintColor = LZ7C69FEColor;
  118. [self.youpaipscrollView addSubview:textView];
  119. textView.youpaiptextView.textColor = LZ273145Color;
  120. self.youpaipliveView = textView;
  121. textView.backgroundColor = LZF7F8FAColor;
  122. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  123. CGFloat margin = 5;
  124. CGFloat itemWH = (KScreenWidth-40)/3.0;
  125. layout.scrollDirection = UICollectionViewScrollDirectionVertical;
  126. layout.itemSize = CGSizeMake(itemWH, itemWH);
  127. layout.minimumInteritemSpacing = margin;
  128. layout.minimumLineSpacing = margin;
  129. _youpaipcollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(14, CGRectGetMaxY(textView.frame) + 14.0f, KScreenWidth-28, itemWH+5) collectionViewLayout:layout];
  130. _youpaipcollectionView.backgroundColor = [UIColor clearColor];
  131. _youpaipcollectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
  132. _youpaipcollectionView.layer.masksToBounds = NO;
  133. _youpaipcollectionView.dataSource = self;
  134. _youpaipcollectionView.delegate = self;
  135. _youpaipcollectionView.scrollEnabled = NO;
  136. [_youpaipcollectionView registerClass:[YOUPAILCImageCollectionCell class] forCellWithReuseIdentifier:@"YOUPAILCImageCollectionCell"];
  137. [scrollV addSubview:_youpaipcollectionView];
  138. self.youpaipsendImageDynamicBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  139. self.youpaipsendImageDynamicBtn.frame = CGRectMake(40,KScreenHeight-NavBarHeight-48-SafeHeight-45,KScreenWidth - 80,48);
  140. [self.youpaipsendImageDynamicBtn setTitle:@"发布动态" forState:0];
  141. [self.youpaipsendImageDynamicBtn setTitleColor:HexColorFromRGB(0x000000) forState:0];
  142. self.youpaipsendImageDynamicBtn.titleLabel.font = LCFont(17);
  143. self.youpaipsendImageDynamicBtn.layer.cornerRadius = 24;
  144. self.youpaipsendImageDynamicBtn.layer.masksToBounds = YES;
  145. [self.youpaipsendImageDynamicBtn addTarget:self action:@selector(youpaifsendClick) forControlEvents:UIControlEventTouchUpInside];
  146. [self.youpaipsendImageDynamicBtn setBackgroundImage:[LCTools ColorImage:self.youpaipsendImageDynamicBtn.frame.size FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)];
  147. [scrollV addSubview:self.youpaipsendImageDynamicBtn];
  148. }
  149. #pragma mark UICollectionView
  150. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  151. if (self.youpaipsendModel.youpaipimages.count==9) {
  152. return self.youpaipsendModel.youpaipimages.count;
  153. }else{
  154. return self.youpaipsendModel.youpaipimages.count+1;
  155. }
  156. }
  157. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  158. YOUPAILCImageCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"YOUPAILCImageCollectionCell" forIndexPath:indexPath];
  159. cell.backgroundColor = [UIColor clearColor];
  160. cell.layer.cornerRadius = 4.0f;
  161. cell.clipsToBounds = YES;
  162. cell.youpaipindexPath = indexPath;
  163. WeakSelf;
  164. [cell setClickRemoveBtnBlock:^(NSIndexPath *indexPath) {
  165. if (weakSelf.youpaipsendModel.youpaipimages.count>indexPath.item) {
  166. [weakSelf.youpaipsendModel.youpaipimages removeObjectAtIndex:indexPath.item];
  167. }
  168. [weakSelf.youpaipcollectionView reloadData];
  169. }];
  170. if (self.youpaipsendModel.youpaipimages.count==9) {
  171. UIImage* image = self.youpaipsendModel.youpaipimages[indexPath.item];
  172. cell.youpaipimageView.image = image ;
  173. UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(youpaiflongPressGesture:)];
  174. [cell addGestureRecognizer:longPress];
  175. cell.youpaipremoveBtn.hidden = NO;
  176. return cell;
  177. }else{
  178. if (indexPath.row==self.youpaipsendModel.youpaipimages.count) {
  179. cell.youpaipimageView.image = [UIImage imageNamed:@"vqu_images_D_dynamic_add"];
  180. cell.youpaipremoveBtn.hidden = YES;
  181. }else{
  182. cell.youpaipremoveBtn.hidden = NO;
  183. UIImage* image = self.youpaipsendModel.youpaipimages[indexPath.item];
  184. cell.youpaipimageView.image = image ;
  185. UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(youpaiflongPressGesture:)];
  186. [cell addGestureRecognizer:longPress];
  187. return cell;
  188. }
  189. }
  190. return cell;
  191. }
  192. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  193. if (self.youpaipsendModel.youpaipimages.count==9) {
  194. [self youpaifshowBigWithIndex:indexPath.item];
  195. }else{
  196. if (indexPath.row==self.youpaipsendModel.youpaipimages.count) {
  197. [self youpaifaddPhotos];
  198. }else{
  199. [self youpaifshowBigWithIndex:indexPath.item];
  200. }
  201. }
  202. }
  203. - (void)youpaifshowBigWithIndex:(NSInteger)index{
  204. NSMutableArray *tempArr = [NSMutableArray array];
  205. for (int i=0; i<self.youpaipsendModel.youpaipimages.count; i++) {
  206. @weakify(self);
  207. YBIBImageData *model = [YBIBImageData new];
  208. [model setImage:^UIImage * _Nullable{
  209. @strongify(self);
  210. return self.youpaipsendModel.youpaipimages[i];
  211. }];
  212. YOUPAILCImageCollectionCell *tmpCell = (YOUPAILCImageCollectionCell*)[self.youpaipcollectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
  213. model.projectiveView = tmpCell.youpaipimageView ;
  214. [tempArr addObject:model];
  215. }
  216. YBImageBrowser *browser = [YBImageBrowser new];
  217. browser.dataSourceArray = tempArr;
  218. browser.currentPage = index;
  219. [browser show];
  220. }
  221. - (void)youpaiflongPressGesture:(UILongPressGestureRecognizer *)sender{
  222. YOUPAILCImageCollectionCell *cell = (YOUPAILCImageCollectionCell *)sender.view;
  223. NSIndexPath *cellIndexPath = [self.youpaipcollectionView indexPathForCell:cell];
  224. cell.transform = CGAffineTransformMakeScale(1.1, 1.1);
  225. [self.youpaipcollectionView bringSubviewToFront:cell];
  226. BOOL isChanged = NO;
  227. if (sender.state == UIGestureRecognizerStateBegan) {
  228. [self.youpaipcellAttributesArray removeAllObjects];
  229. for (int i = 0;i< self.youpaipsendModel.youpaipimages.count; i++) {
  230. [self.youpaipcellAttributesArray addObject:[self.youpaipcollectionView layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]]];
  231. }
  232. self.youpaiplastPressPoint = [sender locationInView:self.youpaipcollectionView];
  233. }else if (sender.state == UIGestureRecognizerStateChanged){
  234. cell.center = [sender locationInView:self.youpaipcollectionView];
  235. if (cell.center.y-10>self.youpaiplastPressPoint.y) {
  236. [UIView animateWithDuration:0.25 animations:^{
  237. self.youpaipdeleteView.frame = CGRectMake(0, KScreenHeight-50, KScreenWidth, 50);
  238. }];
  239. }
  240. for (UICollectionViewLayoutAttributes *attributes in self.youpaipcellAttributesArray) {
  241. if (CGRectContainsPoint(attributes.frame, cell.center) && cellIndexPath != attributes.indexPath ) {
  242. isChanged = YES;
  243. //对数组中存放的元素重新排序
  244. UIImage *tmpImage = self.youpaipsendModel.youpaipimages[cellIndexPath.row];
  245. [self.youpaipsendModel.youpaipimages removeObjectAtIndex:cellIndexPath.row];
  246. [self.youpaipsendModel.youpaipimages insertObject:tmpImage atIndex:attributes.indexPath.row];
  247. [self.self.youpaipcollectionView moveItemAtIndexPath:cellIndexPath toIndexPath:attributes.indexPath];
  248. }
  249. }
  250. CGPoint viewPoint = [sender locationInView:self.view];
  251. if (viewPoint.y>=KScreenHeight-50) {
  252. self.youpaipdeleteView.youpaipstatu = 2;
  253. }else{
  254. self.youpaipdeleteView.youpaipstatu = 1;
  255. }
  256. }else if (sender.state == UIGestureRecognizerStateEnded) {
  257. if (!isChanged) {
  258. cell.center = [self.youpaipcollectionView layoutAttributesForItemAtIndexPath:cellIndexPath].center;
  259. }
  260. cell.transform = CGAffineTransformIdentity;
  261. if (self.youpaipdeleteView.youpaipstatu==2) {
  262. if (self.youpaipsendModel.youpaipimages.count>cell.youpaipitem) {
  263. [self.youpaipsendModel.youpaipimages removeObjectAtIndex:cell.youpaipitem];
  264. }
  265. [self.youpaipcollectionView reloadData];
  266. }
  267. [UIView animateWithDuration:0.25 animations:^{
  268. self.youpaipdeleteView.frame = CGRectMake(0, KScreenHeight, KScreenWidth, 50);
  269. } completion:nil];
  270. }
  271. }
  272. - (void)youpaifaddPhotos{
  273. TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9-self.youpaipsendModel.youpaipimages.count columnNumber:4 delegate:nil];
  274. [LCTZImageConfigHelper setDefaultTZImageConfig:imagePickerVc];
  275. imagePickerVc.allowTakePicture = YES; // 在内部显示拍照按钮
  276. imagePickerVc.allowPickingVideo = NO;//是否允许选择视频
  277. imagePickerVc.allowPickingImage = YES;//是否允许选择照片
  278. imagePickerVc.allowPickingOriginalPhoto = YES;//是否选择原图
  279. imagePickerVc.showSelectedIndex = YES; //显示图片序号
  280. // 4. 照片排列按修改时间升序
  281. imagePickerVc.sortAscendingByModificationDate = YES;//按时间倒序排列图片
  282. // 你可以通过block或者代理,来得到用户选择的照片.
  283. [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  284. for (int i =0 ; i<photos.count; i++) {
  285. UIImage* image = photos[i];
  286. [self.youpaipsendModel.youpaipimages addObject:image];
  287. }
  288. [self.youpaipcollectionView reloadData];
  289. [self youpaifupdateFrame];
  290. }];
  291. [self presentViewController:imagePickerVc animated:YES completion:nil];
  292. }
  293. - (void)youpaifupdateFrame{
  294. CGFloat itemWH = (KScreenWidth-40)/3.0;
  295. if (self.youpaipsendModel.youpaipimages.count==9) {
  296. self.youpaipcollectionView.frame = CGRectMake(14, self.youpaipcollectionView.mj_y, KScreenWidth-28, (itemWH+5)*(int)ceilf(self.youpaipsendModel.youpaipimages.count/3.0));
  297. }else{
  298. self.youpaipcollectionView.frame = CGRectMake(14, self.youpaipcollectionView.mj_y, KScreenWidth-28, (itemWH+5)*(int)ceilf((self.youpaipsendModel.youpaipimages.count+1)/3.0));
  299. }
  300. if (CGRectGetMaxY(self.youpaipcollectionView.frame)>KScreenHeight-NavBarHeight) {
  301. self.youpaipscrollView.contentSize = CGSizeMake(KScreenWidth, CGRectGetMaxY(self.youpaipcollectionView.frame));
  302. }else{
  303. self.youpaipscrollView.contentSize = CGSizeMake(KScreenWidth, KScreenHeight-NavBarHeight+1);
  304. }
  305. }
  306. - (void)youpaifcancelClick{
  307. self.youpaipsendModel.youpaiptit = self.youpaipliveView.youpaiptextView.text;
  308. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"要保存草稿吗?" preferredStyle:UIAlertControllerStyleAlert];
  309. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"放弃" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
  310. [LCSaveModel saveSendDynamicModel:nil];
  311. [self popEffectDismiss];
  312. }];
  313. UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"保存" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
  314. [LCSaveModel saveSendDynamicModel:self.youpaipsendModel];
  315. [self popEffectDismiss];
  316. }];
  317. [alertController addAction:cancelAction];
  318. [alertController addAction:okAction];
  319. [self presentViewController:alertController animated:YES completion:nil];
  320. }
  321. //提示
  322. -(void)youpaifrightClick
  323. {
  324. LZAlertAction *action = [LZAlertAction actionWithTitle:@"我知道了" handler:^(LZAlertAction *action) {
  325. }];
  326. action.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 128.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]];
  327. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"发布须知" content:@"1、禁止发布色情,性暗示等低俗内容;\n\n2、禁止发布国家政治,暴恐暴乱等内容;\n\n3、不可涉及第三方平台信息;\n\n4、不可使用他人的图片或视频发布。" action:@[action]];
  328. alert.contentFont = LCFont16;
  329. alert.contentHorizontalSpace = 32.0f;
  330. [self TFPresentVC:alert completion:^{}];
  331. }
  332. - (void)youpaifsendClick{
  333. self.youpaipsendModel.youpaiptit = self.youpaipliveView.youpaiptextView.text;
  334. if (self.youpaipsendModel.youpaiptit.length>0 && self.youpaipsendModel.youpaipimages.count>0) {
  335. [LCHttpHelper requestWithURLString:DynamicPub parameters:@{@"content":self.youpaipsendModel.youpaiptit} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  336. NSDictionary* dict = (NSDictionary*)responseObject;
  337. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  338. if (code==0) {
  339. NSString* dynamicId = [[dict objectForKey:@"data"]objectForKey:@"dynamic_id"];
  340. [ZCHUDHelper show];
  341. [LCCommonHttp uploadWithImages:self.youpaipsendModel.youpaipimages Type:@"dynamic" successBlock:^(NSArray<NSString *> *ossImagePaths) {
  342. NSMutableString *string = [NSMutableString string];
  343. for (NSString *itemPath in ossImagePaths) {
  344. [string appendString:itemPath];
  345. [string appendString:@","];
  346. }
  347. NSRange range = NSMakeRange(string.length - 1, 1);
  348. [string deleteCharactersInRange:range];
  349. [LCHttpHelper requestWithURLString:DynamicUpdateImage parameters:@{@"type":@"0", @"images":string ,@"dynamic_id":dynamicId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  350. NSDictionary* dict = (NSDictionary*)responseObject;
  351. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  352. if (code==0) {
  353. [LCSaveModel saveSendDynamicModel:nil];
  354. }
  355. [ZCHUDHelper dismiss];
  356. [self popEffectDismiss];
  357. [ZCHUDHelper showTitle:@"发布视频成功,请等待客服审核" showtime:5];
  358. } failure:^(NSError *error) {
  359. [ZCHUDHelper dismiss];
  360. [self popEffectDismiss];
  361. }];
  362. }];
  363. }
  364. } failure:^(NSError *error) {
  365. }];
  366. }else{
  367. [ZCHUDHelper showTitle:@"照片和文字不能为空"];
  368. }
  369. }
  370. -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
  371. [self youpaifhideTheKeyboard];
  372. }
  373. //隐藏键盘
  374. -(void)youpaifhideTheKeyboard {
  375. dispatch_async(dispatch_get_main_queue(), ^{
  376. [self.youpaipliveView.youpaiptextView endEditing:YES];
  377. });
  378. }
  379. @end