MyTDTopicDetailVC.m 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504
  1. //
  2. // MyTDTopicDetailVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2019/12/19.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyTDTopicDetailVC.h"
  9. #import "NoteBookDetailCell.h"
  10. #import "NoteBookShareVC.h"
  11. #import "MoveViewController.h"
  12. #import "ChangeTopicVC.h"
  13. #import "TDGroupInfoListVC.h"
  14. #import "TextInputView.h"
  15. #import "MHTopicCell.h"
  16. #import "MHTopic.h"
  17. #import "MHTopicFrame.h"
  18. #import "ClickOKViewController.h"
  19. #import "ReadListVC.h"
  20. #import "HomeDetailController.h"
  21. #import "ChatMsgNoticeDetailVC.h"
  22. #import "NoteBookDetailVC.h"
  23. #import "MyFavoriteVC.h"
  24. #import "NoteBookVC.h"
  25. #import "TDInterLeterDetailVC.h"
  26. #import "FileOpenViewController.h"
  27. #import "EMChatFileShowVC.h"
  28. #import "MyTDTopicCreateVC.h"
  29. #import "NoticeUnreadVC.h"
  30. #import "DownFileViewController.h"
  31. #import "CountDataVC.h"
  32. #import "WorkFlowDetailsController.h"
  33. #import "MyTDGroupViewController.h"
  34. #import "MoveViewController.h"
  35. #import "MyApprovalPageDetail.h"
  36. #import "WorkFlowDetailsController.h"
  37. #import "OtherFavoriteVC.h"
  38. #import "OtherNoteBookVC.h"
  39. #import "MailListDetailVC.h"
  40. #import "ReadListVC.h"
  41. #import "ShareListVC.h"
  42. @interface MyTDTopicDetailVC ()<UITableViewDataSource,UITableViewDelegate,NoteBookShareVCDelegate,MHTopicCellDelegate,WKUIDelegate,WKNavigationDelegate,UIScrollViewDelegate,WKScriptMessageHandler>
  43. @property (strong,nonatomic) IBOutlet UITableView *tableView;
  44. @property (nonatomic,assign) NSUInteger currentPage;
  45. @property (nonatomic,strong) MyNoteBookDetailModel *currentNoteModel;
  46. @property (nonatomic,strong) MyNodeBookZanModel *currentZanModel;
  47. @property (nonatomic,strong) MyNoteBookCommentModel *currentNoteCommentModel;
  48. @property (nonatomic,strong) NSMutableArray *commentArray;
  49. @property (nonatomic,assign) BOOL isFresh;
  50. @property (weak, nonatomic) IBOutlet UILabel *titleL;
  51. @property (weak, nonatomic) IBOutlet UIButton *commentButton;
  52. @property (weak, nonatomic) IBOutlet UIButton *commentScrollBtn;
  53. @property (weak, nonatomic) IBOutlet UILabel *commentNumberLabel;
  54. @property (weak, nonatomic) IBOutlet UIButton *zanButton;
  55. @property (weak, nonatomic) IBOutlet UIButton *collectButton;
  56. @property (weak, nonatomic) IBOutlet UIButton *shareButton;
  57. @property (weak, nonatomic) IBOutlet UILabel *commentCountL;
  58. @property (weak, nonatomic) IBOutlet UIImageView *zanImgV;
  59. @property (weak, nonatomic) IBOutlet UILabel *zanCountL;
  60. @property (weak, nonatomic) IBOutlet UIImageView *collectImgV;
  61. @property (weak, nonatomic) IBOutlet UILabel *collectL;
  62. @property (weak, nonatomic) IBOutlet UIImageView *shareImgV;
  63. @property (weak, nonatomic) IBOutlet UILabel *shareCountL;
  64. @property (weak, nonatomic) IBOutlet UIView *TalkView;
  65. @property (weak, nonatomic) IBOutlet UIView *ReplayView;
  66. @property (weak, nonatomic) IBOutlet UIButton *ReplayBtn;
  67. @property (weak, nonatomic) IBOutlet UIView *BottomView;
  68. @property (weak, nonatomic) IBOutlet UIButton *musicBtn;
  69. @property (nonatomic, strong) TextInputView *commentInputView;
  70. @property (assign, nonatomic) NSInteger countComment;
  71. @property (strong, nonatomic) NoteBookShareVC *noteBookShareVC;
  72. @property (nonatomic,assign) BOOL isSort;
  73. @property (nonatomic,assign) BOOL isScrComment;
  74. @property (nonatomic,assign) CGFloat webH;
  75. @property (nonatomic,strong) WKWebView * webView;
  76. @property (nonatomic,assign) BOOL dismissSelf;
  77. @property (nonatomic,copy) NSString * shareText;
  78. @property (nonatomic,assign) BOOL IsShareText;
  79. @property (nonatomic,assign) NSInteger commentId;
  80. @property (nonatomic,copy) NSString * commentStr;
  81. @property (nonatomic,assign) BOOL isSelf;
  82. @property (nonatomic,assign) NSInteger sendUserId;
  83. @end
  84. @implementation MyTDTopicDetailVC
  85. +(MyTDTopicDetailVC *)initMyTDTopicDetailVC{
  86. MyTDTopicDetailVC *controller = [StoryboardManager.shared.myTDTopic instantiateViewControllerWithIdentifier:@"MyTDTopicDetailVC"];
  87. return controller;
  88. }
  89. - (void)viewWillAppear:(BOOL)animated
  90. {
  91. [super viewWillAppear:animated];
  92. self.musicBtn.hidden = !self.isMusic;
  93. WS(weakSelf);
  94. switch (self.type) {
  95. case CollectModel_InterMail:
  96. {
  97. [self setMailBottomView:YES];
  98. [self.ReplayBtn setAction:^{
  99. [weakSelf ReplayAction];
  100. }];
  101. self.titleL.text = @"站内信";
  102. }
  103. break;
  104. case CollectModel_NewTopic:
  105. {
  106. self.titleL.text = @"话题";
  107. [self setMailBottomView:NO];
  108. }
  109. break;
  110. case CollectModel_Toipc:
  111. {
  112. self.titleL.text = @"话题";
  113. [self setMailBottomView:NO];
  114. }
  115. break;
  116. case CollectModel_Notice:
  117. {
  118. self.titleL.text = @"通知";
  119. [self setMailBottomView:NO];
  120. }
  121. break;
  122. case CollectModel_NoteBook:
  123. {
  124. self.titleL.text = @"笔记";
  125. [self setMailBottomView:NO];
  126. }
  127. break;
  128. case CollectModel_Aritle:
  129. {
  130. self.titleL.text = @"正文";
  131. [self setMailBottomView:NO];
  132. }
  133. default:
  134. {
  135. self.titleL.text = @"话题";
  136. [self setMailBottomView:NO];
  137. }
  138. break;
  139. }
  140. }
  141. - (void)setMailBottomView:(BOOL)isSet
  142. {
  143. if (isSet) {
  144. self.TalkView.hidden = YES;
  145. self.ReplayView.hidden = NO;
  146. self.ReplayBtn.layer.cornerRadius = 5.f;
  147. self.ReplayBtn.layer.masksToBounds = YES;
  148. self.ReplayBtn.layer.borderColor = UIColorHex(0x0F8AE3).CGColor;
  149. self.ReplayBtn.layer.borderWidth = 0.5f;
  150. [self.BottomView setBackgroundColor:UIColorHex(0xF5F5F5)];
  151. }else{
  152. [self.BottomView setBackgroundColor:[UIColor whiteColor]];
  153. self.TalkView.hidden = NO;
  154. self.TalkView.layer.cornerRadius = 4.f;
  155. self.TalkView.layer.masksToBounds = YES;
  156. self.TalkView.layer.borderColor = UIColorHex(0xE5E5E5).CGColor;
  157. self.TalkView.layer.borderWidth = 0.5f;
  158. self.ReplayView.hidden = YES;
  159. }
  160. }
  161. - (void)ReplayAction{
  162. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  163. UIAlertAction *alertAction1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  164. }];
  165. [alertAction1 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  166. WS(weakSelf);
  167. UIAlertAction *alertAction2 = [UIAlertAction actionWithTitle:@"回复" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  168. weakSelf.webH = 0;
  169. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  170. vc.upDateBlock = ^{
  171. [weakSelf headRefresh];
  172. };
  173. vc.replayType = MailReplayOne;
  174. vc.type = weakSelf.type;
  175. vc.isEdit = YES;
  176. vc.Id = weakSelf.Id;
  177. [weakSelf.navigationController pushViewController:vc animated:YES];
  178. }];
  179. [alertAction2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  180. UIAlertAction *alertAction3 = [UIAlertAction actionWithTitle:@"回复全部" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  181. weakSelf.webH = 0;
  182. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  183. vc.upDateBlock = ^{
  184. [weakSelf headRefresh];
  185. };
  186. vc.replayType = MailReplayAll;
  187. vc.isEdit = YES;
  188. vc.type = weakSelf.type;
  189. vc.Id = weakSelf.Id;
  190. [weakSelf.navigationController pushViewController:vc animated:YES];
  191. }];
  192. [alertAction3 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
  193. [alert addAction:alertAction2];
  194. [alert addAction:alertAction3];
  195. [alert addAction:alertAction1];
  196. [self presentViewController:alert animated:YES completion:^{
  197. }];
  198. }
  199. - (void)viewDidLoad {
  200. [super viewDidLoad];
  201. self.fd_prefersNavigationBarHidden = YES;
  202. [self setTableViewRefresh];
  203. WS(weakSelf);
  204. [self.shareButton setAction:^{
  205. [weakSelf ShareDetail];
  206. }];
  207. [self.zanButton setAction:^{
  208. [weakSelf gotoZanHander];
  209. }];
  210. if (self.type != CollectModel_InterMail) {
  211. [self.commentButton setAction:^{
  212. [weakSelf commentHander];
  213. }];
  214. [self.commentScrollBtn setAction:^{
  215. weakSelf.isScrComment = !weakSelf.isScrComment;
  216. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  217. [weakSelf scrollToCommentViewTop];
  218. });
  219. }];
  220. }
  221. [self.view addSubview:self.noteBookShareVC.view];
  222. [self.view addSubview:self.commentInputView];
  223. self.tableView.tableHeaderView = self.webView;
  224. self.webView.UIDelegate = self;
  225. self.webView.navigationDelegate = self;
  226. self.webView.scrollView.delegate = self;
  227. [self headRefresh];
  228. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuShow) name:UIMenuControllerDidShowMenuNotification object:nil];
  229. //
  230. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(collectSuccess) name:COLLECTSUCCESS object:nil];
  231. // 通知-监听键盘弹出事件
  232. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeKeyboardWillShowNotification:) name:UIKeyboardWillShowNotification object:nil];
  233. // 通知-监听键盘回收事
  234. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeKeyboardWillHideNotification:) name:UIKeyboardWillHideNotification object:nil];
  235. }
  236. #pragma mark - UIKeyBoradNotification
  237. - (void)changeKeyboardWillShowNotification:(NSNotification*)notification
  238. {
  239. WS(weakSelf);
  240. NSDictionary *userInfo = [notification userInfo];
  241. // 键盘弹出后的frame的结构体对象
  242. NSValue *valueEndFrame = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
  243. // 得到键盘弹出后的键盘视图所在y坐标
  244. CGFloat keyBoardEndY = valueEndFrame.CGRectValue.origin.y;
  245. // 键盘弹出的动画时间
  246. NSNumber *duration = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
  247. // 键盘弹出的动画曲线
  248. NSNumber *curve = [userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey];
  249. // 添加移动动画,使视图跟随键盘移动(动画时间和曲线都保持一致)
  250. [UIView animateWithDuration:[duration doubleValue] animations:^{
  251. [UIView setAnimationBeginsFromCurrentState:YES];
  252. [UIView setAnimationCurve:[curve intValue]];
  253. [UIView animateWithDuration:0.5 animations:^{
  254. [weakSelf.commentInputView startAnimationWithY:keyBoardEndY - 150.f];
  255. }];
  256. } completion:^(BOOL finished) {
  257. }];
  258. }
  259. - (void)changeKeyboardWillHideNotification:(NSNotification*)notification
  260. {
  261. WS(weakSelf);
  262. NSDictionary *userInfo = [notification userInfo];
  263. // 键盘弹出的动画时间
  264. NSNumber *duration = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
  265. // 键盘弹出的动画曲线
  266. NSNumber *curve = [userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey];
  267. [UIView animateWithDuration:[duration doubleValue]animations:^{
  268. [weakSelf.commentInputView startAnimationWithY:SCREEN_HEIGHT];
  269. [UIView setAnimationBeginsFromCurrentState:YES];
  270. [UIView setAnimationCurve:[curve intValue]];
  271. } completion:^(BOOL finished) {
  272. }];
  273. }
  274. - (void)setTableViewRefresh{
  275. WS(weakSelf);
  276. self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  277. [weakSelf headRefresh];
  278. }];
  279. self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
  280. [weakSelf footerRefresh];
  281. }];
  282. }
  283. - (void)setBottomViewData:(MyNoteBookDetailModel *)model
  284. {
  285. self.countComment = model.CommentCount;
  286. if (model.CommentCount == 0) {
  287. self.commentCountL.text = [NSString stringWithFormat:@"评 论"];
  288. }else{
  289. if (model.CommentCount > 10000) {
  290. self.commentCountL.text = [NSString stringWithFormat:@"%.1f万\n评 论",model.CommentCount / 10000.0];
  291. }else{
  292. self.commentCountL.text = [NSString stringWithFormat:@"%ld\n评 论",(long)model.CommentCount];
  293. }
  294. }
  295. self.zanCountL.text = [NSString stringWithFormat:@"%ld",(long)model.PraiseCount];
  296. self.collectL.text = [NSString stringWithFormat:@"%ld",(long)model.CollectCount];
  297. self.shareCountL.text = [NSString stringWithFormat:@"%ld",(long)model.RetransmissionCount];
  298. self.zanCountL.hidden = model.PraiseCount == 0 ? YES : NO;
  299. self.collectL.hidden = model.CollectCount == 0 ? YES : NO;
  300. self.shareCountL.hidden = model.RetransmissionCount == 0 ? YES : NO;
  301. self.zanImgV.image = model.IsPraise ? IMG(@"zan_yes"):IMG(@"zan_no");
  302. self.collectImgV.image = model.IsCollect ? IMG(@"icon_collect_off"):IMG(@"收藏五角星");
  303. self.shareImgV.image = IMG(@"icon_share");
  304. WS(weakSelf);
  305. [self.collectButton setAction:^{
  306. if (model.IsCollect) {
  307. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"真的取消收藏吗?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  308. UIAlertAction *actionYes = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  309. NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
  310. [dic setValue:@(self.Id) forKey:@"CollectionDataId"];
  311. /// 1文章 2话题 3 收藏 4笔记 5通知 6站内信 7小组 8 会议详情 14工作流审批 300 文件 400 会议纪要
  312. NSInteger type = weakSelf.type;
  313. switch (weakSelf.type) {
  314. case CollectModel_meet:
  315. type = 400;
  316. break;
  317. case CollectModel_Aritle:
  318. type = 1;
  319. break;
  320. default:
  321. break;
  322. }
  323. [dic setValue:@(type) forKey:@"CollectionType"];
  324. [dic setValue:@(0) forKey:@"FolderId"];
  325. [dic setValue:@(0) forKey:@"SourceUserId"];
  326. [[HttpManager sharedHttpManager] PUTUrl:Host(API_CreateCollect) parameters:dic success:^(id _Nonnull responseObject) {
  327. [weakSelf refreshData];
  328. } failure:^(NSError * _Nonnull error) {
  329. // SHOWERROR([ZYCTool handerResultData:error]);
  330. }];
  331. }];
  332. UIAlertAction *actionNo = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  333. }];
  334. [alert addAction:actionYes];
  335. [alert addAction:actionNo];
  336. [weakSelf presentViewController:alert animated:YES completion:^{
  337. }];
  338. }else{
  339. [weakSelf gotoCollectHander];
  340. }
  341. }];
  342. self.zanCountL.textColor = model.IsPraise ? UIColorHex(#009AFF):UIColorHex(#999999);
  343. self.collectL.textColor = model.IsCollect ? UIColorHex(#009AFF):UIColorHex(#999999);
  344. self.shareCountL.textColor = UIColorHex(#009AFF);
  345. }
  346. #pragma mark - 网络请求数据
  347. - (void)getNoticeData
  348. {
  349. WS(weakSelf);
  350. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  351. __block NSInteger httpFinishCount = 0;
  352. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  353. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%ld",Host(API_Notice_Detail),(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  354. NSLog(@"通知正文%@",responseObject);
  355. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
  356. weakSelf.sendUserId = weakSelf.currentNoteModel.UserId;
  357. if (++httpFinishCount == 3) {
  358. dispatch_semaphore_signal(sem);
  359. }
  360. } failure:^(NSError * _Nonnull error) {
  361. // SHOWERROR([ZYCTool handerResultData:error]);
  362. }];
  363. NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
  364. @"TypeValue":@(2),//通知 2
  365. @"Page":@(self.currentPage),
  366. @"PerPage":@(20),
  367. @"sort":weakSelf.isSort ? @"asc":@"desc"
  368. };
  369. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  370. NSLog(@"评论数据列表%@",responseObject);
  371. if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
  372. for (NSDictionary * dict in responseObject[@"Items"]) {
  373. MHTopic * topic = [MHTopic modelWithDictionary:dict];
  374. if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
  375. NSMutableArray * subArray = [NSMutableArray array];
  376. for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
  377. MHComment * commentModel = [MHComment modelWithDictionary:subDict];
  378. [subArray addObject:commentModel];
  379. }
  380. topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
  381. }
  382. [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
  383. }
  384. }
  385. if (++httpFinishCount == 3) {
  386. dispatch_semaphore_signal(sem);
  387. }
  388. } failure:^(NSError * _Nonnull error) {
  389. // SHOWERROR([ZYCTool handerResultData:error]);
  390. }];
  391. NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
  392. @"TypeValue":@(2),//通知 2
  393. @"Page":@(1),
  394. @"PerPage":@(20),
  395. @"sort":@""
  396. };
  397. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  398. NSLog(@"点赞列表%@",responseObject);
  399. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  400. if (++httpFinishCount == 3) {
  401. dispatch_semaphore_signal(sem);
  402. }
  403. } failure:^(NSError * _Nonnull error) {
  404. // SHOWERROR([ZYCTool handerResultData:error]);
  405. }];
  406. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  407. dispatch_async(dispatch_get_main_queue(), ^{
  408. [weakSelf.tableView.mj_header endRefreshing];
  409. [weakSelf.tableView.mj_footer endRefreshing];
  410. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  411. [weakSelf.tableView reloadData];
  412. });
  413. });
  414. }
  415. - (void)getTopic{
  416. WS(weakSelf);
  417. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  418. __block NSInteger httpFinishCount = 0;
  419. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  420. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_App_Detail) parameters:@{@"Id":@(self.Id),@"UserId":@([AppUserModel sharedAppUserModel].Id)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  421. NSLog(@"话题正文%@",responseObject);
  422. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
  423. if (++httpFinishCount == 3) {
  424. dispatch_semaphore_signal(sem);
  425. }
  426. } failure:^(NSError * _Nonnull error) {
  427. // SHOWERROR([ZYCTool handerResultData:error]);
  428. }];
  429. NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
  430. @"TypeValue":@(1),//话题 1
  431. @"Page":@(self.currentPage),
  432. @"PerPage":@(20),
  433. @"sort":weakSelf.isSort ? @"asc":@"desc"
  434. };
  435. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  436. NSLog(@"评论数据列表%@",responseObject);
  437. if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
  438. for (NSDictionary * dict in responseObject[@"Items"]) {
  439. MHTopic * topic = [MHTopic modelWithDictionary:dict];
  440. if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
  441. NSMutableArray * subArray = [NSMutableArray array];
  442. for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
  443. MHComment * commentModel = [MHComment modelWithDictionary:subDict];
  444. [subArray addObject:commentModel];
  445. }
  446. topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
  447. }
  448. [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
  449. }
  450. }
  451. if (++httpFinishCount == 3) {
  452. dispatch_semaphore_signal(sem);
  453. }
  454. } failure:^(NSError * _Nonnull error) {
  455. // SHOWERROR([ZYCTool handerResultData:error]);
  456. }];
  457. NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
  458. @"TypeValue":@(1),//话题 1
  459. @"Page":@(1),
  460. @"PerPage":@(20),
  461. @"sort":@""
  462. };
  463. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  464. NSLog(@"点赞列表%@",responseObject);
  465. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  466. if (++httpFinishCount == 3) {
  467. dispatch_semaphore_signal(sem);
  468. }
  469. } failure:^(NSError * _Nonnull error) {
  470. // SHOWERROR([ZYCTool handerResultData:error]);
  471. }];
  472. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  473. dispatch_async(dispatch_get_main_queue(), ^{
  474. [weakSelf.tableView.mj_header endRefreshing];
  475. [weakSelf.tableView.mj_footer endRefreshing];
  476. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  477. [weakSelf.tableView reloadData];
  478. });
  479. });
  480. }
  481. - (void)getMeeting{
  482. WS(weakSelf);
  483. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  484. __block NSInteger httpFinishCount = 0;
  485. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  486. NSString * meetId = [NSString stringWithFormat:@"%ld",(long)weakSelf.Id];
  487. [[HttpManager sharedHttpManager] GETUrl:Host(UpdateMeeting(meetId)) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  488. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
  489. if (++httpFinishCount == 3) {
  490. dispatch_semaphore_signal(sem);
  491. }
  492. } failure:^(NSError * _Nonnull error) {
  493. // SHOWERROR([ZYCTool handerResultData:error]);
  494. }];
  495. NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
  496. @"TypeValue":@(10),//会议 10
  497. @"Page":@(self.currentPage),
  498. @"PerPage":@(20),
  499. @"sort":weakSelf.isSort ? @"asc":@"desc"
  500. };
  501. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  502. NSLog(@"评论数据列表%@",responseObject);
  503. if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
  504. for (NSDictionary * dict in responseObject[@"Items"]) {
  505. MHTopic * topic = [MHTopic modelWithDictionary:dict];
  506. if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
  507. NSMutableArray * subArray = [NSMutableArray array];
  508. for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
  509. MHComment * commentModel = [MHComment modelWithDictionary:subDict];
  510. [subArray addObject:commentModel];
  511. }
  512. topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
  513. }
  514. [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
  515. }
  516. }
  517. if (++httpFinishCount == 3) {
  518. dispatch_semaphore_signal(sem);
  519. }
  520. } failure:^(NSError * _Nonnull error) {
  521. // SHOWERROR([ZYCTool handerResultData:error]);
  522. }];
  523. NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
  524. @"TypeValue":@(10),//会议 10
  525. @"Page":@(1),
  526. @"PerPage":@(20),
  527. @"sort":@""
  528. };
  529. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  530. NSLog(@"点赞列表%@",responseObject);
  531. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  532. if (++httpFinishCount == 3) {
  533. dispatch_semaphore_signal(sem);
  534. }
  535. } failure:^(NSError * _Nonnull error) {
  536. // SHOWERROR([ZYCTool handerResultData:error]);
  537. }];
  538. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  539. dispatch_async(dispatch_get_main_queue(), ^{
  540. [weakSelf.tableView.mj_header endRefreshing];
  541. [weakSelf.tableView.mj_footer endRefreshing];
  542. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  543. [weakSelf.tableView reloadData];
  544. });
  545. });
  546. }
  547. - (void)getNote{
  548. WS(weakSelf);
  549. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  550. __block NSInteger httpFinishCount = 0;
  551. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  552. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_NoteBook_Detail,(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  553. NSLog(@"笔记正文%@",responseObject);
  554. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
  555. if (++httpFinishCount == 3) {
  556. dispatch_semaphore_signal(sem);
  557. }
  558. } failure:^(NSError * _Nonnull error) {
  559. // SHOWERROR([ZYCTool handerResultData:error]);
  560. }];
  561. NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
  562. @"TypeValue":@(3),//会议 10
  563. @"Page":@(self.currentPage),
  564. @"PerPage":@(20),
  565. @"sort":weakSelf.isSort ? @"asc":@"desc"
  566. };
  567. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  568. NSLog(@"评论数据列表%@",responseObject);
  569. if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
  570. for (NSDictionary * dict in responseObject[@"Items"]) {
  571. MHTopic * topic = [MHTopic modelWithDictionary:dict];
  572. if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
  573. NSMutableArray * subArray = [NSMutableArray array];
  574. for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
  575. MHComment * commentModel = [MHComment modelWithDictionary:subDict];
  576. [subArray addObject:commentModel];
  577. }
  578. topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
  579. }
  580. [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
  581. }
  582. }
  583. if (++httpFinishCount == 3) {
  584. dispatch_semaphore_signal(sem);
  585. }
  586. } failure:^(NSError * _Nonnull error) {
  587. // SHOWERROR([ZYCTool handerResultData:error]);
  588. }];
  589. NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
  590. @"TypeValue":@(3),//会议 10
  591. @"Page":@(1),
  592. @"PerPage":@(20),
  593. @"sort":@""
  594. };
  595. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  596. NSLog(@"点赞列表%@",responseObject);
  597. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  598. if (++httpFinishCount == 3) {
  599. dispatch_semaphore_signal(sem);
  600. }
  601. } failure:^(NSError * _Nonnull error) {
  602. // SHOWERROR([ZYCTool handerResultData:error]);
  603. }];
  604. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  605. dispatch_async(dispatch_get_main_queue(), ^{
  606. [weakSelf.tableView.mj_header endRefreshing];
  607. [weakSelf.tableView.mj_footer endRefreshing];
  608. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  609. [weakSelf.tableView reloadData];
  610. });
  611. });
  612. }
  613. - (void)getAritle{
  614. WS(weakSelf);
  615. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  616. __block NSInteger httpFinishCount = 0;
  617. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  618. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,[NSString stringWithFormat:@"/api/app/article/detail/%ld",self.Id]] parameters:@{@"id":@(self.Id)}
  619. responseStyle:JOSN success:^(id _Nonnull responseObject) {
  620. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
  621. if (++httpFinishCount == 3) {
  622. dispatch_semaphore_signal(sem);
  623. }
  624. } failure:^(NSError * _Nonnull error) {
  625. }];
  626. NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
  627. @"TypeValue":@(0),//会议 10
  628. @"Page":@(self.currentPage),
  629. @"PerPage":@(20),
  630. @"sort":weakSelf.isSort ? @"asc":@"desc"
  631. };
  632. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  633. NSLog(@"评论数据列表%@",responseObject);
  634. if ([responseObject isKindOfClass:[NSDictionary class]]) {
  635. if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
  636. for (NSDictionary * dict in responseObject[@"Items"]) {
  637. MHTopic * topic = [MHTopic modelWithDictionary:dict];
  638. if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
  639. NSMutableArray * subArray = [NSMutableArray array];
  640. for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
  641. MHComment * commentModel = [MHComment modelWithDictionary:subDict];
  642. [subArray addObject:commentModel];
  643. }
  644. topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
  645. }
  646. [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
  647. }
  648. }
  649. if (++httpFinishCount == 3) {
  650. dispatch_semaphore_signal(sem);
  651. }
  652. }
  653. } failure:^(NSError * _Nonnull error) {
  654. // SHOWERROR([ZYCTool handerResultData:error]);
  655. }];
  656. NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
  657. @"TypeValue":@(0),//会议 10
  658. @"Page":@(1),
  659. @"PerPage":@(20),
  660. @"sort":@""
  661. };
  662. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  663. NSLog(@"点赞列表%@",responseObject);
  664. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  665. if (++httpFinishCount == 3) {
  666. dispatch_semaphore_signal(sem);
  667. }
  668. } failure:^(NSError * _Nonnull error) {
  669. // SHOWERROR([ZYCTool handerResultData:error]);
  670. }];
  671. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  672. dispatch_async(dispatch_get_main_queue(), ^{
  673. [weakSelf.tableView.mj_header endRefreshing];
  674. [weakSelf.tableView.mj_footer endRefreshing];
  675. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  676. [weakSelf.tableView reloadData];
  677. });
  678. });
  679. }
  680. - (void)getMail
  681. {
  682. WS(weakSelf);
  683. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%ld",Host(API_InterLetterDetail),(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  684. NSLog(@"%@",responseObject);
  685. if ([responseObject isKindOfClass:[NSDictionary class]]) {
  686. [weakSelf.tableView.mj_header endRefreshing];
  687. [weakSelf.tableView.mj_footer endRefreshing];
  688. NSArray * array = responseObject[@"Items"];
  689. if ([array.firstObject isKindOfClass:[NSDictionary class]]) {
  690. weakSelf.sendUserId = [[array.firstObject objectForKey:@"UserId"] integerValue];
  691. }
  692. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:array.firstObject error:nil];
  693. dispatch_async(dispatch_get_main_queue(), ^{
  694. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  695. [weakSelf.tableView reloadData];
  696. });
  697. }
  698. } failure:^(NSError * _Nonnull error) {
  699. // SHOWERROR([ZYCTool handerResultData:error]);
  700. }];
  701. }
  702. #pragma mark - 刷新点赞数据
  703. - (void)refreshNoticeData
  704. {
  705. WS(weakSelf);
  706. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  707. __block NSInteger httpFinishCount = 0;
  708. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  709. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%ld",Host(API_Notice_Detail),(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  710. NSLog(@"通知正文%@",responseObject);
  711. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
  712. if (++httpFinishCount == 2) {
  713. dispatch_semaphore_signal(sem);
  714. }
  715. } failure:^(NSError * _Nonnull error) {
  716. // SHOWERROR([ZYCTool handerResultData:error]);
  717. }];
  718. NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
  719. @"TypeValue":@(2),//通知 2
  720. @"Page":@(1),
  721. @"PerPage":@(20),
  722. @"sort":@""
  723. };
  724. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  725. NSLog(@"点赞列表%@",responseObject);
  726. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  727. if (++httpFinishCount == 2) {
  728. dispatch_semaphore_signal(sem);
  729. }
  730. } failure:^(NSError * _Nonnull error) {
  731. // SHOWERROR([ZYCTool handerResultData:error]);
  732. }];
  733. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  734. dispatch_async(dispatch_get_main_queue(), ^{
  735. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  736. [weakSelf.tableView reloadData];
  737. });
  738. });
  739. }
  740. - (void)refreshTopicData
  741. {
  742. WS(weakSelf);
  743. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  744. __block NSInteger httpFinishCount = 0;
  745. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  746. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_App_Detail) parameters:@{@"Id":@(self.Id),@"UserId":@([AppUserModel sharedAppUserModel].Id)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  747. NSLog(@"话题正文%@",responseObject);
  748. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
  749. if (++httpFinishCount == 2) {
  750. dispatch_semaphore_signal(sem);
  751. }
  752. } failure:^(NSError * _Nonnull error) {
  753. // SHOWERROR([ZYCTool handerResultData:error]);
  754. }];
  755. NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
  756. @"TypeValue":@(1),//话题 1
  757. @"Page":@(1),
  758. @"PerPage":@(20),
  759. @"sort":@""
  760. };
  761. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  762. NSLog(@"点赞列表%@",responseObject);
  763. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  764. if (++httpFinishCount == 2) {
  765. dispatch_semaphore_signal(sem);
  766. }
  767. } failure:^(NSError * _Nonnull error) {
  768. // SHOWERROR([ZYCTool handerResultData:error]);
  769. }];
  770. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  771. dispatch_async(dispatch_get_main_queue(), ^{
  772. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  773. [weakSelf.tableView reloadData];
  774. });
  775. });
  776. }
  777. - (void)refreshMeetingData
  778. {
  779. WS(weakSelf);
  780. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  781. __block NSInteger httpFinishCount = 0;
  782. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  783. NSString * meetId = [NSString stringWithFormat:@"%ld",(long)weakSelf.Id];
  784. [[HttpManager sharedHttpManager] GETUrl:Host(UpdateMeeting(meetId)) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  785. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
  786. if (++httpFinishCount == 2) {
  787. dispatch_semaphore_signal(sem);
  788. }
  789. } failure:^(NSError * _Nonnull error) {
  790. // SHOWERROR([ZYCTool handerResultData:error]);
  791. }];
  792. NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
  793. @"TypeValue":@(10),//话题 1
  794. @"Page":@(1),
  795. @"PerPage":@(20),
  796. @"sort":@""
  797. };
  798. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  799. NSLog(@"点赞列表%@",responseObject);
  800. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  801. if (++httpFinishCount == 2) {
  802. dispatch_semaphore_signal(sem);
  803. }
  804. } failure:^(NSError * _Nonnull error) {
  805. // SHOWERROR([ZYCTool handerResultData:error]);
  806. }];
  807. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  808. dispatch_async(dispatch_get_main_queue(), ^{
  809. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  810. [weakSelf.tableView reloadData];
  811. });
  812. });
  813. }
  814. - (void)refreshNoteData
  815. {
  816. WS(weakSelf);
  817. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  818. __block NSInteger httpFinishCount = 0;
  819. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  820. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_NoteBook_Detail,(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  821. NSLog(@"话题正文%@",responseObject);
  822. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
  823. if (++httpFinishCount == 2) {
  824. dispatch_semaphore_signal(sem);
  825. }
  826. } failure:^(NSError * _Nonnull error) {
  827. // SHOWERROR([ZYCTool handerResultData:error]);
  828. }];
  829. NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
  830. @"TypeValue":@(3),//话题 1
  831. @"Page":@(1),
  832. @"PerPage":@(20),
  833. @"sort":@""
  834. };
  835. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  836. NSLog(@"点赞列表%@",responseObject);
  837. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  838. if (++httpFinishCount == 2) {
  839. dispatch_semaphore_signal(sem);
  840. }
  841. } failure:^(NSError * _Nonnull error) {
  842. // SHOWERROR([ZYCTool handerResultData:error]);
  843. }];
  844. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  845. dispatch_async(dispatch_get_main_queue(), ^{
  846. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  847. [weakSelf.tableView reloadData];
  848. });
  849. });
  850. }
  851. - (void)refreshAritleData
  852. {
  853. WS(weakSelf);
  854. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  855. __block NSInteger httpFinishCount = 0;
  856. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  857. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,[NSString stringWithFormat:@"/api/app/article/detail/%ld",self.Id]] parameters:@{@"id":@(self.Id)}
  858. responseStyle:JOSN success:^(id _Nonnull responseObject) {
  859. weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
  860. if (++httpFinishCount == 2) {
  861. dispatch_semaphore_signal(sem);
  862. }
  863. } failure:^(NSError * _Nonnull error) {
  864. }];
  865. NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
  866. @"TypeValue":@(0),//会议 10
  867. @"Page":@(1),
  868. @"PerPage":@(20),
  869. @"sort":@""
  870. };
  871. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  872. NSLog(@"点赞列表%@",responseObject);
  873. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  874. if (++httpFinishCount == 2) {
  875. dispatch_semaphore_signal(sem);
  876. }
  877. } failure:^(NSError * _Nonnull error) {
  878. // SHOWERROR([ZYCTool handerResultData:error]);
  879. }];
  880. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  881. dispatch_async(dispatch_get_main_queue(), ^{
  882. [weakSelf.tableView.mj_header endRefreshing];
  883. [weakSelf.tableView.mj_footer endRefreshing];
  884. [weakSelf setBottomViewData:weakSelf.currentNoteModel];
  885. [weakSelf.tableView reloadData];
  886. });
  887. });
  888. }
  889. - (MHTopicFrame *)_topicFrameWithTopic:(MHTopic *)topic
  890. {
  891. MHTopicFrame *topicFrame = [[MHTopicFrame alloc] init];
  892. // 传递微博模型数据,计算所有子控件的frame
  893. topicFrame.topic = topic;
  894. return topicFrame;
  895. }
  896. - (void)sortCommentList
  897. {
  898. WS(weakSelf);
  899. NSArray * array = self.commentArray;
  900. self.commentArray =[NSMutableArray arrayWithArray:[[array reverseObjectEnumerator] allObjects]];
  901. dispatch_async(dispatch_get_main_queue(), ^{
  902. [weakSelf.tableView reloadData];
  903. });
  904. }
  905. - (void)RefreshCommentList
  906. {
  907. WS(weakSelf);
  908. [self.commentArray removeAllObjects];
  909. self.currentPage = 1;
  910. NSDictionary * paraDict = @{@"ArticleId":@(self.Id),
  911. @"TypeValue":@([self backTypeValue]),//话题 1
  912. @"Page":@(self.currentPage),
  913. @"PerPage":@(20),
  914. @"sort":weakSelf.isSort ? @"asc":@"desc"
  915. };
  916. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  917. NSLog(@"评论数据列表%@",responseObject);
  918. if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
  919. for (NSDictionary * dict in responseObject[@"Items"]) {
  920. MHTopic * topic = [MHTopic modelWithDictionary:dict];
  921. if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
  922. NSMutableArray * subArray = [NSMutableArray array];
  923. for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
  924. MHComment * commentModel = [MHComment modelWithDictionary:subDict];
  925. [subArray addObject:commentModel];
  926. }
  927. topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
  928. }
  929. [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
  930. }
  931. }
  932. dispatch_async(dispatch_get_main_queue(), ^{
  933. [weakSelf.tableView reloadData];
  934. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  935. // weakSelf.isScrComment = YES;
  936. // [weakSelf scrollToCommentViewTop];
  937. // });
  938. });
  939. } failure:^(NSError * _Nonnull error) {
  940. // SHOWERROR([ZYCTool handerResultData:error]);
  941. }];
  942. }
  943. - (void)headRefresh{
  944. self.isFresh = YES;
  945. self.currentPage = 1;
  946. [self.commentArray removeAllObjects];
  947. [self loadDataWebView];
  948. switch (self.type) {
  949. case CollectModel_Notice:
  950. {
  951. [self getNoticeData];
  952. }
  953. break;
  954. case CollectModel_Toipc:
  955. {
  956. [self getTopic];
  957. }
  958. break;
  959. case CollectModel_NewTopic:
  960. {
  961. [self getNote];
  962. }
  963. break;
  964. case CollectModel_Group:
  965. {
  966. [self getTopic];
  967. }
  968. break;
  969. case CollectModel_meetMian:
  970. {
  971. [self getMeeting];
  972. }
  973. break;
  974. case CollectModel_NoteBook:
  975. {
  976. [self getNote];
  977. }
  978. break;
  979. case CollectModel_InterMail:
  980. {
  981. [self getMail];
  982. }
  983. break;
  984. case CollectModel_Aritle:
  985. {
  986. [self getAritle];
  987. }
  988. break;
  989. default:
  990. break;
  991. }
  992. }
  993. - (void)footerRefresh{
  994. self.isFresh = NO;
  995. self.currentPage += 1;
  996. if (self.commentArray.count == self.currentNoteCommentModel.Total) {
  997. self.tableView.mj_footer.hidden = YES;
  998. [self.tableView.mj_footer resetNoMoreData];
  999. return;
  1000. }
  1001. NSDictionary * paraDict = @{@"ArticleId":@(self.Id),
  1002. @"TypeValue":@([self backTypeValue]),//话题 1
  1003. @"Page":@(self.currentPage),
  1004. @"PerPage":@(20),
  1005. @"sort":self.isSort ? @"asc":@"desc"
  1006. };
  1007. WS(weakSelf);
  1008. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  1009. NSLog(@"评论数据列表%@",responseObject);
  1010. if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
  1011. for (NSDictionary * dict in responseObject[@"Items"]) {
  1012. MHTopic * topic = [MHTopic modelWithDictionary:dict];
  1013. if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
  1014. NSMutableArray * subArray = [NSMutableArray array];
  1015. for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
  1016. MHComment * commentModel = [MHComment modelWithDictionary:subDict];
  1017. [subArray addObject:commentModel];
  1018. }
  1019. topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
  1020. }
  1021. [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
  1022. }
  1023. }
  1024. dispatch_async(dispatch_get_main_queue(), ^{
  1025. [weakSelf.tableView reloadData];
  1026. });
  1027. } failure:^(NSError * _Nonnull error) {
  1028. // SHOWERROR([ZYCTool handerResultData:error]);
  1029. weakSelf.currentPage -= 1;
  1030. }];
  1031. [self.tableView.mj_footer endRefreshing];
  1032. }
  1033. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  1034. if (self.type == CollectModel_InterMail) {
  1035. return 0;
  1036. }
  1037. return 2;
  1038. }
  1039. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  1040. if (self.currentZanModel.Items.count == 0 && self.commentArray.count == 0) {
  1041. switch (section) {
  1042. case 0:
  1043. return 0;
  1044. break;
  1045. default:
  1046. return self.commentArray.count;
  1047. break;
  1048. }
  1049. }else{
  1050. switch (section) {
  1051. case 0:
  1052. return 1;
  1053. break;
  1054. default:
  1055. return self.commentArray.count;
  1056. break;
  1057. }
  1058. }
  1059. }
  1060. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  1061. {
  1062. if (self.currentZanModel.Items.count == 0 && self.commentArray.count == 0) {
  1063. MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
  1064. if (topicFrame.tableViewFrame.size.height == 0) {
  1065. return topicFrame.height+topicFrame.tableViewFrame.size.height;
  1066. }else{
  1067. return topicFrame.height+topicFrame.tableViewFrame.size.height+MHTopicVerticalSpace;
  1068. }
  1069. }else{
  1070. switch (indexPath.section) {
  1071. case 0:
  1072. return UITableViewAutomaticDimension;
  1073. break;
  1074. default:
  1075. {
  1076. MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
  1077. if (topicFrame.tableViewFrame.size.height == 0) {
  1078. return topicFrame.height + topicFrame.tableViewFrame.size.height;
  1079. }else{
  1080. return topicFrame.height + topicFrame.tableViewFrame.size.height;
  1081. }
  1082. }
  1083. break;
  1084. }
  1085. }
  1086. }
  1087. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  1088. WS(weakSelf);
  1089. if (self.currentZanModel.Items.count == 0 && self.commentArray.count == 0) {
  1090. MHTopicCell *cell = [MHTopicCell cellWithTableView:tableView];
  1091. cell.backgroundColor = [UIColor whiteColor];
  1092. MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
  1093. cell.topicFrame = topicFrame;
  1094. cell.createTimeLabel.text = [NSString stringWithFormat:@"%@ %@",topicFrame.topic.FloorCount,topicFrame.topic.CreatedTime];
  1095. [cell.thumbBtn setAction:^{
  1096. [weakSelf gotoZanCommentHanderModel:topicFrame.topic indexPath:indexPath];
  1097. }];
  1098. cell.replyContentBlock = ^{
  1099. [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
  1100. // if (topicFrame.topic.UserId != [AppUserModel sharedAppUserModel].Id) {
  1101. // [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
  1102. // }
  1103. };
  1104. __block MHTopicCell * bCell = cell;
  1105. cell.longBlock = ^{
  1106. weakSelf.commentId = topicFrame.topic.Id;
  1107. weakSelf.commentStr = topicFrame.topic.Content;
  1108. weakSelf.isSelf = topicFrame.topic.UserId == [AppUserModel sharedAppUserModel].Id;
  1109. if (weakSelf.isSelf) {
  1110. [weakSelf longDeleteSelf:bCell];
  1111. }
  1112. };
  1113. cell.longSubBlock = ^(NSInteger commentId,UILabel * label,NSString * Content) {
  1114. weakSelf.commentId = commentId;
  1115. weakSelf.commentStr = Content;
  1116. [weakSelf longDeleteSubCell:label];
  1117. };
  1118. cell.delegate = self;
  1119. return cell;
  1120. }else{
  1121. switch (indexPath.section) {
  1122. case 0:{
  1123. WS(weakSelf);
  1124. NoteBookDetailCell *cell = [NoteBookDetailCell configCell3:tableView indexPath:indexPath];
  1125. cell.commentSortBtn.hidden = self.commentArray.count == 0 ? YES : NO;
  1126. [cell.commentSortBtn setAction:^{
  1127. weakSelf.isSort = !weakSelf.isSort;
  1128. cell.commentSortBtn.selected = !cell.commentSortBtn.isSelected;
  1129. [weakSelf sortCommentList];
  1130. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1131. weakSelf.isScrComment = YES;
  1132. [weakSelf scrollToCommentViewTop];
  1133. });
  1134. }];
  1135. switch (self.currentZanModel.Items.count) {
  1136. case 0:{
  1137. cell.zanNameLabel.text = @"";
  1138. cell.zanNumberlabel.text = @"";
  1139. }break;
  1140. case 1:{
  1141. MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
  1142. cell.zanNameLabel.text = model.UserName;
  1143. cell.zanNumberlabel.text = [NSString stringWithFormat:@" %lu人点赞",(unsigned long)self.currentZanModel.Items.count];
  1144. }break;
  1145. case 2:{
  1146. MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
  1147. MyNoteBookZanSubModel *model1 = self.currentZanModel.Items[1];
  1148. cell.zanNameLabel.text = [NSString stringWithFormat:@"%@、%@",model.UserName,model1.UserName];
  1149. cell.zanNumberlabel.text = [NSString stringWithFormat:@" %lu人点赞",(unsigned long)self.currentZanModel.Items.count];
  1150. }break;
  1151. case 3:{
  1152. MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
  1153. MyNoteBookZanSubModel *model1 = self.currentZanModel.Items[1];
  1154. MyNoteBookZanSubModel *model2 = self.currentZanModel.Items[2];
  1155. cell.zanNameLabel.text = [NSString stringWithFormat:@"%@、%@、%@",model.UserName,model1.UserName,model2.UserName];
  1156. cell.zanNumberlabel.text = [NSString stringWithFormat:@" %lu人点赞",(unsigned long)self.currentZanModel.Items.count];
  1157. }break;
  1158. default:{
  1159. MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
  1160. MyNoteBookZanSubModel *model1 = self.currentZanModel.Items[1];
  1161. MyNoteBookZanSubModel *model2 = self.currentZanModel.Items[2];
  1162. cell.zanNameLabel.text = [NSString stringWithFormat:@"%@、%@、%@",model.UserName,model1.UserName,model2.UserName];
  1163. cell.zanNumberlabel.text = [NSString stringWithFormat:@" 等%lu人点赞",(unsigned long)self.currentZanModel.Total];
  1164. }break;
  1165. }
  1166. return cell;
  1167. }break;
  1168. default:{
  1169. MHTopicCell *cell = [MHTopicCell cellWithTableView:tableView];
  1170. MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
  1171. cell.topicFrame = topicFrame;
  1172. cell.createTimeLabel.text = [NSString stringWithFormat:@"%@ %@",topicFrame.topic.FloorCount,topicFrame.topic.CreatedTime];
  1173. [cell.thumbBtn setAction:^{
  1174. [weakSelf gotoZanCommentHanderModel:topicFrame.topic indexPath:indexPath];
  1175. }];
  1176. cell.replyContentBlock = ^{
  1177. [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
  1178. // if (topicFrame.topic.UserId != [AppUserModel sharedAppUserModel].Id) {
  1179. // [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
  1180. // }
  1181. };
  1182. __block MHTopicCell * bCell = cell;
  1183. cell.longBlock = ^{
  1184. weakSelf.commentId = topicFrame.topic.Id;
  1185. weakSelf.commentStr = topicFrame.topic.Content;
  1186. weakSelf.isSelf = topicFrame.topic.UserId == [AppUserModel sharedAppUserModel].Id;
  1187. if (weakSelf.isSelf) {
  1188. [weakSelf longDeleteSelf:bCell];
  1189. }
  1190. };
  1191. cell.longSubBlock = ^(NSInteger commentId,UILabel * label,NSString * Content) {
  1192. weakSelf.commentId = commentId;
  1193. weakSelf.commentStr = Content;
  1194. [weakSelf longDeleteSubCell:label];
  1195. };
  1196. cell.delegate = self;
  1197. return cell;
  1198. }break;
  1199. }
  1200. }
  1201. }
  1202. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  1203. if (self.currentZanModel.Items.count > 0) {
  1204. switch (indexPath.section) {
  1205. case 0://点赞
  1206. {
  1207. ClickOKViewController *vc = [ClickOKViewController initClickOKViewController];
  1208. vc.indexId = self.Id;
  1209. vc.zanToTal = self.currentZanModel.Items.count;
  1210. vc.type = [self backTypeValue];
  1211. [self.navigationController pushViewController:vc animated:YES];
  1212. }
  1213. break;
  1214. default:
  1215. break;
  1216. }
  1217. }
  1218. }
  1219. #pragma mark - 点击文件跳转
  1220. - (void)pushVCWithDict:(NSDictionary *)dict
  1221. {
  1222. NSInteger Id = [dict[@"id"] integerValue];
  1223. NSInteger userId = [dict[@"userId"] integerValue];
  1224. NSString * title = dict[@"title"];
  1225. WS(weakSelf);
  1226. switch ([dict[@"type"] integerValue]) {
  1227. case CollectModel_Group:
  1228. {
  1229. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  1230. vc.GroupId = Id;
  1231. vc.titleStr = title;
  1232. [self.navigationController pushViewController:vc animated:YES];
  1233. }
  1234. break;
  1235. case CollectModel_file:{
  1236. DownFileViewController * vc = [[DownFileViewController alloc] init];
  1237. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  1238. model.Title = title;
  1239. model.SoureId = Id;
  1240. model.Url = dict[@"bigurl"];
  1241. model.MinUrl = dict[@"smallurl"];
  1242. model.SoureTypeId = CollectModel_file;
  1243. vc.model = model;
  1244. [self.navigationController pushViewController:vc animated:YES];
  1245. }break;
  1246. case CollectModel_Image:{
  1247. DownFileViewController * vc = [[DownFileViewController alloc] init];
  1248. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  1249. model.Title = title;
  1250. model.SoureId = Id;
  1251. model.Url = dict[@"bigurl"];
  1252. model.MinUrl = dict[@"smallurl"];
  1253. model.SoureTypeId = CollectModel_Image;
  1254. vc.model = model;
  1255. [self.navigationController pushViewController:vc animated:YES];
  1256. }break;
  1257. case CollectModel_Aritle:{
  1258. SHOWLOADING
  1259. [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)Id] parameters:@{} success:^(id _Nonnull responseObject) {
  1260. REMOVESHOW;
  1261. Item *itemModel = [[Item alloc]initWithDictionary:responseObject error:nil];
  1262. // HomeDetailController *homeDetail = [[HomeDetailController alloc] init];
  1263. // [homeDetail loadCurrentModel:itemModel];
  1264. // [weakSelf.navigationController pushViewController:homeDetail animated:YES];
  1265. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1266. vc.type = CollectModel_Aritle;
  1267. vc.Id = itemModel.Id;
  1268. [weakSelf.navigationController pushViewController:vc animated:YES];
  1269. } failure:^(NSError * _Nonnull error) {
  1270. // SHOWERROR([ZYCTool handerResultData:error]);
  1271. }];
  1272. }break;
  1273. case CollectModel_Notice:{
  1274. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1275. vc.type = CollectModel_Notice;
  1276. vc.Id = Id;
  1277. [self.navigationController pushViewController:vc animated:YES];
  1278. }break;
  1279. case CollectModel_Toipc:{
  1280. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1281. vc.type = CollectModel_Toipc;
  1282. vc.Id = Id;
  1283. [self.navigationController pushViewController:vc animated:YES];
  1284. }break;
  1285. case CollectModel_NewTopic:{
  1286. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1287. vc.type = CollectModel_NewTopic;
  1288. vc.Id = Id;
  1289. [self.navigationController pushViewController:vc animated:YES];
  1290. }break;
  1291. case CollectModel_NoteBook:{
  1292. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1293. vc.type = CollectModel_NoteBook;
  1294. vc.Id = Id;
  1295. [self.navigationController pushViewController:vc animated:YES];
  1296. }break;
  1297. case CollectModel_Collect:{
  1298. }break;
  1299. case CollectModel_CollectFile:{
  1300. if (userId == [AppUserModel sharedAppUserModel].Id) {
  1301. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  1302. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  1303. vc.ParentId = 0;
  1304. vc.FolderId = Id;
  1305. vc.myTitle = title;
  1306. [self.navigationController pushViewController:vc animated:YES];
  1307. }else{
  1308. OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
  1309. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  1310. vc.ParentId = 0;
  1311. vc.FolderId = Id;
  1312. vc.myTitle = title;
  1313. vc.VisitUserId = userId;
  1314. [self.navigationController pushViewController:vc animated:YES];
  1315. }
  1316. }break;
  1317. case CollectModel_NoteFile:{
  1318. if (userId == [AppUserModel sharedAppUserModel].Id) {
  1319. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  1320. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  1321. vc.ParentId = 0;
  1322. vc.FolderId = Id;
  1323. vc.myTitle = title;
  1324. vc.VisitUserId = 0;
  1325. [self.navigationController pushViewController:vc animated:YES];
  1326. }else{
  1327. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  1328. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  1329. vc.ParentId = 0;
  1330. vc.FolderId = Id;
  1331. vc.myTitle = title;
  1332. vc.VisitUserId = userId;
  1333. [self.navigationController pushViewController:vc animated:YES];
  1334. }
  1335. }break;
  1336. case CollectModel_InterMail:{
  1337. TDInterLeterDetailVC * vc = [TDInterLeterDetailVC initTDInterLeterDetailVC];
  1338. vc.detailType = InterLeterDetialType_Sign;
  1339. vc.interLeterID = Id;
  1340. [self.navigationController pushViewController:vc animated:YES];
  1341. }break;
  1342. case CollectModel_work:{
  1343. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  1344. vc.pageType = Type_ONEC;
  1345. vc.indexId = Id;
  1346. vc.title = title;
  1347. vc.TodoId = Id;
  1348. [self.navigationController pushViewController:vc animated:YES];
  1349. }break;
  1350. case CollectModel_meetDetail:{
  1351. WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:Id];
  1352. [self.navigationController pushViewController:vc animated:YES];
  1353. }break;
  1354. case CollectModel_meetMian:{
  1355. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1356. vc.type = CollectModel_meetMian;
  1357. vc.Id = Id;
  1358. [self.navigationController pushViewController:vc animated:YES];
  1359. }break;
  1360. case CollectModel_financeCount:{
  1361. CountDataVC *vc = [CountDataVC initCountDataVC];
  1362. vc.index = 0;
  1363. vc.titleStr = @"财务统计";
  1364. [self.navigationController pushViewController:vc animated:YES];
  1365. }break;
  1366. case CollectModel_affairsCount:{
  1367. CountDataVC *vc = [CountDataVC initCountDataVC];
  1368. vc.index = 1;
  1369. vc.titleStr = @"人事统计";
  1370. [self.navigationController pushViewController:vc animated:YES];
  1371. }break;
  1372. case CollectModel_publishCount:{
  1373. CountDataVC *vc = [CountDataVC initCountDataVC];
  1374. vc.index = 2;
  1375. vc.titleStr = @"出版统计";
  1376. [self.navigationController pushViewController:vc animated:YES];
  1377. }break;
  1378. default:
  1379. break;
  1380. }
  1381. }
  1382. #pragma mark - 操作 (删除 | 编辑 | 点赞列表 | 点赞正文 | 评论正文 | 转发正文 | 点赞评论 )
  1383. /// 删除
  1384. - (void)deleteButtonHander{
  1385. WS(weakSelf);
  1386. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认撤回" preferredStyle:(UIAlertControllerStyleAlert)];
  1387. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  1388. [weakSelf cancelAction];
  1389. }];
  1390. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  1391. }];
  1392. [alert addAction:sureAction];
  1393. [alert addAction:cancelAction];
  1394. [weakSelf presentViewController:alert animated:YES completion:^{
  1395. }];
  1396. }
  1397. - (void)cancelAction
  1398. {
  1399. WS(weakSelf);
  1400. switch (self.type) {
  1401. case CollectModel_Toipc:
  1402. {
  1403. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_APP_Topic),(long)self.Id];
  1404. [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  1405. SHOWSUCCESS(@"撤回成功");
  1406. if (weakSelf.deleteTopicBlock) {
  1407. weakSelf.deleteTopicBlock();
  1408. }
  1409. [weakSelf.navigationController popViewControllerAnimated:YES];
  1410. } failure:^(NSError * _Nonnull error) {
  1411. // SHOWERROR([ZYCTool handerResultData:error]);
  1412. }];
  1413. }
  1414. break;
  1415. case CollectModel_NewTopic:
  1416. {
  1417. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NoteBook_Detail),(long)self.Id];
  1418. [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  1419. SHOWSUCCESS(@"撤回成功");
  1420. if (weakSelf.deleteTopicBlock) {
  1421. weakSelf.deleteTopicBlock();
  1422. }
  1423. [weakSelf.navigationController popViewControllerAnimated:YES];
  1424. } failure:^(NSError * _Nonnull error) {
  1425. // SHOWERROR([ZYCTool handerResultData:error]);
  1426. }];
  1427. }
  1428. break;
  1429. case CollectModel_Group:
  1430. {
  1431. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NoteBook_Detail),(long)self.Id];
  1432. [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  1433. SHOWSUCCESS(@"撤回成功");
  1434. if (weakSelf.deleteTopicBlock) {
  1435. weakSelf.deleteTopicBlock();
  1436. }
  1437. [weakSelf.navigationController popViewControllerAnimated:YES];
  1438. } failure:^(NSError * _Nonnull error) {
  1439. }];
  1440. }
  1441. break;
  1442. case CollectModel_Notice:
  1443. {
  1444. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NOTICE_RECALL),(long)self.Id];
  1445. [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  1446. SHOWSUCCESS(@"撤回成功");
  1447. if (weakSelf.deleteTopicBlock) {
  1448. weakSelf.deleteTopicBlock();
  1449. }
  1450. [weakSelf.navigationController popViewControllerAnimated:YES];
  1451. } failure:^(NSError * _Nonnull error) {
  1452. }];
  1453. }
  1454. break;
  1455. case CollectModel_NoteBook:
  1456. {
  1457. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NoteBook_Detail),(long)self.Id];
  1458. [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  1459. SHOWSUCCESS(@"撤回成功");
  1460. if (weakSelf.deleteTopicBlock) {
  1461. weakSelf.deleteTopicBlock();
  1462. }
  1463. [weakSelf.navigationController popViewControllerAnimated:YES];
  1464. } failure:^(NSError * _Nonnull error) {
  1465. }];
  1466. }
  1467. break;
  1468. case CollectModel_meetMian:
  1469. {
  1470. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/api/app/meeting/summary/"),(long)self.Id];
  1471. [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  1472. SHOWSUCCESS(@"撤回成功");
  1473. if (weakSelf.deleteTopicBlock) {
  1474. weakSelf.deleteTopicBlock();
  1475. }
  1476. [weakSelf.navigationController popViewControllerAnimated:YES];
  1477. } failure:^(NSError * _Nonnull error) {
  1478. }];
  1479. }
  1480. break;
  1481. default:
  1482. break;
  1483. }
  1484. }
  1485. /// 编辑
  1486. - (void)editorButtonHander{
  1487. self.webH = 0;
  1488. WS(weakSelf);
  1489. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  1490. vc.upDateBlock = ^{
  1491. [weakSelf headRefresh];
  1492. };
  1493. vc.isEdit = YES;
  1494. vc.FolderId = self.currentNoteModel.FolderId;
  1495. vc.FolderName = self.currentNoteModel.FolderId == 0 ? @"根目录" :self.currentNoteModel.FolderName;
  1496. vc.replayType = MailReplayEdit;
  1497. vc.type = self.type;
  1498. vc.Id = self.Id;
  1499. [self.navigationController pushViewController:vc animated:YES];
  1500. }
  1501. /// 转发正文
  1502. - (void)ShareDetail{
  1503. SHOWLOADING
  1504. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  1505. [dic setValue:@(self.Id) forKey:@"SourceId"];
  1506. [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1507. [dic setValue:@(4) forKey:@"AnalyzeType"];///转发
  1508. [dic setValue:@(0) forKey:@"CommentId"];
  1509. [dic setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
  1510. WS(weakSelf);
  1511. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1512. REMOVESHOW
  1513. [weakSelf refreshData];
  1514. weakSelf.IsShareText = NO;
  1515. [weakSelf shareHander];
  1516. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1517. weakSelf.isScrComment = YES;
  1518. [weakSelf scrollToCommentViewTop];
  1519. });
  1520. } failure:^(NSError * _Nonnull error) {
  1521. REMOVESHOW
  1522. // SHOWERROR([ZYCTool handerResultData:error]);
  1523. }];
  1524. }
  1525. /// 点赞正文
  1526. - (void)gotoZanHander{
  1527. SHOWLOADING
  1528. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  1529. [dic setValue:@(self.Id) forKey:@"SourceId"];
  1530. [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1531. [dic setValue:@(1) forKey:@"AnalyzeType"];//详情点赞
  1532. [dic setValue:@(0) forKey:@"CommentId"];
  1533. [dic setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
  1534. WS(weakSelf);
  1535. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1536. REMOVESHOW
  1537. [weakSelf refreshData];
  1538. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1539. weakSelf.isScrComment = YES;
  1540. [weakSelf scrollToCommentViewTop];
  1541. });
  1542. } failure:^(NSError * _Nonnull error) {
  1543. REMOVESHOW
  1544. // SHOWERROR([ZYCTool handerResultData:error]);
  1545. }];
  1546. }
  1547. /// 评论正文
  1548. - (void)commentHander{
  1549. [_commentInputView startEditing];
  1550. WEAKSELF
  1551. self.commentInputView.inputBlock = ^(NSString * _Nonnull content) {
  1552. NSLog(@"%@",content);
  1553. [weakSelf sendCommentToServerWithcontent:content];
  1554. };
  1555. }
  1556. - (void)sendCommentToServerWithcontent:(NSString *)content
  1557. {
  1558. WS(weakSelf);
  1559. NSMutableDictionary *dicc = [NSMutableDictionary dictionary];
  1560. [dicc setValue:@(self.Id) forKey:@"ArticleId"];
  1561. [dicc setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1562. [dicc setValue:content forKey:@"Content"];
  1563. [dicc setValue:@(0) forKey:@"Pid"];//回复评论时用到的ID
  1564. [dicc setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
  1565. NSLog(@"%@",dicc);
  1566. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_Add) parameters:dicc responseStyle:DATA success:^(id _Nonnull responseObject) {
  1567. SHOWSUCCESS(@"评论成功");
  1568. weakSelf.countComment ++;
  1569. if (weakSelf.countComment == 0) {
  1570. self.commentCountL.text = [NSString stringWithFormat:@"评 论"];
  1571. }else{
  1572. if (weakSelf.countComment > 10000) {
  1573. weakSelf.commentCountL.text = [NSString stringWithFormat:@"%.1f万\n评 论",weakSelf.countComment / 10000.0];
  1574. }else{
  1575. weakSelf.commentCountL.text = [NSString stringWithFormat:@"%ld\n评 论",(long)weakSelf.countComment];
  1576. }
  1577. }
  1578. [weakSelf RefreshCommentList];
  1579. } failure:^(NSError * _Nonnull error) {
  1580. // SHOWERROR([ZYCTool handerResultData:error]);
  1581. }];
  1582. }
  1583. /// 转发正文
  1584. - (void)shareHander{
  1585. [self.noteBookShareVC initNoteBookShareData];
  1586. self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden;
  1587. }
  1588. - (NoteBookShareVC *)noteBookShareVC{
  1589. if (_noteBookShareVC == nil) {
  1590. _noteBookShareVC = [NoteBookShareVC initNoteBookShareVC];
  1591. [_noteBookShareVC.view setFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)];
  1592. [_noteBookShareVC.view setHidden:YES];
  1593. _noteBookShareVC.delegate = self;
  1594. }
  1595. return _noteBookShareVC;
  1596. }
  1597. -(void)userSelectType:(NSString *)typeName WithIndexPath:(NSIndexPath *)indexPath{
  1598. self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden;
  1599. if ([typeName isEqualToString:@"发给微信好友"]) {
  1600. [self returnToWechatSession];
  1601. }else if ([typeName isEqualToString:@"发到朋友圈"]){
  1602. [self returnToWechatTimeLine];
  1603. }else if ([typeName isEqualToString:@"发到微博"]){
  1604. [self returnToSina];
  1605. }else if ([typeName isEqualToString:@"发给QQ好友"]){
  1606. [self returnToQQ];
  1607. }else if ([typeName isEqualToString:@"发到消息"]){
  1608. [self returnToMessage];
  1609. }else if ([typeName isEqualToString:@"发到小组"]){
  1610. [self returnToGroup];
  1611. }else if ([typeName isEqualToString:@"发到笔记"]){
  1612. [self returnToNote];
  1613. }else if ([typeName isEqualToString:@"发到话题"]){
  1614. [self returnToTopic];
  1615. }else{
  1616. }
  1617. }
  1618. - (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType title:(NSString *)title desc:(NSString *)desc url:(NSString *)url
  1619. {
  1620. //创建分享消息对象
  1621. UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
  1622. messageObject.title = title;
  1623. //创建网页内容对象
  1624. UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:title descr:desc thumImage:IMG(@"logo_60")];
  1625. //设置网页地址
  1626. shareObject.webpageUrl = url;
  1627. //分享消息对象设置分享内容对象
  1628. messageObject.shareObject = shareObject;
  1629. //调用分享接口
  1630. [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
  1631. if (error) {
  1632. NSLog(@"************Share fail with error %@*********",error);
  1633. }else{
  1634. NSLog(@"response data is %@",data);
  1635. }
  1636. }];
  1637. }
  1638. - (void)returnToWechatSession
  1639. {
  1640. [self shareWebPageToPlatformType:UMSocialPlatformType_WechatSession title:self.currentNoteModel.Title desc:[NSString stringWithFormat:@"来自-%@",self.currentNoteModel.UserName] url:[self returnUrl]];
  1641. }
  1642. - (void)returnToWechatTimeLine
  1643. {
  1644. [self shareWebPageToPlatformType:UMSocialPlatformType_WechatTimeLine title:self.currentNoteModel.Title desc:[NSString stringWithFormat:@"来自-%@",self.currentNoteModel.UserName] url:[self returnUrl]];
  1645. }
  1646. - (void)returnToSina
  1647. {
  1648. [self shareWebPageToPlatformType:UMSocialPlatformType_Sina title:self.currentNoteModel.Title desc:[NSString stringWithFormat:@"来自-%@",self.currentNoteModel.UserName] url:[self returnUrl]];
  1649. }
  1650. - (void)returnToQQ
  1651. {
  1652. [self shareWebPageToPlatformType:UMSocialPlatformType_QQ title:self.currentNoteModel.Title desc:[NSString stringWithFormat:@"来自-%@",self.currentNoteModel.UserName] url:[self returnUrl]];
  1653. }
  1654. - (NSString *)returnUrl
  1655. {
  1656. switch (self.type) {
  1657. case CollectModel_Group:
  1658. {
  1659. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/admin/mobile/topicDetailsWx?"),(long)self.currentNoteModel.Id];
  1660. return url;
  1661. }
  1662. break;
  1663. case CollectModel_Toipc:
  1664. {
  1665. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/admin/mobile/topicDetailsWx?"),(long)self.currentNoteModel.Id];
  1666. return url;
  1667. }
  1668. break;
  1669. case CollectModel_NewTopic:
  1670. {
  1671. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/admin/mobile/noteDetailsWx?"),(long)self.currentNoteModel.Id];
  1672. return url;
  1673. }
  1674. break;
  1675. case CollectModel_Notice:
  1676. {
  1677. // NSString * url = [NSString stringWithFormat:@"%@%ld",@"http://192.168.0.119:8080/admin/mobile/noticeDetailsWx?",(long)self.currentNoteModel.Id];
  1678. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/admin/mobile/noticeDetailsWx?"),(long)self.currentNoteModel.Id];
  1679. return url;
  1680. }
  1681. break;
  1682. case CollectModel_NoteBook:
  1683. {
  1684. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/admin/mobile/noteDetailsWx?"),(long)self.currentNoteModel.Id];
  1685. return url;
  1686. }
  1687. break;
  1688. case CollectModel_InterMail:
  1689. {
  1690. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/admin/mobile/mailWx?"),(long)self.currentNoteModel.Id];
  1691. return url;
  1692. }
  1693. break;
  1694. case CollectModel_meetMian:
  1695. {
  1696. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/admin/mobile/minutesMeetingWx?"),(long)self.currentNoteModel.Id];
  1697. return url;
  1698. }
  1699. break;
  1700. case CollectModel_Aritle:
  1701. {
  1702. // NSString * url = [NSString stringWithFormat:@"%@%ld",@"http://192.168.0.119:8080/admin/mobile/mainText?",(long)self.currentNoteModel.Id];
  1703. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/admin/mobile/mainText?"),(long)self.currentNoteModel.Id];
  1704. return url;
  1705. }
  1706. break;
  1707. default:
  1708. {
  1709. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/admin/mobile/noticeDetailsWx?"),(long)self.currentNoteModel.Id];
  1710. return url;
  1711. }
  1712. break;
  1713. }
  1714. return @"";
  1715. }
  1716. #pragma mark - 分享功能
  1717. - (void)returnToMessage
  1718. {
  1719. ShareListVC * vc = [ShareListVC initShareListVC];
  1720. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  1721. model.SoureId = self.Id;
  1722. model.SoureTypeId = self.type;
  1723. model.Title = self.currentNoteModel.Title;
  1724. model.Author = self.currentNoteModel.UserName;
  1725. vc.sendModel = model;
  1726. vc.isReturn = YES;
  1727. [self.navigationController pushViewController:vc animated:YES];
  1728. }
  1729. - (void)returnToGroup
  1730. {
  1731. MyTDGroupViewController * vc = [[MyTDGroupViewController alloc] init];
  1732. vc.type = CollectModel_Group;
  1733. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  1734. model.SoureId = self.Id;
  1735. model.SoureTypeId = self.type;
  1736. model.Title = self.currentNoteModel.Title;
  1737. model.Author = self.currentNoteModel.UserName;
  1738. vc.sendModel = model;
  1739. vc.isReturn = YES;
  1740. [self.navigationController pushViewController:vc animated:YES];
  1741. }
  1742. - (void)returnToNote
  1743. {
  1744. MoveViewController * vc = [MoveViewController initMoveViewController];
  1745. vc.isFromCreateBookVc = YES;
  1746. vc.TypeId = CreateNotesType;
  1747. vc.titleStr = @"我的笔记";
  1748. vc.ParentId = 0;
  1749. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  1750. if (self.IsShareText) {
  1751. model.Title = self.shareText;
  1752. model.SoureTypeId = 1;
  1753. }else{
  1754. model.SoureId = self.Id;
  1755. model.SoureTypeId = self.type;
  1756. model.Title = self.currentNoteModel.Title;
  1757. model.Author = self.currentNoteModel.UserName;
  1758. vc.type = CollectModel_NoteBook;
  1759. }
  1760. vc.sendModel = model;
  1761. vc.isReturn = YES;
  1762. [self.navigationController pushViewController:vc animated:YES];
  1763. }
  1764. - (void)returnToTopic
  1765. {
  1766. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  1767. vc.type = CollectModel_NewTopic;
  1768. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  1769. if (self.IsShareText) {
  1770. model.Title = self.shareText;
  1771. model.SoureTypeId = 1;
  1772. }else{
  1773. model.SoureId = self.Id;
  1774. model.SoureTypeId = self.type;
  1775. model.Title = self.currentNoteModel.Title;
  1776. model.Author = self.currentNoteModel.UserName;
  1777. vc.type = CollectModel_NewTopic;
  1778. }
  1779. vc.sendModel = model;
  1780. vc.isReturn = YES;
  1781. [self.navigationController pushViewController:vc animated:YES];
  1782. }
  1783. /// 点赞评论
  1784. - (void)gotoZanCommentHanderModel:(MHTopic *)model indexPath:(NSIndexPath *)indexPath{
  1785. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  1786. [dic setValue:@(self.Id) forKey:@"SourceId"];
  1787. [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1788. [dic setValue:@(2) forKey:@"AnalyzeType"];//详情点赞
  1789. [dic setValue:@(model.Id) forKey:@"CommentId"];
  1790. [dic setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
  1791. WS(weakSelf);
  1792. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  1793. model.IsLaud = !model.IsLaud;
  1794. if (model.IsLaud) {
  1795. SHOWSUCCESS(@"点赞成功");
  1796. }else{
  1797. SHOWSUCCESS(@"取消点赞");
  1798. }
  1799. dispatch_async(dispatch_get_main_queue(), ^{
  1800. [weakSelf.tableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
  1801. });
  1802. } failure:^(NSError * _Nonnull error) {
  1803. // SHOWERROR([ZYCTool handerResultData:error]);
  1804. }];
  1805. }
  1806. - (void)gotoCollectHander{
  1807. MoveViewController *vc = [MoveViewController initMoveViewController];
  1808. //NSInteger meetId = [self.dataDict[@"MeetingId"] integerValue];
  1809. vc.CollectionDataId = self.Id;
  1810. vc.collectType = CollectHanderType_Collect;
  1811. vc.ParentId = 0;
  1812. vc.titleStr = @"我的收藏";
  1813. vc.TypeId = CreateCollectionType;
  1814. vc.FolderIds = @[].mutableCopy;
  1815. // 收藏类型 1文章 2话题 3 收藏 4笔记 5通知 6站内信 7小组 8 会议详情 14工作流审批 300 文件 400 会议纪要
  1816. switch (self.type) {
  1817. case CollectModel_meet:
  1818. vc.CollectionType = 400;
  1819. break;
  1820. case CollectModel_Aritle:
  1821. vc.CollectionType = 1;
  1822. break;
  1823. default:
  1824. vc.CollectionType = self.type;
  1825. break;
  1826. }
  1827. [self.navigationController pushViewController:vc animated:YES];
  1828. }
  1829. - (void)collectSuccess
  1830. {
  1831. [self refreshData];
  1832. }
  1833. - (NSMutableArray<MyNoteBookCommentSubModel *> *)commentArray{
  1834. if (!_commentArray) {
  1835. _commentArray = [NSMutableArray array];
  1836. }
  1837. return _commentArray;
  1838. }
  1839. - (TextInputView *)commentInputView {
  1840. if (!_commentInputView) {
  1841. _commentInputView = [[TextInputView alloc] initWithFrame:[UIScreen mainScreen].bounds];
  1842. }
  1843. return _commentInputView;
  1844. }
  1845. #pragma mark - MHTopicCellDelegate
  1846. - (void)topicCellForClickedThumbAction:(MHTopicCell *)topicCell
  1847. {
  1848. /**
  1849. * 这里点击事件自行根据自己UI处理
  1850. *
  1851. */
  1852. NSLog(@"---点击👍按钮---");
  1853. }
  1854. - (void)topicCellForClickedMoreAction:(MHTopicCell *)topicCell
  1855. {
  1856. /**
  1857. * 这里点击事件自行根据自己UI处理
  1858. *
  1859. */
  1860. // 修改数据源方法
  1861. MHTopic *topic = topicCell.topicFrame.topic;
  1862. topic.IsLaud = !topic.IsLaud;
  1863. if (topic.IsLaud) {
  1864. // topic.thumbNums+=1;
  1865. // }else{
  1866. // topic.thumbNums-=1;
  1867. }
  1868. // 刷新数据
  1869. [self.tableView reloadData];
  1870. }
  1871. - (void)topicCellDidClickedUser:(MHTopicCell *)topicCell
  1872. {
  1873. NSLog(@"======%ld",(long)topicCell.topicFrame.topic.UserId);
  1874. MailListDetailVC * vc = [MailListDetailVC initMailListDetailVC];
  1875. vc.indexId = topicCell.topicFrame.topic.UserId;
  1876. [self.navigationController pushViewController:vc animated:YES];
  1877. // MHUserInfoController *userInfo = [[MHUserInfoController alloc] init];
  1878. // userInfo.user = topicCell.topicFrame.topic.user;
  1879. // [self.navigationController pushViewController:userInfo animated:YES];
  1880. }
  1881. - (void)topicCell:(MHTopicCell *)topicCell didClickedUser:(NSString *)userId
  1882. {
  1883. NSLog(@"======%@",userId);
  1884. // MHUserInfoController *userInfo = [[MHUserInfoController alloc] init];
  1885. // userInfo.user = user;
  1886. // [self.navigationController pushViewController:userInfo animated:YES];
  1887. }
  1888. - (void)topicCell:(MHTopicCell *)topicCell didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  1889. {
  1890. MHTopicFrame *topicFrame = topicCell.topicFrame;
  1891. MHCommentFrame *commentFrame = topicFrame.commentFrames[indexPath.row];
  1892. NSLog(@"这里回复 -- :%@",commentFrame.comment.Id);
  1893. if (commentFrame.comment.UserId != [AppUserModel sharedAppUserModel].Id) {
  1894. [self replyCommentName:commentFrame.comment.Name andId:commentFrame.comment.Id];
  1895. }
  1896. }
  1897. #pragma mark - 长按删除评论Cell
  1898. - (void)longDeleteSelf:(MHTopicCell *)cell
  1899. {
  1900. [self becomeFirstResponder];
  1901. UIMenuController *menu = [UIMenuController sharedMenuController];
  1902. UIMenuItem *deleteItem = [[UIMenuItem alloc] initWithTitle:@"删除" action:@selector(deleteItemAction:)];
  1903. UIMenuItem *upDateItem = [[UIMenuItem alloc] initWithTitle:@"编辑" action:@selector(upDateItemAction:)];
  1904. [menu setMenuItems: @[deleteItem,upDateItem]];
  1905. NSLog(@"%@",NSStringFromCGRect(cell.frame));
  1906. [menu setTargetRect:cell.contentLabel.frame inView:cell];
  1907. [menu setMenuVisible:YES animated:NO];
  1908. }
  1909. - (void)longDeleteSubCell:(UILabel *)label
  1910. {
  1911. [self becomeFirstResponder];
  1912. UIMenuController *menu = [UIMenuController sharedMenuController];
  1913. UIMenuItem *deleteItem = [[UIMenuItem alloc] initWithTitle:@"删除" action:@selector(deleteItemAction:)];
  1914. UIMenuItem *upDateItem = [[UIMenuItem alloc] initWithTitle:@"编辑" action:@selector(upDateItemAction:)];
  1915. [menu setMenuItems: @[deleteItem,upDateItem]];
  1916. [menu setTargetRect:label.frame inView:label];
  1917. [menu setMenuVisible:YES animated:NO];
  1918. }
  1919. -(BOOL)canBecomeFirstResponder
  1920. {
  1921. return YES;
  1922. }
  1923. //是否可以接收某些菜单的某些交互操作
  1924. -(BOOL)canPerformAction:(SEL)action withSender:(id)sender{
  1925. return (action == @selector(deleteItemAction:)
  1926. ||action == @selector(upDateItemAction:));
  1927. }
  1928. - (void)deleteItemAction:(UIMenuItem *)item
  1929. {
  1930. WS(weakSelf);
  1931. SHOWLOADING
  1932. [[HttpManager sharedHttpManager] DeleteUrl:Host(API_APP_Comment_Delete) parameters:@{@"ArticleId":@(self.Id),@"CommentId":@(self.commentId)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  1933. REMOVESHOW
  1934. SHOWSUCCESS(@"删除成功");
  1935. [weakSelf headRefresh];
  1936. } failure:^(NSError * _Nonnull error) {
  1937. REMOVESHOW
  1938. }];
  1939. }
  1940. - (void)upDateItemAction:(UIMenuItem *)item
  1941. {
  1942. [self upDateComment];
  1943. }
  1944. - (void)upDateComment{
  1945. [_commentInputView setViewText:self.commentStr];
  1946. [_commentInputView startEditing];
  1947. WS(weakSelf);
  1948. self.commentInputView.inputBlock = ^(NSString * _Nonnull content) {
  1949. SHOWLOADING
  1950. [[HttpManager sharedHttpManager] PUTUrl:Host(API_APP_Comment_Update) parameters:@{@"Content":content,@"CommentId":@(weakSelf.commentId)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  1951. REMOVESHOW
  1952. [weakSelf RefreshCommentList];
  1953. } failure:^(NSError * _Nonnull error) {
  1954. REMOVESHOW
  1955. }];
  1956. };
  1957. }
  1958. - (void)replyCommentName:(NSString *)name andId:(NSString *)commentId{
  1959. [_commentInputView setPlaceText:[NSString stringWithFormat:@"回复%@:",name]];
  1960. [_commentInputView startEditing];
  1961. WEAKSELF
  1962. self.commentInputView.inputBlock = ^(NSString * _Nonnull content) {
  1963. NSLog(@"%@",content);
  1964. [weakSelf replyCommentWithcontent:content andId:commentId];
  1965. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1966. weakSelf.isScrComment = YES;
  1967. [weakSelf scrollToCommentViewTop];
  1968. });
  1969. };
  1970. }
  1971. - (void)replyCommentWithcontent:(NSString *)content andId:(NSString *)commentId
  1972. {
  1973. WS(weakSelf);
  1974. NSMutableDictionary *dicc = [NSMutableDictionary dictionary];
  1975. [dicc setValue:@(self.Id) forKey:@"ArticleId"];
  1976. [dicc setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1977. [dicc setValue:content forKey:@"Content"];
  1978. [dicc setValue:commentId forKey:@"Pid"];//回复评论时用到的ID
  1979. [dicc setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
  1980. NSLog(@"%@",dicc);
  1981. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_Add) parameters:dicc responseStyle:DATA success:^(id _Nonnull responseObject) {
  1982. SHOWSUCCESS(@"评论成功");
  1983. [weakSelf RefreshCommentList];
  1984. } failure:^(NSError * _Nonnull error) {
  1985. // SHOWERROR([ZYCTool handerResultData:error]);
  1986. }];
  1987. }
  1988. - (void)scrollToCommentViewTop
  1989. {
  1990. WS(weakSelf);
  1991. if (self.isScrComment) {
  1992. if (self.commentArray.count > 0 || self.currentZanModel.Items.count > 0) {
  1993. NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
  1994. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1995. [weakSelf.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
  1996. });
  1997. }
  1998. }else{
  1999. [self.tableView scrollToTop];
  2000. }
  2001. }
  2002. - (WKWebView *)webView
  2003. {
  2004. if (!_webView) {
  2005. WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
  2006. // 实例化对象
  2007. WKUserContentController* userContent = [[WKUserContentController alloc] init];
  2008. [userContent addScriptMessageHandler:self name:@"delelteAction"];
  2009. [userContent addScriptMessageHandler:self name:@"editAction"];
  2010. [userContent addScriptMessageHandler:self name:@"postTopicDetailsData"];
  2011. [userContent addScriptMessageHandler:self name:@"alreadyRead"];
  2012. [userContent addScriptMessageHandler:self name:@"to"];
  2013. [userContent addScriptMessageHandler:self name:@"goMeeting"];
  2014. [userContent addScriptMessageHandler:self name:@"goUser"];
  2015. [userContent addScriptMessageHandler:self name:@"goRead"];
  2016. [userContent addScriptMessageHandler:self name:@"postH"];
  2017. [userContent addScriptMessageHandler:self name:@"postSave"];
  2018. NSMutableString *javascript = [NSMutableString string];
  2019. [javascript appendString:@"document.documentElement.style.webkitTouchCallout='none';"];//禁止长按
  2020. // [javascript appendString:@"document.documentElement.style.webkitUserSelect='none';"];//禁止选择
  2021. WKUserScript *noneSelectScript = [[WKUserScript alloc] initWithSource:javascript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
  2022. [userContent addUserScript:noneSelectScript];
  2023. configuration.userContentController = userContent;
  2024. WKPreferences *preferences = [WKPreferences new];
  2025. preferences.javaScriptCanOpenWindowsAutomatically = YES;
  2026. preferences.minimumFontSize = 10.0;
  2027. configuration.preferences = preferences;
  2028. // 初始化WKWebView
  2029. _webView = [[WKWebView alloc]initWithFrame:CGRectZero configuration:configuration];
  2030. _webView.scrollView.scrollEnabled = NO;
  2031. _webView.scrollView.bounces = NO;
  2032. _webView.scrollView.showsVerticalScrollIndicator = NO;
  2033. _webView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  2034. }
  2035. return _webView;
  2036. }
  2037. - (void)loadDataWebView
  2038. {
  2039. NSString * url = nil;
  2040. switch (self.type) {
  2041. case CollectModel_Aritle:
  2042. {
  2043. url = @"/mobile/mainTextWeb";
  2044. }
  2045. break;
  2046. case CollectModel_Group:
  2047. {
  2048. url = @"/mobile/topicDetails";
  2049. }
  2050. break;
  2051. case CollectModel_Toipc:
  2052. {
  2053. url = @"/mobile/topicDetails";
  2054. }
  2055. break;
  2056. case CollectModel_NewTopic:
  2057. {
  2058. url = @"/mobile/topicDetails";
  2059. }
  2060. break;
  2061. case CollectModel_NoteBook:
  2062. {
  2063. url = @"/mobile/topicDetails";
  2064. }
  2065. break;
  2066. case CollectModel_Notice:
  2067. {
  2068. url = @"/mobile/noticeDetails";
  2069. }
  2070. break;
  2071. case CollectModel_InterMail:
  2072. {
  2073. url = @"/mobile/mail";
  2074. }
  2075. break;
  2076. case CollectModel_meetMian:
  2077. {
  2078. url = @"/mobile/minutesMeeting";
  2079. }
  2080. break;
  2081. default:
  2082. {
  2083. url = @"/mobile/topicDetails";
  2084. }
  2085. break;
  2086. }
  2087. NSURL *pathUrl = [NSURL URLWithString:HtmlHost(url)];
  2088. // NSURL *pathUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",@"Http://192.168.0.119:8080/admin",url]];
  2089. NSURLRequest *request = [NSURLRequest requestWithURL:pathUrl];
  2090. [self.webView loadRequest:request];
  2091. [self.webView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
  2092. }
  2093. - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
  2094. /** < 法2 > */
  2095. /** < loading:防止滚动一直刷新,出现闪屏 > */
  2096. if ([keyPath isEqualToString:@"contentSize"]) {
  2097. CGFloat H = self.webView.scrollView.contentSize.height;
  2098. NSLog(@"=========== webH :%f",H);
  2099. if (self.webH != H && H != 0) {
  2100. self.webH = H;
  2101. self.tableView.sectionHeaderHeight = self.webH;
  2102. [self.webView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.webH)];
  2103. [self setBottomViewData:self.currentNoteModel];
  2104. [self.tableView reloadData];
  2105. }
  2106. }
  2107. }
  2108. #pragma mark - WKScriptMessageHandler
  2109. - (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
  2110. if ([message.name isEqualToString:@"delelteAction"]) {
  2111. [self deleteButtonHander];
  2112. }
  2113. if ([message.name isEqualToString:@"editAction"]) {
  2114. [self editorButtonHander];
  2115. }
  2116. if ([message.name isEqualToString:@"postTopicDetailsData"]) {
  2117. NSString *jsonString = [NSString stringWithFormat:@"getData('%ld','%@','%ld')",(long)self.Id,USERDEFAULTSGET(@"LOGINTOKEN"),(long)self.type];
  2118. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  2119. NSLog(@"data:%@",data);
  2120. NSLog(@"error:%@",error);
  2121. }];
  2122. }
  2123. if ([message.name isEqualToString:@"postH"]) {
  2124. NSLog(@"msgBody:%@",message.body);
  2125. NSInteger H = [message.body integerValue];
  2126. self.tableView.sectionHeaderHeight = self.webH - H;
  2127. [self.webView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.webH - H)];
  2128. [self.tableView reloadData];
  2129. }
  2130. if ([message.name isEqualToString:@"postSave"]) {
  2131. NSString * imgUrl = message.body;
  2132. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  2133. UIAlertAction *actionYes = [UIAlertAction actionWithTitle:@"保存图片" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  2134. UIImage * img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imgUrl]]];
  2135. [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
  2136. [PHAssetChangeRequest creationRequestForAssetFromImage:img];
  2137. } completionHandler:^(BOOL success, NSError * _Nullable error) {
  2138. dispatch_async(dispatch_get_main_queue(), ^{
  2139. if (success) {
  2140. SHOWSUCCESS(@"图片保存成功");
  2141. }else{
  2142. SHOWERROR(@"图片保存失败");
  2143. }
  2144. });
  2145. }];
  2146. }];
  2147. UIAlertAction *actionNo = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  2148. }];
  2149. [alert addAction:actionYes];
  2150. [alert addAction:actionNo];
  2151. [self presentViewController:alert animated:YES completion:^{
  2152. }];
  2153. }
  2154. if ([message.name isEqualToString:@"alreadyRead"]) {
  2155. NSLog(@"msgBody:%@",message.body);
  2156. NSDictionary * dict = (NSDictionary *)message.body;
  2157. NoticeUnreadVC *vc = [NoticeUnreadVC initNoticeUnreadVC];
  2158. vc.Id = self.Id;
  2159. switch (self.type) {
  2160. case CollectModel_Notice:
  2161. vc.type = ReadNoticeType;
  2162. break;
  2163. case CollectModel_InterMail:
  2164. vc.type = ReadMissiveType;
  2165. break;
  2166. default:
  2167. vc.type = ReadNoticeType;
  2168. break;
  2169. }
  2170. vc.readCount = [dict[@"ReadCount"] integerValue];
  2171. vc.unReadCount = [dict[@"AllCount"] integerValue] - [dict[@"ReadCount"] integerValue];
  2172. [self.navigationController pushViewController:vc animated:YES];
  2173. }
  2174. if ([message.name isEqualToString:@"to"]) {
  2175. NSLog(@"msgBody:%@",message.body);
  2176. NSDictionary * dict = (NSDictionary *)message.body;
  2177. [self pushVCWithDict:dict];
  2178. }
  2179. if ([message.name isEqualToString:@"goMeeting"]) {
  2180. NSLog(@"msgBody:%@",message.body);
  2181. NSInteger meetId = [message.body integerValue];
  2182. WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:meetId];
  2183. [self.navigationController pushViewController:vc animated:YES];
  2184. }
  2185. if ([message.name isEqualToString:@"goUser"]) {
  2186. NSLog(@"msgBody:%@",message.body);
  2187. MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
  2188. vc.indexId = self.sendUserId;
  2189. [self.navigationController pushViewController:vc animated:YES];
  2190. }
  2191. if ([message.name isEqualToString:@"goRead"]) {
  2192. NSLog(@"msgBody:%@",message.body);
  2193. NSInteger count = [message.body integerValue];
  2194. ReadListVC * vc = [ReadListVC initReadListVC];
  2195. vc.type = self.type == CollectModel_Aritle ? 1 : self.type;
  2196. vc.indexId = self.Id;
  2197. vc.ReadTotal = count;
  2198. [self.navigationController pushViewController:vc animated:YES];
  2199. }
  2200. }
  2201. #pragma mark - WKScriptMessageHandler
  2202. - (NSString *)convertToJson:(NSDictionary *)dict
  2203. {
  2204. NSError *error;
  2205. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
  2206. NSString *jsonString;
  2207. if (!jsonData) {
  2208. NSLog(@"%@",error);
  2209. }else{
  2210. jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
  2211. }
  2212. NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
  2213. NSRange range = {0,jsonString.length};
  2214. //去掉字符串中的空格
  2215. [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
  2216. NSRange range2 = {0,mutStr.length};
  2217. //去掉字符串中的换行符
  2218. [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
  2219. return mutStr;
  2220. }
  2221. #pragma mark - WKUIDelegete
  2222. - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(void))completionHandler
  2223. {
  2224. NSLog(@"Aleart=========%@",message);
  2225. completionHandler();
  2226. }
  2227. - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(BOOL))completionHandler
  2228. {
  2229. completionHandler(YES);
  2230. }
  2231. - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(nonnull NSString *)prompt defaultText:(nullable NSString *)defaultText initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(NSString * _Nullable))completionHandler
  2232. {
  2233. completionHandler(@"111");
  2234. }
  2235. - (NSString *)arrayToJSONString:(NSArray *)array
  2236. {
  2237. NSError *error = nil;
  2238. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
  2239. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  2240. return jsonString;
  2241. }
  2242. - (void)dealloc {
  2243. WKWebsiteDataStore *dateStore = [WKWebsiteDataStore defaultDataStore];
  2244. [dateStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
  2245. completionHandler:^(NSArray * __nonnull records) {
  2246. for (WKWebsiteDataRecord *record in records)
  2247. {
  2248. [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
  2249. forDataRecords:@[record]
  2250. completionHandler:^{
  2251. NSLog(@"Cookies for %@ deleted successfully",record.displayName);
  2252. }];
  2253. }
  2254. }];
  2255. WKUserContentController *userCC = self.webView.configuration.userContentController;
  2256. [userCC removeScriptMessageHandlerForName:@"delelteAction"];
  2257. [userCC removeScriptMessageHandlerForName:@"editAction"];
  2258. [userCC removeScriptMessageHandlerForName:@"postTopicDetailsData"];
  2259. [userCC removeScriptMessageHandlerForName:@"alreadyRead"];
  2260. [userCC removeScriptMessageHandlerForName:@"to"];
  2261. [userCC removeScriptMessageHandlerForName:@"goMeeting"];
  2262. [userCC removeScriptMessageHandlerForName:@"goUser"];
  2263. [userCC removeScriptMessageHandlerForName:@"goRead"];
  2264. [userCC removeScriptMessageHandlerForName:@"postH"];
  2265. [userCC removeScriptMessageHandlerForName:@"postSave"];
  2266. [self.webView.scrollView removeObserver:self forKeyPath:@"contentSize"];
  2267. [[NSNotificationCenter defaultCenter] removeObserver:self];
  2268. [self.webView stopLoading];
  2269. self.webView.UIDelegate = nil;
  2270. self.webView.navigationDelegate = nil;
  2271. self.webView.scrollView.delegate = nil;
  2272. [self.webView removeFromSuperview];
  2273. }
  2274. - (NSInteger)backTypeValue
  2275. {
  2276. switch (self.type) {
  2277. case CollectModel_Aritle:
  2278. {
  2279. return 0;
  2280. }
  2281. break;
  2282. case CollectModel_Group:
  2283. {
  2284. return 1;
  2285. }
  2286. break;
  2287. case CollectModel_Toipc:
  2288. {
  2289. return 1;
  2290. }
  2291. break;
  2292. case CollectModel_Notice:
  2293. {
  2294. return 2;
  2295. }
  2296. break;
  2297. case CollectModel_NewTopic:
  2298. {
  2299. return 3;
  2300. }
  2301. break;
  2302. case CollectModel_NoteBook:
  2303. {
  2304. return 3;
  2305. }
  2306. break;
  2307. case CollectModel_meetMian:
  2308. {
  2309. return 10;
  2310. }
  2311. break;
  2312. case CollectModel_InterMail:
  2313. {
  2314. return 4;
  2315. }
  2316. break;
  2317. default:
  2318. {
  2319. return 1;
  2320. }
  2321. break;
  2322. }
  2323. }
  2324. - (void)refreshData
  2325. {
  2326. switch (self.type) {
  2327. case CollectModel_Aritle:
  2328. {
  2329. [self refreshAritleData];
  2330. }
  2331. break;
  2332. case CollectModel_Group:
  2333. {
  2334. [self refreshTopicData];
  2335. }
  2336. break;
  2337. case CollectModel_Toipc:
  2338. {
  2339. [self refreshTopicData];
  2340. }
  2341. break;
  2342. case CollectModel_NewTopic:
  2343. {
  2344. [self refreshNoteData];
  2345. }
  2346. break;
  2347. case CollectModel_Notice:
  2348. {
  2349. [self refreshNoticeData];
  2350. }
  2351. break;
  2352. case CollectModel_NoteBook:
  2353. {
  2354. [self refreshNoteData];
  2355. }
  2356. break;
  2357. case CollectModel_InterMail:
  2358. {
  2359. [self getMail];
  2360. }
  2361. break;
  2362. case CollectModel_meetMian:
  2363. {
  2364. [self refreshMeetingData];
  2365. }
  2366. break;
  2367. default:
  2368. {
  2369. [self refreshTopicData];
  2370. }
  2371. break;
  2372. }
  2373. }
  2374. #pragma mark - UIMenuController
  2375. //指定menu响应事件 屏蔽系统自带响应事件
  2376. //- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
  2377. // NSLog(@"%@", NSStringFromSelector(action));
  2378. // if (action == @selector(tySelectedAll:)
  2379. // ||action == @selector(shareSelectedText:)) {
  2380. // return YES;
  2381. // }
  2382. // if (action == @selector(cut:)
  2383. // ||action == @selector(select:)
  2384. // ||action == @selector(selectAll:)
  2385. // ||action == @selector(paste:)
  2386. // ||action == @selector(delete:)
  2387. // ||action == @selector(makeTextWritingDirectionRightToLeft:)
  2388. // ||action == @selector(makeTextWritingDirectionLeftToRight:)) {
  2389. // return NO;
  2390. // }
  2391. // return NO;
  2392. //}
  2393. //- (void)viewWillDisappear:(BOOL)animated{
  2394. // [super viewWillDisappear:animated];
  2395. // self.dismissSelf = YES;
  2396. //}
  2397. ////允许成为第一响应
  2398. //- (BOOL)canBecomeFirstResponder {
  2399. // return YES;
  2400. //}
  2401. //- (BOOL)canResignFirstResponder {
  2402. // if (self.dismissSelf) {
  2403. // return YES;
  2404. // }
  2405. // return NO;
  2406. //}
  2407. //
  2408. //- (void)tySelectedAll:(UIMenuController *)menu{
  2409. //
  2410. // [self.webView selectAll:menu];
  2411. // self.dismissSelf = YES;
  2412. //}
  2413. //#pragma mark 实现自定义方法
  2414. //- (void)shareSelectedText:(UIMenuController *)menu {
  2415. // WS(weakSelf);
  2416. // [self.webView evaluateJavaScript:@"window.getSelection().toString()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  2417. // NSLog(@"选中的文字为:%@", data);
  2418. // [self.webView copy:data];
  2419. // weakSelf.shareText = data;
  2420. // if (weakSelf.shareText.length > 0) {
  2421. // weakSelf.IsShareText = YES;
  2422. // [weakSelf shareHander];
  2423. // }
  2424. // }];
  2425. //}
  2426. //- (void)createMenuItems
  2427. //{
  2428. // UIMenuController * menu = [UIMenuController sharedMenuController];
  2429. // UIMenuItem *item1 = [[UIMenuItem alloc]initWithTitle:@"全选" action:@selector(tySelectedAll:)];
  2430. // UIMenuItem *item2 = [[UIMenuItem alloc]initWithTitle:@"转发" action:@selector(shareSelectedText:)];
  2431. // [menu setMenuItems:@[item1, item2]];
  2432. // menu.menuVisible = YES;
  2433. //}
  2434. @end