AppDelegate.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. //
  2. // AppDelegate.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/10/21.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "AppDelegate.h"
  9. #import "TabBarController.h"
  10. #import "WorkFlowTabbarController.h"
  11. #import "WXApi.h"
  12. #import "HKFloatManager.h"
  13. @interface AppDelegate ()<JPUSHRegisterDelegate,WXApiDelegate>
  14. @property (nonatomic, strong) TabBarController *tabBar;
  15. @end
  16. @implementation AppDelegate
  17. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  18. // Override point for customization after application launch.
  19. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  20. self.tabBar = [TabBarController sharedTabBarController];
  21. [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
  22. [[IQKeyboardManager sharedManager] setEnableAutoToolbar:NO];
  23. ///友盟分享
  24. [self checkDraft];
  25. [self configUSharePlatforms];
  26. //初始化环信
  27. [[EaseSDKHelper shareHelper] hyphenateApplication:application appkey:kHuanXinAppKey apnsCertName:kHuanXinApnsName];
  28. // [WXApi registerApp:wxAppKey enableMTA:NO];//不崩溃
  29. [WXApi registerApp:wxAppKey universalLink:@"https://apk.tederen.com"];
  30. [self settingPush: launchOptions];
  31. WS(weakSelf);
  32. if (![UserManager checkStringNull:kToken]){
  33. self.window.rootViewController = weakSelf.tabBar;
  34. [[EMClient sharedClient] logout:YES completion:^(EMError *aError) {
  35. NSData * data = USERDEFAULTSGET(@"USERINFO");
  36. AppUserModel * model = (AppUserModel*) [NSKeyedUnarchiver unarchiveObjectWithData:data];
  37. [[EMClient sharedClient] loginWithUsername:model.ImId password:@"123456" completion:^(NSString *aUsername, EMError *aError) {
  38. EMError *error = aError;
  39. dispatch_async(dispatch_get_main_queue(), ^{
  40. if (!error) {
  41. //设置是否自动登录
  42. [[EMClient sharedClient].options setIsAutoLogin:YES];
  43. weakSelf.window.rootViewController = weakSelf.tabBar;
  44. } else {
  45. weakSelf.window.rootViewController = [StoryboardManager shared].login.instantiateInitialViewController;
  46. }
  47. });
  48. }];
  49. }];
  50. }else{
  51. self.window.rootViewController = [StoryboardManager shared].login.instantiateInitialViewController;
  52. }
  53. [self.window makeKeyAndVisible];
  54. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkDraft) name:CHECKDRAFT object:nil];
  55. [HKFloatManager addFloatVcs:@[@"HKSecondViewController"]];
  56. return YES;
  57. }
  58. - (void)dealloc
  59. {
  60. [[NSNotificationCenter defaultCenter] removeObserver:self];
  61. }
  62. - (void)configUSharePlatforms
  63. {
  64. [UMConfigure initWithAppkey:UMengAppKey channel:nil];
  65. /* 设置微信的appKey和appSecret */
  66. [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatSession appKey:wxAppKey appSecret:wxAppSecret redirectURL:@"http://mobile.umeng.com/social"];
  67. [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatTimeLine appKey:wxAppKey appSecret:wxAppSecret redirectURL:@"http://mobile.umeng.com/social"];
  68. /* 设置分享到QQ互联的appID
  69. * U-Share SDK为了兼容大部分平台命名,统一用appKey和appSecret进行参数设置,而QQ平台仅需将appID作为U-Share的appKey参数传进即可。
  70. */
  71. [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_QQ appKey:QQAppKey/*设置QQ平台的appID*/ appSecret:nil redirectURL:@"http://mobile.umeng.com/social"];
  72. /* 设置新浪的appKey和appSecret */
  73. [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_Sina appKey:WBAppKey appSecret:WBAppSecret redirectURL:@"http://mobile.umeng.com/social"];
  74. }
  75. - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
  76. {
  77. NSString * str = [url absoluteString];
  78. if ([str hasPrefix:@"iostedeapp"]) {
  79. if (![UserManager checkStringNull:kToken]){
  80. str = [str substringFromIndex:17];
  81. NSArray *array = [str componentsSeparatedByString:@"&"];
  82. NSLog(@"%@",array);
  83. NSDictionary * dict= @{@"Id":array[0],@"type":array[1],@"userId":array[2],@"name":array[3],@"describe":array[4]};
  84. [self pushVC:dict];
  85. }else{
  86. UIWindow *window = [UtilsTools getWindow];
  87. window.rootViewController = [StoryboardManager shared].login.instantiateInitialViewController;
  88. [window makeKeyAndVisible];
  89. }
  90. return YES;
  91. }
  92. return [WXApi handleOpenURL:url delegate:self];
  93. }
  94. /// 分享回调
  95. - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
  96. {
  97. NSString * str = [url absoluteString];
  98. if ([str hasPrefix:@"iostedeapp"]) {
  99. if (![UserManager checkStringNull:kToken]){
  100. str = [str substringFromIndex:17];
  101. NSArray *array = [str componentsSeparatedByString:@"&"];
  102. NSLog(@"%@",array);
  103. NSDictionary * dict= @{@"Id":array[0],@"type":array[1],@"userId":array[2],@"name":array[3],@"describe":array[4]};
  104. [self pushVC:dict];
  105. }else{
  106. UIWindow *window = [UtilsTools getWindow];
  107. window.rootViewController = [StoryboardManager shared].login.instantiateInitialViewController;
  108. [window makeKeyAndVisible];
  109. }
  110. return YES;
  111. }
  112. return [WXApi handleOpenURL:url delegate:self];
  113. }
  114. -(void)pushVC:(NSDictionary *)dict
  115. {
  116. UIWindow *window = [UtilsTools getWindow];
  117. window.rootViewController = [TabBarController sharedTabBarController];
  118. [[TabBarController sharedTabBarController] setSelectedIndex:0];
  119. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  120. [[NSNotificationCenter defaultCenter] postNotificationName:SHARERETURNSUCCESS object:nil userInfo:dict];
  121. });
  122. [window makeKeyAndVisible];
  123. }
  124. + (UINavigationController *)getRootController {
  125. return (UINavigationController *)[UIApplication sharedApplication].keyWindow.rootViewController;
  126. }
  127. + (UIViewController *)getTopView {
  128. UINavigationController *rootNavigation = [self getRootController];
  129. return rootNavigation.topViewController;
  130. }
  131. + (instancetype)appdelegate {
  132. return [UIApplication sharedApplication].delegate;
  133. }
  134. - (void)applicationWillResignActive:(UIApplication *)application {
  135. NSLog(@"applicationWillResignActive");
  136. // [[NSNotificationCenter defaultCenter] postNotificationName:NOTEBOOKSAVE object:nil];
  137. }
  138. - (void)applicationDidEnterBackground:(UIApplication *)application {
  139. NSLog(@"applicationDidEnterBackground");
  140. }
  141. - (void)applicationWillEnterForeground:(UIApplication *)application {
  142. // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
  143. }
  144. - (void)applicationDidBecomeActive:(UIApplication *)application {
  145. NSLog(@"applicationDidBecomeActive");
  146. }
  147. - (void)applicationWillTerminate:(UIApplication *)application {
  148. NSLog(@"applicationWillTerminate");
  149. }
  150. #pragma mark - 极光
  151. - (void)settingPush:(NSDictionary *)launchOptions {
  152. JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
  153. entity.types = JPAuthorizationOptionAlert | JPAuthorizationOptionBadge | JPAuthorizationOptionSound;
  154. [JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
  155. [JPUSHService setupWithOption:launchOptions appKey:kJGAppKey
  156. channel:@"tederen"
  157. apsForProduction:YES // 如果为开发状态,设置为 NO; 如果为生产状态,应改为 YES.
  158. advertisingIdentifier:nil];
  159. [JpushTool setAlias:@"18224073257" completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
  160. } seq:18224073257];
  161. }
  162. // 此方法是必须要有实现,否则SDK将无法处理应用注册的Token,推送也就不会成功
  163. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  164. NSLog(@"%@",deviceToken);
  165. [JPUSHService registerDeviceToken:deviceToken];
  166. // [[EaseSDKHelper shareHelper] application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
  167. }
  168. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
  169. }
  170. #pragma mark - JPush
  171. // 前台界面收到通知
  172. - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
  173. // Required
  174. NSDictionary * userInfo = notification.request.content.userInfo;
  175. if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
  176. [JPUSHService handleRemoteNotification:userInfo];
  177. }
  178. completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound); // 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
  179. }
  180. // 点击通知消息从后台进入前台 willPresentNotification 接收之后会走这个方法
  181. - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
  182. // Required
  183. NSDictionary * userInfo = response.notification.request.content.userInfo;
  184. if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
  185. [JPUSHService handleRemoteNotification:userInfo];
  186. NSString * message = userInfo[@"aps"][@"alert"];
  187. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:(UIAlertControllerStyleAlert)];
  188. UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:nil];
  189. [alert addAction:sureAction];
  190. [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
  191. [self.window.rootViewController presentViewController:alert animated:YES completion:nil];
  192. }
  193. completionHandler(); // 系统要求执行这个方法
  194. }
  195. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  196. // Required, iOS 7 Support
  197. [JPUSHService handleRemoteNotification:userInfo];
  198. NSString * message = userInfo[@"aps"][@"alert"];
  199. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:(UIAlertControllerStyleAlert)];
  200. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:nil];
  201. [alert addAction:sureAction];
  202. [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
  203. [self.window.rootViewController presentViewController:alert animated:YES completion:nil];
  204. completionHandler(UIBackgroundFetchResultNewData);
  205. }
  206. //#pragma mark 关闭第三方键盘
  207. //- (BOOL)application:(UIApplication*)application shouldAllowExtensionPointIdentifier:(NSString*)extensionPointIdentifier {
  208. // if([extensionPointIdentifier isEqualToString:UIApplicationKeyboardExtensionPointIdentifier]) {
  209. // return NO;
  210. // }
  211. // return YES;
  212. //}
  213. #pragma mark - 微信登录
  214. - (void)onResp:(BaseResp *)resp{
  215. // =============== 获得的微信登录授权回调 ============
  216. if ([resp isMemberOfClass:[SendAuthResp class]]) {
  217. NSLog(@"******************获得的微信登录授权******************");
  218. SendAuthResp *aresp = (SendAuthResp *)resp;
  219. if (aresp.errCode != 0 ) {
  220. dispatch_async(dispatch_get_main_queue(), ^{
  221. dispatch_async(dispatch_get_main_queue(), ^{
  222. SHOWERROR(@"微信授权失败");
  223. });
  224. });
  225. return;
  226. }
  227. //授权成功获取 OpenId
  228. NSString *code = aresp.code;
  229. [self getWeiXinOpenId:code];
  230. }
  231. }
  232. - (void)getWeiXinOpenId:(NSString *)code{
  233. /*
  234. appid 是 应用唯一标识,在微信开放平台提交应用审核通过后获得
  235. secret 是 应用密钥AppSecret,在微信开放平台提交应用审核通过后获得
  236. code 是 填写第一步获取的code参数
  237. grant_type 是 填authorization_code
  238. */
  239. NSString *url =[NSString stringWithFormat:@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%@&secret=%@&code=%@&grant_type=authorization_code",wxAppKey,wxAppSecret,code];
  240. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  241. NSURL *zoneUrl = [NSURL URLWithString:url];
  242. NSString *zoneStr = [NSString stringWithContentsOfURL:zoneUrl encoding:NSUTF8StringEncoding error:nil];
  243. NSData *data1 = [zoneStr dataUsingEncoding:NSUTF8StringEncoding];
  244. if (!data1) {
  245. dispatch_async(dispatch_get_main_queue(), ^{
  246. SHOWERROR(@"微信授权失败");
  247. });
  248. return ;
  249. }
  250. // 授权成功,获取token、openID字典
  251. NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data1 options:NSJSONReadingMutableContainers error:nil];
  252. NSLog(@"token、openID字典===%@",dic);
  253. // NSString *access_token = dic[@"access_token"];
  254. // NSString *openid= dic[@"openid"];
  255. if ([dic[@"openid"] length] > 0) {
  256. [[NSNotificationCenter defaultCenter] postNotificationName:WeiChatSuccess object:nil userInfo:dic];
  257. }else{
  258. dispatch_async(dispatch_get_main_queue(), ^{
  259. SHOWERROR(@"微信授权失败");
  260. });
  261. return ;
  262. }
  263. });
  264. }
  265. - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
  266. if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
  267. NSURL *webpageURL = userActivity.webpageURL;
  268. NSString * str = [webpageURL absoluteString];
  269. if ([str hasPrefix:@"iossmartrhino"]) {
  270. if (![UserManager checkStringNull:kToken]){
  271. str = [str substringFromIndex:20];
  272. NSArray *array = [str componentsSeparatedByString:@"&"];
  273. NSDictionary * dict= @{@"Id":array[0],@"type":array[1],@"userId":array[2],@"name":array[3],@"describe":array[4]};
  274. [[NSNotificationCenter defaultCenter] postNotificationName:SHARERETURNSUCCESS object:nil userInfo:dict];
  275. UIWindow *window = [UtilsTools getWindow];
  276. window.rootViewController = [TabBarController sharedTabBarController];
  277. [[TabBarController sharedTabBarController] setSelectedIndex:0];
  278. [window makeKeyAndVisible];
  279. }else{
  280. UIWindow *window = [UtilsTools getWindow];
  281. window.rootViewController = [StoryboardManager shared].login.instantiateInitialViewController;
  282. [window makeKeyAndVisible];
  283. }
  284. }
  285. // TODO 根据需求进行处理
  286. }
  287. // TODO 根据需求进行处理
  288. return YES;
  289. }
  290. - (void)checkDraft
  291. {
  292. id data = USERDEFAULTSGET(DRAFT);
  293. if ([data isKindOfClass:[NSDictionary class]]) {
  294. NSLog(@"=======%@",data);
  295. switch ([data[@"Type"] integerValue]) {
  296. case CollectModel_Toipc:
  297. {
  298. [self submitTopic:data];
  299. }
  300. break;
  301. case CollectModel_NoteBook:
  302. {
  303. [self submitNoteBook:data withType:CollectModel_NoteBook];
  304. }
  305. break;
  306. case CollectModel_NewTopic:
  307. {
  308. [self submitNoteBook:data withType:CollectModel_NewTopic];
  309. }
  310. break;
  311. case CollectModel_Notice:
  312. {
  313. [self submitNotice:data];
  314. }
  315. break;
  316. case CollectModel_InterMail:
  317. {
  318. [self submitMail:data];
  319. }
  320. break;
  321. default:
  322. break;
  323. }
  324. }
  325. }
  326. - (void)submitTopic:(NSDictionary *)dict
  327. {
  328. if ([dict[@"GroupId"] integerValue] == 0) {
  329. return;
  330. }
  331. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  332. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  333. [paraDict setObject:dict[@"UserId"] forKey:@"UserId"];
  334. [paraDict setObject:dict[@"GroupId"] forKey:@"GroupId"];
  335. [paraDict setObject:dict[@"FolderId"] forKey:@"FolderId"];
  336. [paraDict setObject:dict[@"HtmlContent"] forKey:@"HtmlContent"];
  337. [paraDict setObject:dict[@"IsDraft"] forKey:@"IsDraft"];
  338. [paraDict setObject:dict[@"Content"] forKey:@"Content"];
  339. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_Add) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  340. NSLog(@"%@",responseObject);
  341. NSMutableDictionary * InfoDict = [NSMutableDictionary dictionaryWithDictionary:responseObject[@"Data"]];
  342. NSMutableDictionary * DraftDict = [NSMutableDictionary dictionary];
  343. [DraftDict setObject:dict[@"Type"] forKey:@"Type"];
  344. [DraftDict setObject:InfoDict[@"FolderId"] forKey:@"FolderId"];
  345. [DraftDict setObject:InfoDict[@"GroupId"] forKey:@"GroupId"];
  346. [DraftDict setObject:InfoDict[@"Id"] forKey:@"Id"];
  347. [DraftDict setObject:InfoDict[@"UserId"] forKey:@"UserId"];
  348. [DraftDict setObject:InfoDict[@"UserId"] forKey:@"UserId"];
  349. USERDEFAULTSSET(DraftDict, GROUPTOPICDRAFTINFO);
  350. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  351. } failure:^(NSError * _Nonnull error) {
  352. SHOWERROR([ZYCTool handerResultData:error])
  353. }];
  354. }
  355. - (void)submitNoteBook:(NSDictionary *)dict withType:(CollectModelType)type
  356. {
  357. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  358. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  359. [paraDict setObject:dict[@"UserId"] forKey:@"UserId"];
  360. [paraDict setObject:dict[@"FolderId"] forKey:@"FolderId"];
  361. [paraDict setObject:dict[@"IsDraft"] forKey:@"IsDraft"];
  362. [paraDict setObject:dict[@"HtmlContent"] forKey:@"HtmlContent"];
  363. [paraDict setObject:dict[@"IsTopic"] forKey:@"IsTopic"];
  364. [paraDict setObject:dict[@"Content"] forKey:@"Content"];
  365. [[HttpManager sharedHttpManager] PUTUrl:Host(API_CreateNoteBook) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  366. NSLog(@"%@",responseObject);
  367. NSMutableDictionary * InfoDict = [NSMutableDictionary dictionaryWithDictionary:responseObject];
  368. [InfoDict setObject:dict[@"Type"] forKey:@"Type"];
  369. USERDEFAULTSSET(InfoDict, type == CollectModel_NoteBook ? NOTEBOOKDRAFTINFO : TOPICBOOKDRAFTINFO);
  370. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  371. } failure:^(NSError * _Nonnull error) {
  372. SHOWERROR([ZYCTool handerResultData:error]);
  373. }];
  374. }
  375. - (void)submitNotice:(NSDictionary *)dict
  376. {
  377. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  378. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  379. [paraDict setObject:dict[@"UserId"] forKey:@"UserId"];
  380. [paraDict setObject:dict[@"NoticeType"] forKey:@"NoticeType"];
  381. [paraDict setObject:dict[@"FolderId"] forKey:@"FolderId"];
  382. [paraDict setObject:dict[@"HtmlContent"] forKey:@"HtmlContent"];
  383. [paraDict setObject:dict[@"TypeValue"] forKey:@"TypeValue"];
  384. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  385. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  386. [paraDict setObject:dict[@"Content"] forKey:@"Content"];
  387. [[HttpManager sharedHttpManager] PUTUrl:Host(API_NOTICE_ADD) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  388. NSMutableDictionary * InfoDict = [NSMutableDictionary dictionaryWithDictionary:responseObject];
  389. [InfoDict setObject:dict[@"Type"] forKey:@"Type"];
  390. USERDEFAULTSSET(InfoDict, NOTICERAFTINFO);
  391. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  392. } failure:^(NSError * _Nonnull error) {
  393. SHOWERROR([ZYCTool handerResultData:error]);
  394. }];
  395. }
  396. - (void)submitMail:(NSDictionary *)dict
  397. {
  398. NSMutableDictionary * paraDict = [NSMutableDictionary dictionary];
  399. [paraDict setObject:dict[@"Title"] forKey:@"Title"];
  400. [paraDict setObject:dict[@"UserId"] forKey:@"UserId"];
  401. [paraDict setObject:dict[@"FolderId"] forKey:@"FolderId"];
  402. [paraDict setObject:dict[@"HtmlContent"] forKey:@"HtmlContent"];
  403. [paraDict setObject:dict[@"AddresseeUserMiddles"] forKey:@"AddresseeUserMiddles"];
  404. [paraDict setObject:dict[@"CcUserMiddles"] forKey:@"CcUserMiddles"];
  405. [paraDict setObject:dict[@"Content"] forKey:@"Content"];
  406. [paraDict setObject:dict[@"MissiveType"] forKey:@"MissiveType"];///1 正常 2 匿名
  407. [paraDict setObject:dict[@"ParentId"] forKey:@"ParentId"];///回复ID
  408. [paraDict setObject:dict[@"TypeValue"] forKey:@"TypeValue"];
  409. [paraDict setObject:dict[@"MissiveAttributeType"] forKey:@"MissiveAttributeType"];///1 发送 2 草稿
  410. [[HttpManager sharedHttpManager] PUTUrl:Host(API_InterLetterModify) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  411. NSMutableDictionary * InfoDict = [NSMutableDictionary dictionaryWithDictionary:responseObject];
  412. [InfoDict setObject:dict[@"Type"] forKey:@"Type"];
  413. USERDEFAULTSSET(InfoDict, MAILRAFTINFO);
  414. [[NSUserDefaults standardUserDefaults] removeObjectForKey:DRAFT];
  415. } failure:^(NSError * _Nonnull error) {
  416. SHOWERROR([ZYCTool handerResultData:error]);
  417. }];
  418. }
  419. @end