xiongzhu 7 年之前
父節點
當前提交
919b249dcd

+ 2 - 2
model/AppDelegate.h

@@ -10,8 +10,8 @@
 
 @interface AppDelegate : UIResponder <UIApplicationDelegate>
 
-@property (strong, nonatomic) UIWindow *window;
-
+@property(strong, nonatomic) UIWindow *window;
+@property(nonatomic, assign) BOOL firstLogin;
 
 @end
 

+ 130 - 108
model/AppDelegate.m

@@ -16,17 +16,26 @@
 #import "NTESNotificationCenter.h"
 #import "NTESSessionUtil.h"
 #import "WXApi.h"
+#import "UIAlertView+NTESBlock.h"
 
 @import PushKit;
 
 NSString *NTESNotificationLogout = @"NTESNotificationLogout";
 
 @interface AppDelegate () <NIMLoginManagerDelegate, PKPushRegistryDelegate, WXApiDelegate>
-
+@property(nonatomic, assign) BOOL checkUpdateWhenEnter;
 @end
 
 @implementation AppDelegate
+- (void)showAlert:(UIAlertController *)alert {
+    UIWindow *topWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
+    topWindow.rootViewController = [UIViewController new];
+    topWindow.windowLevel = UIWindowLevelAlert + 1;
+    [topWindow makeKeyAndVisible];
+    [topWindow.rootViewController presentViewController:alert animated:YES completion:nil];
+}
 
+#pragma mark - AppDelegate
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     // Override point for customization after application launch.
@@ -79,7 +88,7 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
     [self.window makeKeyAndVisible];
 
     [WXApi registerApp:@"wx2a873aba839dbb4b" enableMTA:YES];
-
+    [self checkUpdate];
     return YES;
 }
 
@@ -94,6 +103,62 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
     return [WXApi handleOpenURL:url delegate:self];
 }
 
+- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
+    [[NIMSDK sharedSDK] updateApnsToken:deviceToken];
+    NSLog(@"deviceToken=============%@", deviceToken);
+}
+
+- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
+    NSLog(@"receive remote notification:  %@", userInfo);
+    //    [UIApplication sharedApplication].applicationIconBadgeNumber  =  0;
+    //    completionHandler(UIBackgroundFetchResultNewData);
+}
+
+- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
+    // Required, iOS 7 Support
+    completionHandler(UIBackgroundFetchResultNewData);
+    if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
+        // 此时app在前台运行,我的做法是弹出一个alert,告诉用户有一条推送,用户可以选择查看或者忽略
+        // UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"推送消息"
+        //                                                 message:@"您有一条新的推送消息!"
+        //                                                delegate:self
+        //                                       cancelButtonTitle:@"取消"
+        //                                       otherButtonTitles:@"查看", nil];
+        // [alert show];
+    } else {
+
+        //这里是app未运行或者在后台,通过点击手机通知栏的推送消息打开app时可以在这里进行处理,比如,拿到推送里的内容或者附加      字段(假设,推送里附加了一个url为 www.baidu.com),那么你就可以拿到这个url,然后进行跳转到相应店web页,当然,不一定必须是web页,也可以是你app里的任意一个controll,跳转的话用navigation或者模态视图都可以
+    }
+
+    //这里设置app的图片的角标为0,红色但角标就会消失
+    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
+    completionHandler(UIBackgroundFetchResultNewData);
+
+}
+
+- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
+    NSLog(@"fail to get apns token :%@", error);
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+    NSInteger count = [[[NIMSDK sharedSDK] conversationManager] allUnreadCount];
+    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:count];
+    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"reloadUnRead" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"orderMsg" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"hideNavigationBar" object:nil];
+    // 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.
+    if (self.checkUpdateWhenEnter) {
+        [self checkUpdate];
+    }
+}
+
+#pragma mark -
+
 - (void)setupMainViewController {
     NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
     NSString *accid = [user objectForKey:@"accid"];
@@ -140,7 +205,13 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
 
 - (void)onAutoLoginFailed:(NSError *)error {
     NSLog(@"AutoLoginFailed");
-    [self showAutoLoginErrorAlert:error];
+    LoginViewController *loginVC = [[LoginViewController alloc] init];
+    [[[NIMSDK sharedSDK] loginManager] logout:^(NSError *error) {
+        [[NSNotificationCenter defaultCenter] postNotificationName:NTESNotificationLogout object:nil];
+        [self.window.rootViewController presentViewController:loginVC
+                                                     animated:YES
+                                                   completion:nil];
+    }];
 }
 
 - (void)onLogin:(NIMLoginStep)step {
@@ -159,7 +230,7 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
         case NIMKickReasonByClientManually: {
             //            NSString *clientName = [NTESClientUtil clientName:clientType];
             //            reason = clientName.length ? [NSString stringWithFormat:@"你的帐号被%@端踢出下线,请注意帐号信息安全",clientName] : @"你的帐号被踢出下线,请注意帐号信息安全";
-            reason = @"你的帐号被踢出下线,请注意帐号信息安全";
+            reason = @"您的账号已在其他设备登录";
             break;
         }
         case NIMKickReasonByServer:
@@ -168,19 +239,18 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
         default:
             break;
     }
+    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
+    [userDefaults removeObjectForKey:@"token"];
+    [userDefaults synchronize];
     [[[NIMSDK sharedSDK] loginManager] logout:^(NSError *error) {
-        UIWindow* topWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
-        topWindow.rootViewController = [UIViewController new];
-        topWindow.windowLevel = UIWindowLevelAlert + 1;
         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"下线通知" message:reason preferredStyle:UIAlertControllerStyleAlert];
-        [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+        [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull action) {
             [self.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
             LoginViewController *loginController = [[LoginViewController alloc] init];
             UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginController];
             self.window.rootViewController = nav;
         }]];
-        [topWindow makeKeyAndVisible];
-        [topWindow.rootViewController presentViewController:alertController animated:YES completion:nil];
+        [self showAlert:alertController];
     }];
 }
 
@@ -191,43 +261,6 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
     //    [[NTESRedPacketManager sharedManager] start];
 }
 
-- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
-    [[NIMSDK sharedSDK] updateApnsToken:deviceToken];
-    NSLog(@"deviceToken=============%@", deviceToken);
-}
-
-- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
-    NSLog(@"receive remote notification:  %@", userInfo);
-    //    [UIApplication sharedApplication].applicationIconBadgeNumber  =  0;
-    //    completionHandler(UIBackgroundFetchResultNewData);
-}
-
-- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
-    // Required, iOS 7 Support
-    completionHandler(UIBackgroundFetchResultNewData);
-    if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
-        // 此时app在前台运行,我的做法是弹出一个alert,告诉用户有一条推送,用户可以选择查看或者忽略
-        // UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"推送消息"
-        //                                                 message:@"您有一条新的推送消息!"
-        //                                                delegate:self
-        //                                       cancelButtonTitle:@"取消"
-        //                                       otherButtonTitles:@"查看", nil];
-        // [alert show];
-    } else {
-
-        //这里是app未运行或者在后台,通过点击手机通知栏的推送消息打开app时可以在这里进行处理,比如,拿到推送里的内容或者附加      字段(假设,推送里附加了一个url为 www.baidu.com),那么你就可以拿到这个url,然后进行跳转到相应店web页,当然,不一定必须是web页,也可以是你app里的任意一个controll,跳转的话用navigation或者模态视图都可以
-    }
-
-    //这里设置app的图片的角标为0,红色但角标就会消失
-    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
-    completionHandler(UIBackgroundFetchResultNewData);
-
-}
-
-- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
-    NSLog(@"fail to get apns token :%@", error);
-}
-
 #pragma mark PKPushRegistryDelegate
 
 - (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
@@ -275,81 +308,70 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
     PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
     pushRegistry.delegate = self;
     pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
-    
-    NIMPushNotificationSetting *setting =  [[[NIMSDK sharedSDK] apnsManager] currentSetting];
+
+    NIMPushNotificationSetting *setting = [[[NIMSDK sharedSDK] apnsManager] currentSetting];
     setting.noDisturbing = disableNotification;
     setting.noDisturbingStartH = 0;
     setting.noDisturbingStartM = 0;
     setting.noDisturbingEndH = 23;
     setting.noDisturbingEndM = 59;
     [[[NIMSDK sharedSDK] apnsManager] updateApnsSetting:setting
-                                             completion:^(NSError *error) {}];
+                                             completion:^(NSError *error) {
+                                             }];
 }
 
