JSPatch 使用Demo

defineClass("AllControlViewController", {
            //instance method definitions
            ///ROOT_URL_STR 问题  强制转换问题
            ///@selector  直接使用字符串
            ///block中使用self   var sel = self;
            ///代码中包含_的变量   需要用__代替
            ///intValue()   需要用js的转换方式   parseInt

            ///变量比较      isEqual()

           ///获取成员变量  var data = self.valueForKey("_data")
           ///   基础问题:https://github.com/bang590/JSPatch/wiki

            logoutThroughServer: function() {
            
            Unity.addLoadingView_andLoadingTitle(self.view(), "正在哈哈,请稍候...");
            var manager = AFHTTPRequestOperationManager.manager();
            var sel = self;
            manager.POST_parameters_success_failure(NSString.stringWithFormat("%@/User/Logout", "http://xxxxxxxx"), {}, block('AFHTTPRequestOperation*,id', function(operation, responseObject) {
                                                                                                                                         
                                                                                                                                         Unity.removeLoadingView(sel.view());
                                                                                                                                         
                                                                                                                                         if (parseInt(responseObject.objectForKey("status")) == 0) {
                                                                                        {
                                                                                                                                         //退出登录需要重新获取clientid
                                                                                                                                         //                [GeTuiSdk enterBackground];
                                                                                                                                         
                                                                                                                                         //把登录状态置为0
                                                                                                                                         NSUserDefaults.standardUserDefaults().setValue_forKey("0", NSString.stringWithFormat("%@%", "APP_LOGIN_SUCESS_SVAE_MSG", Unity.getCurrentVersion()));
                                                                                                                                         NSUserDefaults.standardUserDefaults().setValue_forKey("0", "APP_LOGIN_USER_CURRENT_LOGIN_ID");
                                                                                                                                         
                                                                                                                                         //                [APP_USERDEFAULTS setValue:"0" forKey:[NSString stringWithFormat:"%@%", [AppDelegate getInstance].currentLoginID(), USER_SET_NOTIFY_ON_OFF]];
                                                                                                                                         
                                                                                                                                         UIApplication.sharedApplication().cancelAllLocalNotifications();
                                                                                                                                         
                                                                                                                                         NSNotificationCenter.defaultCenter().removeObserver_name_object(sel, "REFRESH_HOME_SCROLLVIEW", null);
                                                                                                                                         
                                                                                                                                         NSNotificationCenter.defaultCenter().removeObserver(AppDelegate.getInstance().allControlViewController());
                                                                                                                                         
                                                                                                                                         //判断如果蓝牙连接  取消连接
                                                                                                                                         if (AppDelegate.getInstance().blueManager().bleModel().bleManager().isConnected()) {
                                                                                                                                         
                                                                                                                                         var p = AppDelegate.getInstance().connectedPeripheral();
                                                                                                                                         
                                                                                                                                         AppDelegate.getInstance().disconnectPeripheral(p);
                                                                                                                                         }
                                                                                                                                         
                                                                                                                                         //清空必要的数据
                                                                                                                                         AppDelegate.getInstance().selectedUserIdArr().removeAllObjects();
                                                                                                                                         
                                                                                                                                         var rootNav =  AppDelegate.getInstance().window().rootViewController();
                                                                                                                                         
                                                                                                                                         if (rootNav.viewControllers().firstObject().isEqual(sel)) {
                                                                                                                                         
                                                                                                                                         var lvc = LoginViewController.alloc().init();
                                                                                                                                         
                                                                                                                                         var rootNav = UINavigationController.alloc().initWithRootViewController(lvc);
                                                                                                                                         
                                                                                                                                         AppDelegate.getInstance().window().setRootViewController(rootNav);
                                                                                                                                         
                                                                                                                                         rootNav.setNavigationBarHidden(true);
                                                                                                                                         
                                                                                                                                         return;
                                                                                                                                         }
                                                                                                                                         
                                                                                                                                         //退出到登录界面
                                                                                                                                         sel.navigationController().popToRootViewControllerAnimated(YES);
                                                                                                                                         }
                                                                                                                                         
                                                                                                                                         } else if (parseInt(responseObject.objectForKey("status")) == 3) {
                                                
                                                                                                                                         NSNotificationCenter.defaultCenter().addObserver_selector_name_object(sel, "logoutThroughServer", "RE_LOGIN_NOTIFY_NAME", null);
                                                                                                                                         
                                                                                                                                         Unity.reLoginTheApp(sel);
                                                                                                                                         } else {
                                                
                                                                                                                                         Unity.showSystemAlertWithMessage_andViewController(responseObject.objectForKey("error_message"), null);
                                                                                                                                         }
                                                                                                                                         }), block('AFHTTPRequestOperation*,NSError*', function(operation, error) {
                                                                                                                                                   
                                                                                                                                                   Unity.removeLoadingView(sel.view());
                                                                                                                                                   
                                                                                                                                                   Unity.showTheErrorWhenNetworkConnetFailed(sel);
                                                                                                                                                   }));
            
            }
            });
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值