// // SPSBCustomerServiceManager.m // 我的社保 // // Created by shanp on 2021/4/26. // #import "SPSBCustomerServiceManager.h" #import "SPSBBusinessManager.h" #import #import #import "SPSBAppDifferenceProfile.h" #import "SPSBKeyProfile.h" #import #import "SPSBGeneralManager.h" #import "SPSBConsultationViewController.h" #import "SPSBConfirmAlertViewController.h" #import "SPSBOpenPopupManager.h" #import "SPSBURLApiProfile.h" #import #import #import "SPSBColorProfile.h" @implementation SPSBCustomerServiceManager + (instancetype)alloc { NSAssert(![self isMemberOfClass:[SPSBCustomerServiceManager class]], @"SPSBCustomerServiceManager is singleton, you should not instantiate it directly."); return [super alloc]; } + (SPSBCustomerServiceManager *)shareManager { static SPSBCustomerServiceManager *manager = nil; static dispatch_once_t once; dispatch_once(&once, ^{ manager = [[super allocWithZone:nil] init]; }); return manager; } + (instancetype)allocWithZone:(struct _NSZone *)zone { return [self shareManager]; } - (void)delayToOnlineContact { [self pollHandleOnlineContactWithTime:0]; } - (void)checkSobot { if (!spsb_isLogin()) return; _spsb_isChecking = true; ZCLibInitInfo *initInfo = [ZCLibInitInfo new]; initInfo.app_key = SPSBSobotAppKey; initInfo.partnerid = [jxh_userDefaults() objectForKey:SPSBUser]; [[ZCLibClient getZCLibClient] setLibInitInfo:initInfo]; NSInteger i = [[ZCLibClient getZCLibClient] getUnReadMessage]; _spsb_notificationNum = i; [spsb_consultationHomeVC() reloadViewTips]; debugLog(@"未读消息-----------%ld", (long)i); if (i > 0) { SPSBConfirmAlertViewController *vc = [SPSBConfirmAlertViewController alertWithTitle:@"提示" content:@"你有未读客服信息"]; @weakify(self) [vc setCancelButtonTitle:nil titleColor:nil action:^{ self->_spsb_isChecking = false; }]; [vc setConfirmButtonTitle:@"查看" titleColor:nil action:^{ @strongify(self) [self toOnlineContactWithBaseController:nil]; }]; SPSBOpenPopupModel *model = SPSBOpenPopupModel.new; model.spsb_popup = vc; [SPSBOpenPopupManager insertPopup:model]; } else { _spsb_isChecking = false; } } - (void)pollHandleOnlineContactWithTime:(NSTimeInterval)time { if (time > 10) { return; } if (![[ZCLibClient getZCLibClient] getInitState]) { [self performSelector:@selector(pollHandleOnlineContactWithTime:) withObject:@(time + 1) afterDelay:0.1]; return; } [self toOnlineContactWithBaseController:nil]; } - (void)toOnlineContactWithBaseController:(nullable UIViewController *)vc { debugLog(@"智齿%@", [ZCSobot getVersion]); @weakify(self) spsb_needLogin(^{ @strongify(self) [self inCustomerServiceWithBaseController:vc]; }); } - (void)inCustomerServiceWithBaseController:(nullable UIViewController *)vc { if (_spsb_isIn) return; _spsb_isChecking = true; ZCLibInitInfo *initInfo = [ZCLibInitInfo new]; initInfo.app_key = SPSBSobotAppKey; initInfo.partnerid = [jxh_userDefaults() objectForKey:SPSBUser]; initInfo.user_tels = [jxh_userDefaults() objectForKey:SPSBUserName]; initInfo.face = spsb_fileUrl(spsb_userAvatar()); initInfo.user_nick = [jxh_userDefaults() objectForKey:SPSBUserName]; // initInfo.receptionistId = @"9dc3cbd95e8645dca3f5cc6db201bbd8"; ZCKitInfo *uiInfo = [ZCKitInfo new]; uiInfo.navcBarHidden = true; uiInfo.topViewBgColor = HEX_COLOR(#0DAEAF); uiInfo.chatLeftLinkColor = HEX_COLOR(#0DAEAF); // uiInfo.topViewBgColor = HEX_COLOR(#28AFF0); // uiInfo.rightChatColor = HEX_COLOR(#28AFF0); // uiInfo.satisfactionSelectedBgColor = HEX_COLOR(#3296FB); // uiInfo.noSatisfactionTextColor = HEX_COLOR(#3296FB); // uiInfo.commentCommitButtonBgColor = HEX_COLOR(#3296FB); // uiInfo.commentOtherButtonBgColor = HEX_COLOR(#3296FB); // uiInfo.topBackTitle = @""; uiInfo.titleFont = spsb_font(17); // uiInfo.topViewTextColor = [UIColor redColor]; // uiInfo.topBackNolColor = HEX_COLOR(#3296FB); // uiInfo.customBannerColor = HEX_COLOR(#3296FB); // ZCProductInfo *productInfo = [ZCProductInfo new]; // productInfo.thumbUrl = @""; // productInfo.title = @"123"; // productInfo.desc = @"345"; // productInfo.label = @"&3"; // productInfo.link = @"http://www.baidu.com"; // uiInfo.productInfo = productInfo; [[ZCLibClient getZCLibClient] setLibInitInfo:initInfo]; [[UIApplication sharedApplication] cancelAllLocalNotifications]; if (nil == vc) { vc = jxh_findPresentedViewControllerStartingFrom(spsb_keyWindow().rootViewController); } if (nil == vc) return; bool haveNav = vc.navigationController.navigationBarHidden; // 智齿SDK初始化启动事例 @weakify(self) [ZCSobot startZCChatVC:uiInfo with:vc target:nil pageBlock:^(id object,ZCPageBlockType type){ @strongify(self) if (type == ZCPageBlockLoadFinish) { self->_spsb_isIn = true; self->_spsb_isChecking = false; self->_spsb_notificationNum = 0; [spsb_consultationHomeVC() reloadViewTips]; if (vc.navigationController) { vc.navigationController.interactivePopGestureRecognizer.enabled = false; [vc.navigationController setNavigationBarHidden:true animated:false]; } } if (type == ZCPageBlockGoBack) { self->_spsb_isIn = false; self->_spsb_isClickNotification = false; if (vc.navigationController) { vc.navigationController.interactivePopGestureRecognizer.enabled = true; [vc.navigationController setNavigationBarHidden:haveNav animated:false]; NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: spsb_333333_color(), NSForegroundColorAttributeName, spsb_mediumFont(16), NSFontAttributeName, nil]; [vc.navigationController.navigationBar setTitleTextAttributes:attributes]; } } } messageLinkClick:nil]; } @end SPSBCustomerServiceManager *spsb_customerServiceManager() { return [SPSBCustomerServiceManager shareManager]; }