-#pragma mark - 登录错误回调
-
-- (void)showAutoLoginErrorAlert:(NSError *)error {
-    NSString *message = [NTESSessionUtil formatAutoLoginMessage:error];
-    UIAlertController *vc = [UIAlertController alertControllerWithTitle:@"自动登录失败"
-                                                                message:message
-                                                         preferredStyle:UIAlertControllerStyleAlert];
-
-    if ([error.domain isEqualToString:NIMLocalErrorDomain] &&
-            error.code == NIMLocalErrorCodeAutoLoginRetryLimit) {
-        UIAlertAction *retryAction =
-                [UIAlertAction actionWithTitle:@"重试"
-                                         style:UIAlertActionStyleCancel
-                                       handler:^(UIAlertAction *_Nonnull action) {
-                                           // NTESLoginData *data = [[NTESLoginManager sharedManager] currentLoginData];
-                                           NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
-                                           NSString *account = [user objectForKey:@"accid"];
-                                           NSString *token = [user objectForKey:@"token"];
-                                           //
-                                           // NSString *account = [data account];
-                                           // NSString *token = [data token];
-                                           if ([account length] && [token length]) {
-                                               NIMAutoLoginData *loginData = [[NIMAutoLoginData alloc] init];
-                                               loginData.account = account;
-                                               loginData.token = token;
-
-                                               [[[NIMSDK sharedSDK] loginManager] autoLogin:loginData];
+#pragma mark - appUpdate
+
+- (void)checkUpdate {
+    [YanCNetWorkManager
+            requestPostWithURLStr:Url_checkUpdate(PublicUrl)
+                       parameters:nil
+                           finish:^(id dataDic) {
+                               if ([@"success" isEqualToString:dataDic[@"msg"]]) {
+                                   NSDictionary *data = dataDic[@"data"];
+                                   int currentVersion = [self versionExchangeType:[self getSystemVersion]];
+                                   int latestVersion = [self versionExchangeType:data[@"ios"][@"model"][@"version"]];
+                                   if (currentVersion < latestVersion) {
+                                       UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:[NSString stringWithFormat:@"发现新版本%@", data[@"ios"][@"model"][@"version"]] preferredStyle:UIAlertControllerStyleAlert];
+                                       [alert addAction:@"立即更新" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                                           NSURL *url = [NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id1434011196?mt=8"];
+                                           if (@available(iOS 10.0, *)) {
+                                               [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
+                                           } else {
+                                               [[UIApplication sharedApplication] openURL:url];
                                            }
                                        }];
-        [vc addAction:retryAction];
-    }
-
-    LoginViewController *lVc = [[LoginViewController alloc] init];
-
-    UIAlertAction *logoutAction = [UIAlertAction actionWithTitle:@"注销"
-                                                           style:UIAlertActionStyleDestructive
-                                                         handler:^(UIAlertAction *_Nonnull action) {
-                                                             [[[NIMSDK sharedSDK] loginManager] logout:^(NSError *error) {
-                                                                 [[NSNotificationCenter defaultCenter] postNotificationName:NTESNotificationLogout object:nil];
-                                                                 [self.window.rootViewController presentViewController:lVc
-                                                                                                              animated:YES
-                                                                                                            completion:nil];
-                                                             }];
-                                                         }];
-    [vc addAction:logoutAction];
-
-
-    [self.window.rootViewController presentViewController:vc
-                                                 animated:YES
-                                               completion:nil];
+                                       BOOL force = [data[@"ios"][@"model"][@"force"] boolValue];
+                                       if (force) {
+                                           self.checkUpdateWhenEnter = YES;
+                                       } else {
+                                           [alert addAction:@"取消" style:UIAlertActionStyleCancel handler:nil];
+                                       }
+                                       [self showAlert:alert];
+                                   }
+                               }
+                           }
+                          enError:^(NSError *error) {
+                          }];
 }
 
-- (void)applicationDidEnterBackground:(UIApplication *)application {
-    NSInteger count = [[[NIMSDK sharedSDK] conversationManager] allUnreadCount];
-    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:count];
-    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
-    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+- (NSString *)getSystemVersion {
+    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
+    NSString *currentVersion = infoDic[@"CFBundleShortVersionString"];
+    return currentVersion;
 }
 
-- (void)applicationWillEnterForeground:(UIApplication *)application {
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"reloadUnRead" object:nil];
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"orderMsg" object:nil];
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"hideNavigationBar" object:nil];
-    // 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.
+- (int)versionExchangeType:(NSString *)version {
+    NSArray *subArr = [version componentsSeparatedByString:@"."];
+    if (subArr.count > 0) {
+        NSString *value = @"";
+        for (int i = 0; i < subArr.count; i++) {
+            value = [value stringByAppendingString:subArr[i]];
+        }
+        return value.intValue;
+    } else {
+        return 0;
+    }
 }
 
 @end

+ 109 - 140
model/Classes/Controllers/Controller/MessageVC/MessageViewController.m

@@ -1,4 +1,4 @@
- //
+//
 //  MessageViewController.m
 //  千模
 //
@@ -16,13 +16,13 @@
 #import "NIMKitLocationPoint.h"
 #import "NIMLocationViewController.h"
 
-NSString *const NIMDemoEventNameOpenSnapPicture  = @"NIMDemoEventNameOpenSnapPicture";
+NSString *const NIMDemoEventNameOpenSnapPicture = @"NIMDemoEventNameOpenSnapPicture";
 NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPicture";
 
-@interface MessageViewController ()<NIMMessageObject>
-@property (nonatomic,strong) NTESSessionConfig       *sessionConfig;
-@property (nonatomic,strong) UIView                  * bgblackView;//黑色背景
-@property (nonatomic,strong) UIView                  * bgwhiteView;//下拉选项背景
+@interface MessageViewController () <NIMMessageObject>
+@property(nonatomic, strong) NTESSessionConfig *sessionConfig;
+@property(nonatomic, strong) UIView *bgblackView;//黑色背景
+@property(nonatomic, strong) UIView *bgwhiteView;//下拉选项背景
 @property(nonatomic, assign) BOOL hideTabBarWhenPop;
 
 @end
@@ -39,54 +39,54 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
     [super viewDidLayoutSubviews];
     if ([@"system" isEqualToString:self.session.sessionId]) {
         self.sessionInputView.hidden = YES;
-        [self.tableView setFrame: CGRectMake(0, self.navigationController.navigationBar.frame.size.height, ScreenWidth, self.view.frame.size.height - self.navigationController.navigationBar.frame.size.height)];
+        [self.tableView setFrame:CGRectMake(0, self.navigationController.navigationBar.frame.size.height, ScreenWidth, self.view.frame.size.height - self.navigationController.navigationBar.frame.size.height)];
     }
 }
 
-- (void)setupNav{
+- (void)setupNav {
     [super setUpTitleView];
-    if ([UIScreen spt_currentScreenMode]== LESScreenModeIPhoneX){
-        self.view.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight+34);
+    if ([UIScreen spt_currentScreenMode] == LESScreenModeIPhoneX) {
+        self.view.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight + 34);
     }
-    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
+    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
     btn.frame = CGRectMake(0, 0, 40, 40);
     [btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal];
-    btn.imageEdgeInsets =  UIEdgeInsetsMake(0, -20, 0, 0);
+    btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
     [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
     UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
-    UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
+    UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
     nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
     self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
-    
+
     UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
     rightBtn.frame = CGRectMake(0, 0, 40, 40);
     [rightBtn setImage:[UIImage imageNamed:@"more"] forState:UIControlStateNormal];
-    rightBtn.imageEdgeInsets =  UIEdgeInsetsMake(0, 0, 0, -20);
+    rightBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -20);
     [rightBtn addTarget:self action:@selector(rightBtnClick) forControlEvents:UIControlEventTouchUpInside];
     UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
-    UIBarButtonItem *nagetiveRightSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
+    UIBarButtonItem *nagetiveRightSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
     //    nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
     self.navigationItem.rightBarButtonItems = @[rightItem, nagetiveRightSpacer];
 }
 
--(void)rightBtnClick{
-    
+- (void)rightBtnClick {
+
     if (!_bgblackView) {
-        _bgblackView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
+        _bgblackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
         _bgblackView.backgroundColor = RGBA(0, 0, 0, 0.6);
         _bgblackView.hidden = YES;
-        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickHiddenSiftView)];
+        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickHiddenSiftView)];
         [_bgblackView addGestureRecognizer:tap];
         [self.view addSubview:_bgblackView];
-        
-        self.bgwhiteView = [[UIView alloc]initWithFrame:CGRectMake(ScreenWidth-100, -100, 100, 100)];
+
+        self.bgwhiteView = [[UIView alloc] initWithFrame:CGRectMake(ScreenWidth - 100, -100, 100, 100)];
         self.bgwhiteView.backgroundColor = [UIColor whiteColor];
         self.bgwhiteView.layer.shadowColor = RGB(200, 200, 200).CGColor;
         self.bgwhiteView.layer.shadowOffset = CGSizeMake(0, 1);
         self.bgwhiteView.layer.shadowOpacity = 0.5;
         [_bgblackView addSubview:self.bgwhiteView];
-        
-        UIButton *reportButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 50)];
+
+        UIButton *reportButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
         reportButton.backgroundColor = [UIColor whiteColor];
         [reportButton setImage:[UIImage imageNamed:@"report"] forState:UIControlStateNormal];
         [reportButton setTitle:@"举报" forState:UIControlStateNormal];
@@ -97,8 +97,8 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
         [reportButton setTitleEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
         [reportButton addTarget:self action:@selector(clickReport) forControlEvents:UIControlEventTouchUpInside];
         [self.bgwhiteView addSubview:reportButton];
-        
-        UIButton *screenButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 50, 100, 50)];
+
+        UIButton *screenButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 50, 100, 50)];
         screenButton.backgroundColor = [UIColor whiteColor];
         [screenButton setImage:[UIImage imageNamed:@"screen"] forState:UIControlStateNormal];
         [screenButton setTitle:@"屏蔽" forState:UIControlStateNormal];
@@ -109,79 +109,79 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
         [screenButton setTitleEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
         [screenButton addTarget:self action:@selector(clickScreen) forControlEvents:UIControlEventTouchUpInside];
         [self.bgwhiteView addSubview:screenButton];
-        
-        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 50, 100, 0.5)];
+
+        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 50, 100, 0.5)];
         line.backgroundColor = RGB(151, 151, 151);
         [self.bgwhiteView addSubview:line];
     }
-    
+
     _bgblackView.hidden = NO;
-    
+
     [UIView animateWithDuration:0.25 animations:^{
-        
-        self.bgwhiteView.frame = CGRectMake(ScreenWidth-100, 64, 100, 100);
-    } completion:^(BOOL finished) {
-        
+
+        self.bgwhiteView.frame = CGRectMake(ScreenWidth - 100, 64, 100, 100);
+    }                completion:^(BOOL finished) {
+
     }];
 }
 
 //点击隐藏
