MyTDTopicDetailVC.m 132 KB

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