MyTDTopicDetailVC.m 131 KB

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