MyTDTopicDetailVC.m 94 KB

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