// // AppDelegate.swift // CommonFrame // // Created by Virgil on 2016/10/11. // Copyright © 2016年 Virgil. All rights reserved. // import UIKit var navheight = CGFloat(0) @UIApplicationMain @objcMembers class AppDelegate: UIResponder, UIApplicationDelegate, JPUSHRegisterDelegate, WXApiDelegate, UITabBarControllerDelegate { //,WXApiDelegate var window: UIWindow? let openMerchants = OpeningMerchantsQybRequestEntity() let arrIcon = ["ion_tab_01", "ion_tab_02", "ion_tab_wallet", "ion_tab_04"] /// 融云appKey var rongYunAppkey = ""; //n19jmcy5n1da9// //微信appKey let wxAppKey = "wxa6b6403ce27573d1" /// 友盟appKey var umAppKey = "5cb15084570df3a22f001381"; //595d8990734be40a6500069a ///极光appkey var jpushAppKey = "9f1d705c47d3893d5e31aae4" //3b57540b3c44cdb07944f876 var dicDefault = NSMutableDictionary() var mainTabbar: CustomTabBarController! var navController: MainNavigationController! func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { //H5Manager.checkIsUse(); if CommonValue.getDefaultUserInfoForString(key: "common_default_is_ss_password") == "" || CommonValue.getUserId() == "" { CommonValue.setDefaultUserInfoForString(value: "0", key: "common_default_is_ss_password") } window = UIWindow(frame: UIScreen.main.bounds) initCusService() //腾讯bug 上报 let config = BuglyConfig() config.channel = "AppStore" //Bugly.start(withAppId: "eac41aea64") Bugly.start(withAppId: "eac41aea64", config: config) //禁止启动横屏时放开 //application.setStatusBarOrientation(.portrait, animated: false); if ScreenHeight < ScreenWidth { ScreenWidth = UIScreen.main.bounds.size.height ScreenHeight = UIScreen.main.bounds.size.width } //地址 let searchPaths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) print(searchPaths) UIApplication.shared.setStatusBarStyle(.lightContent, animated: false) mainTabbar = CustomTabBarController() // mainTabbar.delegate = self //mainTabbar.initMenuImageAnimation();//需要动画效果就加上 //mainTabbar.initMenuBigCenterButton();//需要中间大按钮就加上 navController = MainNavigationController(rootViewController: mainTabbar) //loadGuangGao(); // initTabbarController() //navController.navigationBar.barTintColor = ThemeManager.sharedInstance().getNavBackgroudColor() //navController.navigationBar.tintColor = ThemeManager.sharedInstance().getNavBackgroudColor() navController.navigationBar.isTranslucent = false navController.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: ThemeManager.sharedInstance().getNavTitleColor()] GB_Nav = navController IQKeyboardManager.shared.enable = true var navImageName = "img_nav_common" if isIphoneX { navImageName = "img_nav_common_x" } navController.navigationBar.setBackgroundImage(UIImage(named: navImageName), for: .default) navController.navigationBar.alpha = 1 window?.rootViewController = navController //微信支付时需要 if !CommonUntils.getIsSimulator() { WXApi.registerApp(wxAppKey) } //初始化友盟 if !CommonUntils.getIsSimulator() { initUMInfo() //初始化极光 regusterJPush(launchOptions: launchOptions) } window?.makeKeyAndVisible() if !GlobalMethod.isLoginSuccess(){ let vcvc = LoginViewController() GB_Nav.pushViewController(vcvc, animated: true) } // TalkingData.setExceptionReportEnabled(true); // TalkingData.sessionStarted("4070F01D80F349328DE5DFA70B712C49", withChannelId: "AppStore") initSystem() //getAddressSavePlist(); if ScreenHeight == 812 { navheight = 88 } else { navheight = 64 } UIApplication.shared.applicationIconBadgeNumber = 0 return true } ///集成客服 func initCusService() { QYSDK.shared().registerAppId("de75afb7b0a388e038e03e6eb51d73d0", appName: "星创客") } func initCusServiceUserInfo() { let userInfo = QYUserInfo() userInfo.userId = CommonValue.getUserId() let dicName = ["key": "real_name", "value": CommonValue.getUserNickName()] let dicPhone = ["key": "mobile_phone", "value": CommonValue.getUserPhone()] let dicCode = ["key": "bankcard", "value": CommonValue.getUserRecCode(), "index": "0", "label": "推荐码"] let array = NSMutableArray(array: [dicName, dicPhone, dicCode]) userInfo.data = CommonJSON.arrayToJson(arr: array) QYSDK.shared()?.setUserInfo(userInfo, authTokenVerificationResultBlock: { (succ) in print("====\(succ)===") }) } let menu1 = HomeViewController() //初始化Tabbar func initTabbarController() { let menu2 = BusinessMainViewController() // let menu3 = StudyViewController(); let menu3 = WalletMainViewController() let menu4 = MyViewController() menu1.tabBarItem.tag = 1001 menu1.tabBarItem.image = UIImage.init(named: "") menu1.title = "首页" menu2.tabBarItem.tag = 1002 menu2.tabBarItem.image = UIImage.init(named: "") menu2.title = "业务" menu3.tabBarItem.tag = 1003 menu3.tabBarItem.image = UIImage.init(named: "") menu3.title = "钱包" menu4.tabBarItem.tag = 1004 menu4.tabBarItem.image = UIImage.init(named: "") menu4.title = "我的" mainTabbar.viewControllers = [menu1, menu2, menu3, menu4] let frame = CGRect(x: 0, y: 0, width: ScreenWidth, height: 49) let bottomView = UIView(frame: frame) bottomView.backgroundColor = UIColor.white mainTabbar.tabBar.insertSubview(bottomView, at: 0) mainTabbar.tabBar.isOpaque = true let items = mainTabbar.tabBar.items for i in 0...arrIcon.count-1 { if i >= items!.count { break } let item = items![i] item.image = UIImage(named: "\(arrIcon[i])_n")?.withRenderingMode(.alwaysOriginal) item.selectedImage = UIImage(named: "\(arrIcon[i])_s")?.withRenderingMode(.alwaysOriginal) item.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: ThemeManager.sharedInstance().getTabbarDefaultFontColor()], for: .normal) item.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: ThemeManager.sharedInstance().getTabbarSelectedFontColor()], for: .highlighted) } } func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool { if CommonValue.getUserId() == "" { appDelegate.navController.pushViewController(LoginViewController(), animated: true) return false } return true } //初始化友盟 func initUMInfo() { if umAppKey == "" { return } print("====初始化友盟====") //打开调度日志 分享 UMSocialManager.default().openLog(true) UMSocialManager.default().umSocialAppkey = umAppKey UMSocialManager.default().setPlaform(.wechatSession, appKey: wxAppKey, appSecret: "", redirectURL: "http://mobile.umeng.com/social") //UMSocialManager.default().setPlaform(.QQ, appKey: "1105863397", appSecret: nil, redirectURL: "http://mobile.umeng.com/social") // UMSocialManager.default().setPlaform(.sina, appKey: "440352374", appSecret: nil, redirectURL: "http://mobile.umeng.com/social") // //统计 // UMAnalyticsConfig.sharedInstance().appKey = umAppKey // UMAnalyticsConfig.sharedInstance().channelId = "AppStore" // MobClick.start(withConfigure: UMAnalyticsConfig.sharedInstance()) } //极光注册 func regusterJPush(launchOptions: [UIApplication.LaunchOptionsKey: Any]?) { if jpushAppKey == "" { return } print("====初始化极光====") UIRemoteNotificationType.badge print(UIDevice.current.systemVersion) //注册JPUSH regJpush() //JPUSHService.setupWithOption(launchOptions) JPUSHService.setup(withOption: launchOptions, appKey: jpushAppKey, channel: "Publish channel", apsForProduction: false) } func getValueForSystemVersion() -> Float { let str = UIDevice.current.systemVersion // as! String; let strs = str.split(s: ".") if strs.count >= 1 { return Float(strs[0] + "." + strs[1])! } else { return Float(str)! } } var timer: Timer! var isBackgroudRun = false /** 注册JPUSH */ func regJpush() { if getValueForSystemVersion() >= Float(10.0) { let entity = JPUSHRegisterEntity() entity.types = Int(UIUserNotificationType.badge.rawValue) | Int(UIUserNotificationType.sound.rawValue) | Int(UIUserNotificationType.alert.rawValue) JPUSHService.register(forRemoteNotificationConfig: entity, delegate: self) } else if getValueForSystemVersion() >= Float(8.0) { regjpushtwo() } else { regjpushtwo() } } func regjpushtwo() { JPUSHService.register(forRemoteNotificationTypes: UIRemoteNotificationType.badge.rawValue | UIRemoteNotificationType.sound.rawValue, categories: nil) } @available(iOS 10.0, *) func jpushNotificationCenter(_ center: UNUserNotificationCenter!, willPresent notification: UNNotification!, withCompletionHandler completionHandler: ((Int) -> Void)!) { let userIf = notification.request.content.userInfo print("-----收到推送处理11111 运行中") completionHandler(Int(UNAuthorizationOptions.badge.rawValue)) jPushinfo(userInfo: userIf as NSDictionary) completionHandler } @available(iOS 10.0, *) func jpushNotificationCenter(_ center: UNUserNotificationCenter!, didReceive response: UNNotificationResponse!, withCompletionHandler completionHandler: (() -> Void)!) { let userIf = response.notification.request.content.userInfo print("-----收到推送处理22222 后台") jPushinfo(userInfo: userIf as NSDictionary) completionHandler } func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { JPUSHService.registerDeviceToken(deviceToken) } func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { JPUSHService.handleRemoteNotification(userInfo) } func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { print("-----收到推送处理3333---=IOS 10以下自己判断前后台=") jPushinfo(userInfo: userInfo as NSDictionary) } func jPushinfo(userInfo: NSDictionary) { print("-----收到推送处理\n") print(userInfo) if userInfo["messageId"] as? String == nil { return } else { var strTitle = "" let dicAPS = userInfo["aps"] as? NSDictionary if dicAPS != nil { strTitle = dicAPS!.getString(key: "alert") } if isBackgroudRun { let view = CommonWebViewViewController() view.strTitle = strTitle view.url = "http://106.xingchuangke.net:8889/phoneMobile/messageWeb?id=\(userInfo["messageId"] as! String)" navController.pushViewController(view, animated: true) } else { CommonUntils.AlertView(controller: navController, title: "提示", message: "收到系统消息,是否立即查看?", buttons: ["立即查看"], style: .alert) {[weak self] (_, _) in let view = CommonWebViewViewController() view.strTitle = strTitle view.url = "http://106.xingchuangke.net:8889/phoneMobile/messageWeb?id=\(userInfo["messageId"] as! String)" self!.navController.pushViewController(view, animated: true) } } } } @objc func timerAction() { isBackgroudRun = false } func application(_ application: UIApplication, handleOpen url: URL) -> Bool { _ = UMSocialManager.default().handleOpen(url) return true } func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. } func applicationDidEnterBackground(_ application: UIApplication) { isBackgroudRun = true print("====go Background===") NotificationCenter.default.post(name: NSNotification.Name(rawValue: "defulat_notification_go_backgroud"), object: nil, userInfo: nil) // 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. } func applicationWillEnterForeground(_ application: UIApplication) { reloadUserInfo() print("====go Foreground===") UIApplication.shared.applicationIconBadgeNumber = 0 NotificationCenter.default.post(name: NSNotification.Name(rawValue: "defulat_notification_go_foreground"), object: nil, userInfo: 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. } func applicationDidBecomeActive(_ application: UIApplication) { self.perform(#selector(AppDelegate.timerAction), with: nil, afterDelay: 2) print("====go BecomeActive===") if CommonValue.getIsValitePassword() { let guest = GuesturePasswordViewController() guest.type = 1 appDelegate.navController.pushViewController(guest, animated: true) } // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } var viewGuangGao: UIView! var imgGuangGao: UIImageView! var lblCloseTime: UILabel! var dicImageInfo: NSDictionary! //加载广告View func loadGuangGao() { viewGuangGao = UIView(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenHeight)) //640*920 744 if ScreenHeight <= 480 { imgGuangGao = UIImageView(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenWidth * 1.16)) } else { imgGuangGao = UIImageView(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenWidth * 1.4375)) } viewGuangGao.addSubview(imgGuangGao) //860*294 let imgView = UIImageView(frame: CGRect(x: 0, y: ScreenHeight - (ScreenWidth * 0.34), width: ScreenWidth, height: ScreenWidth * 0.34)) imgView.image = UIImage(named: "ad_logo_860x294_@1x") viewGuangGao.addSubview(imgView) viewGuangGao.layer.zPosition = 9999999 lblCloseTime = UILabel(frame: CGRect(x: ScreenWidth - 85, y: 30, width: 70, height: 30)) lblCloseTime.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x000000, alpha: 0.5) lblCloseTime.textColor = UIColor.white lblCloseTime.font = UIFont.systemFont(ofSize: 13) lblCloseTime.textAlignment = .center lblCloseTime.setCornerRadius(size: 4) lblCloseTime.isHidden = true viewGuangGao.addSubview(lblCloseTime) // window?.addSubview(viewGuangGao) appDelegate.navController.view.addSubview(viewGuangGao) //5秒后,未取回初始化数据就隐藏 self.perform(#selector(autoHiddenGuangGao), with: nil, afterDelay: 6) } var isLoadGuangGao = false @objc func autoHiddenGuangGao() { if !isLoadGuangGao { hiddenGuangGao() } } //图片地址获取到后,调用显示图片,开始倒计时 func loadGuangGaoImage(dic: NSDictionary) { isLoadGuangGao = true var imgUrl = "" if CommonUntils.isIphonex() { if dic["imageSpe"] != nil { imgUrl = dic["imageSpe"] as! String } } else { if dic["image"] != nil { imgUrl = dic["image"] as! String } } if imgUrl == "" { hiddenGuangGao() } else { lblCloseTime.isHidden = false imgGuangGao.sd_setImage(with: URL(string: imgUrl)!) {[weak self] (img, _, _, _) in self!.imgGuangGao.setSizeWidth(width: ScreenWidth) self!.imgGuangGao.setSizeHeight(height: ScreenWidth / img!.size.width * img!.size.height) self!.timerAD = Timer.scheduledTimer(timeInterval: 1, target: self!, selector: #selector(self!.refreshTime), userInfo: nil, repeats: true) self!.timerAD.fireDate = Date.distantPast } let btn = UIButton(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenHeight)) viewGuangGao.addSubview(btn) btn.addTarget(self, action: #selector(btnGuangGaoClick), for: .touchUpInside) lblCloseTime.text = "\(count)s跳过" // self.perform(#selector(refreshTime), with: nil, afterDelay: 1) //好用 // self.perform(#selector(refreshTime), with: nil, afterDelay: 2) //好用 // self.perform(#selector(refreshTime), with: nil, afterDelay: 3) //好用 } } var timerAD: Timer! //点击跳转到广告页 @objc func btnGuangGaoClick() { count = 1 hiddenGuangGao() // let view = CommonWebViewViewController() // view.isUseCurrentTitle = true; // // view.url = RequestURL.hostMain1 + (dicImageInfo["jump_url"] as! String) + "&_token=\(CommonValue.getUserToken())&build=9.3.4.0&appversion=\(CommonUntils.getSystemVersion())&deviceid=\(CommonUntils.getImei())&jssdk=1&clienttype=ios&version=56&network=&themecolor=12b8f6"; // appDelegate.toViewController(vc: view) } var count = 3 @objc func refreshTime() { if count == 1 { if timerAD != nil { timerAD.fireDate = Date.distantFuture } hiddenGuangGao() return } else if count < 1 { if timerAD != nil { timerAD.fireDate = Date.distantFuture } hiddenGuangGao() return } count -= 1 lblCloseTime.text = "\(count)s跳过" } ///广告是否已经隐藏 var isHiddenGuangeGao = false func hiddenGuangGao() { if isHiddenGuangeGao { return } isHiddenGuangeGao = true if viewGuangGao != nil { UIView.animate(withDuration: 0.6, animations: { self.viewGuangGao.alpha = 0 self.viewGuangGao.transform = CGAffineTransform(scaleX: 1.1, y: 1.1) }, completion: { (_) in self.viewGuangGao.isHidden = true //弹屏广告放在这 }) } } var isInitSysteming = false var initSystemIsSucces = false ///初始化系统 func initSystem() { if initSystemIsSucces || isInitSysteming { return } isInitSysteming = true let params = NSMutableDictionary() if CommonValue.getUserId() == "" { params.setValue("", forKey: "aid") } else { params.setValue(CommonValue.getUserId(), forKey: "aid") } let http = CommonValue.getHttp() let url = RequestURL.initProgram http.get(url, parameters: params, progress: nil, success: {[weak self] (_, json1) -> Void in self!.isInitSysteming = false self!.initSystemIsSucces = true let json = json1 as! NSDictionary if isPrintLog { print(json) } let succeed = json.object(forKey: "succeed") as! String if succeed == "000" { let dataInfo = json["dataInfo"] as? NSDictionary CommonValue.setDefaultUserInfoForObject(value: dataInfo!, key: "common_default_init_data") self!.dicDefault.setDictionary(dataInfo! as! [AnyHashable: Any]) RequestURL.qiNiuImageUrl = dataInfo!["qnUrl"] as! String //加载广告 //self!.loadGuangGaoImage(dic: dataInfo!); self!.upgradeSystem() self!.reloadUserInfo() if self!.menu1.headerView != nil { self!.menu1.headerView.initView() } if self!.menu1.tableView != nil { self!.menu1.tableView.reloadData() } } }, failure: {[weak self] (_, _) -> Void in self!.isInitSysteming = false self!.reloadUserInfo() let obj = CommonValue.getDefaultUserInfoForObject(key: "common_default_init_data") if obj != nil && (obj as? NSDictionary) != nil { self!.dicDefault.setDictionary((obj as! NSDictionary) as! [AnyHashable: Any]) RequestURL.qiNiuImageUrl = self!.dicDefault["qnUrl"] as! String //加载广告 //self!.loadGuangGaoImage(dic: self!.dicDefault); } else { self!.hiddenGuangGao() } }) } func upgradeSystem() { if UserDefault.object(forKey: launchView) == nil { return } if dicDefault["apkVersion"] as? NSDictionary != nil { let dicApkVersion = dicDefault["apkVersion"] as! NSDictionary if CommonUntils.getSystemVersion() != dicApkVersion.getString(key: "apkversion") { if CommonUntils.checkVersionIsUpload(serverVersion: dicApkVersion.getString(key: "apkversion")) { let viewAlert = CommonViewUntils.getViewForXIB(xibName: "UpdateAlertView") as! UpdateAlertView viewAlert.initView(alert: dicApkVersion.getString(key: "detail"), upgradeUrl: dicApkVersion.getString(key: "apkurl")) appDelegate.navController.showBackgroudView(viewContent: viewAlert, isCenter: true, clickOtherIsClose: false) return } } } } ///更新用户信息 func reloadUserInfo() { if CommonValue.getUserId() == "" { return } let params = NSMutableDictionary() // let http = AFHTTPSessionManager() // http.requestSerializer.setValue(CommonValue.getUserId(), forHTTPHeaderField: "userId") // http.requestSerializer.setValue("1", forHTTPHeaderField: "phoneType") // http.requestSerializer.setValue(CommonUntils.getSystemVersion(), forHTTPHeaderField: "apkVersion") let http = CommonValue.getHttp() params.setValue(CommonValue.getUserId(), forKey: "userId") let url = RequestURL.findUserById http.get(url, parameters: params, progress: nil, success: {[weak self] (_, json1) -> Void in print(json1) let json = json1 as! NSDictionary let succeed = json.object(forKey: "succeed") as! String self!.initCusServiceUserInfo() if succeed == "000" { let dataInfo = json["dataInfo"] as? NSDictionary if dataInfo != nil { CommonValue.setLoginUserInfo(loginUser: NSMutableDictionary(dictionary: dataInfo!)) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "noti_reload_user"), object: nil, userInfo: nil) //self.jpushSetAlias(alias: CommonValue.getUserId()) } } }, failure: { (_, _) -> Void in }) } ///获取省市县并存到本地 func getAddressSavePlist() { let params = NSMutableDictionary() let http = AFHTTPSessionManager() http.requestSerializer.setValue(CommonValue.getUserId(), forHTTPHeaderField: "userId") http.requestSerializer.setValue("1", forHTTPHeaderField: "phoneType") http.requestSerializer.setValue(CommonUntils.getSystemVersion(), forHTTPHeaderField: "apkVersion") params.setValue(CommonValue.getUserId(), forKey: "userId") let url = RequestURL.getProvincesOrCity http.get(url, parameters: params, progress: nil, success: { (_, json1) -> Void in let json = json1 as! NSDictionary let succeed = json.object(forKey: "succeed") as! String if succeed == "000" { let dataInfo = json["dataInfo"] as? NSArray if dataInfo != nil { dataInfo!.write(toFile: "\(CommonUntils.getAppPath())address1111.plist", atomically: true) print(CommonUntils.getAppPath()) print("====保存成功=") } } }, failure: { (_, _) -> Void in }) } // MARK: 状态栏点击事件 override func touchesBegan(_ touches: Set, with event: UIEvent?) { for touch: AnyObject in touches { let t = touch as! UITouch if t.location(in: nil).y > 20 { return } } NotificationCenter.default.post(name: NSNotification.Name(rawValue: "commo_stateBarClick"), object: nil) } // MARK: =========支付宝========= func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { if url.host!.has(s: "safepay") { AlipaySDK.defaultService().processOrder(withPaymentResult: url, standbyCallback: { (content) in let nc = NotificationCenter.default nc.post(name: NSNotification.Name(rawValue: "notification_alipay"), object: String((content as! NSDictionary)["resultStatus"] as! String)) }) } UMSocialManager.default().handleOpen(url) WXApi.handleOpen(url, delegate: self) return true } func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { if url.host!.has(s: "safepay") { AlipaySDK.defaultService().processOrder(withPaymentResult: url, standbyCallback: { (content) in let nc = NotificationCenter.default nc.post(name: NSNotification.Name(rawValue: "notification_alipay"), object: String((content as! NSDictionary)["resultStatus"] as! String)) }) } UMSocialManager.default().handleOpen(url) WXApi.handleOpen(url, delegate: self) return true } // MARK: 微信回调 func onResp(_ resp: BaseResp) { print("微信回调\n\(resp.type)") print("微信回调\n\(resp.errCode)") print("微信回调\n\(resp.errStr)") let nc = NotificationCenter.default nc.post(name: NSNotification.Name(rawValue: "notification_weixinpay"), object: String(resp.errCode)) } func setNavigationBarHidden(isHidden: Bool) { if navController != nil { navController.setNavigationBarHidden(isHidden, animated: false) } } }