12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254 |
- //
- // MyTDTopicDetailVC.m
- // smartRhino
- //
- // Created by niuzhen on 2019/12/19.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "MyTDTopicDetailVC.h"
- #import "NoteBookDetailCell.h"
- #import "NoteBookShareVC.h"
- #import "MoveViewController.h"
- #import "ChangeTopicVC.h"
- #import "TDGroupInfoListVC.h"
- #import "TextInputView.h"
- #import "MHTopicCell.h"
- #import "MHTopic.h"
- #import "MHTopicFrame.h"
- #import "ClickOKViewController.h"
- #import "ReadListVC.h"
- #import "HomeDetailController.h"
- #import "ChatMsgNoticeDetailVC.h"
- #import "NoteBookDetailVC.h"
- #import "MyFavoriteVC.h"
- #import "NoteBookVC.h"
- #import "TDInterLeterDetailVC.h"
- #import "FileOpenViewController.h"
- #import "EMChatFileShowVC.h"
- #import "MyTDTopicCreateVC.h"
- #import "NoticeUnreadVC.h"
- #import "DownFileViewController.h"
- #import "CountDataVC.h"
- #import "WorkFlowDetailsController.h"
- #import "MyTDGroupViewController.h"
- #import "MoveViewController.h"
- #import "MyApprovalPageDetail.h"
- #import "WorkFlowDetailsController.h"
- #import "OtherFavoriteVC.h"
- #import "OtherNoteBookVC.h"
- #import "MailListDetailVC.h"
- #import "ReadListVC.h"
- #import "ShareListVC.h"
- #import "BookWCDetailVC.h"
- #import "BookListenVC.h"
- #import "ShowImageVC.h"
- @interface MyTDTopicDetailVC ()<UITableViewDataSource,UITableViewDelegate,NoteBookShareVCDelegate,MHTopicCellDelegate,WKUIDelegate,WKNavigationDelegate,UIScrollViewDelegate,WKScriptMessageHandler>
- @property (strong,nonatomic) IBOutlet UITableView *tableView;
- @property (nonatomic,assign) NSUInteger currentPage;
- @property (nonatomic,strong) MyNoteBookDetailModel *currentNoteModel;
- @property (nonatomic,strong) MyNodeBookZanModel *currentZanModel;
- @property (nonatomic,strong) MyNoteBookCommentModel *currentNoteCommentModel;
- @property (nonatomic,strong) NSMutableArray *commentArray;
- @property (nonatomic,assign) BOOL isFresh;
- @property (weak, nonatomic) IBOutlet UILabel *titleL;
- @property (weak, nonatomic) IBOutlet UIButton *commentButton;
- @property (weak, nonatomic) IBOutlet UIButton *commentScrollBtn;
- @property (weak, nonatomic) IBOutlet UILabel *commentNumberLabel;
- @property (weak, nonatomic) IBOutlet UIButton *zanButton;
- @property (weak, nonatomic) IBOutlet UIButton *collectButton;
- @property (weak, nonatomic) IBOutlet UIButton *shareButton;
- @property (weak, nonatomic) IBOutlet UILabel *commentCountL;
- @property (weak, nonatomic) IBOutlet UIImageView *zanImgV;
- @property (weak, nonatomic) IBOutlet UILabel *zanCountL;
- @property (weak, nonatomic) IBOutlet UIImageView *collectImgV;
- @property (weak, nonatomic) IBOutlet UILabel *collectL;
- @property (weak, nonatomic) IBOutlet UIImageView *shareImgV;
- @property (weak, nonatomic) IBOutlet UILabel *shareCountL;
- @property (weak, nonatomic) IBOutlet UIView *TalkView;
- @property (weak, nonatomic) IBOutlet UIView *ReplayView;
- @property (weak, nonatomic) IBOutlet UIButton *ReplayBtn;
- @property (weak, nonatomic) IBOutlet UIView *BottomView;
- @property (weak, nonatomic) IBOutlet UIButton *musicBtn;
- @property (weak, nonatomic) IBOutlet UIButton *shareBtn;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *shareWidth;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomHeight;
- @property (nonatomic, strong) TextInputView *commentInputView;
- @property (assign, nonatomic) NSInteger countComment;
- @property (strong, nonatomic) NoteBookShareVC *noteBookShareVC;
- @property (nonatomic,assign) BOOL isSort;
- @property (nonatomic,assign) BOOL isScrComment;
- @property (nonatomic,assign) CGFloat webH;
- @property (nonatomic,strong) WKWebView * webView;
- @property (nonatomic,assign) BOOL dismissSelf;
- @property (nonatomic,copy) NSString * shareText;
- @property (nonatomic,assign) BOOL IsShareText;
- @property (nonatomic,assign) NSInteger commentId;
- @property (nonatomic,copy) NSString * commentStr;
- @property (nonatomic,assign) BOOL isSelf;
- @property (nonatomic,assign) BOOL IsCollect;
- @property (nonatomic,assign) NSInteger sendUserId;
- @end
- @implementation MyTDTopicDetailVC
- +(MyTDTopicDetailVC *)initMyTDTopicDetailVC{
- MyTDTopicDetailVC *controller = [StoryboardManager.shared.myTDTopic instantiateViewControllerWithIdentifier:@"MyTDTopicDetailVC"];
- return controller;
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- WS(weakSelf);
- self.dismissSelf = NO;
- NSString *jsonString = [NSString stringWithFormat:@"getData('%ld','%@','%ld')",(long)self.Id,USERDEFAULTSGET(@"LOGINTOKEN"),(long)self.type];
-
- self.musicBtn.hidden = YES;
- switch (self.type) {
- case CollectModel_InterMail:
- {
- [self setMailBottomView:YES];
- [self.ReplayBtn setAction:^{
- weakSelf.dismissSelf = YES;
- [weakSelf ReplayAction];
- }];
- self.titleL.text = @"站内信";
- }
- break;
- case CollectModel_NoSignMail:
- {
- [self setMailBottomView:YES];
- [self.ReplayBtn setAction:^{
- weakSelf.dismissSelf = YES;
- [weakSelf ReplayAction];
- }];
- self.titleL.text = @"站内信";
- }
- break;
- case CollectModel_NewTopic:
- {
- self.titleL.text = @"话题";
- self.musicBtn.hidden = NO;
- [self setMailBottomView:NO];
- }
- break;
- case CollectModel_Toipc:
- {
- self.titleL.text = @"话题";
- self.musicBtn.hidden = NO;
- [self setMailBottomView:NO];
- }
- break;
- case CollectModel_Notice:
- {
- self.titleL.text = @"通知";
- [self setMailBottomView:NO];
- }
- break;
- case CollectModel_NoteBook:
- {
- self.titleL.text = @"笔记";
- self.shareWidth.constant = 50.f;
- self.bottomHeight.constant = 0.f;
- [self.shareBtn setAction:^{
- [weakSelf shareHander];
- }];
- self.BottomView.hidden = YES;
- self.shareBtn.hidden = NO;
- self.musicBtn.hidden = NO;
- }
- break;
- case CollectModel_Aritle:
- {
- self.titleL.text = @"正文";
- self.musicBtn.hidden = NO;
- [self setMailBottomView:NO];
- }
- break;
- case CollectModel_MediaAritle:
- {
- self.titleL.text = @"正文";
- self.musicBtn.hidden = NO;
- [self setMailBottomView:NO];
- }
- break;
- case CollectModel_meetMian:
- {
- self.titleL.text = @"会议纪要";
- self.musicBtn.hidden = NO;
- [self setMailBottomView:NO];
- }
- break;
- default:
- {
- self.titleL.text = @"正文";
- self.musicBtn.hidden = NO;
- [self setMailBottomView:NO];
- }
- break;
- }
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
- self.dismissSelf = YES;
- }
- - (void)setMailBottomView:(BOOL)isSet
- {
- if (isSet) {
- self.TalkView.hidden = YES;
- self.ReplayView.hidden = NO;
- self.ReplayBtn.layer.cornerRadius = 5.f;
- self.ReplayBtn.layer.masksToBounds = YES;
- self.ReplayBtn.layer.borderColor = UIColorHex(0x0F8AE3).CGColor;
- self.ReplayBtn.layer.borderWidth = 0.5f;
- [self.BottomView setBackgroundColor:UIColorHex(0xF5F5F5)];
- }else{
- [self.BottomView setBackgroundColor:[UIColor whiteColor]];
- self.TalkView.hidden = NO;
- self.TalkView.layer.cornerRadius = 4.f;
- self.TalkView.layer.masksToBounds = YES;
- self.TalkView.layer.borderColor = UIColorHex(0xE5E5E5).CGColor;
- self.TalkView.layer.borderWidth = 0.5f;
- self.ReplayView.hidden = YES;
- }
- }
- - (void)ReplayAction{
- WS(weakSelf);
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-
- UIAlertAction *alertAction1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf setCusMenuShare];
- }];
- [alertAction1 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- UIAlertAction *alertAction2 = [UIAlertAction actionWithTitle:@"回复" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- weakSelf.webH = 0;
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.upDateBlock = ^{
- [weakSelf headRefresh];
- };
- vc.replayType = MailReplayOne;
- vc.type = weakSelf.type;
- vc.isEdit = YES;
- vc.Id = weakSelf.Id;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- [alertAction2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"];
- UIAlertAction *alertAction3 = [UIAlertAction actionWithTitle:@"回复全部" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- weakSelf.webH = 0;
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.upDateBlock = ^{
- [weakSelf headRefresh];
- };
- vc.replayType = MailReplayAll;
- vc.isEdit = YES;
- vc.type = CollectModel_InterMail;
- vc.Id = weakSelf.Id;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- [alertAction3 setValue:UIColorHex(0x0A0A0A) forKey:@"titleTextColor"];
- [alert addAction:alertAction2];
- [alert addAction:alertAction3];
- [alert addAction:alertAction1];
-
- [self presentViewController:alert animated:YES completion:^{
-
- }];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
-
- [self setTableViewRefresh];
- WS(weakSelf);
- [self.shareButton setAction:^{
- weakSelf.dismissSelf = YES;
- [weakSelf ShareDetail];
- }];
- [self.zanButton setAction:^{
- weakSelf.dismissSelf = YES;
- [weakSelf gotoZanHander];
- }];
-
- if (self.type != CollectModel_InterMail || self.type != CollectModel_NoSignMail) {
- [self.commentButton setAction:^{
- weakSelf.dismissSelf = YES;
- [weakSelf commentHander];
- }];
- [self.commentScrollBtn setAction:^{
- weakSelf.isScrComment = !weakSelf.isScrComment;
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf scrollToCommentViewTop];
- });
- }];
- }
-
- [self.view addSubview:self.noteBookShareVC.view];
- [self.view addSubview:self.commentInputView];
- self.tableView.tableHeaderView = self.webView;
- self.webView.UIDelegate = self;
- self.webView.navigationDelegate = self;
- self.webView.scrollView.delegate = self;
- [self headRefresh];
- // UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
- // if (weakSelf.currentNoteModel.UserId == [AppUserModel sharedAppUserModel].Id) {
- // [weakSelf editorButtonHander];
- // }
- // }];
- // [self.webView addGestureRecognizer:tap];
- // self.webView.userInteractionEnabled = YES;
- // tap.numberOfTouchesRequired = 2;
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuShow) name:UIMenuControllerDidShowMenuNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(collectSuccess) name:COLLECTSUCCESS object:nil];
- // 通知-监听键盘弹出事件
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeKeyboardWillShowNotification:) name:UIKeyboardWillShowNotification object:nil];
- // 通知-监听键盘回收事
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeKeyboardWillHideNotification:) name:UIKeyboardWillHideNotification object:nil];
- [self createMenuItems];
- [self becomeFirstResponder];
- }
- #pragma mark - UIKeyBoradNotification
- - (void)changeKeyboardWillShowNotification:(NSNotification*)notification
- {
- WS(weakSelf);
- NSDictionary *userInfo = [notification userInfo];
- // 键盘弹出后的frame的结构体对象
- NSValue *valueEndFrame = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
- // 得到键盘弹出后的键盘视图所在y坐标
- CGFloat keyBoardEndY = valueEndFrame.CGRectValue.origin.y;
- // 键盘弹出的动画时间
- NSNumber *duration = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
- // 键盘弹出的动画曲线
- NSNumber *curve = [userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey];
- // 添加移动动画,使视图跟随键盘移动(动画时间和曲线都保持一致)
- [UIView animateWithDuration:[duration doubleValue] animations:^{
- [UIView setAnimationBeginsFromCurrentState:YES];
- [UIView setAnimationCurve:[curve intValue]];
- [UIView animateWithDuration:0.5 animations:^{
- [weakSelf.commentInputView startAnimationWithY:keyBoardEndY - 150.f];
- }];
- } completion:^(BOOL finished) {
-
- }];
- }
- - (void)changeKeyboardWillHideNotification:(NSNotification*)notification
- {
- WS(weakSelf);
- NSDictionary *userInfo = [notification userInfo];
- // 键盘弹出的动画时间
- NSNumber *duration = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
- // 键盘弹出的动画曲线
- NSNumber *curve = [userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey];
- [UIView animateWithDuration:[duration doubleValue]animations:^{
- [weakSelf.commentInputView startAnimationWithY:SCREEN_HEIGHT];
- [UIView setAnimationBeginsFromCurrentState:YES];
- [UIView setAnimationCurve:[curve intValue]];
- } completion:^(BOOL finished) {
- [weakSelf setCusMenuShare];
- }];
- }
- - (void)setTableViewRefresh{
- WS(weakSelf);
- self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- [weakSelf headRefresh];
- }];
- self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
- [weakSelf footerRefresh];
- }];
- }
- - (void)setBottomViewData:(MyNoteBookDetailModel *)model
- {
- WS(weakSelf);
- __block MyNoteBookDetailModel * weakModel = model;
- self.IsCollect = model.IsCollect;
- dispatch_async(dispatch_get_main_queue(), ^{
- weakSelf.countComment = weakModel.CommentCount;
- if (weakModel.CommentCount == 0) {
- weakSelf.commentCountL.text = [NSString stringWithFormat:@"评 论"];
- }else{
- if (weakModel.CommentCount > 10000) {
- weakSelf.commentCountL.text = [NSString stringWithFormat:@"%.1f万\n评 论",weakModel.CommentCount / 10000.0];
- }else{
- weakSelf.commentCountL.text = [NSString stringWithFormat:@"%ld\n评 论",(long)weakModel.CommentCount];
- }
- }
- weakSelf.zanCountL.text = [NSString stringWithFormat:@"%ld",(long)weakModel.PraiseCount];
- weakSelf.collectL.text = [NSString stringWithFormat:@"%ld",(long)weakModel.CollectCount];
- weakSelf.shareCountL.text = [NSString stringWithFormat:@"%ld",(long)weakModel.RetransmissionCount];
-
- weakSelf.zanCountL.hidden = weakModel.PraiseCount == 0 ? YES : NO;
- weakSelf.collectL.hidden = weakModel.CollectCount == 0 ? YES : NO;
- weakSelf.shareCountL.hidden = weakModel.RetransmissionCount == 0 ? YES : NO;
-
- weakSelf.zanImgV.image = weakModel.IsPraise ? IMG(@"zan_yes"):IMG(@"zan_no");
- weakSelf.collectImgV.image = weakModel.IsCollect ? IMG(@"icon_collect_off"):IMG(@"收藏五角星");
- weakSelf.shareImgV.image = IMG(@"icon_share");
- weakSelf.zanCountL.textColor = weakModel.IsPraise ? UIColorHex(#009AFF):UIColorHex(#999999);
- weakSelf.collectL.textColor = weakModel.IsCollect ? UIColorHex(#009AFF):UIColorHex(#999999);
- weakSelf.shareCountL.textColor = UIColorHex(#009AFF);
- [weakSelf.collectButton setAction:^{
- weakSelf.dismissSelf = YES;
- if (weakModel.IsCollect) {
- dispatch_async(dispatch_get_main_queue(), ^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"真的取消收藏吗?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *actionYes = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
- [dic setValue:@(weakSelf.Id) forKey:@"CollectionDataId"];
- /// 1文章 2话题 3 收藏 4笔记 5通知 6站内信 7小组 8 会议详情 14工作流审批 300 文件 400 会议纪要
- NSInteger type = weakSelf.type;
- [dic setValue:@(type) forKey:@"CollectionType"];
- [dic setValue:@(0) forKey:@"FolderId"];
- [dic setValue:@(0) forKey:@"SourceUserId"];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_CreateCollect) parameters:dic success:^(id _Nonnull responseObject) {
- [weakSelf refreshData];
- weakSelf.IsCollect = NO;
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- });
- [weakSelf setCusMenuShare];
- }];
- UIAlertAction *actionNo = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf setCusMenuShare];
- }];
- [alert addAction:actionYes];
- [alert addAction:actionNo];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- });
- }else{
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf gotoCollectHander];
- });
- }
- }];
- });
- }
- #pragma mark - 网络请求数据
- - (void)getNoticeData
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%ld",Host(API_Notice_Detail),(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"通知正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- weakSelf.sendUserId = weakSelf.currentNoteModel.UserId;
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
-
- NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//通知 2
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- }
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
-
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//通知 2
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)getTopic{
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_App_Detail) parameters:@{@"Id":@(self.Id),@"UserId":@([AppUserModel sharedAppUserModel].Id)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"话题正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//话题 1
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
-
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- }
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//话题 1
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)getMeeting{
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- NSString * meetId = [NSString stringWithFormat:@"%ld",(long)weakSelf.Id];
- [[HttpManager sharedHttpManager] GETUrl:Host(UpdateMeeting(meetId)) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//会议 10
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
-
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- }
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//会议 10
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)getNote{
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_NoteBook_Detail,(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"笔记正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
-
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- }
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//会议 10
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)getAritle{
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,[NSString stringWithFormat:@"/api/app/article/detail/%ld",self.Id]] parameters:@{@"id":@(self.Id)}
- responseStyle:JOSN success:^(id _Nonnull responseObject) {
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
-
- }];
- NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//会议 10
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- }
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//会议 10
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)getMediaAritle{
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_APP_Media),weakSelf.Id];
- [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- }];
- NSDictionary * comParaDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//会议 10
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:comParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- }
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//会议 10
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- if (++httpFinishCount == 3) {
- dispatch_semaphore_signal(sem);
- }
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)getMail
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%ld",Host(API_InterLetterDetail),(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- NSArray * array = responseObject[@"Items"];
- if ([array.firstObject isKindOfClass:[NSDictionary class]]) {
- weakSelf.sendUserId = [[array.firstObject objectForKey:@"UserId"] integerValue];
- }
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:array.firstObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//会议 10
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- #pragma mark - 刷新点赞数据
- - (void)refreshNoticeData
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%ld",Host(API_Notice_Detail),(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"通知正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
-
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//通知 2
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)refreshTopicData
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_App_Detail) parameters:@{@"Id":@(self.Id),@"UserId":@([AppUserModel sharedAppUserModel].Id)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"话题正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//话题 1
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)refreshMeetingData
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- NSString * meetId = [NSString stringWithFormat:@"%ld",(long)weakSelf.Id];
- [[HttpManager sharedHttpManager] GETUrl:Host(UpdateMeeting(meetId)) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//话题 1
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)refreshNoteData
- {
- WS(weakSelf);
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_NoteBook_Detail,(long)self.Id] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"话题正文%@",responseObject);
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//话题 1
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)refreshAritleData
- {
- WS(weakSelf);
- SHOWLOADING
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,[NSString stringWithFormat:@"/api/app/article/detail/%ld",self.Id]] parameters:@{@"id":@(self.Id)}
- responseStyle:JOSN success:^(id _Nonnull responseObject) {
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//会议 10
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- REMOVESHOW
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (void)refreshMediaAritleData
- {
- WS(weakSelf);
- SHOWLOADING
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
- __block NSInteger httpFinishCount = 0;
- [[HttpManager sharedHttpManager] cancelRequest];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_APP_Media),weakSelf.Id];
- [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
- weakSelf.currentNoteModel = [[MyNoteBookDetailModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- }else{
- NSLog(@"asfasfas");
- }
- } failure:^(NSError * _Nonnull error) {
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- }];
- NSDictionary * AnaParaDict = @{@"SourceId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//会议 10
- @"Page":@(1),
- @"PerPage":@(20),
- @"sort":@""
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"点赞列表%@",responseObject);
- weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- } failure:^(NSError * _Nonnull error) {
- if (++httpFinishCount == 2) {
- dispatch_semaphore_signal(sem);
- }
- }];
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
- dispatch_async(dispatch_get_main_queue(), ^{
- REMOVESHOW
- [weakSelf.tableView.mj_header endRefreshing];
- [weakSelf.tableView.mj_footer endRefreshing];
- [weakSelf setBottomViewData:weakSelf.currentNoteModel];
- [weakSelf.tableView reloadData];
- });
- });
- }
- - (MHTopicFrame *)_topicFrameWithTopic:(MHTopic *)topic
- {
- MHTopicFrame *topicFrame = [[MHTopicFrame alloc] init];
- // 传递微博模型数据,计算所有子控件的frame
- topicFrame.topic = topic;
-
- return topicFrame;
- }
- - (void)sortCommentList
- {
- WS(weakSelf);
- NSArray * array = self.commentArray;
- self.commentArray =[NSMutableArray arrayWithArray:[[array reverseObjectEnumerator] allObjects]];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- }
- - (void)RefreshCommentList
- {
- WS(weakSelf);
- [self.commentArray removeAllObjects];
- self.currentPage = 1;
- NSDictionary * paraDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//话题 1
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":weakSelf.isSort ? @"asc":@"desc"
- };
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
-
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.dismissSelf = NO;
- });
- });
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)headRefresh{
- self.isFresh = YES;
- self.currentPage = 1;
- [self.commentArray removeAllObjects];
- [self loadDataWebView];
- switch (self.type) {
- case CollectModel_Notice:
- {
- [self getNoticeData];
- }
- break;
- case CollectModel_Toipc:
- {
- [self getTopic];
- }
- break;
- case CollectModel_NewTopic:
- {
- [self getNote];
- }
- break;
- case CollectModel_Group:
- {
- [self getTopic];
- }
- break;
- case CollectModel_meetMian:
- {
- [self getMeeting];
- }
- break;
-
- case CollectModel_NoteBook:
- {
- [self getNote];
- }
- break;
- case CollectModel_InterMail:
- {
- [self getMail];
- }
- break;
- case CollectModel_NoSignMail:
- {
- [self getMail];
- }
- break;
- case CollectModel_Aritle:
- {
- [self getAritle];
- }
- break;
- case CollectModel_MediaAritle:
- {
- [self getMediaAritle];
- }
- break;
- default:
- break;
- }
- }
- - (void)footerRefresh{
- self.isFresh = NO;
- self.currentPage += 1;
- if (self.commentArray.count == self.currentNoteCommentModel.Total) {
- self.tableView.mj_footer.hidden = YES;
- [self.tableView.mj_footer resetNoMoreData];
- return;
- }
- NSDictionary * paraDict = @{@"ArticleId":@(self.Id),
- @"TypeValue":@([self backTypeValue]),//话题 1
- @"Page":@(self.currentPage),
- @"PerPage":@(20),
- @"sort":self.isSort ? @"asc":@"desc"
- };
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_List) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"评论数据列表%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
-
- if ([responseObject[@"Items"] isKindOfClass:[NSArray class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- MHTopic * topic = [MHTopic modelWithDictionary:dict];
- if ([[dict objectForKey:@"TopicCommentReplyResults"] isKindOfClass:[NSArray class]]) {
- NSMutableArray * subArray = [NSMutableArray array];
- for (NSDictionary * subDict in dict[@"TopicCommentReplyResults"]) {
- MHComment * commentModel = [MHComment modelWithDictionary:subDict];
- [subArray addObject:commentModel];
- }
- topic.CommentReplyResults = [NSMutableArray arrayWithArray:subArray];
- }
- [weakSelf.commentArray addObject:[weakSelf _topicFrameWithTopic:topic]];
- }
- }
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- weakSelf.currentPage -= 1;
- }];
- [self.tableView.mj_footer endRefreshing];
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- if (self.type == CollectModel_InterMail || self.type == CollectModel_NoSignMail) {
- return 1;
- }
- return 2;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- if (self.currentZanModel.Items.count == 0) {
- switch (section) {
- case 0:
- return 0;
- break;
- default:
- return self.commentArray.count;
- break;
- }
- }else{
- switch (section) {
- case 0:
- return 1;
- break;
- default:
- return self.commentArray.count;
- break;
- }
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (self.currentZanModel.Items.count == 0 && self.commentArray.count == 0) {
- MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
- if (topicFrame.tableViewFrame.size.height == 0) {
- return topicFrame.height+topicFrame.tableViewFrame.size.height;
- }else{
- return topicFrame.height+topicFrame.tableViewFrame.size.height+MHTopicVerticalSpace;
- }
- }else{
- switch (indexPath.section) {
- case 0:
- return UITableViewAutomaticDimension;
- break;
- default:
- {
- MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
- if (topicFrame.tableViewFrame.size.height == 0) {
- return topicFrame.height + topicFrame.tableViewFrame.size.height;
- }else{
- return topicFrame.height + topicFrame.tableViewFrame.size.height;
- }
- }
- break;
- }
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- WS(weakSelf);
- if (self.currentZanModel.Items.count == 0 && self.commentArray.count == 0) {
- MHTopicCell *cell = [MHTopicCell cellWithTableView:tableView];
- cell.backgroundColor = [UIColor whiteColor];
- MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
- cell.topicFrame = topicFrame;
- cell.createTimeLabel.text = [NSString stringWithFormat:@"%@ %@",topicFrame.topic.FloorCount,topicFrame.topic.CreatedTime];
- [cell.thumbBtn setAction:^{
- [weakSelf gotoZanCommentHanderModel:topicFrame.topic indexPath:indexPath];
- }];
- cell.replyContentBlock = ^{
- [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
- // if (topicFrame.topic.UserId != [AppUserModel sharedAppUserModel].Id) {
- // [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
- // }
- };
- __block MHTopicCell * bCell = cell;
- cell.longBlock = ^{
- weakSelf.commentId = topicFrame.topic.Id;
- weakSelf.commentStr = topicFrame.topic.Content;
- weakSelf.isSelf = topicFrame.topic.UserId == [AppUserModel sharedAppUserModel].Id;
- if (weakSelf.isSelf) {
- [weakSelf longDeleteSelf:bCell];
- }
- };
- cell.longSubBlock = ^(NSInteger commentId,UILabel * label,NSString * Content) {
- weakSelf.commentId = commentId;
- weakSelf.commentStr = Content;
- [weakSelf longDeleteSubCell:label];
- };
- cell.delegate = self;
- return cell;
- }else{
- switch (indexPath.section) {
- case 0:{
- WS(weakSelf);
- NoteBookDetailCell *cell = [NoteBookDetailCell configCell3:tableView indexPath:indexPath];
- cell.commentSortBtn.hidden = self.commentArray.count == 0 ? YES : NO;
- [cell.commentSortBtn setAction:^{
- weakSelf.isSort = !weakSelf.isSort;
- cell.commentSortBtn.selected = !cell.commentSortBtn.isSelected;
- [weakSelf sortCommentList];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.isScrComment = YES;
- [weakSelf scrollToCommentViewTop];
- });
- }];
- switch (self.currentZanModel.Items.count) {
- case 0:{
- cell.zanNameLabel.text = @"";
- cell.zanNumberlabel.text = @"";
- }break;
- case 1:{
- MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
- cell.zanNameLabel.text = model.UserName;
- cell.zanNumberlabel.text = [NSString stringWithFormat:@" %lu人点赞",(unsigned long)self.currentZanModel.Items.count];
- }break;
- case 2:{
- MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
- MyNoteBookZanSubModel *model1 = self.currentZanModel.Items[1];
- cell.zanNameLabel.text = [NSString stringWithFormat:@"%@、%@",model.UserName,model1.UserName];
- cell.zanNumberlabel.text = [NSString stringWithFormat:@" %lu人点赞",(unsigned long)self.currentZanModel.Items.count];
- }break;
- case 3:{
- MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
- MyNoteBookZanSubModel *model1 = self.currentZanModel.Items[1];
- MyNoteBookZanSubModel *model2 = self.currentZanModel.Items[2];
- cell.zanNameLabel.text = [NSString stringWithFormat:@"%@、%@、%@",model.UserName,model1.UserName,model2.UserName];
- cell.zanNumberlabel.text = [NSString stringWithFormat:@" %lu人点赞",(unsigned long)self.currentZanModel.Items.count];
- }break;
- default:{
- MyNoteBookZanSubModel *model = self.currentZanModel.Items[0];
- MyNoteBookZanSubModel *model1 = self.currentZanModel.Items[1];
- MyNoteBookZanSubModel *model2 = self.currentZanModel.Items[2];
- cell.zanNameLabel.text = [NSString stringWithFormat:@"%@、%@、%@",model.UserName,model1.UserName,model2.UserName];
- cell.zanNumberlabel.text = [NSString stringWithFormat:@" 等%lu人点赞",(unsigned long)self.currentZanModel.Total];
- }break;
- }
- return cell;
- }break;
- default:{
- MHTopicCell *cell = [MHTopicCell cellWithTableView:tableView];
- MHTopicFrame *topicFrame = self.commentArray[indexPath.row];
- cell.topicFrame = topicFrame;
- cell.createTimeLabel.text = [NSString stringWithFormat:@"%@ %@",topicFrame.topic.FloorCount,topicFrame.topic.CreatedTime];
- [cell.thumbBtn setAction:^{
- [weakSelf gotoZanCommentHanderModel:topicFrame.topic indexPath:indexPath];
- }];
- cell.replyContentBlock = ^{
- [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
- // if (topicFrame.topic.UserId != [AppUserModel sharedAppUserModel].Id) {
- // [weakSelf replyCommentName:topicFrame.topic.Name andId:[NSString stringWithFormat:@"%ld",(long)topicFrame.topic.Id]];
- // }
- };
- __block MHTopicCell * bCell = cell;
- cell.longBlock = ^{
- weakSelf.commentId = topicFrame.topic.Id;
- weakSelf.commentStr = topicFrame.topic.Content;
- weakSelf.isSelf = topicFrame.topic.UserId == [AppUserModel sharedAppUserModel].Id;
- if (weakSelf.isSelf) {
- [weakSelf longDeleteSelf:bCell];
- }
- };
- cell.longSubBlock = ^(NSInteger commentId,UILabel * label,NSString * Content) {
- weakSelf.commentId = commentId;
- weakSelf.commentStr = Content;
- [weakSelf longDeleteSubCell:label];
- };
- cell.delegate = self;
- return cell;
- }break;
- }
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- if (self.currentZanModel.Items.count > 0) {
- switch (indexPath.section) {
- case 0://点赞
- {
- ClickOKViewController *vc = [ClickOKViewController initClickOKViewController];
- vc.indexId = self.Id;
- vc.zanToTal = self.currentZanModel.Items.count;
- vc.type = [self backTypeValue];
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- default:
- break;
- }
- }
- }
- #pragma mark - 点击文件跳转
- - (void)pushVCWithDict:(NSDictionary *)dict
- {
- NSInteger Id = [dict[@"id"] integerValue];
- NSInteger userId = [dict[@"userId"] integerValue];
- NSString * title = dict[@"title"];
- WS(weakSelf);
- switch ([dict[@"type"] integerValue]) {
- case CollectModel_Group:
- {
- TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
- vc.GroupId = Id;
- vc.titleStr = title;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_file:{
- DownFileViewController * vc = [[DownFileViewController alloc] init];
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.Title = title;
- model.SoureId = Id;
- model.Url = dict[@"bigurl"];
- model.MinUrl = dict[@"smallurl"];
- model.SoureTypeId = CollectModel_file;
- vc.model = model;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Image:{
- DownFileViewController * vc = [[DownFileViewController alloc] init];
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.Title = title;
- model.SoureId = Id;
- model.Url = dict[@"bigurl"];
- model.MinUrl = dict[@"smallurl"];
- model.SoureTypeId = CollectModel_Image;
- vc.model = model;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Aritle:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_Aritle;
- vc.Id = Id;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_MediaAritle:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_Aritle;
- vc.Id = Id;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Notice:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_Notice;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_TopicBooK:{
- OtherNoteBookVC * vc = [OtherNoteBookVC initOtherNoteBookVC];
- vc.listType = MyFavoriteListLevelTypeA ;
- vc.FolderId = Id;
- vc.CollectionDataId = Id;
- vc.CollectionType = CollectModel_TopicBooK;
- vc.Author = title;
- vc.TypeValue = 1;
- vc.myTitle = title;
- vc.VisitUserId = userId;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_TopicSubBooK:{
- OtherNoteBookVC * vc = [OtherNoteBookVC initOtherNoteBookVC];
- vc.listType = MyFavoriteListLevelTypeB ;
- vc.FolderId = Id;
- vc.CollectionDataId = Id;
- vc.CollectionType = CollectModel_TopicSubBooK;
- vc.Author = title;
- vc.TypeValue = 1;
- vc.myTitle = title;
- vc.VisitUserId = userId;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Toipc:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_Toipc;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_NewTopic:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_NewTopic;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_NoteBook:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_NoteBook;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_Collect:{
-
- }break;
- case CollectModel_CollectFile:{
- if (userId == [AppUserModel sharedAppUserModel].Id) {
- MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
- vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- [self.navigationController pushViewController:vc animated:YES];
- }else{
- OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
- vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- vc.VisitUserId = userId;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }break;
- case CollectModel_NoteFile:{
- if (userId == [AppUserModel sharedAppUserModel].Id) {
- NoteBookVC *vc = [NoteBookVC initNoteBookVC];
- vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- vc.TypeValue = 1;
- vc.VisitUserId = 0;
- [self.navigationController pushViewController:vc animated:YES];
- }else{
- OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
- vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
- vc.ParentId = 0;
- vc.FolderId = Id;
- vc.myTitle = title;
- vc.TypeValue = 1;
- vc.VisitUserId = userId;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }break;
- case CollectModel_InterMail:{
- TDInterLeterDetailVC * vc = [TDInterLeterDetailVC initTDInterLeterDetailVC];
- vc.detailType = InterLeterDetialType_Sign;
- vc.interLeterID = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_NoSignMail:{
- TDInterLeterDetailVC * vc = [TDInterLeterDetailVC initTDInterLeterDetailVC];
- vc.detailType = InterLeterDetialType_NoSign;
- vc.interLeterID = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_work:{
- MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
- vc.pageType = Type_ONEC;
- vc.indexId = Id;
- vc.title = title;
- vc.TodoId = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_StoreSound:
- {
- BookListenVC * vc = [BookListenVC initBookListenVC];
- vc.Id = Id;
- vc.MediaType = MediaMusicType;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_StoreVideo:
- {
- BookWCDetailVC * vc = [BookWCDetailVC initBookWCDetailVC];
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_meetDetail:{
- WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:Id];
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_meetMian:{
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = CollectModel_meetMian;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_financeCount:{
- CountDataVC *vc = [CountDataVC initCountDataVC];
- vc.index = 0;
- vc.titleStr = @"财务统计";
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_affairsCount:{
- CountDataVC *vc = [CountDataVC initCountDataVC];
- vc.index = 1;
- vc.titleStr = @"人事统计";
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case CollectModel_publishCount:{
- CountDataVC *vc = [CountDataVC initCountDataVC];
- vc.index = 2;
- vc.titleStr = @"出版统计";
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- default:
- break;
- }
- }
- #pragma mark - 操作 (删除 | 编辑 | 点赞列表 | 点赞正文 | 评论正文 | 转发正文 | 点赞评论 )
- /// 删除
- - (void)deleteButtonHander{
- WS(weakSelf);
- NSString * title = @"确认删除";
- switch (self.type) {
- case CollectModel_Notice:
- {
- title = @"确认撤回";
- }
- break;
- case CollectModel_InterMail:
- {
- title = @"确认撤回";
- }
- break;
- default:
- {
- title = @"确认删除";
- }
- break;
- }
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:title preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf cancelAction];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
- }];
- }
- - (void)cancelAction
- {
- WS(weakSelf);
- switch (self.type) {
- case CollectModel_Toipc:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_APP_Topic),(long)self.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"删除成功");
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
-
- }];
- }
- break;
- case CollectModel_NewTopic:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NoteBook_Detail),(long)self.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"删除成功");
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- break;
- case CollectModel_Group:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NoteBook_Detail),(long)self.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"删除成功");
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- break;
- case CollectModel_Notice:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NOTICE_RECALL),(long)self.Id];
- [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"撤回成功");
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- break;
- case CollectModel_NoteBook:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NoteBook_Detail),(long)self.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"删除成功");
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- break;
- case CollectModel_InterMail:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NOTICE_RECALL),(long)self.Id];
- [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"撤回成功");
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- break;
- case CollectModel_meetMian:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/api/app/meeting/summary/"),(long)self.Id];
- [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"撤回成功");
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- break;
- case CollectModel_NoSignMail:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_NOTICE_RECALL),(long)self.Id];
- [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"撤回成功");
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- break;
- default:
- break;
- }
- }
- /// 编辑
- - (void)editorButtonHander{
- self.webH = 0;
- WS(weakSelf);
- if (self.RefreshTopicBlock) {
- self.RefreshTopicBlock();
- }
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.upDateBlock = ^{
- [weakSelf headRefresh];
- };
- vc.isEdit = YES;
- vc.FolderId = self.currentNoteModel.FolderId;
- vc.FolderName = self.currentNoteModel.FolderId == 0 ? @"根目录" :self.currentNoteModel.FolderName;
- vc.replayType = MailReplayEdit;
- switch (self.type) {
- case CollectModel_Notice:
- {
- vc.MailType = 3;
- vc.type = self.type;
- }
- break;
- case CollectModel_InterMail:
- {
- vc.MailType = 1;
- vc.type = self.type;
- }
- break;
- case CollectModel_NoSignMail:
- {
- vc.MailType = 2;
- vc.type = CollectModel_InterMail;
- }
- break;
- default:
- {
- vc.type = self.type;
- }
- break;
- }
- vc.Id = self.Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- /// 转发正文
- - (void)ShareDetail{
- SHOWLOADING
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setValue:@(self.Id) forKey:@"SourceId"];
- [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dic setValue:@(4) forKey:@"AnalyzeType"];///转发
- [dic setValue:@(0) forKey:@"CommentId"];
- [dic setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- [weakSelf refreshData];
- weakSelf.IsShareText = NO;
- [weakSelf shareHander];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.isScrComment = YES;
- [weakSelf scrollToCommentViewTop];
- });
- [weakSelf setCusMenuShare];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- [weakSelf setCusMenuShare];
- }];
- }
- /// 点赞正文
- - (void)gotoZanHander{
- SHOWLOADING
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setValue:@(self.Id) forKey:@"SourceId"];
- [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dic setValue:@(1) forKey:@"AnalyzeType"];//详情点赞
- [dic setValue:@(0) forKey:@"CommentId"];
- [dic setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- weakSelf.currentNoteModel.IsPraise = !weakSelf.currentNoteModel.IsPraise;
- if (weakSelf.currentNoteModel.IsPraise) {
- SHOWSUCCESS(@"点赞成功");
- }else{
- SHOWSUCCESS(@"已取消点赞");
- }
- [weakSelf refreshData];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.isScrComment = YES;
- [weakSelf scrollToCommentViewTop];
- [weakSelf setCusMenuShare];
- });
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- [weakSelf setCusMenuShare];
- }];
- }
- /// 评论正文
- - (void)commentHander{
- [self.commentInputView startEditing];
- WEAKSELF
- self.commentInputView.inputBlock = ^(NSString * _Nonnull content) {
- NSLog(@"%@",content);
- [weakSelf setCusMenuShare];
- [weakSelf sendCommentToServerWithcontent:content];
- };
- }
- - (void)sendCommentToServerWithcontent:(NSString *)content
- {
- WS(weakSelf);
- NSMutableDictionary *dicc = [NSMutableDictionary dictionary];
- [dicc setValue:@(self.Id) forKey:@"ArticleId"];
- [dicc setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dicc setValue:content forKey:@"Content"];
- [dicc setValue:@(0) forKey:@"Pid"];//回复评论时用到的ID
- [dicc setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
- NSLog(@"%@",dicc);
-
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_Add) parameters:dicc responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"评论成功");
- weakSelf.countComment ++;
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- if (weakSelf.countComment == 0) {
- self.commentCountL.text = [NSString stringWithFormat:@"评 论"];
- }else{
- if (weakSelf.countComment >= 10000) {
- weakSelf.commentCountL.text = [NSString stringWithFormat:@"%.1f万\n评 论",weakSelf.countComment / 10000.0];
- }else{
- weakSelf.commentCountL.text = [NSString stringWithFormat:@"%ld\n评 论",(long)weakSelf.countComment];
- }
- }
- [weakSelf RefreshCommentList];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- /// 转发正文
- - (void)shareHander{
- [self.noteBookShareVC initNoteBookShareData];
- self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden;
- }
- - (NoteBookShareVC *)noteBookShareVC{
- if (_noteBookShareVC == nil) {
- _noteBookShareVC = [NoteBookShareVC initNoteBookShareVC];
- [_noteBookShareVC.view setFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)];
- [_noteBookShareVC.view setHidden:YES];
- _noteBookShareVC.delegate = self;
- }
- return _noteBookShareVC;
- }
- -(void)userSelectType:(NSString *)typeName WithIndexPath:(NSIndexPath *)indexPath{
- self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden;
- if ([typeName isEqualToString:@"发给微信好友"]) {
- [self returnToWechatSession];
- }else if ([typeName isEqualToString:@"发到朋友圈"]){
- [self returnToWechatTimeLine];
- }else if ([typeName isEqualToString:@"发到微博"]){
- [self returnToSina];
- }else if ([typeName isEqualToString:@"发给QQ好友"]){
- [self returnToQQ];
- }else if ([typeName isEqualToString:@"发到消息"]){
- [self returnToMessage];
- }else if ([typeName isEqualToString:@"发到小组"]){
- [self returnToGroup];
- }else if ([typeName isEqualToString:@"发到笔记"]){
- [self returnToNote];
- }else if ([typeName isEqualToString:@"发到话题"]){
- [self returnToTopic];
- }else{
-
- }
- }
- - (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType title:(NSString *)title desc:(NSString *)desc url:(NSString *)url
- {
- //创建分享消息对象
- UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
-
- messageObject.title = title;
- //创建网页内容对象
- UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:title descr:desc thumImage:IMG(@"logo_60")];
- //设置网页地址
- shareObject.webpageUrl = url;
-
- //分享消息对象设置分享内容对象
- messageObject.shareObject = shareObject;
-
- //调用分享接口
- [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
- if (error) {
- NSLog(@"************Share fail with error %@*********",error);
- }else{
- NSLog(@"response data is %@",data);
- }
- }];
- }
- - (void)returnToWechatSession
- {
- NSString * name = @"";
- if (![self.currentNoteModel.Name isKindOfClass:[NSNull class]] && self.currentNoteModel.Name.length > 0) {
- name = self.currentNoteModel.Name;
- }else if(![self.currentNoteModel.UserName isKindOfClass:[NSNull class]] && self.currentNoteModel.UserName.length > 0) {
- name = self.currentNoteModel.UserName;
- }
- if (self.type == CollectModel_NoSignMail) {
- name = @"匿名";
- }
- if (self.type == CollectModel_Toipc) {
- name = [NSString stringWithFormat:@"%@ 来自-%@",name, self.currentNoteModel.GroupName];
- }
- [self shareWebPageToPlatformType:UMSocialPlatformType_WechatSession title:self.currentNoteModel.Title desc:name url:[self returnUrl] img:[self returnImage]];
- }
- - (void)returnToWechatTimeLine
- {
- NSString * name = @"";
- if (![self.currentNoteModel.Name isKindOfClass:[NSNull class]] && self.currentNoteModel.Name.length > 0) {
- name = self.currentNoteModel.Name;
- }else if(![self.currentNoteModel.UserName isKindOfClass:[NSNull class]] && self.currentNoteModel.UserName.length > 0) {
- name = self.currentNoteModel.UserName;
- }
- if (self.type == CollectModel_NoSignMail) {
- name = @"匿名";
- }
- if (self.type == CollectModel_Toipc) {
- name = [NSString stringWithFormat:@"%@ 来自-%@",name, self.currentNoteModel.GroupName];
- }
- [self shareWebPageToPlatformType:UMSocialPlatformType_WechatTimeLine title:self.currentNoteModel.Title desc:name url:[self returnUrl] img:[self returnImage]];
- }
- - (void)returnToSina
- {
- [self shareWebPageToPlatformType:UMSocialPlatformType_Sina title:self.currentNoteModel.Title desc:[NSString stringWithFormat:@"来自-%@",self.currentNoteModel.Name] url:[self returnUrl] img:[self returnImage]];
- }
- - (void)returnToQQ
- {
- [self shareWebPageToPlatformType:UMSocialPlatformType_QQ title:self.currentNoteModel.Title desc:[NSString stringWithFormat:@"来自-%@",self.currentNoteModel.Name] url:[self returnUrl] img:[self returnImage]];
- }
- - (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType title:(NSString *)title desc:(NSString *)desc url:(NSString *)url img:(NSString *)image
- {
- //创建分享消息对象
- UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
-
- messageObject.title = title;
- //创建网页内容对象
- UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:title descr:desc thumImage:[UIImage imageNamed:image]];
- //设置网页地址
- shareObject.webpageUrl = url;
-
- //分享消息对象设置分享内容对象
- messageObject.shareObject = shareObject;
-
- //调用分享接口
- [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
- if (error) {
- NSLog(@"************Share fail with error %@*********",error);
- }else{
- NSLog(@"response data is %@",data);
- }
- }];
- }
- - (NSString *)returnUrl
- {
- switch (self.type) {
- case CollectModel_Group:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/topicDetailsWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- case CollectModel_Toipc:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/topicDetailsWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- case CollectModel_NewTopic:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/noteDetailsWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- case CollectModel_Notice:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/noticeDetailsWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- case CollectModel_NoteBook:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/noteDetailsWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- case CollectModel_InterMail:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/mailWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- case CollectModel_NoSignMail:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/mailWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- case CollectModel_meetMian:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/minutesMeetingWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- case CollectModel_meetDetail:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/meetingWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- case CollectModel_Aritle:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/mainText?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- case CollectModel_NoteFile:
- {
- 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,@"笔记文件夹"];
- return url;
- }
- break;
- case CollectModel_CollectFile:
- {
- 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,@"收藏文件夹"];
- return url;
- }
- break;
- case CollectModel_TopicBooK:
- {
- 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,@"文件夹"];
- return url;
- }
- break;
- case CollectModel_TopicSubBooK:
- {
- 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,@"文件夹"];
- return url;
- }
- break;
- case CollectModel_work:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/approvalWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- default:
- {
- NSString * url = [NSString stringWithFormat:@"%@%ld",ShareHost(@"mobile/noticeDetailsWx?"),(long)self.currentNoteModel.Id];
- return url;
- }
- break;
- }
- return @"";
- }
- - (NSString *)returnImage
- {
- switch (self.type) {
- case CollectModel_Group:
- {
- NSString * url = @"笔记小组";
- return url;
- }
- break;
- case CollectModel_Toipc:
- {
- NSString * url = @"话题";
- return url;
- }
- break;
- case CollectModel_NewTopic:
- {
- NSString * url = @"话题";
- return url;
- }
- break;
- case CollectModel_Notice:
- {
- NSString * url = @"通知图标";
- return url;
- }
- break;
- case CollectModel_NoteBook:
- {
- NSString * url = @"noteBook_icon";
- return url;
- }
- break;
- case CollectModel_NoteFile:
- {
- NSString * url = @"share_file";
- return url;
- }
- break;
- case CollectModel_CollectFile:
- {
- NSString * url = @"share_file";
- return url;
- }
- break;
- case CollectModel_InterMail:
- {
- NSString * url = @"站内信";
- return url;
- }
- break;
- case CollectModel_NoSignMail:
- {
- NSString * url = @"站内信";
- return url;
- }
- break;
- case CollectModel_meetMian:
- {
- NSString * url = @"会议纪要";
- return url;
- }
- break;
- case CollectModel_meetDetail:
- {
- NSString * url = @"会议";
- return url;
- }
- break;
- case CollectModel_Aritle:
- {
- NSString * url = @"文章";
- return url;
- }
- break;
- case CollectModel_TopicBooK:
- {
- NSString * url = @"topicBook";
- return url;
- }
- break;
- case CollectModel_TopicSubBooK:
- {
- NSString * url = @"share_file";
- return url;
- }
- break;
- default:
- {
- NSString * url = @"笔记文章";
- return url;
- }
- break;
- }
- return @"";
- }
- #pragma mark - 分享功能
- - (void)returnToMessage
- {
- ShareListVC * vc = [ShareListVC initShareListVC];
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.SoureId = self.Id;
- model.SoureTypeId = self.type;
- model.Title = self.currentNoteModel.Title;
- model.Author = self.currentNoteModel.UserName;
- model.GroupId = self.currentNoteModel.GroupId;
- model.GroupName = self.currentNoteModel.GroupName;
- vc.sendModel = model;
- vc.isReturn = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)returnToGroup
- {
- MyTDGroupViewController * vc = [[MyTDGroupViewController alloc] init];
- vc.type = CollectModel_Toipc;
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- model.SoureId = self.Id;
- model.SoureTypeId = self.type;
- model.Title = self.currentNoteModel.Title;
- model.Author = self.currentNoteModel.UserName ? self.currentNoteModel.UserName : self.currentNoteModel.Name;
- model.SourceUserId = self.currentNoteModel.UserId;
- model.GroupId = self.currentNoteModel.GroupId;
- model.GroupName = self.currentNoteModel.GroupName;
- vc.sendModel = model;
- vc.isReturn = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)returnToNote
- {
- MoveViewController * vc = [MoveViewController initMoveViewController];
- vc.isFromCreateBookVc = YES;
- vc.TypeId = CreateNotesType;
- vc.CollectionType = CollectModel_NoteBook;
- vc.titleStr = @"我的笔记";
- vc.ParentId = 0;
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- if (self.IsShareText) {
- model.Title = self.shareText;
- model.SoureTypeId = 1;
- }else{
- model.SoureId = self.Id;
- model.SoureTypeId = self.type;
- model.Title = self.currentNoteModel.Title;
- model.Author = self.currentNoteModel.UserName ? self.currentNoteModel.UserName : self.currentNoteModel.Name;
- model.SourceUserId = self.currentNoteModel.UserId;
- model.GroupId = self.currentNoteModel.GroupId;
- model.GroupName = self.currentNoteModel.GroupName;
- vc.type = CollectModel_NoteBook;
- }
- vc.sendModel = model;
- vc.isReturn = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)returnToTopic
- {
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.type = CollectModel_NewTopic;
- FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
- if (self.IsShareText) {
- model.Title = self.shareText;
- model.SoureTypeId = 1;
- }else{
- model.SoureId = self.Id;
- model.SoureTypeId = self.type;
- model.Title = self.currentNoteModel.Title;
- model.Author = self.currentNoteModel.UserName ? self.currentNoteModel.UserName : self.currentNoteModel.Name;
- model.SourceUserId = self.currentNoteModel.UserId;
- model.GroupId = self.currentNoteModel.GroupId;
- model.GroupName = self.currentNoteModel.GroupName;
- vc.type = CollectModel_NewTopic;
- }
- vc.sendModel = model;
- vc.isReturn = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- /// 点赞评论
- - (void)gotoZanCommentHanderModel:(MHTopic *)model indexPath:(NSIndexPath *)indexPath{
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setValue:@(self.Id) forKey:@"SourceId"];
- [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dic setValue:@(2) forKey:@"AnalyzeType"];//详情点赞
- [dic setValue:@(model.Id) forKey:@"CommentId"];
- [dic setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
- WS(weakSelf);
-
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- model.IsLaud = !model.IsLaud;
- if (model.IsLaud) {
- SHOWSUCCESS(@"点赞成功");
- }else{
- SHOWSUCCESS(@"已取消点赞");
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
- });
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)gotoCollectHander{
- MoveViewController *vc = [MoveViewController initMoveViewController];
- //NSInteger meetId = [self.dataDict[@"MeetingId"] integerValue];
- vc.CollectionDataId = self.Id;
- vc.collectType = CollectHanderType_Collect;
- vc.CollectionType = self.type == CollectModel_NoSignMail ? CollectModel_InterMail : self.type;
- vc.ParentId = 0;
- vc.titleStr = @"我的收藏";
- vc.TypeId = CreateCollectionType;
- vc.FolderIds = @[].mutableCopy;
- // 收藏类型 1文章 2话题 3 收藏 4笔记 5通知 6站内信 7小组 8 会议详情 14工作流审批 300 文件 400 会议纪要
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)collectSuccess
- {
- NSString *jsonString = [NSString stringWithFormat:@"showCollection('%d')",1];
- [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"data:%@",data);
- NSLog(@"error:%@",error);
- }];
- NSLog(@"12313");
- WS(weakSelf);
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf refreshData];
- weakSelf.IsCollect = YES;
- });
- }
- - (NSMutableArray<MyNoteBookCommentSubModel *> *)commentArray{
- if (!_commentArray) {
- _commentArray = [NSMutableArray array];
- }
- return _commentArray;
- }
- - (TextInputView *)commentInputView {
- if (!_commentInputView) {
- _commentInputView = [[TextInputView alloc] initWithFrame:[UIScreen mainScreen].bounds];
- }
- return _commentInputView;
- }
- #pragma mark - MHTopicCellDelegate
- - (void)topicCellForClickedThumbAction:(MHTopicCell *)topicCell
- {
- /**
- * 这里点击事件自行根据自己UI处理
- *
- */
- NSLog(@"---点击👍按钮---");
- }
- - (void)topicCellForClickedMoreAction:(MHTopicCell *)topicCell
- {
- /**
- * 这里点击事件自行根据自己UI处理
- *
- */
- // 修改数据源方法
- MHTopic *topic = topicCell.topicFrame.topic;
- topic.IsLaud = !topic.IsLaud;
- if (topic.IsLaud) {
- // topic.thumbNums+=1;
- // }else{
- // topic.thumbNums-=1;
- }
-
- // 刷新数据
- [self.tableView reloadData];
- }
- - (void)topicCellDidClickedUser:(MHTopicCell *)topicCell
- {
- NSLog(@"======%ld",(long)topicCell.topicFrame.topic.UserId);
- MailListDetailVC * vc = [MailListDetailVC initMailListDetailVC];
- vc.indexId = topicCell.topicFrame.topic.UserId;
- [self.navigationController pushViewController:vc animated:YES];
- // MHUserInfoController *userInfo = [[MHUserInfoController alloc] init];
- // userInfo.user = topicCell.topicFrame.topic.user;
- // [self.navigationController pushViewController:userInfo animated:YES];
- }
- - (void)topicCell:(MHTopicCell *)topicCell didClickedUser:(NSString *)userId
- {
- NSLog(@"======%@",userId);
-
- // MHUserInfoController *userInfo = [[MHUserInfoController alloc] init];
- // userInfo.user = user;
- // [self.navigationController pushViewController:userInfo animated:YES];
- }
- - (void)topicCell:(MHTopicCell *)topicCell didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- MHTopicFrame *topicFrame = topicCell.topicFrame;
- MHCommentFrame *commentFrame = topicFrame.commentFrames[indexPath.row];
- NSLog(@"这里回复 -- :%@",commentFrame.comment.Id);
- if (commentFrame.comment.UserId != [AppUserModel sharedAppUserModel].Id) {
- [self replyCommentName:commentFrame.comment.Name andId:commentFrame.comment.Id];
- }
- }
- #pragma mark - 长按删除评论Cell
- - (void)longDeleteSelf:(MHTopicCell *)cell
- {
- [self becomeFirstResponder];
- UIMenuController *menu = [UIMenuController sharedMenuController];
- // UIMenuItem *copyItem = [[UIMenuItem alloc] initWithTitle:@"复制" action:@selector(copyItemAction:)];
- UIMenuItem *deleteItem = [[UIMenuItem alloc] initWithTitle:@"删除" action:@selector(deleteItemAction:)];
- UIMenuItem *upDateItem = [[UIMenuItem alloc] initWithTitle:@"编辑" action:@selector(upDateItemAction:)];
- [menu setMenuItems: @[deleteItem,upDateItem]];
- NSLog(@"%@",NSStringFromCGRect(cell.frame));
- [menu setTargetRect:cell.contentLabel.frame inView:cell];
- [menu setMenuVisible:YES animated:NO];
- }
- - (void)longDeleteSubCell:(UILabel *)label
- {
- [self becomeFirstResponder];
- UIMenuController *menu = [UIMenuController sharedMenuController];
- UIMenuItem *deleteItem = [[UIMenuItem alloc] initWithTitle:@"删除" action:@selector(deleteItemAction:)];
- UIMenuItem *upDateItem = [[UIMenuItem alloc] initWithTitle:@"编辑" action:@selector(upDateItemAction:)];
- [menu setMenuItems: @[deleteItem,upDateItem]];
- [menu setTargetRect:label.frame inView:label];
- [menu setMenuVisible:YES animated:NO];
- }
- //-(BOOL)canBecomeFirstResponder
- //{
- // return YES;
- //}
- //是否可以接收某些菜单的某些交互操作
- //-(BOOL)canPerformAction:(SEL)action withSender:(id)sender{
- // return (action == @selector(deleteItemAction:)
- // ||action == @selector(upDateItemAction:));
- //}
- - (void)copyItemAction:(UIMenuItem *)item
- {
- UIPasteboard *pboard = [UIPasteboard generalPasteboard];
- pboard.string = self.commentStr;
- SHOWSUCCESS(@"复制成功");
- NSLog(@"选中-----%@", pboard.string);
- }
- - (void)deleteItemAction:(UIMenuItem *)item
- {
- WS(weakSelf);
- SHOWLOADING
- [[HttpManager sharedHttpManager] DeleteUrl:Host(API_APP_Comment_Delete) parameters:@{@"ArticleId":@(self.Id),@"CommentId":@(self.commentId)} responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- SHOWSUCCESS(@"删除成功");
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf headRefresh];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- }];
- }
- - (void)upDateItemAction:(UIMenuItem *)item
- {
- [self upDateComment];
- }
- - (void)upDateComment{
- self.dismissSelf = YES;
- [self.view endEditing:YES];
- [self.commentInputView setViewText:self.commentStr];
- [self.commentInputView startEditing];
- WS(weakSelf);
- self.commentInputView.inputBlock = ^(NSString * _Nonnull content) {
- SHOWLOADING
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_APP_Comment_Update) parameters:@{@"Content":content,@"CommentId":@(weakSelf.commentId)} responseStyle:DATA success:^(id _Nonnull responseObject) {
- REMOVESHOW
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf RefreshCommentList];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- weakSelf.dismissSelf = NO;
- }];
- };
- }
- - (void)replyCommentName:(NSString *)name andId:(NSString *)commentId{
- WS(weakSelf);
- self.dismissSelf = YES;
- [self.commentInputView setPlaceText:[NSString stringWithFormat:@"回复%@:",name]];
- [self.commentInputView startEditing];
- self.commentInputView.inputBlock = ^(NSString * _Nonnull content) {
- NSLog(@"%@",content);
- weakSelf.dismissSelf = NO;
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf replyCommentWithcontent:content andId:commentId];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- weakSelf.isScrComment = YES;
- [weakSelf scrollToCommentViewTop];
- });
- };
- }
- - (void)replyCommentWithcontent:(NSString *)content andId:(NSString *)commentId
- {
- WS(weakSelf);
- NSMutableDictionary *dicc = [NSMutableDictionary dictionary];
- [dicc setValue:@(self.Id) forKey:@"ArticleId"];
- [dicc setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
- [dicc setValue:content forKey:@"Content"];
- [dicc setValue:commentId forKey:@"Pid"];//回复评论时用到的ID
- [dicc setValue:@([self backTypeValue]) forKey:@"TypeValue"];//话题 1
- NSLog(@"%@",dicc);
-
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Comment_Add) parameters:dicc responseStyle:DATA success:^(id _Nonnull responseObject) {
- SHOWSUCCESS(@"评论成功");
- if (weakSelf.RefreshTopicBlock) {
- weakSelf.RefreshTopicBlock();
- }
- [weakSelf RefreshCommentList];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)scrollToCommentViewTop
- {
- WS(weakSelf);
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- if (weakSelf.isScrComment) {
- if ((weakSelf.commentArray.count > 0 || weakSelf.currentZanModel.Items.count > 0) && weakSelf.tableView) {
- // NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
- [weakSelf.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:NSNotFound inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
- }
- }else{
- [weakSelf.tableView scrollToTop];
- }
- });
- }
- - (WKWebView *)webView
- {
- if (!_webView) {
- WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
- // 实例化对象
- WKUserContentController* userContent = [[WKUserContentController alloc] init];
- [userContent addScriptMessageHandler:self name:@"delelteAction"];
- [userContent addScriptMessageHandler:self name:@"editAction"];
- [userContent addScriptMessageHandler:self name:@"postTopicDetailsData"];
- [userContent addScriptMessageHandler:self name:@"alreadyRead"];
- [userContent addScriptMessageHandler:self name:@"to"];
- [userContent addScriptMessageHandler:self name:@"goMeeting"];
- [userContent addScriptMessageHandler:self name:@"goUser"];
- [userContent addScriptMessageHandler:self name:@"goRead"];
- [userContent addScriptMessageHandler:self name:@"postH"];
- [userContent addScriptMessageHandler:self name:@"postSave"];
- [userContent addScriptMessageHandler:self name:@"appCollection"];
- [userContent addScriptMessageHandler:self name:@"enlargeImg"];
- [userContent addScriptMessageHandler:self name:@"toNav"];
- NSMutableString *javascript = [NSMutableString string];
- [javascript appendString:@"document.documentElement.style.webkitTouchCallout='none';"];//禁止长按
- // [javascript appendString:@"document.documentElement.style.webkitUserSelect='none';"];//禁止选择
- WKUserScript *noneSelectScript = [[WKUserScript alloc] initWithSource:javascript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
- [userContent addUserScript:noneSelectScript];
-
- configuration.userContentController = userContent;
- WKPreferences *preferences = [WKPreferences new];
- preferences.javaScriptCanOpenWindowsAutomatically = YES;
- preferences.minimumFontSize = 10.0;
- configuration.preferences = preferences;
- // 初始化WKWebView
- _webView = [[WKWebView alloc]initWithFrame:CGRectZero configuration:configuration];
- _webView.scrollView.scrollEnabled = NO;
- _webView.scrollView.bounces = NO;
- _webView.scrollView.showsVerticalScrollIndicator = NO;
- _webView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- }
- return _webView;
- }
- - (void)loadDataWebView
- {
- NSString * url = nil;
- switch (self.type) {
- case CollectModel_Aritle:
- {
- url = @"/mobile/mainTextWeb";
- }
- break;
- case CollectModel_MediaAritle:
- {
- url = @"/mobile/periodicalWeb";
- }
- break;
- case CollectModel_Group:
- {
- url = @"/mobile/topicDetails";
- }
- break;
- case CollectModel_Toipc:
- {
- url = @"/mobile/topicDetails";
- }
- break;
- case CollectModel_NewTopic:
- {
- url = @"/mobile/topicDetails";
- }
- break;
- case CollectModel_NoteBook:
- {
- url = @"/mobile/topicDetails";
- }
- break;
- case CollectModel_Notice:
- {
- url = @"/mobile/noticeDetails";
- }
- break;
- case CollectModel_InterMail:
- {
- url = @"/mobile/mail";
- }
- break;
- case CollectModel_NoSignMail:
- {
- url = @"/mobile/mail";
- }
- break;
- case CollectModel_meetMian:
- {
- url = @"/mobile/minutesMeeting";
- }
- break;
- default:
- {
- url = @"/mobile/topicDetails";
- }
- break;
- }
- NSURL *pathUrl = [NSURL URLWithString:HtmlHost(url)];
- // NSURL *pathUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",@"Http://192.168.0.119:8080/admin",url]];
- NSURLRequest *request = [NSURLRequest requestWithURL:pathUrl];
- [self.webView loadRequest:request];
- [self.webView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
- }
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
- /** < 法2 > */
- /** < loading:防止滚动一直刷新,出现闪屏 > */
- if ([keyPath isEqualToString:@"contentSize"]) {
- CGFloat H = self.webView.scrollView.contentSize.height;
- NSLog(@"=========== webH :%f",H);
- if (self.webH != H && H != 0) {
- self.webH = H;
- self.tableView.sectionHeaderHeight = self.webH;
- [self.webView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.webH)];
- [self setBottomViewData:self.currentNoteModel];
- [self.tableView reloadData];
- }
- }
- }
- #pragma mark - WKScriptMessageHandler
- - (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
- if ([message.name isEqualToString:@"delelteAction"]) {
- [self deleteButtonHander];
- }
- if ([message.name isEqualToString:@"editAction"]) {
- [self editorButtonHander];
- }
- if ([message.name isEqualToString:@"postTopicDetailsData"]) {
- NSString *jsonString = [NSString stringWithFormat:@"getData('%ld','%@','%ld','%ld')",(long)self.Id,USERDEFAULTSGET(@"LOGINTOKEN"),(long)self.type,[AppUserModel sharedAppUserModel].Id];
- [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"data:%@",data);
- NSLog(@"error:%@",error);
- }];
- }
- if ([message.name isEqualToString:@"postH"]) {
- NSLog(@"msgBody:%@",message.body);
- NSInteger H = [message.body integerValue];
- self.tableView.sectionHeaderHeight = self.webH - H;
- [self.webView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.webH - H)];
- [self.tableView reloadData];
- }
- if ([message.name isEqualToString:@"postSave"]) {
- NSString * imgUrl = message.body;
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
- UIAlertAction *actionYes = [UIAlertAction actionWithTitle:@"保存图片" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- UIImage * img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imgUrl]]];
- [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
- [PHAssetChangeRequest creationRequestForAssetFromImage:img];
- } completionHandler:^(BOOL success, NSError * _Nullable error) {
- dispatch_async(dispatch_get_main_queue(), ^{
- if (success) {
- SHOWSUCCESS(@"图片保存成功");
- }else{
- SHOWERROR(@"图片保存失败");
- }
- });
- }];
- }];
- UIAlertAction *actionNo = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:actionYes];
- [alert addAction:actionNo];
- [self presentViewController:alert animated:YES completion:^{
- }];
- }
- if ([message.name isEqualToString:@"appCollection"]) {
- WS(weakSelf);
- if (self.IsCollect) {
- dispatch_async(dispatch_get_main_queue(), ^{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"真的取消收藏吗?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *actionYes = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
- [dic setValue:@(weakSelf.Id) forKey:@"CollectionDataId"];
- /// 1文章 2话题 3 收藏 4笔记 5通知 6站内信 7小组 8 会议详情 14工作流审批 300 文件 400 会议纪要
- NSInteger type = weakSelf.type;
- [dic setValue:@(type) forKey:@"CollectionType"];
- [dic setValue:@(0) forKey:@"FolderId"];
- [dic setValue:@(0) forKey:@"SourceUserId"];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [[HttpManager sharedHttpManager] PUTUrl:Host(API_CreateCollect) parameters:dic success:^(id _Nonnull responseObject) {
- [weakSelf refreshData];
- weakSelf.IsCollect = NO;
- NSString *jsonString = [NSString stringWithFormat:@"showCollection('%d')",0];
- [weakSelf.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"data:%@",data);
- NSLog(@"error:%@",error);
- }];
- } failure:^(NSError * _Nonnull error) {
- // SHOWERROR([ZYCTool handerResultData:error]);
- }];
- });
- [weakSelf setCusMenuShare];
- }];
- UIAlertAction *actionNo = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf setCusMenuShare];
- }];
- [alert addAction:actionYes];
- [alert addAction:actionNo];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- });
- }else{
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf gotoCollectHander];
- });
- }
- }
- if ([message.name isEqualToString:@"alreadyRead"]) {
- NSLog(@"msgBody:%@",message.body);
- NSDictionary * dict = (NSDictionary *)message.body;
- NoticeUnreadVC *vc = [NoticeUnreadVC initNoticeUnreadVC];
- vc.Id = self.Id;
- switch (self.type) {
- case CollectModel_Notice:
- vc.type = ReadNoticeType;
- break;
- case CollectModel_InterMail:
- vc.type = ReadMissiveType;
- break;
- case CollectModel_NoSignMail:
- vc.type = ReadMissiveType;
- break;
- default:
- vc.type = ReadNoticeType;
- break;
- }
- vc.readCount = [dict[@"ReadCount"] integerValue];
- vc.unReadCount = [dict[@"AllCount"] integerValue] - [dict[@"ReadCount"] integerValue];
- [self.navigationController pushViewController:vc animated:YES];
- }
- if ([message.name isEqualToString:@"to"]) {
- NSLog(@"msgBody:%@",message.body);
- NSDictionary * dict = (NSDictionary *)message.body;
- [self pushVCWithDict:dict];
- }
- if ([message.name isEqualToString:@"enlargeImg"]) {
- NSLog(@"msgBody:%@",message.body);
- [self showImageAction:message.body];
- }
- if ([message.name isEqualToString:@"toNav"]) {
- NSLog(@"msgBody:%@",message.body);
- [self OpenHttp:message.body];
- }
- if ([message.name isEqualToString:@"goMeeting"]) {
- NSLog(@"msgBody:%@",message.body);
- NSInteger meetId = [message.body integerValue];
- WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:meetId];
- [self.navigationController pushViewController:vc animated:YES];
- }
- if ([message.name isEqualToString:@"goUser"]) {
- NSLog(@"msgBody:%@",message.body);
- MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
- vc.indexId = self.sendUserId;
- [self.navigationController pushViewController:vc animated:YES];
- }
- if ([message.name isEqualToString:@"goRead"]) {
- NSLog(@"msgBody:%@",message.body);
- NSInteger count = [message.body integerValue];
- ReadListVC * vc = [ReadListVC initReadListVC];
- vc.type = self.type;
- vc.indexId = self.Id;
- vc.ReadTotal = count;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- #pragma mark - WKScriptMessageHandler
- - (NSString *)convertToJson:(NSDictionary *)dict
- {
- NSError *error;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
- NSString *jsonString;
- if (!jsonData) {
- NSLog(@"%@",error);
- }else{
- jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
- }
- NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
- NSRange range = {0,jsonString.length};
- //去掉字符串中的空格
- [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
- NSRange range2 = {0,mutStr.length};
- //去掉字符串中的换行符
- [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
- return mutStr;
- }
- //#pragma mark - WKUIDelegete
- //- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(void))completionHandler
- //{
- // UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:message?:@"" preferredStyle:UIAlertControllerStyleAlert];
- // [alertController addAction:([UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- // completionHandler();
- // }])];
- // [self presentViewController:alertController animated:YES completion:nil];
- // NSLog(@"Aleart=========%@",message);
- // completionHandler();
- //}
- //- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL))completionHandler{
- // // DLOG(@"msg = %@ frmae = %@",message,frame);
- // UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:message?:@"" preferredStyle:UIAlertControllerStyleAlert];
- // [alertController addAction:([UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- // completionHandler(NO);
- // }])];
- // [alertController addAction:([UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- // completionHandler(YES);
- // }])];
- // [self presentViewController:alertController animated:YES completion:nil];
- //}
- //- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString * _Nullable))completionHandler{
- // UIAlertController *alertController = [UIAlertController alertControllerWithTitle:prompt message:@"" preferredStyle:UIAlertControllerStyleAlert];
- // [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
- // textField.text = defaultText;
- // }];
- // [alertController addAction:([UIAlertAction actionWithTitle:@"完成" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- // completionHandler(alertController.textFields[0].text?:@"");
- // }])];
- // [self presentViewController:alertController animated:YES completion:nil];
- //}
- - (NSString *)arrayToJSONString:(NSArray *)array
- {
-
- NSError *error = nil;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
- NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- return jsonString;
- }
- - (void)dealloc {
- WKWebsiteDataStore *dateStore = [WKWebsiteDataStore defaultDataStore];
- [dateStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
- completionHandler:^(NSArray * __nonnull records) {
- for (WKWebsiteDataRecord *record in records)
- {
- [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
- forDataRecords:@[record]
- completionHandler:^{
- NSLog(@"Cookies for %@ deleted successfully",record.displayName);
- }];
- }
- }];
-
- WKUserContentController *userCC = self.webView.configuration.userContentController;
- [userCC removeScriptMessageHandlerForName:@"delelteAction"];
- [userCC removeScriptMessageHandlerForName:@"editAction"];
- [userCC removeScriptMessageHandlerForName:@"postTopicDetailsData"];
- [userCC removeScriptMessageHandlerForName:@"alreadyRead"];
- [userCC removeScriptMessageHandlerForName:@"to"];
- [userCC removeScriptMessageHandlerForName:@"goMeeting"];
- [userCC removeScriptMessageHandlerForName:@"goUser"];
- [userCC removeScriptMessageHandlerForName:@"goRead"];
- [userCC removeScriptMessageHandlerForName:@"postH"];
- [userCC removeScriptMessageHandlerForName:@"postSave"];
-
- [self.webView.scrollView removeObserver:self forKeyPath:@"contentSize"];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [self.webView stopLoading];
- self.webView.UIDelegate = nil;
- self.webView.navigationDelegate = nil;
- self.webView.scrollView.delegate = nil;
- [self.webView removeFromSuperview];
- }
- - (NSInteger)backTypeValue
- {
- switch (self.type) {
- case CollectModel_Aritle:
- {
- return 100;
- }
- break;
- case CollectModel_MediaAritle:
- {
- return 101;
- }
- break;
- case CollectModel_Group:
- {
- return 1;
- }
- break;
- case CollectModel_Toipc:
- {
- return 2;
- }
- break;
- case CollectModel_Notice:
- {
- return 5;
- }
- break;
- case CollectModel_NewTopic:
- {
- return -4;
- }
- break;
- case CollectModel_NoteBook:
- {
- return 4;
- }
- break;
- case CollectModel_meetMian:
- {
- return 8;
- }
- break;
- case CollectModel_InterMail:
- {
- return 6;
- }
- break;
- case CollectModel_NoSignMail:
- {
- return 6;
- }
- break;
- default:
- {
- return 1;
- }
- break;
- }
- }
- - (void)refreshData
- {
- switch (self.type) {
- case CollectModel_Aritle:
- {
- [self refreshAritleData];
- }
- break;
- case CollectModel_MediaAritle:
- {
- [self refreshMediaAritleData];
- }
- break;
- case CollectModel_Group:
- {
- [self refreshTopicData];
- }
- break;
- case CollectModel_Toipc:
- {
- [self refreshTopicData];
- }
- break;
- case CollectModel_NewTopic:
- {
- [self refreshNoteData];
- }
- break;
- case CollectModel_Notice:
- {
- [self refreshNoticeData];
- }
- break;
- case CollectModel_NoteBook:
- {
- [self refreshNoteData];
- }
- break;
- case CollectModel_InterMail:
- {
- [self getMail];
- }
- break;
- case CollectModel_NoSignMail:
- {
- [self getMail];
- }
- break;
- case CollectModel_meetMian:
- {
- [self refreshMeetingData];
- }
- break;
- default:
- {
- [self refreshTopicData];
- }
- break;
- }
- }
- #pragma mark - UIMenuController
- //指定menu响应事件 屏蔽系统自带响应事件
- - (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
- NSLog(@"%@", NSStringFromSelector(action));
- if (action == @selector(copyAction:)
- ||action == @selector(tySelectedAll:)
- ||action == @selector(shareSelectedText:)
- ||action == @selector(searchAction:)
- ||action == @selector(deleteItemAction:)
- ||action == @selector(upDateItemAction:)) {
- return YES;
- }
- if (action == @selector(cut:)
- ||action == @selector(select:)
- ||action == @selector(selectAll:)
- ||action == @selector(paste:)
- ||action == @selector(delete:)
- ||action == @selector(makeTextWritingDirectionRightToLeft:)
- ||action == @selector(makeTextWritingDirectionLeftToRight:)) {
- return NO;
- }
- return NO;
- }
- //允许成为第一响应
- - (BOOL)canBecomeFirstResponder {
- UIWindow *window = [[UIApplication sharedApplication].delegate window];
- if ([window isKeyWindow] == NO)
- {
- [window becomeKeyWindow];
- [window makeKeyAndVisible];
- }
- return YES;
- }
- - (BOOL)canResignFirstResponder {
- if (self.dismissSelf) {
- return YES;
- }
- return NO;
- }
- #pragma mark 实现自定义方法
- - (void)setCusMenuShare
- {
- self.dismissSelf = NO;
- // [self createMenuItems];
- }
- - (void)copyAction:(UIMenuController *)menu
- {
- SHOWSUCCESS(@"复制成功");
- [self.webView evaluateJavaScript:@"window.getSelection().toString()" completionHandler:^(id _Nullable content, NSError * _Nullable error) {
- UIPasteboard *pboard = [UIPasteboard generalPasteboard];
- pboard.string = (NSString *)content;
- NSLog(@"选中-----%@", pboard.string);
- }];
- }
- - (void)searchAction:(UIMenuController *)menu
- {
-
- }
- - (void)tySelectedAll:(UIMenuController *)menu{
-
- [self.webView selectAll:menu];
- self.dismissSelf = YES;
- }
- - (void)shareSelectedText:(UIMenuController *)menu {
- WS(weakSelf);
- [self.webView evaluateJavaScript:@"window.getSelection().toString()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
- NSLog(@"选中的文字为:%@", data);
- [self.webView copy:data];
- weakSelf.shareText = data;
- if (weakSelf.shareText.length > 0) {
- weakSelf.IsShareText = YES;
- [weakSelf shareHander];
- }
- }];
- }
- - (void)handleLongPress:(UILongPressGestureRecognizer *)sender
- {
- [self createMenuItems];
- }
- - (void)createMenuItems
- {
- UIMenuController * menu = [UIMenuController sharedMenuController];
- UIMenuItem *item1 = [[UIMenuItem alloc]initWithTitle:@"复制" action:@selector(copyAction:)];
- UIMenuItem *item2 = [[UIMenuItem alloc]initWithTitle:@"全选" action:@selector(tySelectedAll:)];
- UIMenuItem *item3 = [[UIMenuItem alloc]initWithTitle:@"摘录" action:@selector(shareSelectedText:)];
- UIMenuItem *item4 = [[UIMenuItem alloc]initWithTitle:@"搜索" action:@selector(searchAction:)];
- [menu setMenuItems:@[item1, item2, item3, item4]];
- menu.menuVisible = YES;
- }
- - (void)showImageAction:(NSString *)url
- {
- ShowImageVC * vc = [[ShowImageVC alloc] init];
- vc.url = url;
- vc.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:vc animated:YES completion:^{
-
- }];
- }
- - (void)OpenHttp:(NSString *)url
- {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url] options:@{} completionHandler:^(BOOL success) {
-
- }];
- }
- @end
|