commCell.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. //
  2. // commCell.m
  3. // yunbaolive
  4. //
  5. // Created by Boom on 2018/12/17.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "commCell.h"
  9. #import "commDetailCell.h"
  10. #import "detailmodel.h"
  11. #import "YBCenterVC.h"
  12. @interface commCell ()<detailDelegate>
  13. {
  14. UIView *topview;
  15. BOOL isLandScreen;
  16. }
  17. @property (nonatomic,strong) NSURL *anImgUrl;
  18. @end
  19. @implementation commCell{
  20. int page;
  21. }
  22. - (void)awakeFromNib {
  23. [super awakeFromNib];
  24. // Initialization code
  25. self.contentView.backgroundColor = [UIColor clearColor];
  26. page = 1;
  27. _authorL.text = YZMsg(@"作者");
  28. //长按
  29. UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
  30. [_replyTable addGestureRecognizer:longPress];
  31. }
  32. -(void)longPress:(UILongPressGestureRecognizer*)longPressGesture {
  33. if (_replyArray.count <= 0) {
  34. return;
  35. }
  36. if (_delegate && [_delegate respondsToSelector:@selector(longPressing)] && [_toolTextView isFirstResponder]) {
  37. [_delegate longPressing];
  38. return;
  39. }
  40. commDetailCell *cell;
  41. if (longPressGesture.state == UIGestureRecognizerStateBegan) {
  42. CGPoint point = [longPressGesture locationInView:_replyTable];
  43. NSIndexPath *currentIndexPath = [_replyTable indexPathForRowAtPoint:point];
  44. if (currentIndexPath) {
  45. cell = [_replyTable cellForRowAtIndexPath:currentIndexPath];
  46. }
  47. cell.longPressView.backgroundColor = RGB_COLOR(@"#ffffff", 0.1);
  48. [self showActionSheet:currentIndexPath model:cell.model];
  49. }
  50. if (longPressGesture.state == UIGestureRecognizerStateChanged || longPressGesture.state == UIGestureRecognizerStateEnded) {
  51. CGPoint point = [longPressGesture locationInView:_replyTable];
  52. NSIndexPath *currentIndexPath = [_replyTable indexPathForRowAtPoint:point];
  53. if (currentIndexPath) {
  54. cell = [_replyTable cellForRowAtIndexPath:currentIndexPath];
  55. }
  56. cell.longPressView.backgroundColor = UIColor.clearColor;
  57. }
  58. }
  59. -(void)showActionSheet:(NSIndexPath*)indexPath model:(detailmodel *)dModel{
  60. if ([[Config getOwnID] intValue]<=0 && self.comCellEvent) {
  61. self.comCellEvent();
  62. return;
  63. }
  64. NSDictionary *subdic = _replyArray[indexPath.row];
  65. NSDictionary *userinfo = [subdic valueForKey:@"userinfo"];
  66. BOOL isVoice = [dModel.isvoice boolValue];
  67. YBWeakSelf;
  68. RKActionSheet *sheet = [[RKActionSheet alloc]initWithTitle:@""];
  69. if (!isVoice) {
  70. [sheet addActionWithType:RKSheet_Default andTitle:YZMsg(@"复制") complete:^{
  71. dispatch_async(dispatch_get_main_queue(), ^{
  72. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  73. pasteboard.string = [NSString stringWithFormat:@"@%@:%@",dModel.user_nickname,dModel.content];
  74. [MBProgressHUD showPop:YZMsg(@"复制成功")];
  75. });
  76. }];
  77. }
  78. BOOL haveDel = NO;
  79. if ([_authorID isEqual:[Config getOwnID]] || [minstr([userinfo valueForKey:@"id"]) isEqual:[Config getOwnID]]) {
  80. haveDel = YES;
  81. [sheet addActionWithType:RKSheet_Default andTitle:YZMsg(@"删除") complete:^{
  82. [weakSelf delComments:subdic index:indexPath];
  83. }];
  84. }
  85. if (!isVoice || haveDel) {
  86. [sheet addActionWithType:RKSheet_Cancle andTitle:YZMsg(@"取消") complete:^{
  87. }];
  88. [sheet showSheet];
  89. }
  90. }
  91. #pragma mark - 删除评论接口
  92. -(void)delComments:(NSDictionary *)subdic index:(NSIndexPath *)indexPath{
  93. NSString *commentid = minstr([subdic valueForKey:@"id"]);
  94. NSDictionary *userinfo = [subdic valueForKey:@"userinfo"];
  95. NSString *commentUid = minstr([userinfo valueForKey:@"id"]);
  96. [MBProgressHUD showMessage:@""];
  97. [YBNetworking postWithUrl:@"Video.delComments" Dic:@{@"videoid":_videoid,@"commentid":commentid,@"commentuid":commentUid} Suc:^(int code, id info, NSString *msg) {
  98. [MBProgressHUD hideHUD];
  99. [MBProgressHUD showPop:msg];
  100. if (code == 0) {
  101. [self requestData:YES andBtn:_model.replyMoreBtn];
  102. }
  103. } Fail:^(id fail) {
  104. [MBProgressHUD hideHUD];
  105. }];
  106. }
  107. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  108. [super setSelected:selected animated:animated];
  109. // Configure the view for the selected state
  110. }
  111. -(void)setAuthorID:(NSString *)authorID {
  112. _authorID = authorID;
  113. }
  114. - (NSURL *)anImgUrl{
  115. if (!_anImgUrl) {
  116. _anImgUrl = [[NSBundle mainBundle] URLForResource:@"voice_pinglun" withExtension:@"gif"];
  117. }
  118. return _anImgUrl;
  119. }
  120. - (void)setModel:(commentModel *)model{
  121. _model = model;
  122. _authorL.hidden = YES;
  123. if ([_authorID isEqual:_model.ID]) {
  124. _authorL.hidden = NO;
  125. }
  126. if ([_model.isvoice isEqual:@"1"]) {
  127. _voiceViewHeight.constant = 20;
  128. _voiceView.hidden = NO;
  129. _animationView.hidden = YES;
  130. _animationView.yy_imageURL = self.anImgUrl;
  131. _voiceTimeL.text = [NSString stringWithFormat:@"%@\"",model.voiceTime];
  132. }else{
  133. _voiceViewHeight.constant = 0;
  134. _voiceView.hidden = YES;
  135. }
  136. NSLog(@"_replyArray=%@",_model.replyList);
  137. _replyArray = _model.replyList.mutableCopy;
  138. [_iconImgView sd_setImageWithURL:[NSURL URLWithString:_model.avatar_thumb]];
  139. _nameL.text = _model.user_nickname;
  140. // _contentL.text = _model.content;
  141. _zanNumL.text = _model.likes;
  142. if ([_model.islike isEqual:@"1"]) {
  143. [_zanBtn setImage:[UIImage imageNamed:@"likecomment-click"] forState:0];
  144. _zanNumL.textColor = Pink_Cor;
  145. }else{
  146. [_zanBtn setImage:[UIImage imageNamed:@"likecomment"] forState:0];
  147. _zanNumL.textColor = RGB_COLOR(@"#828282", 1);
  148. }
  149. //匹配表情文字
  150. NSArray *resultArr = [PublicObj machesWithPattern:emojiPattern andStr:_model.content];
  151. if (!resultArr) return;
  152. NSUInteger lengthDetail = 0;
  153. NSMutableAttributedString *attstr = [[NSMutableAttributedString alloc]initWithString:_model.content];
  154. //遍历所有的result 取出range
  155. for (NSTextCheckingResult *result in resultArr) {
  156. //取出图片名
  157. NSString *imageName = [_model.content substringWithRange:NSMakeRange(result.range.location, result.range.length)];
  158. if ([lagType isEqual:EN]) {
  159. if ([imageName isEqual:@"[互粉]"] ||
  160. [imageName isEqual:@"[关注]"] ||
  161. [imageName isEqual:@"[粉]"] ||
  162. [imageName isEqual:@"[给力]"]) {
  163. imageName = [imageName stringByAppendingFormat:@"_en"];
  164. }
  165. }
  166. NSLog(@"--------%@",imageName);
  167. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  168. UIImage *emojiImage = [UIImage imageNamed:imageName];
  169. NSAttributedString *imageString;
  170. if (emojiImage) {
  171. /*
  172. attach.image = emojiImage;
  173. attach.bounds = CGRectMake(0, -2, 15, 15);
  174. imageString = [NSAttributedString attributedStringWithAttachment:attach];
  175. */
  176. UIImageView *imageV = [[UIImageView alloc] init];
  177. imageV.frame = CGRectMake(0, -2, 15, 15);
  178. imageV.image = emojiImage;
  179. imageString = [NSAttributedString yy_attachmentStringWithContent:imageV contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(15, 15) alignToFont:_contentL.font alignment:YYTextVerticalAlignmentCenter];
  180. }else{
  181. imageString = [[NSMutableAttributedString alloc]initWithString:imageName];
  182. }
  183. //图片附件的文本长度是1
  184. NSLog(@"emoj===%zd===size-w:%f==size-h:%f",imageString.length,imageString.size.width,imageString.size.height);
  185. NSUInteger length = attstr.length;
  186. NSRange newRange = NSMakeRange(result.range.location - lengthDetail, result.range.length);
  187. [attstr replaceCharactersInRange:newRange withAttributedString:imageString];
  188. lengthDetail += length - attstr.length;
  189. }
  190. NSAttributedString *dateStr = [[NSAttributedString alloc]initWithString:[NSString stringWithFormat:@" %@",_model.datetime] attributes:@{NSForegroundColorAttributeName:RGB_COLOR(@"#969696", 1),NSFontAttributeName:[UIFont systemFontOfSize:11]}];
  191. [attstr appendAttributedString:dateStr];
  192. //不同字体居中对齐、基线偏移比率
  193. [attstr addAttribute:NSBaselineOffsetAttributeName value:@(0.36 * (14 - 11)) range:NSMakeRange(attstr.length - _model.datetime.length, _model.datetime.length)];
  194. //更新到label上
  195. [_replyTable reloadData];
  196. _contentL.textColor = UIColor.blackColor;
  197. _contentL.font = SYS_Font(15);
  198. _contentL.numberOfLines = 0;
  199. [attstr addAttribute:NSForegroundColorAttributeName value:UIColor.blackColor range:attstr.yy_rangeOfAll];
  200. //给被@加颜色
  201. NSData *mix_data = [_model.at_info dataUsingEncoding:NSUTF8StringEncoding];
  202. NSArray *atArray = [NSJSONSerialization JSONObjectWithData:mix_data options:NSJSONReadingAllowFragments error:nil];
  203. if (atArray.count>0) {
  204. //有@
  205. for (int i=0; i<atArray.count; i++) {
  206. NSDictionary *u_dic = atArray[i];
  207. NSString *uname = [NSString stringWithFormat:@"@%@",[u_dic valueForKey:@"name"]];
  208. if ([_model.content containsString:uname]) {
  209. NSRange uRang = [_model.content rangeOfString:uname];
  210. // [attstr addAttribute:NSForegroundColorAttributeName value:AtCol range:uRang];
  211. [attstr yy_setTextHighlightRange:uRang color:AtCol backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  212. NSLog(@"进入个人中心");
  213. YBCenterVC *center = [[YBCenterVC alloc]init];
  214. center.otherUid = minstr([u_dic valueForKey:@"uid"]);
  215. center.isPush = YES;
  216. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:center animated:YES];
  217. if (self.delegate && [self.delegate respondsToSelector:@selector(endEnterCenter)]) {
  218. [self.delegate endEnterCenter];
  219. }
  220. }];
  221. }
  222. }
  223. }
  224. _contentL.attributedText = attstr;
  225. if ([_model.replys intValue] > 0) {
  226. CGFloat HHHH = 0.0;
  227. for (NSDictionary *dic in _replyArray) {
  228. detailmodel *model = [[detailmodel alloc]initWithDic:dic];
  229. HHHH += model.rowH;
  230. }
  231. if ([_model.replys intValue] == 1) {
  232. _tableHeight.constant = HHHH;
  233. _replyTable.tableFooterView = nil;
  234. }else{
  235. // if (!_replyBottomView) {
  236. NSLog(@"===%d",page);
  237. _model.replayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 20)];
  238. _model.replayView.backgroundColor = UIColor.whiteColor;
  239. //回复
  240. UIButton * replyBtn = [UIButton buttonWithType:0];
  241. replyBtn.backgroundColor = [UIColor clearColor];
  242. replyBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
  243. replyBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  244. [replyBtn addTarget:self action:@selector(makeReply:) forControlEvents:UIControlEventTouchUpInside];
  245. BOOL showNum = NO;
  246. if (_model.replyList.count==1) {
  247. showNum = YES;
  248. }
  249. [self changeMoreShowText:showNum andBtn:replyBtn];
  250. /*
  251. NSString *tempStr = [NSString stringWithFormat:@"展开%d条回复",[_model.replys intValue]>=2?([_model.replys intValue]-1):(1)];
  252. NSMutableAttributedString *attstr = [[NSMutableAttributedString alloc]initWithString:tempStr];
  253. [attstr addAttribute:NSForegroundColorAttributeName value:RGB_COLOR(@"#969696", 1) range:NSMakeRange(0, tempStr.length)];
  254. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  255. UIImage *image = [UIImage imageNamed:@"relpay_三角下.png"];
  256. NSAttributedString *imageString;
  257. if (image) {
  258. attach.image = image;
  259. attach.bounds = CGRectMake(0, -4, 15, 15);
  260. imageString = [NSAttributedString attributedStringWithAttachment:attach];
  261. [attstr appendAttributedString:imageString];
  262. }
  263. [_Reply_Button setAttributedTitle:attstr forState:0];
  264. */
  265. NSMutableAttributedString *attstr2 = [[NSMutableAttributedString alloc]initWithString:YZMsg(@"收起")];
  266. [attstr2 addAttribute:NSForegroundColorAttributeName value:RGB_COLOR(@"#969696", 1) range:NSMakeRange(0, 2)];
  267. NSTextAttachment *attach2 = [[NSTextAttachment alloc] init];
  268. UIImage *image2 = [UIImage imageNamed:@"relpay_三角上.png"];
  269. NSAttributedString *imageString2;
  270. if (image2) {
  271. attach2.image = image2;
  272. attach2.bounds = CGRectMake(0, -4, 15, 15);
  273. imageString2 = [NSAttributedString attributedStringWithAttachment:attach2];
  274. [attstr2 appendAttributedString:imageString2];
  275. }
  276. [replyBtn setAttributedTitle:attstr2 forState:UIControlStateSelected];
  277. [_model.replayView addSubview:replyBtn];
  278. //记录按钮属性
  279. _model.replyMoreBtn = replyBtn;
  280. [replyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  281. make.top.bottom.equalTo(_model.replayView);
  282. make.left.equalTo(_model.replayView).offset(26);
  283. }];
  284. NSLog(@"list:%lu==replays:%@",(unsigned long)_model.replyList.count,_model.replys);
  285. //rk_3-2
  286. if ((_model.replyList.count % 10 != 0
  287. && _model.replyList.count % 10 != 1
  288. && _model.replyList.count % 10 != 2
  289. && _model.replyList.count% 10 != 3)
  290. || ((_model.replyList.count)== [_model.replys intValue])
  291. ) {
  292. replyBtn.selected = YES;
  293. }else{
  294. replyBtn.selected = NO;
  295. }
  296. // replyBtn.selected = NO;
  297. // if (_model.replyList.count % 10 != 0) {
  298. // replyBtn.selected = YES;
  299. // }
  300. // if (_model.replyList.count == 2) {
  301. // replyBtn.selected = YES;
  302. // }
  303. // if (_model.replyList.count == 3) {
  304. // replyBtn.selected = YES;
  305. // }
  306. // }
  307. _replyTable.tableFooterView = _model.replayView;
  308. _tableHeight.constant = HHHH+20;
  309. }
  310. }else{
  311. _tableHeight.constant = 0;
  312. _replyTable.tableFooterView = nil;
  313. }
  314. }
  315. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  316. return _replyArray.count;
  317. }
  318. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  319. commDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"commDetailCELL"];
  320. if (!cell) {
  321. cell = [[commDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"commDetailCell"];
  322. }
  323. detailmodel *model = [[detailmodel alloc]initWithDic:_replyArray[indexPath.row]];
  324. cell.authorID = _authorID;
  325. cell.model = model;
  326. cell.delegate = self;
  327. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  328. cell.backgroundColor = UIColor.whiteColor;
  329. return cell;
  330. }
  331. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  332. detailmodel *model = [[detailmodel alloc]initWithDic:_replyArray[indexPath.row]];
  333. return model.rowH;
  334. }
  335. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  336. [tableView deselectRowAtIndexPath:indexPath animated:NO];
  337. NSDictionary *subdic = _replyArray[indexPath.row];
  338. if ([[Config getOwnID] intValue]<=0 && self.comCellEvent) {
  339. self.comCellEvent();
  340. return;
  341. }
  342. [self.delegate pushDetails:subdic andCell:self];
  343. }
  344. - (void)makeReply:(UIButton *)replyBtn{
  345. if (replyBtn.selected) {
  346. NSDictionary *dic = [_replyArray firstObject];
  347. [_replyArray removeAllObjects];
  348. [_replyArray addObject:[dic mutableCopy]];
  349. _model.replyList = [_replyArray mutableCopy];
  350. // [_replyTable reloadData];
  351. replyBtn.selected = NO;
  352. [self changeMoreShowText:YES andBtn:replyBtn];
  353. [self.delegate reloadCurCell:_model andIndex:_curIndex andReplist:_replyArray needRefresh:YES];
  354. }else{
  355. if (_replyArray.count == 1) {
  356. page = 1;
  357. }else{
  358. page ++;
  359. }
  360. [self requestData:NO andBtn:replyBtn];
  361. }
  362. }
  363. -(void)changeMoreShowText:(BOOL)isFirstPage andBtn:(UIButton *)replyBtn{
  364. NSString *tempStr;
  365. if (isFirstPage) {
  366. tempStr = [NSString stringWithFormat:@"%@%d%@",YZMsg(@"展开"),[_model.replys intValue]>=2?([_model.replys intValue]-1):(1),YZMsg(@"条回复")];
  367. }else{
  368. tempStr = [NSString stringWithFormat:@"%@",YZMsg(@"展开更多回复")];
  369. }
  370. NSMutableAttributedString *attstr = [[NSMutableAttributedString alloc]initWithString:tempStr];
  371. [attstr addAttribute:NSForegroundColorAttributeName value:RGB_COLOR(@"#969696", 1) range:NSMakeRange(0, tempStr.length)];
  372. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  373. UIImage *image = [UIImage imageNamed:@"relpay_三角下.png"];
  374. NSAttributedString *imageString;
  375. if (image) {
  376. attach.image = image;
  377. attach.bounds = CGRectMake(0, -4, 15, 15);
  378. imageString = [NSAttributedString attributedStringWithAttachment:attach];
  379. [attstr appendAttributedString:imageString];
  380. }
  381. [replyBtn setAttributedTitle:attstr forState:0];
  382. }
  383. - (void)requestData:(BOOL)flag andBtn:(UIButton *)replyBtn{
  384. NSString *last_replyid = @"0";
  385. NSDictionary *dic = [_replyArray lastObject];
  386. if ([dic isKindOfClass:[NSDictionary class]] && flag == NO) {
  387. last_replyid = [NSString stringWithFormat:@"%@",[dic valueForKey:@"id"]];
  388. }
  389. if (flag) {
  390. //有新回复,pag重置
  391. page = 1;
  392. }
  393. NSString *url = [NSString stringWithFormat:@"Video.getReplys&commentid=%@&p=%d&uid=%@&last_replyid=%@",_model.parentid,page,[Config getOwnID],last_replyid];
  394. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  395. if (code == 0) {
  396. [self changeMoreShowText:NO andBtn:replyBtn];
  397. NSDictionary *infoDic = [info lastObject];
  398. if ([last_replyid isEqual:@"0"]) {
  399. //自己回复了评论,重置replys的值
  400. _model.replys = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"replys"]];
  401. }
  402. NSArray *infoA = [infoDic valueForKey:@"lists"];
  403. //rk_2-27
  404. //if (page == 1 && infoA.count>0) {
  405. // [infoA removeObjectAtIndex:0];
  406. //}
  407. if (page == 1 && flag == YES) {
  408. [_replyArray removeAllObjects];
  409. }
  410. for (NSDictionary *dic in infoA) {
  411. [_replyArray addObject:[dic mutableCopy]];
  412. }
  413. _model.replyList = [_replyArray mutableCopy];
  414. //[_replyTable reloadData];
  415. //rk_3-2
  416. if (infoA.count <= 0 ) {
  417. replyBtn.selected = YES;
  418. }
  419. [self.delegate reloadCurCell:_model andIndex:_curIndex andReplist:_replyArray needRefresh:YES];
  420. }else{
  421. [MBProgressHUD showPop:msg];
  422. }
  423. } Fail:^(id fail) {
  424. }];
  425. }
  426. - (void)endEditOfGoHome {
  427. [self endEditing:YES];
  428. }
  429. -(void)endEnterCenter
  430. {
  431. if (self.delegate && [self.delegate respondsToSelector:@selector(endEnterCenter)]) {
  432. [self.delegate endEnterCenter];
  433. }
  434. }
  435. #pragma mark - 评论的回复的赞
  436. -(void)refreshDtailDataWithId:(NSString *)commectid andLikes:(NSString *)likes islike:(NSString *)islike {
  437. int numbers = 0;
  438. for (int i=0; i<_model.replyList.count; i++) {
  439. NSMutableDictionary *subdic = _model.replyList[i];
  440. NSString *parentid = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"id"]];
  441. if ([parentid isEqual:commectid]) {
  442. [subdic setObject:likes forKey:@"likes"];
  443. [subdic setObject:islike forKey:@"islike"];
  444. numbers = i;
  445. //更改源数据,不要刷新cell(点赞接口返回处,已经处理了当前页面显示数据,这里只需修改源数据即可)
  446. [self.delegate reloadCurCell:_model andIndex:[NSIndexPath indexPathForRow:numbers inSection:0] andReplist:_model.replyList needRefresh:NO];
  447. break;
  448. }
  449. }
  450. }
  451. -(void)showLandscapeSuper:(UIView*)view{
  452. topview = view;
  453. }
  454. - (IBAction)zanBtnClick:(id)sender {
  455. if ([[Config getOwnID] intValue]<=0 && self.comCellEvent) {
  456. self.comCellEvent();
  457. return;
  458. }
  459. if ([_model.ID isEqual:[Config getOwnID]]) {
  460. // [MBProgressHUD showPop:YZMsg(@"不能给自己的评论点赞")];
  461. [MBProgressHUD showError:YZMsg(@"不能给自己的评论点赞") toView:topview.superview];
  462. return;
  463. }
  464. //_bigbtn.userInteractionEnabled = NO;
  465. NSString *url = [NSString stringWithFormat:@"Video.addCommentLike&uid=%@&commentid=%@&token=%@",[Config getOwnID],_model.parentid,[Config getOwnToken]];
  466. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  467. if (code == 0) {
  468. //动画
  469. dispatch_async(dispatch_get_main_queue(), ^{
  470. [_zanBtn.imageView.layer addAnimation:[PublicObj bigToSmallRecovery] forKey:nil];
  471. });
  472. NSDictionary *infoDic = [info firstObject];
  473. NSString *islike = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"islike"]];
  474. NSString *likes = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"likes"]];
  475. _zanNumL.text = likes;
  476. if ([islike isEqual:@"1"]) {
  477. [_zanBtn setImage:[UIImage imageNamed:@"likecomment-click"] forState:0];
  478. _zanNumL.textColor = Pink_Cor;
  479. }else{
  480. [_zanBtn setImage:[UIImage imageNamed:@"likecomment"] forState:0];
  481. _zanNumL.textColor = RGB_COLOR(@"#828282", 1);
  482. }
  483. [self.delegate makeLikeRloadList:_model.parentid andLikes:likes islike:islike];
  484. }else{
  485. [MBProgressHUD showPop:msg];
  486. }
  487. } Fail:^(id fail) {
  488. }];
  489. }
  490. - (IBAction)playVoice:(id)sender {
  491. [self.delegate playVoice:_model andCell:self];
  492. }
  493. - (void)playVoice:(detailmodel *)model andCell:(id)comcell{
  494. [self.delegate playDetailesVoice:model andCell:comcell];
  495. }
  496. - (void)warningLogin{
  497. if (self.comCellEvent) {
  498. self.comCellEvent();
  499. }
  500. }
  501. - (IBAction)clickIconBtn:(id)sender {
  502. if ([[Config getOwnID] intValue]<=0 && self.comCellEvent) {
  503. self.comCellEvent();
  504. return;
  505. }
  506. if (self.delegate && [self.delegate respondsToSelector:@selector(endEditOfGoHome)]) {
  507. [self.delegate endEditOfGoHome];
  508. }
  509. [[NSNotificationCenter defaultCenter]postNotificationName:@"goCenterNot" object:@"1"];
  510. YBCenterVC *center = [[YBCenterVC alloc]init];
  511. center.otherUid = _model.ID;
  512. center.isPush = YES;
  513. center.hidesBottomBarWhenPushed = YES;
  514. center.backEvent = ^{
  515. [[NSNotificationCenter defaultCenter]postNotificationName:@"goCenterNot" object:@"0"];
  516. };
  517. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:center animated:YES];
  518. }
  519. @end