MyTDTopicDetailVC.m 141 KB

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