MyTDTopicDetailVC.m 140 KB

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