當(dāng)前位置:
                    首頁 >
                            前端技术
>                            javascript
>内容正文                
                        
                    javascript
JSPatch 使用Demo
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                JSPatch 使用Demo
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個(gè)參考.                        
                                
                            
                            
                            defineClass("AllControlViewController", {
??????????? //instance method definitions
??????????? ///ROOT_URL_STR 問題? 強(qiáng)制轉(zhuǎn)換問題
??????????? ///@selector? 直接使用字符串
??????????? ///block中使用self?? var sel = self;
??????????? ///代碼中包含_的變量?? 需要用__代替
??????????? ///intValue()?? 需要用js的轉(zhuǎn)換方式?? parseInt
 
?????????? ?
??????????? 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];
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //把登錄狀態(tài)置為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());
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //判斷如果藍(lán)牙連接? 取消連接
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? if (AppDelegate.getInstance().blueManager().bleModel().bleManager().isConnected()) {
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? var p = AppDelegate.getInstance().connectedPeripheral();
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? AppDelegate.getInstance().disconnectPeripheral(p);
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? }
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //清空必要的數(shù)據(jù)
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? 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);
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? }));
?????????? ?
??????????? }
??????????? });
                        
                        
                        ??????????? //instance method definitions
??????????? ///ROOT_URL_STR 問題? 強(qiáng)制轉(zhuǎn)換問題
??????????? ///@selector? 直接使用字符串
??????????? ///block中使用self?? var sel = self;
??????????? ///代碼中包含_的變量?? 需要用__代替
??????????? ///intValue()?? 需要用js的轉(zhuǎn)換方式?? parseInt
??????????? ///變量比較????? isEqual()
?????????? ///獲取成員變量? var data = self.valueForKey("_data")
 ?????????? ///?? 基礎(chǔ)問題:https://github.com/bang590/JSPatch/wiki
 
?????????? ?
??????????? 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];
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //把登錄狀態(tài)置為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());
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //判斷如果藍(lán)牙連接? 取消連接
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? if (AppDelegate.getInstance().blueManager().bleModel().bleManager().isConnected()) {
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? var p = AppDelegate.getInstance().connectedPeripheral();
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? AppDelegate.getInstance().disconnectPeripheral(p);
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? }
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //清空必要的數(shù)據(jù)
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? 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);
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? }));
?????????? ?
??????????? }
??????????? });
總結(jié)
以上是生活随笔為你收集整理的JSPatch 使用Demo的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: cad通过钢筋大样生成钢筋明细表插件_R
 - 下一篇: 儿童编程软件python征服_少儿编程P