RANavigationController.m 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // RANavigationController.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/8/31.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RANavigationController.h"
  9. #import "RAOrderDetailViewController.h"
  10. @interface RANavigationController ()
  11. @end
  12. @implementation RANavigationController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. // Do any additional setup after loading the view.
  16. [self registNotification];
  17. }
  18. - (void)dealloc {
  19. [[NSNotificationCenter defaultCenter] removeObserver:self];
  20. }
  21. - (void)didReceiveMemoryWarning {
  22. [super didReceiveMemoryWarning];
  23. // Dispose of any resources that can be recreated.
  24. }
  25. - (void)registNotification {
  26. // [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"%s",__func__]];
  27. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveHandleOrderNotification:) name:RANotificationHandleOrder object:nil];
  28. }
  29. - (void)receiveHandleOrderNotification:(NSNotification *)notification {
  30. NSDictionary *userInfo = notification.userInfo;
  31. NSDictionary *aps = [userInfo objectForKey:@"aps"];
  32. NSString *orderID = [aps objectForKey:@"order-id"];
  33. NSInteger orderType = [[aps objectForKey:@"order-type"] integerValue];
  34. NSString *orderType2 = [aps objectForKey:@"order-type2"];
  35. if (!orderType2) {
  36. orderType2 = @"";
  37. }
  38. // [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"%s",__func__]];
  39. if (orderID) {
  40. NSString *msg = [aps objectForKey:@"message"];
  41. if (msg.length == 0) {
  42. msg = [NSString stringWithFormat:@"%@ status changed,view detail?",orderID];
  43. }
  44. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
  45. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  46. }];
  47. __weak typeof(self) weakSelf = self;
  48. UIAlertAction *detailAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  49. [weakSelf pushDetailViewControllerForOrderID:orderID type:orderType type2:orderType2];
  50. }];
  51. [alertVC addAction:cancelAction];
  52. [alertVC addAction:detailAction];
  53. [self presentViewController:alertVC animated:YES completion:nil];
  54. }
  55. }
  56. - (void)pushDetailViewControllerForOrderID:(NSString *)orderID type:(NSInteger)type type2:(NSString *)type2 {
  57. if (!orderID) {
  58. return;
  59. }
  60. RAOrderDetailViewController *detailVC = [RAOrderDetailViewController viewControllerFromStoryboard];
  61. detailVC.orderID = orderID;
  62. detailVC.orderType = type;
  63. detailVC.orderType2 = type2;
  64. [self pushViewController:detailVC animated:YES];
  65. }
  66. @end