192.m 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  1. //
  2. // MyTDTopicCreateVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2019/12/20.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyTDTopicCreateVC.h"
  9. #import "LYLPhotoTailoringTool.h"
  10. #import "FWZFileGetTool.h"
  11. #import "FWZGetNoteBookTool.h"
  12. #import "RichTextEditViewController.h"
  13. #import "AddLookUpUserSecondVC.h"
  14. #import "MyTDTopicSelectExtentVC.h"
  15. #import "FecordJoinWorkFlowListController.h"
  16. #import "_NoInputAccessoryView.h"
  17. #import "SelectSaveVC.h"
  18. #import "ShowBtn.h"
  19. #import "HomeDetailController.h"
  20. #import "ChatMsgNoticeDetailVC.h"
  21. #import "NoteBookDetailVC.h"
  22. #import "MyFavoriteVC.h"
  23. #import "NoteBookVC.h"
  24. #import "TDGroupInfoListVC.h"
  25. #import "TDInterLeterDetailVC.h"
  26. #import "FileOpenViewController.h"
  27. #import "EMChatFileShowVC.h"
  28. #import "MyTDTopicCreateVC.h"
  29. #import "NoticeUnreadVC.h"
  30. #import "DownFileViewController.h"
  31. #import "CountDataVC.h"
  32. #import "WorkFlowDetailsController.h"
  33. #import "MyTDGroupViewController.h"
  34. #import "MoveViewController.h"
  35. #import "ShowKeepNoticeAlert.h"
  36. #import "YCMenuView.h"
  37. #import "MyApprovalPageDetail.h"
  38. #import "OtherFavoriteVC.h"
  39. #import <objc/runtime.h>
  40. @interface MyTDTopicCreateVC ()<WKUIDelegate,WKNavigationDelegate,UIScrollViewDelegate,WKScriptMessageHandler>
  41. @property (weak, nonatomic) IBOutlet UIView *NavBarV;
  42. @property (weak, nonatomic) IBOutlet UIButton *DoneBtn;
  43. @property (nonatomic,strong) WKWebView *webView;
  44. @property (weak, nonatomic) IBOutlet UILabel *TitleL;
  45. @property (nonatomic,assign) CGFloat keyBoardH;
  46. @property (nonatomic,assign) BOOL isShoujianren;
  47. @property (nonatomic,assign) BOOL isChaosongren;
  48. @property (nonatomic,assign) NSInteger meetingId;
  49. @property (nonatomic,strong) NSMutableArray <SelectModel *> *chaoShongArray;
  50. @property (nonatomic,strong) NSMutableArray <SelectModel *> *shouJianArray;
  51. @property (nonatomic,strong) NSMutableArray * MeetingArray;
  52. @property (strong, nonatomic) ShowBtn * titleBtn;
  53. @property (copy, nonatomic) NSDictionary * H5JsonDict;
  54. @end
  55. @implementation MyTDTopicCreateVC
  56. + (MyTDTopicCreateVC *)initMyTDTopicCreateVC{
  57. MyTDTopicCreateVC *controller = [StoryboardManager.shared.myTDTopicExtent instantiateViewControllerWithIdentifier:@"MyTDTopicCreateVC"];
  58. return controller;
  59. }
  60. - (ShowBtn *)titleBtn
  61. {
  62. if (!_titleBtn) {
  63. _titleBtn = [[ShowBtn alloc] init];
  64. }
  65. return _titleBtn;
  66. }
  67. -(NSMutableArray *)getMenuDataSource{
  68. NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
  69. NSArray * titleArray = @[@"写信件",@"匿名信"];
  70. for(int i = 0;i < titleArray.count;i ++){
  71. NSString *titleStr = [titleArray objectAtIndex:i];
  72. WS(weakSelf);
  73. YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
  74. [weakSelf autoSizeBtn:action.title];
  75. if([@"写信件" isEqualToString:action.title]){
  76. weakSelf.MailType = 1;
  77. }
  78. else if ([@"匿名信" isEqualToString:action.title]){
  79. weakSelf.MailType = 2;
  80. }else{
  81. weakSelf.MailType = 1;
  82. }
  83. }];
  84. [menuDataSourceArray addObject:actionMenu];
  85. }
  86. return menuDataSourceArray;
  87. }
  88. - (void)autoSizeBtn:(NSString *)title
  89. {
  90. if (title.length > 9) {
  91. NSRange range1 = NSMakeRange(9, title.length - 9);
  92. NSString *resultStr1 = [title stringByReplacingCharactersInRange:range1 withString:@"..."];
  93. [self.titleBtn setLabelTitle:resultStr1];
  94. }else{
  95. [self.titleBtn setLabelTitle:title];
  96. }
  97. WS(weakSelf);
  98. [self.titleBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  99. make.center.mas_equalTo(weakSelf.NavBarV);
  100. }];
  101. [self.NavBarV layoutIfNeeded];
  102. }
  103. - (void)viewDidLoad {
  104. [super viewDidLoad];
  105. [self.DoneBtn setEnabled:NO];
  106. self.fd_prefersNavigationBarHidden = YES;
  107. WS(weakSelf);
  108. [self.DoneBtn setAction:^{
  109. [weakSelf submit];
  110. }];
  111. [self.NavBarV addSubview:self.titleBtn];
  112. [self.titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  113. make.center.mas_equalTo(weakSelf.NavBarV);
  114. }];
  115. [self.view addSubview:self.webView];
  116. [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
  117. make.top.mas_equalTo(weakSelf.NavBarV.mas_bottom);
  118. make.left.right.mas_equalTo(weakSelf.view);
  119. if (@available(iOS 11.0, *)) {
  120. make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
  121. } else {
  122. make.bottom.equalTo(weakSelf.view.mas_bottom);
  123. }
  124. }];
  125. self.webView.UIDelegate = self;
  126. // 导航代理
  127. self.webView.navigationDelegate = self;
  128. self.webView.scrollView.delegate = self;
  129. self.automaticallyAdjustsScrollViewInsets = YES;
  130. // NSURL *pathUrl = [NSURL URLWithString:HtmlHost(@"/#/mobile/editor")];
  131. NSURL *pathUrl = [NSURL URLWithString:@"http://192.168.0.119:8080/#/mobile/editor"];
  132. NSURLRequest *request = [NSURLRequest requestWithURL:pathUrl];
  133. [self.webView loadRequest:request];
  134. // [self hideWKWebviewKeyboardShortcutBar:self.webView];
  135. switch (self.type) {
  136. case CollectModel_Notice:
  137. {
  138. self.TitleL.hidden = NO;
  139. self.titleBtn.hidden = YES;
  140. self.TitleL.text = @"写通知";
  141. }
  142. break;
  143. case CollectModel_Toipc:
  144. {
  145. self.TitleL.hidden = NO;
  146. self.titleBtn.hidden = YES;
  147. self.TitleL.text = @"新建话题";
  148. }
  149. break;
  150. case CollectModel_NewTopic:
  151. {
  152. [self setDowntitleBtn];
  153. self.TitleL.hidden = YES;
  154. self.titleBtn.hidden = NO;
  155. if (self.FolderName.length > 0 && self.FolderId > 0) {
  156. [self autoSizeBtn:self.FolderName];
  157. }else{
  158. [self getTopicDefault];
  159. }
  160. }
  161. break;
  162. case CollectModel_NoteBook:
  163. {
  164. [self selectFold];
  165. self.TitleL.hidden = YES;
  166. self.titleBtn.hidden = NO;
  167. if (self.FolderName.length > 0 && self.FolderId > 0) {
  168. [self autoSizeBtn:self.FolderName];
  169. }else{
  170. [self getNoteDefault];
  171. }
  172. }
  173. break;
  174. case CollectModel_Group:
  175. {
  176. self.TitleL.hidden = NO;
  177. self.titleBtn.hidden = YES;
  178. self.TitleL.text = @"新建话题";
  179. }
  180. break;
  181. case CollectModel_InterMail:
  182. {
  183. if (self.replayType == MailReplayOne || self.replayType == MailReplayAll) {
  184. self.TitleL.hidden = NO;
  185. self.titleBtn.hidden = YES;
  186. self.TitleL.text = @"回复信函";
  187. }else{
  188. self.TitleL.hidden = YES;
  189. self.titleBtn.hidden = NO;
  190. [self selectMailType];
  191. if (self.MailType == 2) {
  192. [self autoSizeBtn:@"匿名信"];
  193. }else{
  194. [self autoSizeBtn:@"写信件"];
  195. self.MailType = 1;
  196. }
  197. }
  198. }
  199. break;
  200. case CollectModel_meetMian:
  201. {
  202. self.TitleL.hidden = NO;
  203. self.titleBtn.hidden = YES;
  204. self.TitleL.text = @"会议纪要";
  205. }
  206. break;
  207. default:
  208. break;
  209. }
  210. if (self.isEdit) {
  211. if (self.isFromDraft) {
  212. [self.DoneBtn setTitle:@"发送" forState:UIControlStateNormal];
  213. }else{
  214. [self.DoneBtn setTitle:@"完成" forState:UIControlStateNormal];
  215. }
  216. }else{
  217. [self.DoneBtn setTitle:@"发送" forState:UIControlStateNormal];
  218. }
  219. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ChangetitleBtn:) name:SELECTEXTENTSUCCESS object:nil];
  220. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
  221. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
  222. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recviveChaoSongRen:) name:NOTIFI_ChaoSongRen object:nil];
  223. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectFolder:) name:NOTIFI_SELECTCREATENOTEFOLDER object:nil];
  224. }
  225. - (void)selectMailType
  226. {
  227. WS(weakSelf);
  228. [self.titleBtn setAction:^{
  229. NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource];
  230. YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:114 relyonView:weakSelf.titleBtn];
  231. view.menuColor = RGB(255, 255, 255);
  232. view.separatorColor = RGB(234, 234, 234);
  233. view.textColor = RGB(102, 102, 102);
  234. view.textFont = [UIFont systemFontOfSize:16.0];
  235. view.menuCellHeight = 43.5;
  236. view.maxDisplayCount = 10;
  237. view.offset = -6;
  238. [view show];
  239. }];
  240. }
  241. - (void)upDateAction:(NSString *)action
  242. {
  243. [self.webView evaluateJavaScript:action completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  244. NSLog(@"data=====%@",data);
  245. NSLog(@"error=====%@",error);
  246. }];
  247. }
  248. - (void)getTopicDefault
  249. {
  250. WS(weakSelf);
  251. NSString * url = [NSString stringWithFormat:@"%@%d",Host(API_APP_Middle_Enjoy_Defaul),21];
  252. [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  253. dispatch_async(dispatch_get_main_queue(), ^{
  254. NSInteger MiddleId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  255. if (MiddleId > 0) {
  256. weakSelf.FolderId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  257. [weakSelf setSelectExtentText:[responseObject objectForKey:@"FolderName"]];
  258. }else{
  259. weakSelf.FolderId = 0;
  260. [weakSelf autoSizeBtn:@"选择发布范围"];
  261. }
  262. });
  263. } failure:^(NSError * _Nonnull error) {
  264. }];
  265. }
  266. - (void)getNoteDefault
  267. {
  268. WS(weakSelf);
  269. NSString * url = [NSString stringWithFormat:@"%@%d",Host(API_APP_Middle_Enjoy_Defaul),4];
  270. [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  271. dispatch_async(dispatch_get_main_queue(), ^{
  272. NSInteger MiddleId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  273. if (MiddleId > 0) {
  274. weakSelf.FolderId = [[responseObject objectForKey:@"MiddleId"] integerValue];
  275. [weakSelf autoSizeBtn:[responseObject objectForKey:@"FolderName"]];
  276. }else{
  277. weakSelf.FolderId = 0;
  278. [weakSelf autoSizeBtn:@"根目录"];
  279. }
  280. });
  281. } failure:^(NSError * _Nonnull error) {
  282. }];
  283. }
  284. - (void)selectFold{
  285. WS(weakSelf);
  286. [self.titleBtn setAction:^{
  287. SelectSaveVC * vc = [SelectSaveVC initSelectSaveVC];
  288. vc.isFromCreateBookVc = YES;
  289. vc.TypeId = CreateNotesType;
  290. vc.ParentId = 0;
  291. vc.FolderIds = @[].mutableCopy;
  292. vc.titleStr = @"选择存入范围";
  293. [weakSelf.navigationController pushViewController:vc animated:YES];
  294. }];
  295. }
  296. - (void)selectFolder:(NSNotification *)noti
  297. {
  298. NSDictionary * dict = noti.userInfo;
  299. [self autoSizeBtn:[dict objectForKey:@"FolderName"]];
  300. self.FolderId = [[dict objectForKey:@"FolderId"] integerValue];
  301. }
  302. - (void)ChangetitleBtn:(NSNotification *)notification
  303. {
  304. NSDictionary * dict = notification.userInfo;
  305. NSString * title = [NSString stringWithFormat:@"%@",[dict objectForKey:@"Name"]];
  306. self.FolderId = [[dict objectForKey:@"Id"] integerValue];
  307. if (title.length > 0) {
  308. [self setSelectExtentText:title];
  309. }
  310. }
  311. - (void)setDowntitleBtn
  312. {
  313. WS(weakSelf);
  314. [self.titleBtn setAction:^{
  315. MyTDTopicSelectExtentVC * vc = [MyTDTopicSelectExtentVC initMyTDTopicSelectExtentVC];
  316. vc.isSubVC = NO;
  317. vc.titleStr = @"选择发布范围";
  318. [weakSelf.navigationController pushViewController:vc animated:YES];
  319. }];
  320. }
  321. - (void)setSelectExtentText:(NSString *)title
  322. {
  323. if (title.length > 5) {
  324. NSRange range1 = NSMakeRange(5, title.length - 5);
  325. NSString *resultStr1 = [title stringByReplacingCharactersInRange:range1 withString:@"..."];
  326. NSString * title = [NSString stringWithFormat:@"发布范围:%@",resultStr1];
  327. [self autoSizeBtn:title];
  328. }else{
  329. NSString * cusTitle = [NSString stringWithFormat:@"发布范围:%@",title];
  330. [self autoSizeBtn:cusTitle];
  331. }
  332. }
  333. #pragma mark - layload
  334. - (WKWebView *)webView
  335. {
  336. if (!_webView) {
  337. WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
  338. // 实例化对象
  339. WKUserContentController* userContent = [[WKUserContentController alloc] init];
  340. [userContent addScriptMessageHandler:self name:@"chosePic"];
  341. [userContent addScriptMessageHandler:self name:@"toPZ"];
  342. [userContent addScriptMessageHandler:self name:@"toBJ"];
  343. [userContent addScriptMessageHandler:self name:@"toSC"];
  344. [userContent addScriptMessageHandler:self name:@"toWJ"];
  345. [userContent addScriptMessageHandler:self name:@"keyBoard"];
  346. [userContent addScriptMessageHandler:self name:@"approverCheckUsers"];
  347. [userContent addScriptMessageHandler:self name:@"carbonCopyUsers"];
  348. [userContent addScriptMessageHandler:self name:@"changeState"];
  349. [userContent addScriptMessageHandler:self name:@"getType"];
  350. [userContent addScriptMessageHandler:self name:@"to"];
  351. [userContent addScriptMessageHandler:self name:@"getJp"];
  352. configuration.userContentController = userContent;
  353. WKPreferences *preferences = [WKPreferences new];
  354. preferences.javaScriptCanOpenWindowsAutomatically = YES;
  355. preferences.minimumFontSize = 10.0;
  356. configuration.preferences = preferences;
  357. // 初始化WKWebView
  358. _webView = [[WKWebView alloc]initWithFrame:CGRectZero configuration:configuration];
  359. _NoInputAccessoryView *noInputView = [[_NoInputAccessoryView alloc] init];
  360. [noInputView removeInputAccessoryViewFromWKWebView:_webView];
  361. // UI代理
  362. }
  363. return _webView;
  364. }
  365. -(NSMutableArray<SelectModel *> *)shouJianArray{
  366. if(!_shouJianArray){
  367. _shouJianArray = [[NSMutableArray alloc] init];
  368. }
  369. return _shouJianArray;
  370. }
  371. -(NSMutableArray<SelectModel *> *)chaoShongArray{
  372. if(!_chaoShongArray){
  373. _chaoShongArray = [[NSMutableArray alloc] init];
  374. }
  375. return _chaoShongArray;
  376. }
  377. #pragma mark - KeyBoard
  378. - (void)keyBoardWillShow:(NSNotification *)note
  379. {
  380. // 获取用户信息
  381. NSDictionary *userInfo = [NSDictionary dictionaryWithDictionary:note.userInfo];
  382. // 获取键盘高度
  383. CGRect keyBoardBounds = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
  384. if (IS_IPHONEX) {
  385. self.keyBoardH = keyBoardBounds.size.height - 34;
  386. }else{
  387. self.keyBoardH = keyBoardBounds.size.height;
  388. }
  389. [self.webView evaluateJavaScript:@"textFocus()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  390. NSLog(@"keyShow");
  391. }];
  392. }
  393. - (void)keyBoardWillHide:(NSNotification *)note
  394. {
  395. self.keyBoardH = 0.f;
  396. [self.webView evaluateJavaScript:@"textBlur()" completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  397. NSLog(@"keyHidden");
  398. }];
  399. }
  400. #pragma mark - WKScriptMessageHandler
  401. - (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
  402. WS(weakSelf);
  403. NSLog(@"messageName:%@",message.name);
  404. if ([message.name isEqualToString:@"chosePic"]) {
  405. [self chatBarDidPhotoAction];
  406. }
  407. if ([message.name isEqualToString:@"toPZ"]) {
  408. [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
  409. } choosImgBlock:^(UIImage *image) {
  410. [weakSelf didSelectImage:@[image]];
  411. }];
  412. }
  413. if ([message.name isEqualToString:@"toBJ"]) {
  414. [[FWZGetNoteBookTool sharedTool] openNoteBookListChooseNoteBookBlock:^(NSMutableArray<MyNoteBookSubModel *> * _Nonnull noteArr) {
  415. NSLog(@"SmartBarNotes %@",noteArr);
  416. [weakSelf disSelectNoteBook:noteArr];
  417. }];
  418. }
  419. if ([message.name isEqualToString:@"toSC"]) {
  420. [[FWZGetNoteBookTool sharedTool] openCollectListChooseCollectBlock:^(NSMutableArray<MyFavoriteSubModel *> * _Nonnull collectArr) {
  421. NSLog(@"SmartBarCollection %@",collectArr);
  422. [weakSelf disSelectCollect:collectArr];
  423. }];
  424. }
  425. if ([message.name isEqualToString:@"toWJ"]) {
  426. [[FWZFileGetTool sharedTool] openFileWithCrop:YES showImgBlock:^(NSString * _Nonnull fileUrlStr) {
  427. } choosFileBlock:^(NSData * _Nonnull fileData, NSString * _Nonnull fileName) {
  428. SHOWLOADING
  429. [[HttpManager sharedHttpManager] HeaderUploadFileUrl:Host(Modify_UserImages_Post) parameters:@{} fileData:fileData fileKey:@"file" fileName:fileName mimeType:@"multipart/form-data" success:^(id _Nonnull responseObject) {
  430. REMOVESHOW
  431. NSDictionary * dict = responseObject[0];
  432. if ([dict[@"FileType"] isEqualToString:@"image"]) {
  433. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_Image,dict[@"FileName"],(long)[dict[@"FileId"] integerValue],@"",dict[@"MinAbsolutePath"],dict[@"AbsolutePath"],(long)[AppUserModel sharedAppUserModel].Id];
  434. [weakSelf upDateAction:jsonString];
  435. }else{
  436. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_file,dict[@"FileName"],(long)[dict[@"FileId"] integerValue],@"",dict[@"MinAbsolutePath"],dict[@"AbsolutePath"],(long)[AppUserModel sharedAppUserModel].Id];
  437. [weakSelf upDateAction:jsonString];
  438. }
  439. } failure:^(NSError * _Nonnull error) {
  440. REMOVESHOW
  441. }];
  442. }];
  443. }
  444. if ([message.name isEqualToString:@"keyBoard"]) {
  445. NSString *jsonString = [NSString stringWithFormat:@"getIosKeyBorad('%f')",self.keyBoardH];
  446. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  447. }];
  448. }
  449. if ([message.name isEqualToString:@"changeState"]) {
  450. NSLog(@"msgBody:%@",message.body);
  451. NSInteger status = [message.body integerValue];
  452. if (status == 1) {
  453. // [self.DoneBtn setTitleColor:UIColorHex(0x3979D3) forState:UIControlStateNormal];
  454. [self.DoneBtn setEnabled:YES];
  455. }else{
  456. // [self.DoneBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
  457. [self.DoneBtn setEnabled:NO];
  458. }
  459. }
  460. if ([message.name isEqualToString:@"approverCheckUsers"]) {
  461. if (self.type == CollectModel_meetMian) {
  462. [self selectMeeting];
  463. }else{
  464. self.isShoujianren = YES;
  465. self.isChaosongren = NO;
  466. [self selectPeopleWithType:1];
  467. }
  468. }
  469. if ([message.name isEqualToString:@"getJp"]) {
  470. [self allowDisplayingKeyboardWithoutUserAction];
  471. }
  472. if ([message.name isEqualToString:@"carbonCopyUsers"]) {
  473. self.isShoujianren = NO;
  474. self.isChaosongren = YES;
  475. [self selectPeopleWithType:2];
  476. }
  477. if ([message.name isEqualToString:@"getType"]) {
  478. NSString *jsonString = [NSString stringWithFormat:@"getType('%d','%d','%ld','%@','%ld')",self.type,self.isEdit,(long)self.Id,USERDEFAULTSGET(@"LOGINTOKEN"),(long)self.replayType];
  479. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  480. if (weakSelf.isReturn) {
  481. FlowAttachmentsModel * model = weakSelf.sendModel;
  482. NSInteger fileType = model.SoureTypeId;
  483. if (fileType == CollectModel_file) {
  484. if (model.MinUrl.length > 0) {
  485. fileType = CollectModel_Image;
  486. NSString *jsonString = [NSString stringWithFormat:@"getAndroidImg('%@','%@','%ld')",model.Url,model.Title,(long)[self returnType:model.Url]];
  487. [weakSelf upDateAction:jsonString];
  488. }else{
  489. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)model.SoureTypeId,model.Title,(long)model.SoureId,model.Author.length > 0 ? model.Author : @"",model.MinUrl,model.Url,(long)[AppUserModel sharedAppUserModel].Id];
  490. [weakSelf upDateAction:jsonString];
  491. }
  492. }else{
  493. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)model.SoureTypeId,model.Title,(long)model.SoureId,model.Author.length > 0 ? model.Author : @"",model.MinUrl,model.Url,(long)[AppUserModel sharedAppUserModel].Id];
  494. [weakSelf upDateAction:jsonString];
  495. }
  496. }
  497. }];
  498. }
  499. if ([message.name isEqualToString:@"to"]) {
  500. NSLog(@"msgBody:%@",message.body);
  501. NSDictionary * dict = (NSDictionary *)message.body;
  502. [self pushVCWithDict:dict];
  503. }
  504. }
  505. - (void)pushVCWithDict:(NSDictionary *)dict
  506. {
  507. NSInteger Id = [dict[@"id"] integerValue];
  508. NSInteger userId = [dict[@"userId"] integerValue];
  509. NSString * title = dict[@"title"];
  510. WS(weakSelf);
  511. switch ([dict[@"type"] integerValue]) {
  512. case CollectModel_Group:
  513. {
  514. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  515. vc.GroupId = Id;
  516. vc.titleStr = title;
  517. [self.navigationController pushViewController:vc animated:YES];
  518. }break;
  519. case CollectModel_file:{
  520. DownFileViewController * vc = [[DownFileViewController alloc] init];
  521. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  522. model.Title = title;
  523. model.SoureId = Id;
  524. model.Url = dict[@"bigurl"];
  525. model.MinUrl = dict[@"smallurl"];
  526. vc.model = model;
  527. [self.navigationController pushViewController:vc animated:YES];
  528. }break;
  529. case CollectModel_Image:{
  530. DownFileViewController * vc = [[DownFileViewController alloc] init];
  531. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  532. model.Title = title;
  533. model.SoureId = Id;
  534. model.Url = dict[@"bigurl"];
  535. model.MinUrl = dict[@"smallurl"];
  536. vc.model = model;
  537. [self.navigationController pushViewController:vc animated:YES];
  538. }break;
  539. case CollectModel_Aritle:{
  540. SHOWLOADING
  541. [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)Id] parameters:@{} success:^(id _Nonnull responseObject) {
  542. REMOVESHOW;
  543. Item *itemModel = [[Item alloc]initWithDictionary:responseObject error:nil];
  544. HomeDetailController *homeDetail = [[HomeDetailController alloc] init];
  545. [homeDetail loadCurrentModel:itemModel];
  546. [weakSelf.navigationController pushViewController:homeDetail animated:YES];
  547. } failure:^(NSError * _Nonnull error) {
  548. SHOWERROR([ZYCTool handerResultData:error]);
  549. }];
  550. }break;
  551. case CollectModel_Notice:{
  552. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  553. vc.type = CollectModel_Notice;
  554. vc.Id = Id;
  555. [self.navigationController pushViewController:vc animated:YES];
  556. }break;
  557. case CollectModel_Toipc:{
  558. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  559. vc.type = CollectModel_Toipc;
  560. vc.Id = Id;
  561. [self.navigationController pushViewController:vc animated:YES];
  562. }break;
  563. case CollectModel_NewTopic:{
  564. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  565. vc.type = CollectModel_NewTopic;
  566. vc.Id = Id;
  567. [self.navigationController pushViewController:vc animated:YES];
  568. }break;
  569. case CollectModel_NoteBook:{
  570. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  571. vc.type = CollectModel_NoteBook;
  572. vc.Id = Id;
  573. [self.navigationController pushViewController:vc animated:YES];
  574. }break;
  575. case CollectModel_Collect:{
  576. }break;
  577. case CollectModel_CollectFile:{
  578. if (userId == [AppUserModel sharedAppUserModel].Id) {
  579. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  580. vc.listType = MyFavoriteListLevelTypeB;
  581. vc.ParentId = 0;
  582. vc.FolderId = Id;
  583. vc.myTitle = title;
  584. [self.navigationController pushViewController:vc animated:YES];
  585. }else{
  586. OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
  587. vc.listType = MyFavoriteListLevelTypeB;
  588. vc.ParentId = 0;
  589. vc.FolderId = Id;
  590. vc.myTitle = title;
  591. vc.VisitUserId = userId;
  592. [self.navigationController pushViewController:vc animated:YES];
  593. }
  594. }break;
  595. case CollectModel_NoteFile:{
  596. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  597. vc.listType = MyFavoriteListLevelTypeB;
  598. vc.ParentId = 0;
  599. vc.FolderId = Id;
  600. vc.myTitle = title;
  601. vc.VisitUserId = 0;
  602. [self.navigationController pushViewController:vc animated:YES];
  603. }break;
  604. case CollectModel_InterMail:{
  605. TDInterLeterDetailVC * vc = [TDInterLeterDetailVC initTDInterLeterDetailVC];
  606. vc.detailType = InterLeterDetialType_Sign;
  607. vc.interLeterID = Id;
  608. [self.navigationController pushViewController:vc animated:YES];
  609. }break;
  610. case CollectModel_meetDetail:{
  611. WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:Id];
  612. [self.navigationController pushViewController:vc animated:YES];
  613. }break;
  614. case CollectModel_work:{
  615. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  616. vc.pageType = Type_ONEC;
  617. vc.indexId = Id;
  618. vc.title = title;
  619. vc.TodoId = Id;
  620. [self.navigationController pushViewController:vc animated:YES];
  621. }break;
  622. case CollectModel_meetMian:{
  623. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  624. vc.type = CollectModel_meetMian;
  625. vc.Id = Id;
  626. [self.navigationController pushViewController:vc animated:YES];
  627. }break;
  628. case CollectModel_financeCount:{
  629. CountDataVC *vc = [CountDataVC initCountDataVC];
  630. vc.index = 0;
  631. vc.titleStr = @"财务统计";
  632. [self.navigationController pushViewController:vc animated:YES];
  633. }break;
  634. case CollectModel_affairsCount:{
  635. CountDataVC *vc = [CountDataVC initCountDataVC];
  636. vc.index = 1;
  637. vc.titleStr = @"人事统计";
  638. [self.navigationController pushViewController:vc animated:YES];
  639. }break;
  640. case CollectModel_publishCount:{
  641. CountDataVC *vc = [CountDataVC initCountDataVC];
  642. vc.index = 2;
  643. vc.titleStr = @"出版统计";
  644. [self.navigationController pushViewController:vc animated:YES];
  645. }break;
  646. default:
  647. break;
  648. }
  649. }
  650. #pragma mark - 选择关联会议
  651. - (void)selectMeeting
  652. {
  653. WS(weakSelf);
  654. FecordJoinWorkFlowListController *vc = [[FecordJoinWorkFlowListController alloc] init];
  655. [vc setSelectedMeetingBlock:^(NSString * _Nonnull mid, NSString * _Nonnull meetingName) {
  656. weakSelf.meetingId = [mid integerValue];
  657. NSDictionary * dict = @{@"SourceId":mid,@"SourceName":meetingName};
  658. NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[self arrayToJSONModel:@[dict]]];
  659. [weakSelf.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  660. NSLog(@"data:%@",data);
  661. NSLog(@"error:%@",error);
  662. }];
  663. }];
  664. vc.IsSelect = YES;
  665. [self.navigationController pushViewController:vc animated:YES];
  666. }
  667. - (void)selectPeopleWithType:(NSInteger)type {
  668. AddLookUpUserSecondVC *vc = [[AddLookUpUserSecondVC alloc] init];
  669. vc.isAllSelected = YES;
  670. Department *defaltGroupSetion = [[Department alloc]init];
  671. defaltGroupSetion.Name = @"默认分组";
  672. defaltGroupSetion.Id = 0;
  673. defaltGroupSetion.SourceId = 0;
  674. defaltGroupSetion.SourceType = 1;
  675. defaltGroupSetion.SourceName = @"默认分组";
  676. defaltGroupSetion.MiddleType = type;
  677. Department *myGroupSetion = [[Department alloc]init];
  678. myGroupSetion.Name = @"我的分组";
  679. myGroupSetion.Id = 0;
  680. myGroupSetion.MiddleType = type;
  681. myGroupSetion.SourceType = 3;
  682. myGroupSetion.SourceId = 0;
  683. myGroupSetion.SourceName = @"我的分组";
  684. vc.isAllSelected = YES;
  685. vc.departSourceDataArray = @[defaltGroupSetion,myGroupSetion].mutableCopy;
  686. vc.isDefalutPage = 1;
  687. vc.titleStr = self.type == CollectModel_meetMian ? @"发送范围" : @"选人";
  688. [self.navigationController pushViewController:vc animated:YES];
  689. }
  690. - (void)recviveChaoSongRen:(NSNotification *)notification{
  691. if (self.isShoujianren) {
  692. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  693. if (array.count > 0) {
  694. NSLog(@"shouJianArray结果数据组%@",array);
  695. NSString *jsonString = [NSString stringWithFormat:@"getApproverCheckUsersList('%@')",[self arrayToJSONModel:array]];
  696. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  697. NSLog(@"data:%@",data);
  698. NSLog(@"error:%@",error);
  699. }];
  700. }
  701. }
  702. if (self.isChaosongren) {
  703. NSMutableArray <SelectModel *>* array = notification.userInfo[@"selectPeople"];
  704. if (array.count > 0) {
  705. NSLog(@"chaoShongArray结果数据组%@",array);
  706. NSString *jsonString = [NSString stringWithFormat:@"getCarbonCopyUsersList('%@')",[self arrayToJSONModel:array]];
  707. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  708. NSLog(@"data:%@",data);
  709. NSLog(@"error:%@",error);
  710. }];
  711. }
  712. }
  713. }
  714. #pragma mark - 选择图片
  715. - (void)chatBarDidPhotoAction
  716. {
  717. WS(weakSelf);
  718. [self.view endEditing:YES];
  719. TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:nil];
  720. [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
  721. leftButton.hidden = YES;
  722. }];
  723. imagePickerVc.showSelectBtn = NO;
  724. imagePickerVc.allowCrop = YES;
  725. imagePickerVc.cropRect = CGRectMake(0, (SCREEN_HEIGHT - SCREEN_WIDTH) * 0.5, SCREEN_WIDTH, SCREEN_WIDTH);
  726. imagePickerVc.allowTakePicture = NO;
  727. imagePickerVc.allowTakeVideo = NO;
  728. imagePickerVc.allowPickingOriginalPhoto = NO;
  729. imagePickerVc.allowPickingGif = NO;
  730. [imagePickerVc setIsStatusBarDefault:YES];
  731. [imagePickerVc setNaviTitleColor:[UIColor blackColor]];
  732. [imagePickerVc setBarItemTextColor:[UIColor blackColor]];
  733. [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  734. PHAsset *asset = assets.firstObject;
  735. switch (asset.mediaType) {
  736. case PHAssetMediaTypeVideo: {
  737. } break;
  738. case PHAssetMediaTypeImage: {
  739. [weakSelf didSelectImage:photos];
  740. } break;
  741. case PHAssetMediaTypeAudio:
  742. break;
  743. case PHAssetMediaTypeUnknown:
  744. break;
  745. default: break;
  746. }
  747. }];
  748. [self presentViewController:imagePickerVc animated:YES completion:nil];
  749. }
  750. - (void)didSelectImage:(NSArray *)images
  751. {
  752. NSMutableArray * array = [NSMutableArray array];
  753. for (UIImage * image in images) {
  754. NSData *data = UIImageJPEGRepresentation(image, 1);
  755. [array addObject:data];
  756. }
  757. WS(weakSelf);
  758. NSString *urlString = [[NSString alloc] initWithFormat:@"%@%@",BaseUrl,Modify_UserImages_Post];
  759. [[HttpManager sharedHttpManager] HeaderUploadUrl:urlString parameters:@{} pictureArray:array pictureKey:@"file" success:^(id _Nonnull responseObject) {
  760. NSLog(@"%@",responseObject);
  761. for (NSDictionary * dict in responseObject) {
  762. NSString *jsonString = [NSString stringWithFormat:@"getAndroidImg('%@','%@','%ld')",dict[@"AbsolutePath"],dict[@"FileName"],(long)CollectModel_Image];
  763. [weakSelf upDateAction:jsonString];
  764. }
  765. } failure:^(NSError * _Nonnull error) {
  766. }];
  767. }
  768. #pragma mark - 选择笔记
  769. - (void)disSelectNoteBook:(NSMutableArray<MyNoteBookSubModel *>*_Nonnull )noteArr{
  770. for (MyNoteBookSubModel *dataModel in noteArr ) {
  771. if (dataModel.AttributeValue == 1) {
  772. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_NoteBook,dataModel.Title,(long)dataModel.MiddleId,dataModel.Name,@"",@"",(long)[AppUserModel sharedAppUserModel].Id];
  773. [self upDateAction:jsonString];
  774. }else{
  775. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_NoteFile,dataModel.FolderName,(long)dataModel.Id,[AppUserModel sharedAppUserModel].Name,@"",@"",(long)[AppUserModel sharedAppUserModel].Id];
  776. [self upDateAction:jsonString];
  777. }
  778. }
  779. }
  780. #pragma mark - 选择收藏
  781. - (void)disSelectCollect:(NSMutableArray<MyFavoriteSubModel *> * _Nonnull) collectArr{
  782. for (MyFavoriteSubModel *dataModel in collectArr ) {
  783. if(dataModel.AttributeValue == 1)
  784. {
  785. if (dataModel.CollectionType == CollectModel_file) {
  786. if (dataModel.Data.MinFile.length > 0) {
  787. dataModel.CollectionType = CollectModel_Image;
  788. }
  789. }
  790. if (dataModel.CollectionType == 1) {
  791. dataModel.CollectionType = CollectModel_Aritle;
  792. }
  793. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)dataModel.CollectionType,dataModel.Title,(long)dataModel.CollectionDataId,dataModel.Data.Author.length > 0 ? dataModel.Data.Author : @"" ,dataModel.Data.MinFile,dataModel.Data.File,(long)[AppUserModel sharedAppUserModel].Id];
  794. [self upDateAction:jsonString];
  795. }else{
  796. NSString *jsonString = [NSString stringWithFormat:@"getAndroidNoteCollection('%ld','%@','%ld','%@','%@','%@','%ld')",(long)CollectModel_CollectFile,dataModel.FolderName,(long)dataModel.Id,[AppUserModel sharedAppUserModel].Name,@"",@"",(long)[AppUserModel sharedAppUserModel].Id];
  797. [self upDateAction:jsonString];
  798. }
  799. }
  800. }
  801. #pragma mark - WKScriptMessageHandler
  802. -(NSString *)convertToJson:(NSDictionary *)dict
  803. {
  804. NSError *error;
  805. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
  806. NSString *jsonString;
  807. if (!jsonData) {
  808. NSLog(@"%@",error);
  809. }else{
  810. jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
  811. }
  812. NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
  813. NSRange range = {0,jsonString.length};
  814. //去掉字符串中的空格
  815. [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
  816. NSRange range2 = {0,mutStr.length};
  817. //去掉字符串中的换行符
  818. [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
  819. return mutStr;
  820. }
  821. #pragma mark - WKUIDelegete
  822. - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(void))completionHandler
  823. {
  824. NSLog(@"%@",message);
  825. completionHandler();
  826. }
  827. - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(BOOL))completionHandler
  828. {
  829. NSLog(@"223123");
  830. completionHandler(YES);
  831. }
  832. - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(nonnull NSString *)prompt defaultText:(nullable NSString *)defaultText initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(NSString * _Nullable))completionHandler
  833. {
  834. NSLog(@"323123");
  835. completionHandler(@"111");
  836. }
  837. #pragma mark - 提交富文本
  838. - (void)submit
  839. {
  840. NSString *jsonString = [NSString stringWithFormat:@"getEditorText()"];
  841. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  842. NSLog(@"submit:%@",data);
  843. NSDictionary * dict = (NSDictionary *)data;
  844. switch (self.type) {
  845. case CollectModel_Notice:
  846. {
  847. [self submitNotice:dict];
  848. }
  849. break;
  850. case CollectModel_Toipc:
  851. {
  852. if (self.isEdit) {
  853. [self changeTopic:dict];
  854. }else{
  855. [self submitTopic:dict];
  856. }
  857. }
  858. break;
  859. case CollectModel_NewTopic:
  860. {
  861. if (self.isEdit) {
  862. [self changeNoteBook:dict];
  863. }else{
  864. [self submitNoteBook:dict];
  865. }
  866. }
  867. break;
  868. case CollectModel_Group:
  869. {
  870. if (self.isEdit) {
  871. [self changeTopic:dict];
  872. }else{
  873. [self submitTopic:dict];
  874. }
  875. }
  876. break;
  877. case CollectModel_meetMian:
  878. {
  879. if (self.isEdit) {
  880. [self changeMeeting:dict];
  881. }else{
  882. [self submitMeeting:dict];
  883. }
  884. }
  885. break;
  886. case CollectModel_NoteBook:
  887. {
  888. if (self.isEdit) {
  889. [self changeNoteBook:dict];
  890. }else{
  891. [self submitNoteBook:dict];
  892. }
  893. }
  894. break;
  895. case CollectModel_InterMail:
  896. {
  897. [self submitMail:dict];
  898. }
  899. break;
  900. default:
  901. break;
  902. }
  903. }];
  904. }
  905. #pragma mark - 提交通知
  906. - (void)submitNotice:(NSDictionary *)dict
  907. {
  908. self.H5JsonDict = dict;
  909. NSString * html = dict[@"html"];
  910. NSArray * jsonArray = dict[@"json"];
  911. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  912. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  913. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  914. [paraDict setValue:self.isDraft ? @(2) : @(1) forKey:@"NoticeType"];
  915. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  916. [paraDict setObject:html forKey:@"HtmlContent"];
  917. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  918. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  919. [paraDict setObject:[self arrayToJSONString:jsonArray] forKey:@"Content"];
  920. NSArray * addArray = self.H5JsonDict[@"AddresseeUserMiddles"];
  921. NSArray * ccArray = self.H5JsonDict[@"CcUserMiddles"];
  922. if ([self.H5JsonDict[@"Title"] length] == 0 &&
  923. [self.H5JsonDict[@"html"] length] == 0 &&
  924. addArray.count == 0 &&
  925. ccArray.count == 0) {
  926. SHOWERROR(@"请填写标题或内容");
  927. return;
  928. }
  929. if (self.isEdit) {
  930. [paraDict setObject:@(self.Id) forKey:@"Id"];
  931. [self sentChangeNotice:paraDict withNoticeType:self.isDraft ? 2 : 1];
  932. }else{
  933. [self sentNoticeRequeast:paraDict withNoticeType:self.isDraft ? 2 : 1];
  934. }
  935. }
  936. - (void)sentChangeNotice:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{
  937. WS(weakSelf);
  938. [[HttpManager sharedHttpManager] POSTUrl:Host(API_NOTICE_EDIT) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  939. REMOVESHOW
  940. if(NoticeType == 1){
  941. SHOWSUCCESS(@"通知已经发送");
  942. if (weakSelf.upDateBlock) {
  943. weakSelf.upDateBlock();
  944. }
  945. }else{
  946. SHOWSUCCESS(@"通知已经存放草稿箱");
  947. }
  948. [weakSelf.navigationController popViewControllerAnimated:YES];
  949. } failure:^(NSError * _Nonnull error) {
  950. SHOWERROR([ZYCTool handerResultData:error]);
  951. }];
  952. }
  953. - (void)sentNoticeRequeast:(NSMutableDictionary *)dic withNoticeType:(NSInteger)NoticeType{
  954. WS(weakSelf);
  955. [[HttpManager sharedHttpManager] PUTUrl:Host(API_NOTICE_ADD) parameters:dic success:^(id _Nonnull responseObject) {
  956. REMOVESHOW
  957. if(NoticeType == 1){
  958. SHOWSUCCESS(@"通知已经发送");
  959. if (weakSelf.upDateBlock) {
  960. weakSelf.upDateBlock();
  961. }
  962. }else{
  963. SHOWSUCCESS(@"通知已经存放草稿箱");
  964. }
  965. [weakSelf.navigationController popViewControllerAnimated:YES];
  966. } failure:^(NSError * _Nonnull error) {
  967. SHOWERROR([ZYCTool handerResultData:error]);
  968. }];
  969. }
  970. #pragma mark - 提交话题
  971. - (void)submitTopic:(NSDictionary *)dict
  972. {
  973. NSString * html = dict[@"html"];
  974. NSArray * jsonArray = dict[@"json"];
  975. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  976. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  977. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  978. [paraDict setObject:@(self.Id) forKey:@"GroupId"];
  979. [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
  980. [paraDict setObject:html forKey:@"HtmlContent"];
  981. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  982. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  983. SHOWERROR(@"请填写标题或内容");
  984. return;
  985. }
  986. SHOWLOADING
  987. WS(weakSelf);
  988. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_Add) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  989. NSLog(@"%@",responseObject);
  990. REMOVESHOW
  991. SHOWSUCCESS(@"创建成功");
  992. if (weakSelf.upDateBlock) {
  993. weakSelf.upDateBlock();
  994. }
  995. [weakSelf back1];
  996. } failure:^(NSError * _Nonnull error) {
  997. REMOVESHOW
  998. SHOWERROR([ZYCTool handerResultData:error])
  999. }];
  1000. }
  1001. #pragma mark - 修改话题
  1002. - (void)changeTopic:(NSDictionary *)dict
  1003. {
  1004. NSString * html = dict[@"html"];
  1005. NSArray * jsonArray = dict[@"json"];
  1006. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1007. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1008. [paraDict setObject:@(self.Id) forKey:@"Id"];
  1009. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  1010. [paraDict setObject:html forKey:@"HtmlContent"];
  1011. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1012. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1013. SHOWERROR(@"请填写标题或内容");
  1014. return;
  1015. }
  1016. WS(weakSelf);
  1017. SHOWLOADING
  1018. [[HttpManager sharedHttpManager] PUTUrl:Host(API_APP_Topic_Update) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  1019. NSLog(@"%@",responseObject);
  1020. REMOVESHOW
  1021. SHOWSUCCESS(@"创建成功");
  1022. if (weakSelf.upDateBlock) {
  1023. weakSelf.upDateBlock();
  1024. }
  1025. [weakSelf.navigationController popViewControllerAnimated:YES];
  1026. } failure:^(NSError * _Nonnull error) {
  1027. REMOVESHOW
  1028. }];
  1029. }
  1030. #pragma mark - 提交会议纪要
  1031. - (void)submitMeeting:(NSDictionary *)dict
  1032. {
  1033. NSString * html = dict[@"html"];
  1034. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1035. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1036. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1037. if (self.meetingId > 0) {
  1038. [paraDict setObject:@(self.meetingId) forKey:@"MeetingId"];
  1039. }
  1040. [paraDict setObject:html forKey:@"Content"];
  1041. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1042. SHOWERROR(@"请填写标题或内容");
  1043. return;
  1044. }
  1045. SHOWLOADING
  1046. WS(weakSelf);
  1047. [[HttpManager sharedHttpManager] POSTUrl:Host(MeetingSummary) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  1048. REMOVESHOW
  1049. SHOWSUCCESS(@"创建成功");
  1050. if (weakSelf.upDateBlock) {
  1051. weakSelf.upDateBlock();
  1052. }
  1053. [weakSelf.navigationController popViewControllerAnimated:YES];
  1054. } failure:^(NSError * _Nonnull error) {
  1055. REMOVESHOW
  1056. SHOWERROR([ZYCTool handerResultData:error]);
  1057. }];
  1058. }
  1059. - (void)changeMeeting:(NSDictionary *)dict
  1060. {
  1061. NSString * html = dict[@"html"];
  1062. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1063. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1064. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1065. if (self.meetingId > 0) {
  1066. [paraDict setObject:@(self.meetingId) forKey:@"MeetingId"];
  1067. }
  1068. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1069. SHOWERROR(@"请填写标题或内容");
  1070. return;
  1071. }
  1072. [paraDict setObject:html forKey:@"Content"];
  1073. SHOWLOADING
  1074. WS(weakSelf);
  1075. NSString * meetId = [NSString stringWithFormat:@"%ld",(long)self.Id];
  1076. [[HttpManager sharedHttpManager] PUTUrl:Host(UpdateMeeting(meetId)) parameters:paraDict success:^(id _Nonnull responseObject) {
  1077. REMOVESHOW
  1078. SHOWSUCCESS(@"修改会议纪要成功");
  1079. if (weakSelf.upDateBlock) {
  1080. weakSelf.upDateBlock();
  1081. }
  1082. [weakSelf.navigationController popViewControllerAnimated:YES];
  1083. } failure:^(NSError * _Nonnull error) {
  1084. REMOVESHOW
  1085. SHOWERROR([ZYCTool handerResultData:error]);
  1086. }];
  1087. }
  1088. #pragma mark - 提交笔记
  1089. - (void)submitNoteBook:(NSDictionary *)dict
  1090. {
  1091. WS(weakSelf);
  1092. NSString * html = dict[@"html"];
  1093. NSArray * jsonArray = dict[@"json"];
  1094. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1095. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1096. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1097. [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
  1098. [paraDict setObject:html forKey:@"HtmlContent"];
  1099. [paraDict setObject:(self.type == CollectModel_NewTopic ? @(1) : @(0)) forKey:@"IsTopic"];
  1100. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1101. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1102. SHOWERROR(@"请填写标题或内容");
  1103. return;
  1104. }
  1105. if (self.type == CollectModel_NewTopic && self.FolderId == 0) {
  1106. SHOWERROR(@"请选择发布范围");
  1107. return;
  1108. }
  1109. [[HttpManager sharedHttpManager] PUTUrl:Host(API_CreateNoteBook) parameters:paraDict success:^(id _Nonnull responseObject) {
  1110. NSLog(@"%@",responseObject);
  1111. SHOWSUCCESS(@"创建成功");
  1112. if (weakSelf.upDateBlock) {
  1113. weakSelf.upDateBlock();
  1114. }
  1115. [weakSelf back1];
  1116. } failure:^(NSError * _Nonnull error) {
  1117. SHOWERROR([ZYCTool handerResultData:error]);
  1118. }];
  1119. }
  1120. - (void)changeNoteBook:(NSDictionary *)dict
  1121. {
  1122. WS(weakSelf);
  1123. NSString * html = dict[@"html"];
  1124. NSArray * jsonArray = dict[@"json"];
  1125. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1126. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1127. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1128. [paraDict setObject:@(self.Id) forKey:@"Id"];
  1129. [paraDict setObject:@(self.FolderId) forKey:@"FolderId"];
  1130. [paraDict setObject:html forKey:@"HtmlContent"];
  1131. [paraDict setObject:[self arrayTosumbitString:jsonArray] forKey:@"Content"];
  1132. if ([dict[@"Title"] length] == 0 && html.length == 0) {
  1133. SHOWERROR(@"请填写标题或内容");
  1134. return;
  1135. }
  1136. if (self.type == CollectModel_NewTopic && self.FolderId == 0) {
  1137. SHOWERROR(@"请选择发布范围");
  1138. return;
  1139. }
  1140. [[HttpManager sharedHttpManager] PUTUrl:Host(API_NoteBook_Modify) parameters:paraDict success:^(id _Nonnull responseObject) {
  1141. NSLog(@"%@",responseObject);
  1142. if (weakSelf.upDateBlock) {
  1143. weakSelf.upDateBlock();
  1144. }
  1145. SHOWSUCCESS(@"修改成功");
  1146. [weakSelf.navigationController popViewControllerAnimated:YES];
  1147. } failure:^(NSError * _Nonnull error) {
  1148. SHOWERROR([ZYCTool handerResultData:error]);
  1149. }];
  1150. }
  1151. #pragma mark - 提交站内信
  1152. - (void)submitMail:(NSDictionary *)dict
  1153. {
  1154. self.H5JsonDict = dict;
  1155. NSString * html = dict[@"html"];
  1156. NSArray * jsonArray = dict[@"json"];
  1157. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  1158. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  1159. [paraDict setObject:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"];
  1160. [paraDict setValue:@(self.FolderId) forKey:@"FolderId"];
  1161. [paraDict setObject:html forKey:@"HtmlContent"];
  1162. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  1163. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  1164. [paraDict setObject:[self arrayToJSONString:jsonArray] forKey:@"Content"];
  1165. [paraDict setObject:@(self.MailType) forKey:@"MissiveType"];///1 正常 2 匿名
  1166. [paraDict setObject:@(self.Id) forKey:@"ParentId"];///回复ID
  1167. [paraDict setObject:@(self.isDraft ? 2 : 1) forKey:@"MissiveAttributeType"];///1 发送 2 草稿
  1168. NSArray * addArray = self.H5JsonDict[@"AddresseeUserMiddles"];
  1169. NSArray * ccArray = self.H5JsonDict[@"CcUserMiddles"];
  1170. if ([self.H5JsonDict[@"Title"] length] == 0 &&
  1171. [self.H5JsonDict[@"html"] length] == 0 &&
  1172. addArray.count == 0 &&
  1173. ccArray.count == 0) {
  1174. SHOWERROR(@"请填写标题或内容");
  1175. return;
  1176. }
  1177. if (self.isEdit) {
  1178. if (self.replayType == MailReplayOne || self.replayType == MailReplayAll) {
  1179. }else{
  1180. [paraDict setObject:@(self.Id) forKey:@"Id"];
  1181. }
  1182. }
  1183. [self sentMailRequeast:paraDict];
  1184. }
  1185. - (void)sentMailRequeast:(NSMutableDictionary *)dic
  1186. {
  1187. WS(weakSelf);
  1188. [[HttpManager sharedHttpManager] PUTUrl:Host(API_InterLetterModify) parameters:dic success:^(id _Nonnull responseObject) {
  1189. if(weakSelf.isDraft){
  1190. SHOWSUCCESS(@"站内信已经存放草稿箱");
  1191. }else{
  1192. SHOWSUCCESS(@"站内信已经发送");
  1193. }
  1194. if (weakSelf.replayType == MailReplayOne || weakSelf.replayType == MailReplayAll) {
  1195. [weakSelf backMailList];
  1196. }else{
  1197. [weakSelf.navigationController popViewControllerAnimated:YES];
  1198. }
  1199. } failure:^(NSError * _Nonnull error) {
  1200. SHOWERROR([ZYCTool handerResultData:error]);
  1201. }];
  1202. }
  1203. - (NSString *)arrayToJSONModel:(NSArray *)array
  1204. {
  1205. NSMutableArray * mArray = [NSMutableArray array];
  1206. for (SelectModel * model in array) {
  1207. NSDictionary * dict = [model modelToJSONObject];
  1208. [mArray addObject:@{@"SourceType":dict[@"SourceType"],@"SourceId":dict[@"SourceId"],@"SourceName":dict[@"SourceName"],@"MiddleType":@(self.type)}];
  1209. }
  1210. return [self arrayToJSONString:mArray];
  1211. }
  1212. - (NSString *)arrayTosumbitString:(NSArray *)array
  1213. {
  1214. NSError *error = nil;
  1215. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
  1216. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  1217. NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
  1218. return mutStr;
  1219. }
  1220. - (NSString *)arrayToJSONString:(NSArray *)array
  1221. {
  1222. NSError *error = nil;
  1223. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error];
  1224. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  1225. NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
  1226. NSRange range = {0,jsonString.length};
  1227. //去掉字符串中的空格
  1228. [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
  1229. NSRange range2 = {0,mutStr.length};
  1230. //去掉字符串中的换行符
  1231. [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
  1232. return mutStr;
  1233. }
  1234. - (void)dealloc {
  1235. [self.webView stopLoading];
  1236. self.webView.UIDelegate = nil;
  1237. self.webView.navigationDelegate = nil;
  1238. self.webView.scrollView.delegate = nil;
  1239. [self.webView removeFromSuperview];
  1240. WKWebsiteDataStore *dateStore = [WKWebsiteDataStore defaultDataStore];
  1241. [dateStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
  1242. completionHandler:^(NSArray * __nonnull records) {
  1243. for (WKWebsiteDataRecord *record in records)
  1244. {
  1245. [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
  1246. forDataRecords:@[record]
  1247. completionHandler:^{
  1248. NSLog(@"Cookies for %@ deleted successfully",record.displayName);
  1249. }];
  1250. }
  1251. }];
  1252. WKUserContentController *userCC = self.webView.configuration.userContentController;
  1253. [userCC removeScriptMessageHandlerForName:@"chosePic"];
  1254. [userCC removeScriptMessageHandlerForName:@"toPZ"];
  1255. [userCC removeScriptMessageHandlerForName:@"toBJ"];
  1256. [userCC removeScriptMessageHandlerForName:@"getJp"];
  1257. [userCC removeScriptMessageHandlerForName:@"toSC"];
  1258. [userCC removeScriptMessageHandlerForName:@"toWJ"];
  1259. [userCC removeScriptMessageHandlerForName:@"keyBoard"];
  1260. [userCC removeScriptMessageHandlerForName:@"getType"];
  1261. [userCC removeScriptMessageHandlerForName:@"approverCheckUsers"];
  1262. [userCC removeScriptMessageHandlerForName:@"carbonCopyUsers"];
  1263. [userCC removeScriptMessageHandlerForName:@"changeState"];
  1264. [userCC removeScriptMessageHandlerForName:@"to"];
  1265. [userCC removeAllUserScripts];
  1266. [[NSNotificationCenter defaultCenter] removeObserver:self];
  1267. }
  1268. //- (void)hideWKWebviewKeyboardShortcutBar:(WKWebView *)webView {
  1269. // UIView *targetView;
  1270. //
  1271. // for (UIView *view in webView.scrollView.subviews) {
  1272. // if([[view.class description] hasPrefix:@"WKContent"]) {
  1273. // targetView = view;
  1274. // }
  1275. // }
  1276. // if (!targetView) {
  1277. // return;
  1278. // }
  1279. // NSString *noInputAccessoryViewClassName = [NSString stringWithFormat:@"%@_NoInputAccessoryView", targetView.class.superclass];
  1280. // Class newClass = NSClassFromString(noInputAccessoryViewClassName);
  1281. //
  1282. // if(newClass == nil) {
  1283. // newClass = objc_allocateClassPair(targetView.class, [noInputAccessoryViewClassName cStringUsingEncoding:NSASCIIStringEncoding], 0);
  1284. // if(!newClass) {
  1285. // return;
  1286. // }
  1287. //
  1288. // Method method = class_getInstanceMethod([_NoInputAccessoryView class], @selector(inputAccessoryView));
  1289. //
  1290. // class_addMethod(newClass, @selector(inputAccessoryView), method_getImplementation(method), method_getTypeEncoding(method));
  1291. //
  1292. // objc_registerClassPair(newClass);
  1293. // }
  1294. //
  1295. // object_setClass(targetView, newClass);
  1296. //}
  1297. - (CollectModelType)returnType:(NSString *)url
  1298. {
  1299. NSString * name = [[url pathExtension] lowercaseString];
  1300. if([name hasSuffix:@"png"] || [name hasSuffix:@"jpg"] || [name hasSuffix:@"jpeg"] || [name hasSuffix:@"bmp"]){
  1301. return CollectModel_Image;
  1302. }else{
  1303. return CollectModel_file;
  1304. }
  1305. }
  1306. #pragma mark - 通知存草稿箱
  1307. - (void)backAction:(id)sender{
  1308. if (self.type == CollectModel_Notice || self.type == CollectModel_InterMail) {
  1309. WS(weakSelf);
  1310. NSString *jsonString = [NSString stringWithFormat:@"getEditorText()"];
  1311. [self.webView evaluateJavaScript:jsonString completionHandler:^(id _Nullable data, NSError * _Nullable error) {
  1312. NSLog(@"submit:%@",data);
  1313. NSDictionary * dict = (NSDictionary *)data;
  1314. NSArray * addArray = dict[@"AddresseeUserMiddles"];
  1315. NSArray * ccArray = dict[@"CcUserMiddles"];
  1316. if ([dict[@"Title"] length] == 0 &&
  1317. [dict[@"html"] length] == 0 &&
  1318. addArray.count == 0 &&
  1319. ccArray.count == 0) {
  1320. [super backAction:sender];
  1321. }else{
  1322. [weakSelf saveToDraftBox];
  1323. }
  1324. }];
  1325. }else{
  1326. [super backAction:sender];
  1327. }
  1328. }
  1329. - (void)saveToDraftBox
  1330. {
  1331. WS(weakSelf);
  1332. [[ShowKeepNoticeAlert initShowKeepNoticeAlertConfirm:^{
  1333. weakSelf.isDraft = YES;
  1334. [weakSelf submit];
  1335. } cancle:^(ShowKeepNoticeCloseType colseType) {
  1336. if(colseType == ShowKeepNoticeCloseType1){
  1337. [weakSelf.navigationController popViewControllerAnimated:YES];
  1338. }
  1339. }] show];
  1340. }
  1341. - (void)backMailList
  1342. {
  1343. for ( NSInteger i = (self.navigationController.viewControllers.count - 1); i > 0 ;i --) {
  1344. if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"TDInterLeterHomeViewController")]) {
  1345. [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
  1346. return;
  1347. }
  1348. }
  1349. }
  1350. - (void)back1
  1351. {
  1352. if (self.isReturn) {
  1353. for ( NSInteger i = (self.navigationController.viewControllers.count - 1); i > 0 ;i --) {
  1354. if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"CountDataVC")]
  1355. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyApprovalPageDetail")]
  1356. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"WorkFlowOrderController")]
  1357. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"WorkFlowDetailsController")]
  1358. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"TDGroupInfoListVC")]
  1359. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"HomeDetailController")]
  1360. || [self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDTopicDetailVC")]) {
  1361. [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
  1362. return;
  1363. }
  1364. }
  1365. }else{
  1366. [self.navigationController popViewControllerAnimated:YES];
  1367. }
  1368. }
  1369. #pragma mark - JS调起键盘
  1370. - (void)allowDisplayingKeyboardWithoutUserAction {
  1371. Class class = NSClassFromString(@"WKContentView");
  1372. NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
  1373. NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
  1374. NSOperatingSystemVersion iOS_13_0_0 = (NSOperatingSystemVersion){13, 0, 0};
  1375. char * methodSignature = "_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:";
  1376. if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_13_0_0]) {
  1377. methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:";
  1378. } else if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) {
  1379. methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:";
  1380. }
  1381. if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) {
  1382. SEL selector = sel_getUid(methodSignature);
  1383. Method method = class_getInstanceMethod(class, selector);
  1384. IMP original = method_getImplementation(method);
  1385. IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
  1386. ((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
  1387. });
  1388. method_setImplementation(method, override);
  1389. } else {
  1390. SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
  1391. Method method = class_getInstanceMethod(class, selector);
  1392. IMP original = method_getImplementation(method);
  1393. IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
  1394. ((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3);
  1395. });
  1396. method_setImplementation(method, override);
  1397. }
  1398. }
  1399. @end