MyTDTopicDetailVC.m 112 KB

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