MyTDTopicCreateVC.m 65 KB

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