--(void)clickHiddenSiftView{
-    
+- (void)clickHiddenSiftView {
+
     [UIView animateWithDuration:0.25 animations:^{
-        
-        self.bgwhiteView.frame = CGRectMake(ScreenWidth-100, -100, 100, 100);
-        
-    } completion:^(BOOL finished) {
+
+        self.bgwhiteView.frame = CGRectMake(ScreenWidth - 100, -100, 100, 100);
+
+    }                completion:^(BOOL finished) {
         _bgblackView.hidden = YES;
     }];
 }
 
 //举报
--(void)clickReport{
-    
+- (void)clickReport {
+
     UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"是否确定举报该用户" preferredStyle:UIAlertControllerStyleAlert];
     UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
-    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        
+    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
+
         [self postReport];
     }];
     [alertVc addAction:cancelAction];
     [alertVc addAction:sureAction];
     [self presentViewController:alertVc animated:YES completion:nil];
-    
+
     [self clickHiddenSiftView];
 }
 
-- (void)postReport{
-    NSString *str = [NSString stringWithFormat:@"%@/memberInfo?action=report&accuserpk=%@&appelleepk=%@&reason=%@",PublicUrl,[ModelUser user].pk,self.session.sessionId,@""];
-    [[AHHttpManager sharedManager]POST:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(id responseObject) {
-        
-        if ([[responseObject objectForKey:@"msg"]isEqualToString:@"success"]) {
-            
+- (void)postReport {
+    NSString *str = [NSString stringWithFormat:@"%@/memberInfo?action=report&accuserpk=%@&appelleepk=%@&reason=%@", PublicUrl, [ModelUser user].pk, self.session.sessionId, @""];
+    [[AHHttpManager sharedManager] POST:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(id responseObject) {
+
+        if ([[responseObject objectForKey:@"msg"] isEqualToString:@"success"]) {
+
             UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"举报成功,我们将会在24小时之内给出回复" preferredStyle:UIAlertControllerStyleAlert];
-            UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-                
+            UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
+
             }];
             [alertVc addAction:sureAction];
             [self presentViewController:alertVc animated:YES completion:nil];
-        }else{
+        } else {
             [MBProgressHUD showTextHUD:@"超时" inView:self.view hideAfterDelay:1];
         }
-    } failure:^(NSError *error) {
-        NSLog(@"error = %@",error);
+    }                           failure:^(NSError *error) {
+        NSLog(@"error = %@", error);
         [MBProgressHUD showTextHUD:@"超时" inView:self.view hideAfterDelay:1];
     }];
 }
 
 //屏蔽
--(void)clickScreen{
-    
+- (void)clickScreen {
+
     UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"是否确定屏蔽该用户" preferredStyle:UIAlertControllerStyleAlert];
     UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
-    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        
-        [[NIMSDK sharedSDK].userManager addToBlackList:self.session.sessionId completion:^(NSError * _Nullable error) {
+    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
+
+        [[NIMSDK sharedSDK].userManager addToBlackList:self.session.sessionId completion:^(NSError *_Nullable error) {
             if (!error) {
                 [MBProgressHUD showTextHUD:@"已屏蔽该用户" inView:self.view hideAfterDelay:1];
             }
@@ -190,7 +190,7 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
     [alertVc addAction:cancelAction];
     [alertVc addAction:sureAction];
     [self presentViewController:alertVc animated:YES completion:nil];
-    
+
     [self clickHiddenSiftView];
 }
 
@@ -233,12 +233,11 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
 //}
 
 #pragma mark - Cell事件
-- (BOOL)onTapCell:(NIMKitEvent *)event
-{
+
+- (BOOL)onTapCell:(NIMKitEvent *)event {
     BOOL handled = [super onTapCell:event];
     NSString *eventName = event.eventName;
-    if ([eventName isEqualToString:NIMKitEventNameTapContent])
-    {
+    if ([eventName isEqualToString:NIMKitEventNameTapContent]) {
         NIMMessage *message = event.messageModel.message;
         NSDictionary *actions = [self cellActions];
         NSString *value = actions[@(message.messageType)];
@@ -249,15 +248,11 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
                 handled = YES;
             }
         }
-    }
-    else if([eventName isEqualToString:NIMKitEventNameTapLabelLink])
-    {
+    } else if ([eventName isEqualToString:NIMKitEventNameTapLabelLink]) {
         NSString *link = event.data;
         [self openSafari:link];
         handled = YES;
-    }
-    else if([eventName isEqualToString:NIMDemoEventNameOpenSnapPicture])
-    {
+    } else if ([eventName isEqualToString:NIMDemoEventNameOpenSnapPicture]) {
 //        NIMCustomObject *object = event.messageModel.message.messageObject;
 //        NTESSnapchatAttachment *attachment = (NTESSnapchatAttachment *)object.attachment;
 //        if(attachment.isFired){
@@ -266,9 +261,7 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
 //        UIView *sender = event.data;
 //        self.currentSingleSnapView = [NTESGalleryViewController alertSingleSnapViewWithMessage:object.message baseView:sender];
 //        handled = YES;
-    }
-    else if([eventName isEqualToString:NIMDemoEventNameCloseSnapPicture])
-    {
+    } else if ([eventName isEqualToString:NIMDemoEventNameCloseSnapPicture]) {
 //        //点击很快的时候可能会触发两次查看,所以这里不管有没有查看过 先强直销毁掉
 //        NIMCustomObject *object = event.messageModel.message.messageObject;
 //        UIView *senderView = event.data;
@@ -290,9 +283,7 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
 //        [[NSFileManager defaultManager] removeItemAtPath:attachment.filepath error:nil];
 //        self.currentSingleSnapView = nil;
 //        handled = YES;
-    }
-    else if([eventName isEqualToString:NIMKitEventNameTapRobotLink])
-    {
+    } else if ([eventName isEqualToString:NIMKitEventNameTapRobotLink]) {
         NSString *link = event.data;
         [self openSafari:link];
         handled = YES;
@@ -305,21 +296,21 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
 }
 
 #pragma mark - Cell Actions
-- (void)showImage:(NIMMessage *)message
-{
+
+- (void)showImage:(NIMMessage *)message {
     NIMImageObject *object = message.messageObject;
     NTESGalleryItem *item = [[NTESGalleryItem alloc] init];
-    item.thumbPath      = [object thumbPath];
-    item.imageURL       = [object url];
-    item.name           = [object displayName];
-    item.itemId         = [message messageId];
-    item.size           = [object size];
-    
-    NIMSession *session = [self isMemberOfClass:[MessageViewController class]]? self.session : nil;
-    
+    item.thumbPath = [object thumbPath];
+    item.imageURL = [object url];
+    item.name = [object displayName];
+    item.itemId = [message messageId];
+    item.size = [object size];
+
+    NIMSession *session = [self isMemberOfClass:[MessageViewController class]] ? self.session : nil;
+
     NTESGalleryViewController *vc = [[NTESGalleryViewController alloc] initWithItem:item session:session];
     [self.navigationController pushViewController:vc animated:YES];
-    if(![[NSFileManager defaultManager] fileExistsAtPath:object.thumbPath]){
+    if (![[NSFileManager defaultManager] fileExistsAtPath:object.thumbPath]) {
         //如果缩略图下跪了,点进看大图的时候再去下一把缩略图
         __weak typeof(self) wself = self;
         [[NIMSDK sharedSDK].resourceManager download:object.thumbUrl filepath:object.thumbPath progress:nil completion:^(NSError *error) {
@@ -330,20 +321,19 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
     }
 }
 
-- (void)showVideo:(NIMMessage *)message
-{
+- (void)showVideo:(NIMMessage *)message {
     NIMVideoObject *object = message.messageObject;
-    NIMSession *session = [self isMemberOfClass:[MessageViewController class]]? self.session : nil;
-    
+    NIMSession *session = [self isMemberOfClass:[MessageViewController class]] ? self.session : nil;
+
     NTESVideoViewItem *item = [[NTESVideoViewItem alloc] init];
     item.path = object.path;
-    item.url  = object.url;
+    item.url = object.url;
     item.session = session;
-    item.itemId  = object.message.messageId;
-    
+    item.itemId = object.message.messageId;
+
     NTESVideoViewController *playerViewController = [[NTESVideoViewController alloc] initWithVideoViewItem:item];
     [self.navigationController pushViewController:playerViewController animated:YES];
-    if(![[NSFileManager defaultManager] fileExistsAtPath:object.coverPath]){
+    if (![[NSFileManager defaultManager] fileExistsAtPath:object.coverPath]) {
         //如果封面图下跪了,点进视频的时候再去下一把封面图
         __weak typeof(self) wself = self;
         [[NIMSDK sharedSDK].resourceManager download:object.coverUrl filepath:object.coverPath progress:nil completion:^(NSError *error) {
@@ -354,8 +344,7 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
     }
 }
 
-- (void)showLocation:(NIMMessage *)message
-{
+- (void)showLocation:(NIMMessage *)message {
     NIMLocationObject *object = message.messageObject;
     NIMKitLocationPoint *locationPoint = [[NIMKitLocationPoint alloc] initWithLocationObject:object];
     NIMLocationViewController *vc = [[NIMLocationViewController alloc] initWithLocationPoint:locationPoint];
@@ -369,18 +358,14 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
 //    [self.navigationController pushViewController:vc animated:YES];
 //}
 
-- (void)showCustom:(NIMMessage *)message
-{
+- (void)showCustom:(NIMMessage *)message {
     //普通的自定义消息点击事件可以在这里做哦~
 }
 
-- (void)openSafari:(NSString *)link
-{
+- (void)openSafari:(NSString *)link {
     NSURLComponents *components = [[NSURLComponents alloc] initWithString:link];
-    if (components)
-    {
-        if (!components.scheme)
-        {
+    if (components) {
+        if (!components.scheme) {
             //默认添加 http
             components.scheme = @"http";
         }
@@ -389,26 +374,24 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
 }
 
 
-- (NSDictionary *)cellActions
-{
+- (NSDictionary *)cellActions {
     static NSDictionary *actions = nil;
     static dispatch_once_t onceToken;
     dispatch_once(&onceToken, ^{
-        actions = @{@(NIMMessageTypeImage) :    @"showImage:",
-                    @(NIMMessageTypeVideo) :    @"showVideo:",
-                    @(NIMMessageTypeLocation) : @"showLocation:",
-                    @(NIMMessageTypeFile)  :    @"showFile:",
-                    @(NIMMessageTypeCustom):    @"showCustom:"};
+        actions = @{@(NIMMessageTypeImage): @"showImage:",
+                @(NIMMessageTypeVideo): @"showVideo:",
+                @(NIMMessageTypeLocation): @"showLocation:",
+                @(NIMMessageTypeFile): @"showFile:",
+                @(NIMMessageTypeCustom): @"showCustom:"};
     });
     return actions;
 }
 
--(void)backClick{
+- (void)backClick {
     [self.navigationController popViewControllerAnimated:YES];
 }
 
-- (id<NIMSessionConfig>)sessionConfig
-{
+- (id <NIMSessionConfig>)sessionConfig {
     if (_sessionConfig == nil) {
         _sessionConfig = [[NTESSessionConfig alloc] init];
         _sessionConfig.session = self.session;
@@ -416,27 +399,22 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
     return _sessionConfig;
 }
 
-- (BOOL)checkRTSCondition
-{
+- (BOOL)checkRTSCondition {
     BOOL result = YES;
-    
-    if (![[Reachability reachabilityForInternetConnection] isReachable])
-    {
+
+    if (![[Reachability reachabilityForInternetConnection] isReachable]) {
         [self.view makeToast:@"请检查网络" duration:2.0 position:CSToastPositionCenter];
         result = NO;
     }
     NSString *currentAccount = [[NIMSDK sharedSDK].loginManager currentAccount];
-    if (self.session.sessionType == NIMSessionTypeP2P && [currentAccount isEqualToString:self.session.sessionId])
-    {
+    if (self.session.sessionType == NIMSessionTypeP2P && [currentAccount isEqualToString:self.session.sessionId]) {
         [self.view makeToast:@"不能和自己通话哦" duration:2.0 position:CSToastPositionCenter];
         result = NO;
     }
-    if (self.session.sessionType == NIMSessionTypeTeam)
-    {
+    if (self.session.sessionType == NIMSessionTypeTeam) {
         NIMTeam *team = [[NIMSDK sharedSDK].teamManager teamById:self.session.sessionId];
         NSInteger memberNumber = team.memberNumber;
-        if (memberNumber < 2)
-        {
+        if (memberNumber < 2) {
             [self.view makeToast:@"无法发起,群人数少于2人" duration:2.0 position:CSToastPositionCenter];
             result = NO;
         }
@@ -445,20 +423,12 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
 }
 
 #pragma mark - 视频聊天
-- (void)onTapMediaItemVideoChat:(NIMMediaItem *)item
-{
+
+- (void)onTapMediaItemVideoChat:(NIMMediaItem *)item {
     if ([self checkRTSCondition]) {
         //由于音视频聊天里头有音频和视频聊天界面的切换,直接用present的话页面过渡会不太自然,这里还是用push,然后做出present的效果
         NTESVideoChatViewController *vc = [[NTESVideoChatViewController alloc] initWithCallee:self.session.sessionId];
-        vc.hidesBottomBarWhenPushed = YES;
-        CATransition *transition = [CATransition animation];
-        transition.duration = 0.25;
-        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
-        transition.type = kCATransitionPush;
-        transition.subtype = kCATransitionFromTop;
-        [self.navigationController.view.layer addAnimation:transition forKey:nil];
-        self.navigationController.navigationBarHidden = YES;
-        [self.navigationController pushViewController:vc animated:NO];
+        [self.navigationController presentViewController:vc animated:YES completion:nil];
     }
 }
 
@@ -477,5 +447,4 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
 }
 
 
-
 @end

+ 48 - 30
model/Classes/Controllers/Controller/MineVC/MineNewViewController.m

@@ -22,6 +22,8 @@
 #import "RankController.h"
 #import "ApplyRecommendView.h"
 #import "WZLBadgeImport.h"
+#import "AppDelegate.h"
+#import "LoginViewController.h"
 
 @interface MineNewViewController () {
     BOOL online;
@@ -107,8 +109,8 @@
 
 - (void)viewDidAppear:(BOOL)animated {
     [super viewDidAppear:animated];
-    NSNumber *intro = [[NSUserDefaults standardUserDefaults] objectForKey:@"intro"];
-    if (!intro) {
+    AppDelegate *app = [[UIApplication sharedApplication] delegate];
+    if (app.firstLogin) {
         __weak MineNewViewController *this = self;
         IntroView *introView = [[IntroView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)
                                                         confirm:^{
@@ -129,7 +131,7 @@
         [window addSubview:introView];
         [introView updateConstraints];
         [introView layoutIfNeeded];
-        [[NSUserDefaults standardUserDefaults] setObject:@1 forKey:@"intro"];
+        app.firstLogin = false;
     }
 }
 
@@ -140,38 +142,54 @@
 - (void)getDataFromNetworking {
 //    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
     NSDictionary *dic = @{@"modelpk": [ModelUser user].modelpk};
-    [YanCNetWorkManager requestPostWithURLStr:Url_refreshLogin(PublicUrl) parameters:dic finish:^(id dataDic) {
-        [MBProgressHUD hideHUDForView:self.view animated:YES];
+    [YanCNetWorkManager
+            requestPostWithURLStr:Url_refreshLogin(PublicUrl)
+                       parameters:dic
+                           finish:^(id dataDic) {
+                               [MBProgressHUD hideHUDForView:self.view animated:YES];
 
-        NSString *issuccess = dataDic[@"msg"];
-        if ([issuccess isEqualToString:@"success"]) {
-            ModelUser *user = [ModelUser modelUser];
-            [user setValuesForKeysWithDictionary:dataDic[@"data"]];
-            user.modelpk = dataDic[@"data"][@"modelpk"];
-            user.coin_a = dataDic[@"data"][@"coin_a"];
-            user.coin_ir = dataDic[@"data"][@"coin_ir"];
-            user.pk = dataDic[@"data"][@"pk"];
-            user.qrcode = dataDic[@"data"][@"qrcode"];
-            [ModelUser save:user];
+                               NSString *issuccess = dataDic[@"msg"];
+                               if ([issuccess isEqualToString:@"success"]) {
+                                   ModelUser *user = [ModelUser modelUser];
+                                   [user setValuesForKeysWithDictionary:dataDic[@"data"]];
+                                   user.modelpk = dataDic[@"data"][@"modelpk"];
+                                   user.coin_a = dataDic[@"data"][@"coin_a"];
+                                   user.coin_ir = dataDic[@"data"][@"coin_ir"];
+                                   user.pk = dataDic[@"data"][@"pk"];
+                                   user.qrcode = dataDic[@"data"][@"qrcode"];
+                                   [ModelUser save:user];
 
-            self.nameLabel.text = [NSString stringWithFormat:@"%@", dataDic[@"data"][@"pet"]];
-            [self.avatarView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", PublicUrl, dataDic[@"data"][@"hphoto"]]] placeholderImage:[UIImage imageNamed:@"morentouxiang"]];
-            online = user.is_a;
-            [self setSwitchState:user.is_a];
+                                   self.nameLabel.text = [NSString stringWithFormat:@"%@", dataDic[@"data"][@"pet"]];
+                                   [self.avatarView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", PublicUrl, dataDic[@"data"][@"hphoto"]]] placeholderImage:[UIImage imageNamed:@"morentouxiang"]];
+                                   online = user.is_a;
+                                   [self setSwitchState:user.is_a];
 
-            if ([dataDic[@"data"][@"hasred"] isEqualToString:@"1"]) {
-                [self.orderIcon showBadge];
-            } else {
-                [self.orderIcon clearBadge];
-            }
+                                   if ([dataDic[@"data"][@"hasred"] isEqualToString:@"1"]) {
+                                       [self.orderIcon showBadge];
+                                   } else {
+                                       [self.orderIcon clearBadge];
+                                   }
 
-            [self getIncomeFromNetworking];
-        } else {
-            [MBProgressHUD showInfo:@"请求失败!"];
-        }
-    }                                 enError:^(NSError *error) {
-        [MBProgressHUD hideHUDForView:self.view animated:YES];
+                                   [self getIncomeFromNetworking];
+                               } else {
+                                   [MBProgressHUD showInfo:@"请重新登录"];
+                                   [self logout];
+                               }
+                           }
+                          enError:^(NSError *error) {
+                              [MBProgressHUD hideHUDForView:self.view animated:YES];
+                          }];
+}
+
+- (void)logout {
+    [[[NIMSDK sharedSDK] loginManager] logout:^(NSError *error) {
     }];
+    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"token"];
+    [[NSUserDefaults standardUserDefaults] synchronize];
+    [self.view.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
+    LoginViewController *loginController = [[LoginViewController alloc] init];
+    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginController];
+    self.view.window.rootViewController = nav;
 }
 
 - (void)getIncomeFromNetworking {

+ 105 - 97
model/Classes/Controllers/Controller/MyOrderVC/SkillOrderController.m

@@ -12,15 +12,14 @@
 #import "OrderDetailViewController.h"
 #import "MessageViewController.h"
 
-@interface SkillOrderController ()<UITableViewDelegate, UITableViewDataSource>
-{
+@interface SkillOrderController () <UITableViewDelegate, UITableViewDataSource> {
     NSInteger index;
     NSString *selectState;
 }
 
-@property (nonatomic, strong) UITableView *tableView;
-@property (nonatomic, strong) NSMutableArray *dataArr;
-@property (nonatomic, assign) NSInteger selectIndex; //0 1 2 3 4
+@property(nonatomic, strong) UITableView *tableView;
+@property(nonatomic, strong) NSMutableArray *dataArr;
+@property(nonatomic, assign) NSInteger selectIndex; //0 1 2 3 4
 @end
 
 @implementation SkillOrderController
@@ -34,7 +33,7 @@
 
 - (void)viewDidLoad {
     [super viewDidLoad];
-    
+
     index = 1;
     selectState = @"all";
     self.selectIndex = 0;
@@ -45,7 +44,7 @@
     [self getDataFromNetworking:selectState];
 }
 
-- (void)viewWillAppear:(BOOL)animated{
+- (void)viewWillAppear:(BOOL)animated {
     self.tabBarController.tabBar.hidden = YES;
 }
 
@@ -60,10 +59,10 @@
     UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
     btn.frame = CGRectMake(0, 0, 40, 40);
     [btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal];
-    btn.imageEdgeInsets =  UIEdgeInsetsMake(0, -20, 0, 0); // backBtn2
+    btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0); // backBtn2
     [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
     UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
-    UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
+    UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
     //    nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
     self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
 }
@@ -73,108 +72,108 @@
 }
 
 #pragma mark -- 网络请求
+
 - (void)getDataFromNetworking:(NSString *)state {
-    
+
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
-    NSString *indexStr = [NSString stringWithFormat:@"%zd",index];
-    
-    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].modelpk,@"modelpk",state,@"state",indexStr,@"index",@"10",@"size", nil];
-    
+    NSString *indexStr = [NSString stringWithFormat:@"%zd", index];
+
+    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].modelpk, @"modelpk", state, @"state", indexStr, @"index", @"10", @"size", nil];
+
     [YanCNetWorkManager requestPostWithURLStr:Url_dogetorderlist(PublicUrl) parameters:dic finish:^(id dataDic) {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
-        
+
         NSString *issuccess = dataDic[@"msg"];
         if ([issuccess isEqualToString:@"success"]) {
-            
+
             if (index == 1) {
                 [self.dataArr removeAllObjects];
             }
-            
+
             [self.dataArr addObjectsFromArray:dataDic[@"data"]];
-            
+
             [self.tableView reloadData];
-            
+
             NSString *number = dataDic[@"count"];
             NSInteger num = [number integerValue];
-            
+
             [self.tableView.mj_header endRefreshing];
             if (num == self.dataArr.count || num == 0) {
                 [self.tableView.mj_footer endRefreshingWithNoMoreData];
-            }else{
+            } else {
                 [self.tableView.mj_footer endRefreshing];
             }
-            
+
         } else {
             [MBProgressHUD showInfo:@"请求失败!"];
         }
-    } enError:^(NSError *error) {
+    }                                 enError:^(NSError *error) {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
     }];
 }
 
 //
 - (void)creatSubViews {
-    
-    NSArray *stateArr = @[@"all",@"1",@"2",@"3"];
-    
+
+    NSArray *stateArr = @[@"all", @"1", @"2", @"3"];
+
     ModelTitleView *titlesView = [[ModelTitleView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
     titlesView.titleArr = @[@"全部", @"待接单", @"进行中", @"已完成"];
-    __weak typeof (self) weakself = self;
+    __weak typeof(self) weakself = self;
     titlesView.ModelTitleViewBlock = ^(NSInteger tag) {
         NSLog(@"tag %ld", tag);
         weakself.selectIndex = tag;
-        
-        if (self.dataArr.count>0) {
+
+        if (self.dataArr.count > 0) {
             NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
             [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
         }
-        
+
         selectState = stateArr[tag];
         index = 1;
         [self getDataFromNetworking:selectState];
     };
     [self.view addSubview:titlesView];
-    
+
     //
     float height = Height_NaviBar;
-    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(titlesView.frame), ScreenWidth, ScreenHeight-40-height) style:UITableViewStyleGrouped];
+    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(titlesView.frame), ScreenWidth, ScreenHeight - 40 - height) style:UITableViewStyleGrouped];
     self.tableView.backgroundColor = [UIColor whiteColor];
     self.tableView.delegate = self;
     self.tableView.dataSource = self;
     self.tableView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
     self.tableView.showsVerticalScrollIndicator = NO;
     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
-    
+
     self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshList)];
     self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
     [self.view addSubview:self.tableView];
 }
 
--(void)refreshList{
-    
+- (void)refreshList {
+
     index = 1;
     [self getDataFromNetworking:selectState];
 }
 
-- (void)loadMoreData{
-    
+- (void)loadMoreData {
+
     index++;
     [self getDataFromNetworking:selectState];
 }
 
 #pragma mark -- UITableViewDelegate, UITableViewDataSource
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
-{    
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
     return self.dataArr.count;
 }
 
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
-{
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
     return 1;
 }
 
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-    
+
     static NSString *cellid = @"cellid";
     SkillsOrderCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid];
     if (!cell) {
@@ -183,27 +182,27 @@
     cell.arrowView.hidden = YES;
 
     [cell setSkillsOrderCellValueWithDic:self.dataArr[indexPath.section]];
-    
+
     cell.cancelBtn.tag = indexPath.section;
     cell.receiveBtn.tag = indexPath.section;
     cell.completeBtn.tag = indexPath.section;
-    
+
     cell.iconImageView.tag = indexPath.section;
     UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toMessageView:)];
     [cell.iconImageView addGestureRecognizer:tap];
     cell.iconImageView.userInteractionEnabled = YES;
-    
+
     [cell.cancelBtn addTarget:self action:@selector(cancel:) forControlEvents:UIControlEventTouchUpInside];
     [cell.receiveBtn addTarget:self action:@selector(receive:) forControlEvents:UIControlEventTouchUpInside];
     [cell.completeBtn addTarget:self action:@selector(complete:) forControlEvents:UIControlEventTouchUpInside];
-    
+
     return cell;
 }
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-    
+
     NSDictionary *dic = self.dataArr[indexPath.section];
-    OrderDetailViewController *vc = [[OrderDetailViewController alloc]initWithOrderpk:dic[@"pk"]];
+    OrderDetailViewController *vc = [[OrderDetailViewController alloc] initWithOrderpk:dic[@"pk"]];
     [self.navigationController pushViewController:vc animated:YES];
 }
 
@@ -235,103 +234,112 @@
     }
 }
 
--(void)cancel:(UIButton *)button{
-    
+- (void)cancel:(UIButton *)button {
+
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
-    
+
     NSDictionary *orderDic = self.dataArr[button.tag];
-    
-    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].modelpk,@"modelpk",[orderDic objectForKey:@"pk"],@"orderpk", nil];
-    
+
+    NSDictionary *dic = @{@"modelpk": [ModelUser user].modelpk, @"orderpk": orderDic[@"pk"]};
+
     [YanCNetWorkManager requestPostWithURLStr:Url_cancelordermodel(PublicUrl) parameters:dic finish:^(id dataDic) {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
-        
+
         NSString *issuccess = dataDic[@"msg"];
         if ([issuccess isEqualToString:@"success"]) {
-            
+
             [MBProgressHUD showInfo:@"已取消"];
             [self refreshList];
-            [self postNotification:[orderDic objectForKey:@"memberpk"] andMsg:@"提示,模特取消了您的订单"];
+            [self postNotification:orderDic[@"memberpk"] andMsg:@"提示,模特取消了您的订单" orderPK:orderDic[@"pk"]];
         } else {
             [MBProgressHUD showInfo:dataDic[@"desc"]];
         }
-    } enError:^(NSError *error) {
+    }                                 enError:^(NSError *error) {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
     }];
 }
 
--(void)receive:(UIButton *)button{
-    
+- (void)receive:(UIButton *)button {
+
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
-    
+
     NSDictionary *orderDic = self.dataArr[button.tag];
-    
-    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].modelpk,@"modelpk",[orderDic objectForKey:@"pk"],@"orderpk", nil];
-    
+
+    NSDictionary *dic = @{@"modelpk": [ModelUser user].modelpk, @"orderpk": orderDic[@"pk"]};
+
     [YanCNetWorkManager requestPostWithURLStr:Url_confirmordermodel(PublicUrl) parameters:dic finish:^(id dataDic) {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
-        
+
         NSString *issuccess = dataDic[@"msg"];
         if ([issuccess isEqualToString:@"success"]) {
-            
+
             [MBProgressHUD showInfo:@"接单成功"];
             [self refreshList];
-            [self postNotification:[orderDic objectForKey:@"memberpk"] andMsg:@"恭喜,模特已经接单啦!"];
+            [self postNotification:orderDic[@"memberpk"] andMsg:@"恭喜,模特已经接单啦!" orderPK:orderDic[@"pk"]];
         } else {
             [MBProgressHUD showInfo:dataDic[@"desc"]];
         }
-    } enError:^(NSError *error) {
+    }                                 enError:^(NSError *error) {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
     }];
 }
 
--(void)complete:(UIButton *)button{
-    
+- (void)complete:(UIButton *)button {
+
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
-    
+
     NSDictionary *orderDic = self.dataArr[button.tag];
-    
-    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[orderDic objectForKey:@"pk"],@"orderpk", nil];
-    
+
+    NSDictionary *dic = @{@"orderpk": orderDic[@"pk"]};
+
     [YanCNetWorkManager requestPostWithURLStr:Url_dosettlementorder(PublicUrl) parameters:dic finish:^(id dataDic) {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
-        
+
         NSString *issuccess = dataDic[@"msg"];
         if ([issuccess isEqualToString:@"success"]) {
-            
+
             [MBProgressHUD showInfo:@"已确认完成"];
             [self refreshList];
-            [self postNotification:[orderDic objectForKey:@"memberpk"] andMsg:@"模特已经确认完成订单了"];
+            [self postNotification:orderDic[@"memberpk"] andMsg:@"模特已经确认完成订单了" orderPK:orderDic[@"pk"]];
         } else {
             [MBProgressHUD showInfo:dataDic[@"desc"]];
         }
-    } enError:^(NSError *error) {
+    }                                 enError:^(NSError *error) {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
     }];
 }
 
--(void)postNotification:(NSString *)memberpk andMsg:(NSString *)msg{
-    
-    NSString *str = [NSString stringWithFormat:@"%@/netease?action=sendAttachMsg&from=%@&to=%@&pushcontent=%@",PublicUrl,[ModelUser modelUser].pk,memberpk,msg];
-    [[AHHttpManager sharedManager]POST:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(id responseObject) {
-        NSLog(@"%@",responseObject);
-        if ([[responseObject objectForKey:@"msg"]isEqualToString:@"200"]) {
-            
-        }else{
-            
-        }
-    } failure:^(NSError *error) {
-        NSLog(@"error = %@",error);
-    }];
+- (void)postNotification:(NSString *)memberpk andMsg:(NSString *)msg orderPK:(NSString *)orderPK {
+    NSDictionary *dict = @{
+            @"content": msg,
+            @"orderPK": orderPK
+    };
+    NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
+    NSString *content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+    NSString *str = [NSString stringWithFormat:@"%@/netease?action=sendAttachMsg&from=%@&to=%@&pushcontent=%@&attach=%@", PublicUrl, [ModelUser modelUser].pk, memberpk, msg, content];
+    [[AHHttpManager sharedManager]
+            POST:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
+      parameters:nil
+         success:^(id responseObject) {
+             NSLog(@"%@", responseObject);
+             if ([[responseObject objectForKey:@"msg"] isEqualToString:@"200"]) {
+
+             } else {
+
+             }
+         }
+         failure:^(NSError *error) {
+             NSLog(@"error = %@", error);
+         }];
 }
 
-- (void)toMessageView:(UIGestureRecognizer *)recognizer{
-    
-    UIImageView *img = (UIImageView *)recognizer.view;
+- (void)toMessageView:(UIGestureRecognizer *)recognizer {
+
+    UIImageView *img = (UIImageView *) recognizer.view;
     NSDictionary *orderDic = self.dataArr[img.tag];
-    
-    NIMSession *session  = [NIMSession session:[orderDic objectForKey:@"memberpk"] type:NIMSessionTypeP2P];
-    MessageViewController *mVc = [[MessageViewController alloc]initWithSession:session];
+
+    NIMSession *session = [NIMSession session:[orderDic objectForKey:@"memberpk"] type:NIMSessionTypeP2P];
+    MessageViewController *mVc = [[MessageViewController alloc] initWithSession:session];
     [self.navigationController pushViewController:mVc animated:YES];
 }
 

+ 33 - 22
model/Classes/Controllers/Controller/MyProfileVC/ModelCardController.m

@@ -149,7 +149,13 @@
 }
 
 - (void)backClick {
-    [self.navigationController popViewControllerAnimated:YES];
+    if ([@"init" isEqualToString:self.type]) {
+        if ([self checkInfo]) {
+            [self.navigationController popViewControllerAnimated:YES];
+        }
+    } else {
+        [self.navigationController popViewControllerAnimated:YES];
+    }
 }
 
 #pragma mark -- UITableViewDelegate, UITableViewDataSource
@@ -350,65 +356,70 @@
 
 #pragma mark -- 保存按钮
 
-- (void)bindingBtnAction {
+- (BOOL)checkInfo {
     if ([tempUser.photocount intValue] < 5) {
         [self.view makeToast:@"请至少上传5张照片" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.pet.length == 0) {
         [self.view makeToast:@"请填写姓名" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.lname.length == 0) {
         [self.view makeToast:@"请填写个性签名" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.vprice.length == 0) {
         [self.view makeToast:@"请填写视频单价" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.hei.length == 0 || [@"0" isEqualToString:tempUser.hei]) {
         [self.view makeToast:@"请填写身高" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.wei.length == 0 || [@"0" isEqualToString:tempUser.wei]) {
         [self.view makeToast:@"请填写体重" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.bust.length == 0) {
         [self.view makeToast:@"请填写三围" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.area.length == 0) {
         [self.view makeToast:@"请填写地区" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.age.length == 0) {
         [self.view makeToast:@"请填写年龄" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.occupation.length == 0) {
         [self.view makeToast:@"请填写职业" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.constellation.length == 0) {
         [self.view makeToast:@"请填写星座" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
     if (tempUser.college.length == 0) {
         [self.view makeToast:@"请填写毕业院校" duration:2.0 position:CSToastPositionCenter];
-        return;
+        return NO;
     }
-    // [MBProgressHUD showSuccess:@"保存成功"];
-    // [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(backClick) userInfo:nil repeats:NO];
+    return YES;
+}
 
-    if ([@"init" isEqualToString:self.type]) {
-        MySkillsController *mySkillsVC = [[MySkillsController alloc] init];
-        [self.navigationController pushViewController:mySkillsVC animated:YES];
-    } else {
-        ShareCardController *shareCardVC = [[ShareCardController alloc] init];
-        [self.navigationController pushViewController:shareCardVC animated:YES];
+- (void)bindingBtnAction {
+    if ([self checkInfo]) {
+        if ([@"init" isEqualToString:self.type]) {
+            MySkillsController *mySkillsVC = [[MySkillsController alloc] init];
+            [self.navigationController pushViewController:mySkillsVC animated:YES];
+        } else {
+            ShareCardController *shareCardVC = [[ShareCardController alloc] init];
+            [self.navigationController pushViewController:shareCardVC animated:YES];
+        }
     }
+    // [MBProgressHUD showSuccess:@"保存成功"];
+    // [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(backClick) userInfo:nil repeats:NO];
 }
 
 #pragma mark -- 网络请求

+ 2 - 2
model/Classes/Controllers/Controller/ShareVC/ShareViewController.m

@@ -127,12 +127,12 @@
 
 - (void)shareWxSession {
     NSString *description = self.type == 1 ? @"找模特、艺人做商演;找空姐、校花做朋友。" : @"更多商演订单,视频面试可收取佣金,小姐妹们快来注册。";
-    [self shareToWechat:WXSceneSession withTitle:@"千模" description:description url:shareUrl(@(self.type), [[NSUserDefaults standardUserDefaults] objectForKey:@"qrcode"])];
+    [self shareToWechat:WXSceneSession withTitle:self.type == 1 ? @"千模通告" : @"千模模特版" description:description url:shareUrl(@(self.type), [[NSUserDefaults standardUserDefaults] objectForKey:@"qrcode"])];
 }
 
 - (void)shareWxTimeline {
     NSString *description = self.type == 1 ? @"找模特、艺人做商演;找空姐、校花做朋友。" : @"更多商演订单,视频面试可收取佣金,小姐妹们快来注册。";
-    [self shareToWechat:WXSceneTimeline withTitle:@"千模" description:description url:shareUrl(@(self.type), [[NSUserDefaults standardUserDefaults] objectForKey:@"qrcode"])];
+    [self shareToWechat:WXSceneTimeline withTitle:self.type == 1 ? @"千模通告" : @"千模模特版" description:description url:shareUrl(@(self.type), [[NSUserDefaults standardUserDefaults] objectForKey:@"qrcode"])];
 }
 
 - (void)shareToWechat:(enum WXScene)scene withTitle:(NSString *)title description:(NSString *)description url:(NSString *)url {

+ 98 - 104
model/Classes/Public/LoginViewController.m

@@ -12,25 +12,26 @@
 #import "ModelRootViewController.h"
 #import "ForgetViewController.h"
 #import "AppDelegate.h"
-@interface LoginViewController ()<UITextFieldDelegate>
-@property (strong, nonatomic) IBOutlet UITextField *usernameTextField;
-@property (strong, nonatomic) IBOutlet UITextField *passwordTextField;
-@property (weak, nonatomic) IBOutlet UIImageView *loginBtn;
-@property (weak, nonatomic) IBOutlet UILabel *wxLoginLabel;
-@property (weak, nonatomic) IBOutlet UILabel *forgetLabel;
-@property (weak, nonatomic) IBOutlet UIButton *wxLoginBtn;
-@property (weak, nonatomic) IBOutlet UILabel *toRegister;
-@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottom;
+
+@interface LoginViewController () <UITextFieldDelegate>
+@property(strong, nonatomic) IBOutlet UITextField *usernameTextField;
+@property(strong, nonatomic) IBOutlet UITextField *passwordTextField;
+@property(weak, nonatomic) IBOutlet UIImageView *loginBtn;
+@property(weak, nonatomic) IBOutlet UILabel *wxLoginLabel;
+@property(weak, nonatomic) IBOutlet UILabel *forgetLabel;
+@property(weak, nonatomic) IBOutlet UIButton *wxLoginBtn;
+@property(weak, nonatomic) IBOutlet UILabel *toRegister;
+@property(weak, nonatomic) IBOutlet NSLayoutConstraint *bottom;
 
 @end
 
 @implementation LoginViewController
-- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
+- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     if (self) {
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:nil];
-        
+
     }
     return self;
 }
@@ -41,116 +42,110 @@
 
     //检查网络情况
     [self checkNetwork];
-    
+
     _loginBtn.userInteractionEnabled = YES;
     UITapGestureRecognizer *loginTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doLogin)];;
     [_loginBtn addGestureRecognizer:loginTap];
     _toRegister.userInteractionEnabled = YES;
-    UITapGestureRecognizer *toRegister = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(toRegisterVc:)];
+    UITapGestureRecognizer *toRegister = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toRegisterVc:)];
     [_toRegister addGestureRecognizer:toRegister];
     _wxLoginLabel.userInteractionEnabled = YES;
-    UITapGestureRecognizer *wxLogin = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(towxLogin:)];
+    UITapGestureRecognizer *wxLogin = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(towxLogin:)];
     [_wxLoginLabel addGestureRecognizer:wxLogin];
     [_wxLoginBtn addTarget:self action:@selector(towxLogin:) forControlEvents:UIControlEventTouchUpInside];
-    UITapGestureRecognizer *forget = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(toForget:)];
+    UITapGestureRecognizer *forget = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toForget:)];
     [_forgetLabel addGestureRecognizer:forget];
     _forgetLabel.userInteractionEnabled = YES;
 }
 
 //检查网络情况
-- (void)checkNetwork
-{
+- (void)checkNetwork {
     // 如果要检测网络状态的变化,必须用检测管理器的单例的startMonitoring
     [[AFNetworkReachabilityManager sharedManager] startMonitoring];
-    __block   BOOL network =  network ;  //
-    __block   BOOL change =  change ;  //
+    __block BOOL network = network;  //
+    __block BOOL change = change;  //
     change = NO;
     network = NO;
-    
+
     // 检测网络连接的单例,网络变化时的回调方法
-    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status)
-     {
-         switch (status) {
-             case AFNetworkReachabilityStatusNotReachable:
-             {
-                 NSLog(@"无网络");
-                 network = NO;
-                 change = YES;
-                 [self initAlertView];
-                 break;
-             }
-                 
-             case AFNetworkReachabilityStatusReachableViaWiFi:
-             {
-                 NSLog(@"WiFi网络");
-                 network = YES;
-                 change = YES;
-                 break;
-             }
-                 
-             case AFNetworkReachabilityStatusReachableViaWWAN:
-             {
-                 NSLog(@"无线网络");
-                 network = YES;
-                 change = YES;
-                 break;
-             }
-                 
-             default:
-                 break;
-         }
-     }];
+    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
+        switch (status) {
+            case AFNetworkReachabilityStatusNotReachable: {
+                NSLog(@"无网络");
+                network = NO;
+                change = YES;
+                [self initAlertView];
+                break;
+            }
+
+            case AFNetworkReachabilityStatusReachableViaWiFi: {
+                NSLog(@"WiFi网络");
+                network = YES;
+                change = YES;
+                break;
+            }
+
+            case AFNetworkReachabilityStatusReachableViaWWAN: {
+                NSLog(@"无线网络");
+                network = YES;
+                change = YES;
+                break;
+            }
+
+            default:
+                break;
+        }
+    }];
 }
 
--(void)initAlertView{
-    
-    NSString * info;
-    info = @"    网络异常!                        网络不给力,请检查网络";
-    
+- (void)initAlertView {
+
+    NSString *info;
+    info = @"网络异常!\n网络不给力,请检查网络";
+
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:info preferredStyle:UIAlertControllerStyleAlert];
     NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:info];
-    int num = (int)hogan.length;
+    int num = (int) hogan.length;
     [hogan addAttribute:NSFontAttributeName
                   value:[UIFont systemFontOfSize:16.0]
-                  range:NSMakeRange(num-11, 11)];
-    
+                  range:NSMakeRange(num - 11, 11)];
+
     [hogan addAttribute:NSFontAttributeName
                   value:[UIFont systemFontOfSize:18.0]
-                  range:NSMakeRange(0, num-11)];
-    
+                  range:NSMakeRange(0, num - 11)];
+
     [alertController setValue:hogan forKey:@"attributedMessage"];
-    UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"重试" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
-                                    {
-                                        [self checkNetwork];
-                                    }];
+    UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"重试" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+        [self checkNetwork];
+    }];
     [alertController addAction:confirmAction];
-    [self presentViewController:alertController animated:YES completion:^{ }];
+    [self presentViewController:alertController animated:YES completion:^{
+    }];
 }
 
-- (void)toForget:(UITapGestureRecognizer*)recognizer
-{
-    AppDelegate *delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
-    ForgetViewController *rVc = [[ForgetViewController alloc]init];
-    RootNavigaViewController * nvc = [[RootNavigaViewController alloc]initWithRootViewController:rVc];
+- (void)toForget:(UITapGestureRecognizer *)recognizer {
+    AppDelegate *delegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
+    ForgetViewController *rVc = [[ForgetViewController alloc] init];
+    RootNavigaViewController *nvc = [[RootNavigaViewController alloc] initWithRootViewController:rVc];
     delegate.window.rootViewController = nvc;
 }
 
 - (void)doLogin {
-    
+
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
-    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:self.usernameTextField.text,@"mobile",self.passwordTextField.text,@"pass", nil];
+    NSDictionary *dic = @{@"mobile": self.usernameTextField.text, @"pass": self.passwordTextField.text};
     [YanCNetWorkManager requestPostWithURLStr:Url_doLogin(PublicUrl) parameters:dic finish:^(id dataDic) {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
-        
+
         NSString *issuccess = dataDic[@"msg"];
         if ([issuccess isEqualToString:@"success"]) {
 
             [[[NIMSDK sharedSDK] loginManager] login:dataDic[@"data"][@"pk"]
                                                token:dataDic[@"data"][@"token"]
                                           completion:^(NSError *error) {
-                                              if (error==nil) {
+                                              if (error == nil) {
                                                   NSString *token = dataDic[@"data"][@"token"];
-                                                  
+
                                                   NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
                                                   [userDefaults setObject:self.usernameTextField.text forKey:@"account"];
                                                   [userDefaults setObject:self.passwordTextField.text forKey:@"pwd"];
@@ -158,7 +153,7 @@
                                                   [userDefaults setObject:token forKey:@"token"];
                                                   [userDefaults setObject:dataDic[@"data"][@"qrcode"] forKey:@"qrcode"];
                                                   [userDefaults synchronize];
-                                                  
+
                                                   ModelUser *user = [ModelUser modelUser];
                                                   [user setValuesForKeysWithDictionary:dataDic[@"data"]];
                                                   user.modelpk = dataDic[@"data"][@"modelpk"];
@@ -166,10 +161,10 @@
                                                   user.coin_ir = dataDic[@"data"][@"coin_ir"];
                                                   user.pk = dataDic[@"data"][@"pk"];
                                                   user.token = token;
-                                                  NSLog(@"----%@",user.pet);
+                                                  NSLog(@"----%@", user.pet);
                                                   [ModelUser save:user];
-                                                  AppDelegate *delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
-                                                  delegate.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
+                                                  AppDelegate *delegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
+                                                  delegate.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
                                                   //    创建并初始化UITabBarController
                                                   ModelRootViewController *mineVc = [[ModelRootViewController alloc] init];
                                                   delegate.window.rootViewController = mineVc;
@@ -177,14 +172,14 @@
                                                   [delegate.window makeKeyAndVisible];
                                               }
                                           }
-             ];
-        } else if ([dataDic[@"msg"] isEqualToString:@"fail"]){
+            ];
+        } else if ([dataDic[@"msg"] isEqualToString:@"fail"]) {
             NSString *str = dataDic[@"desc"];
             [MBProgressHUD showTextHUD:str inView:self.view hideAfterDelay:1];
-        }else{
+        } else {
             [MBProgressHUD showTextHUD:@"登陆失败" inView:self.view hideAfterDelay:1];
         }
-    } enError:^(NSError *error) {
+    }                                 enError:^(NSError *error) {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
     }];
 }
@@ -195,9 +190,9 @@
     self.usernameTextField.keyboardType = UIKeyboardTypeNumberPad;
     self.passwordTextField.delegate = self;
     self.usernameTextField.delegate = self;
-    if (self.registerPwd.length!=0&&self.registerAccount.length!=0) {
-        self.passwordTextField.text = [NSString stringWithFormat:@"%@",self.registerPwd];
-        self.usernameTextField.text = [NSString stringWithFormat:@"%@",self.registerAccount];
+    if (self.registerPwd.length != 0 && self.registerAccount.length != 0) {
+        self.passwordTextField.text = [NSString stringWithFormat:@"%@", self.registerPwd];
+        self.usernameTextField.text = [NSString stringWithFormat:@"%@", self.registerAccount];
     }
     [self.navigationController setNavigationBarHidden:YES animated:YES];
 }
@@ -209,23 +204,22 @@
     }
 }
 
-- (void)toRegisterVc:(UITapGestureRecognizer*)recognizer
-{
-    AppDelegate *delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
-    RegisterViewController *rVc = [[RegisterViewController alloc]init];
-    RootNavigaViewController * nvc = [[RootNavigaViewController alloc]initWithRootViewController:rVc];
+- (void)toRegisterVc:(UITapGestureRecognizer *)recognizer {
+    AppDelegate *delegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
+    RegisterViewController *rVc = [[RegisterViewController alloc] init];
+    RootNavigaViewController *nvc = [[RootNavigaViewController alloc] initWithRootViewController:rVc];
     delegate.window.rootViewController = nvc;
 }
 
-- (void)towxLogin:(UITapGestureRecognizer*)recognizer
-{
+- (void)towxLogin:(UITapGestureRecognizer *)recognizer {
     NSLog(@"wx");
 }
 
 #pragma mark - Notification
-- (void)keyboardWillShow:(NSNotification*)notification{
-    
-    NSDictionary* userInfo = [notification userInfo];
+
+- (void)keyboardWillShow:(NSNotification *)notification {
+
+    NSDictionary *userInfo = [notification userInfo];
     NSTimeInterval animationDuration;
     UIViewAnimationCurve animationCurve;
     CGRect keyboardFrame;
@@ -239,11 +233,12 @@
 }
 
 #pragma mark - UITextFieldDelegate
-- (void)textFieldDidChange:(NSNotification*)notification{
+
+- (void)textFieldDidChange:(NSNotification *)notification {
 
 }
 
-- (void)textFieldDidBeginEditing:(UITextField *)textField{
+- (void)textFieldDidBeginEditing:(UITextField *)textField {
 
     NSTimeInterval animationDuration = 0.30f;
     [UIView beginAnimations:@ "ResizeForKeyboard" context:nil];
@@ -251,15 +246,14 @@
     //将视图的Y坐标向上移动,以使下面腾出地方用于软键盘的显示
     if (textField == self.passwordTextField) {
         self.view.frame = CGRectMake(0.0f, -140.0f/*屏幕上移的高度,可以自己定*/, self.view.frame.size.width, self.view.frame.size.height);
-    }else{
+    } else {
         self.view.frame = CGRectMake(0.0f, -100.0f/*屏幕上移的高度,可以自己定*/, self.view.frame.size.width, self.view.frame.size.height);
     }
-    
+
     [UIView commitAnimations];
 }
 
-- (void)textFieldDidEndEditing:(UITextField *)textField
-{
+- (void)textFieldDidEndEditing:(UITextField *)textField {
     //滑动效果
     NSTimeInterval animationDuration = 0.30f;
     [UIView beginAnimations:@ "ResizeForKeyboard" context:nil];

+ 14 - 9
model/Classes/Public/RegisterViewController.m

@@ -10,6 +10,7 @@
 #import "LoginViewController.h"
 #import "AgreementViewController.h"
 #import "privateViewController.h"
+#import "AppDelegate.h"
 
 #define SET_WIFI_TIMES 60
 
@@ -46,7 +47,6 @@
     [super viewDidLoad];
 
     if ([UIScreen spt_currentScreenMode] == LESScreenModeIPhoneX) {
-
         self.tableHeight.constant = 400;
     }
     UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
@@ -207,6 +207,8 @@
         if ([issuccess isEqualToString:@"success"]) {
 
             [MBProgressHUD showInfo:@"注册成功"];
+            AppDelegate *app = [[UIApplication sharedApplication] delegate];
+            app.firstLogin = YES;
             [self successBack];
 
         } else if ([dataDic[@"msg"] isEqualToString:@"fail"]) {
@@ -254,13 +256,16 @@
 
     AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
     manager.responseSerializer = [AFHTTPResponseSerializer serializer];
-    [manager GET:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
-        NSString *result = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
-        isRight = [result containsString:@"-"];
-        NSLog(@"%@", result);
-    }    failure:^(NSURLSessionDataTask *task, NSError *error) {
-        NSLog(@"%@", error);
-    }];
+    [manager GET:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
+      parameters:nil
+         success:^(NSURLSessionDataTask *task, id responseObject) {
+             NSString *result = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
+             isRight = [result containsString:@"-"];
+             NSLog(@"%@", result);
+         }
+         failure:^(NSURLSessionDataTask *task, NSError *error) {
+             NSLog(@"%@", error);
+         }];
 }
 
 #pragma mark tableViewDelegate
@@ -323,7 +328,7 @@
             input.tag = 102;
             input.keyboardType = UIKeyboardTypeNumberPad;
             cell.textLabel.text = @"邀请码";
-            [input setPlaceholder:@"请输入邀请码"];
+            [input setPlaceholder:@"请输入邀请码(非必填)"];
             break;
         case 2:
             input.tag = 103;

+ 30 - 183
model/Classes/Tools/Category/Helper.m

@@ -9,216 +9,63 @@
 #import "Helper.h"
 
 @implementation Helper
-+(Helper*)sharedAccount
-{
++ (Helper *)sharedAccount {
     static Helper *sharedAccount = nil;
     @synchronized (self) {
         if (!sharedAccount) {
-            sharedAccount = [[Helper alloc]init];
+            sharedAccount = [[Helper alloc] init];
         }
         return sharedAccount;
-        
+
     }
 }
 
-+(NSString*)getCurrentTimes{
-    
++ (NSString *)getCurrentTimes {
+
     NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
-    
+
     // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
-    
+
     [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
-    
+
     //现在时间,你可以输出来看下是什么格式
-    
+
     NSDate *datenow = [NSDate date];
-    
+
     //----------将nsdate按formatter格式转成nsstring
-    
+
     NSString *currentTimeString = [formatter stringFromDate:datenow];
-    
-    NSLog(@"currentTimeString =  %@",currentTimeString);
-    
+
+    NSLog(@"currentTimeString =  %@", currentTimeString);
+
     return currentTimeString;
-    
+
 }
 
-+(NSString*)getLastTimes{
-    
++ (NSString *)getLastTimes {
+
     NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
-    
+
     // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
-    
+
     [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
-    
+
     //现在时间,你可以输出来看下是什么格式
-    
+
     NSDate *date = [NSDate date];
-    NSDate *lastDay = [NSDate dateWithTimeInterval:-24*60*60 sinceDate:date];
-    
+    NSDate *lastDay = [NSDate dateWithTimeInterval:-24 * 60 * 60 sinceDate:date];
+
     //----------将nsdate按formatter格式转成nsstring
-    
+
     NSString *lastTimeString = [formatter stringFromDate:lastDay];
-    
-    NSLog(@"lastTimeString =  %@",lastTimeString);
-    
+
+    NSLog(@"lastTimeString =  %@", lastTimeString);
+
     return lastTimeString;
-    
+
 }
 
-+ (BOOL)valiMobile:(NSString *)mobile{
-    
-    if (mobile.length != 11)
-        
-    {
-        
-        return NO;
-        
-    }
-    
-    /**
-     
-     * 手机号码:
-     
-     * 13[0-9], 14[5,7], 15[0, 1, 2, 3, 5, 6, 7, 8, 9], 17[0, 1, 6, 7, 8], 18[0-9]
-     
-     * 移动号段: 134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188
-     
-     * 联通号段: 130,131,132,145,155,156,170,171,175,176,185,186
-     
-     * 电信号段: 133,149,153,170,173,177,180,181,189
-     
-     */
-    
-    NSString *MOBILE = @"^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\\d{8}$";
-    
-    /**
-     
-     * 中国移动:China Mobile
-     
-     * 134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188
-     
-     */
-    
-    NSString *CM = @"^1(3[4-9]|4[7]|5[0-27-9]|7[08]|8[2-478])\\d{8}$";
-    
-    /**
-     
-     * 中国联通:China Unicom
-     
-     * 130,131,132,145,155,156,170,171,175,176,185,186
-     
-     */
-    
-    NSString *CU = @"^1(3[0-2]|4[5]|5[56]|7[0156]|8[56])\\d{8}$";
-    
-    /**
-     
-     * 中国电信:China Telecom
-     
-     * 133,149,153,170,173,177,180,181,189
-     
-     */
-    
-    NSString *CT = @"^1(3[3]|4[9]|53|7[037]|8[019])\\d{8}$";
-    
-    
-    
-    
-    
-    NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
-    
-    NSPredicate *regextestcm = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CM];
-    
-    NSPredicate *regextestcu = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CU];
-    
-    NSPredicate *regextestct = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CT];
-    
-    
-    
-    if (([regextestmobile evaluateWithObject:mobile] == YES)
-        
-        || ([regextestcm evaluateWithObject:mobile] == YES)
-        
-        || ([regextestct evaluateWithObject:mobile] == YES)
-        
-        || ([regextestcu evaluateWithObject:mobile] == YES))
-        
-    {
-        
-        return YES;
-        
-    }
-    
-    else
-        
-    {
-        
-        return NO;
-        
-    }
-    
-    //旧的正则表达式
-    
-    //    if (mobile.length < 11)
-    
-    //    {
-    
-    //        return NO;
-    
-    //    }else{
-    
-    //        /**
-    
-    //         * 移动号段正则表达式
-    
-    //         */
-    
-    //        NSString *CM_NUM = @"^((13[4-9])|(147)|(15[0-2,7-9])|(178)|(18[2-4,7-8]))\\d{8}|(1705)\\d{7}$";
-    
-    //        /**
-    
-    //         * 联通号段正则表达式
-    
-    //         */
-    
-    //        NSString *CU_NUM = @"^((13[0-2])|(145)|(15[5-6])|(176)|(18[5,6]))\\d{8}|(1709)\\d{7}$";
-    
-    //        /**
-    
-    //         * 电信号段正则表达式
-    
-    //         */
-    
-    //        NSString *CT_NUM = @"^((133)|(153)|(177)|(18[0,1,9]))\\d{8}$";
-    
-    //        NSPredicate *pred1 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CM_NUM];
-    
-    //        BOOL isMatch1 = [pred1 evaluateWithObject:mobile];
-    
-    //        NSPredicate *pred2 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CU_NUM];
-    
-    //        BOOL isMatch2 = [pred2 evaluateWithObject:mobile];
-    
-    //        NSPredicate *pred3 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CT_NUM];
-    
-    //        BOOL isMatch3 = [pred3 evaluateWithObject:mobile];
-    
-    //
-    
-    //        if (isMatch1 || isMatch2 || isMatch3) {
-    
-    //            return YES;
-    
-    //        }else{
-    
-    //            return NO;
-    
-    //        }
-    
-    //    }
-    
-    //    return YES;
-    
++ (BOOL)valiMobile:(NSString *)mobile {
+    return [[NSPredicate predicateWithFormat:@"SELF MATCHES %@", @"^1[3-9]\\d{9}$"] evaluateWithObject:mobile];
 }
 @end

+ 2 - 2
model/Info.plist

@@ -19,7 +19,7 @@
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>1.0.4</string>
+	<string>1.0.5</string>
 	<key>CFBundleURLTypes</key>
 	<array>
 		<dict>
@@ -34,7 +34,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>4</string>
+	<string>1</string>
 	<key>ITSAppUsesNonExemptEncryption</key>
 	<false/>
 	<key>LSApplicationCategoryType</key>

+ 3 - 1
model/ModelHeader.h

@@ -13,7 +13,7 @@
 ///公共url
 #define PublicUrl @"http://app.chmo.net/thmodel"
 #define imageURl @"http://app.chmo.net/thmodel/"
-#define apnsCernameStr @"modelDev"
+#define apnsCernameStr @"model"
 
 // #define PublicUrl @"http://118.190.49.85:8080/thmodel"
 // #define imageURl @"http://118.190.49.85:8080/thmodel/"
@@ -144,6 +144,8 @@
 
 #define Url_applyRecommend(x)  [NSString stringWithFormat:@"%@/modelInfo?action=applyRecommend", x]
 
+#define Url_checkUpdate(x)  [NSString stringWithFormat:@"%@/memberInfo?action=appVersion", x]
+
 #endif /* ModelHeader_h */
 
 

+ 1 - 1
model/model.entitlements

@@ -3,6 +3,6 @@
 <plist version="1.0">
 <dict>
 	<key>aps-environment</key>
-	<string>development</string>
+	<string>production</string>
 </dict>
 </plist>