123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- //
- // SPSBConsultationViewController.m
- // 我的社保
- //
- // Created by shanp on 2021/4/20.
- //
- #import "SPSBConsultationViewController.h"
- #import "SPSBUIGeneralHeader.h"
- #import "SPSBConsultationTableViewController.h"
- #import "UIViewController+SPSBInitialization.h"
- #import "UIViewController+SPSBNavigationBar.h"
- #import "SPSBBroadcastView.h"
- #import "SPSBCustomerServiceManager.h"
- #import "SPSBTabBarView.h"
- #import "UIViewController+SPSBNetworkManager.h"
- #import "SPSBCustomerServiceManager.h"
- #import "SPSBMakePhoneCallManager.h"
- #import "SPSBBusinessManager.h"
- #import "SPSBFeedbackListModel.h"
- #import "SPSBFeedbackListViewController.h"
- #import "SPSBAddFeedbackViewViewController.h"
- #import "SPSBNavigationController.h"
- typedef NS_ENUM(NSUInteger, SPSBConsultationHeaderActionType) {
- SPSBConsultationHeaderActionTypeCustomerService = 3000,
- SPSBConsultationHeaderActionTypePhone,
- SPSBConsultationHeaderActionTypeFeedback,
- };
- @interface SPSBConsultationViewController () {
- SPSBConsultationTableViewController *_tableVC;
- UIView *_headerView;
- NSString *_cacheBroadcast;
- SPSBBroadcastView *_broadcastView;
- UIView *_tipsView;
- SPSBMakePhoneCallManager *_makePhoneCallManager;
- }
- @end
- @implementation SPSBConsultationViewController
- - (instancetype)init {
- self = [super init];
- if (!self) return nil;
- self.spsb_isLightContent = true;
- return self;
- }
- - (UIStatusBarStyle)preferredStatusBarStyle {
- return self.spsb_statusBarStyle;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initData];
- [self setupUI];
- }
- - (void)initData {
- _cacheBroadcast = @"";
- _makePhoneCallManager = [[SPSBMakePhoneCallManager alloc] initWithController:self];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [_broadcastView beginAnimation];
- [self getBroadcast];
- [self reloadViewTips];
- //去掉智齿的toolbar
- [self.navigationController setToolbarHidden:true animated:true];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [_broadcastView stopAnimation];
- }
- #pragma mark - Action
- - (void)reloadViewTips {
- NSString *tips = [NSString stringWithFormat:@"%ld", (long)spsb_customerServiceManager().spsb_notificationNum];
- [spsb_tabBarView() tipsViewHidden:spsb_customerServiceManager().spsb_notificationNum <= 0 tips:tips tabBarType:SPSBTabBarTypeConsultation];
- _tipsView.hidden = spsb_customerServiceManager().spsb_notificationNum <= 0;
- ((UILabel *)[_tipsView viewWithTag:spsb_numberTipsViewLabelTag]).text = tips;
- }
- - (void)headerButtonAction:(UIButton *)sender {
- switch (sender.tag) {
- case SPSBConsultationHeaderActionTypeCustomerService:
- [spsb_customerServiceManager() toOnlineContactWithBaseController:self];
- break;
- case SPSBConsultationHeaderActionTypePhone:
- [_makePhoneCallManager showHandleContactMenu];
- break;
- case SPSBConsultationHeaderActionTypeFeedback: {
- @weakify(self)
- spsb_needLogin(^{
- @strongify(self)
- [self getFeedbackList];
- });
- }
- break;
-
- default:
- break;
- }
- }
- #pragma mark - Network Action
- - (void)getBroadcast {
- [self networkUseMethod:SPSBNetworkMethodGET loadingTips:nil isLogin:false url:spsb_appUrl(SPSBUrlGetBroadcast) urlParameters:nil parameters:nil success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- [self getBroadcastSuccess:data];
- return nil;
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- return nil;
- }];
- }
- - (void)getBroadcastSuccess:(id)data {
- if (![_cacheBroadcast isEqualToString:data[@"data"]]) {
- _cacheBroadcast = data[@"data"];
- [_broadcastView reloadData:_cacheBroadcast];
- }
- }
- - (void)getFeedbackList {
- [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:@"正在加载" isLogin:true url:spsb_appUrl(SPSBUrlGetFeedbackList) urlParameters:nil parameters:nil success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- [self getFeedbackListSuccess:data];
- return @"";
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- return @"加载失败";
- }];
- }
- - (void)getFeedbackListSuccess:(id)data {
- NSArray *array = [SPSBFeedbackListModel getModelListWithArray:data[@"data"]];
- if (array.count == 0) {
- SPSBAddFeedbackViewViewController *vc = SPSBAddFeedbackViewViewController.new;
- @weakify(self)
- vc.spsb_successSave = ^{
- @strongify(self)
- [self getFeedbackList];
- };
- SPSBNavigationController *nav = [[SPSBNavigationController alloc] initWithRootViewController:vc];
- [self presentViewController:nav animated:true completion:nil];
- } else {
- SPSBFeedbackListViewController *vc = SPSBFeedbackListViewController.new;
- vc.spsb_data = array;
- [self.navigationController pushViewController:vc animated:true];
- }
- }
- #pragma mark - UI
- - (void)setupUI {
- //取消返回按钮
- self.navigationItem.leftBarButtonItem = nil;
- self.spsb_isHiddenNavigationBar = true;
- self.title = @"咨询";
- [self createHeaderView];
- [self createTableView];
- [self createNavigationBar];
- [self setNavigationBar];
- }
- - (void)createTableView {
- _tableVC = SPSBConsultationTableViewController.new;
- _tableVC.tableView.tableHeaderView = _headerView;
- @weakify(self)
- _tableVC.spsb_scrollAction = ^(CGFloat offset) {
- @strongify(self)
- [self judgeNavigationBarWithOffset:offset];
- };
- [self addChildViewController:_tableVC];
- [self.view addSubview:_tableVC.tableView];
- [_tableVC.tableView makeConstraints:^(JXHConstraintMaker *make) {
- make.top.and.leading.and.trailing.equalTo(0);
- make.bottom.equalTo(self.view.safebottom).offset(-SPSBTabBarHeight);
- }];
- }
- - (void)createHeaderView {
- CGFloat top;
- if (@available(iOS 11.0, *)) {
- top = jxh_safeInsets(spsb_keyWindow()).top - 20;
- } else {
- top = jxh_statusBarHeight() - 20;
- }
- CGFloat headerHeight = jxh_screenWidth() / 2.5685;
- _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, jxh_screenWidth(), top + headerHeight + 114 + 12)];
- _headerView.backgroundColor = spsb_3296FB_color();
-
- UIImageView *backgroundView1 = [[UIImageView alloc] initWithImage:jxh_getImage(zixun_bg)];
- [_headerView addSubview:backgroundView1];
- [backgroundView1 makeConstraints:^(JXHConstraintMaker *make) {
- make.top.equalTo(top);
- make.leading.and.trailing.equalTo(0);
- make.size.equalTo(CGSizeMake(jxh_screenWidth(), headerHeight));
- }];
-
- CGFloat _height = jxh_screenWidth() / 2.68;
- UIImageView *backgroundView = [[UIImageView alloc] initWithImage:jxh_getImage(advisory_bg)];
- [backgroundView1 addSubview:backgroundView];
- [backgroundView makeConstraints:^(JXHConstraintMaker *make) {
- make.bottom.equalTo(backgroundView1);
- make.leading.and.trailing.equalTo(0);
- make.size.equalTo(CGSizeMake(jxh_screenWidth(), _height));
- }];
-
- @weakify(self)
- _broadcastView = [[SPSBBroadcastView alloc] initWithReloadDataAction:^(CGFloat height) {
- @strongify(self)
- self->_headerView.frame = CGRectMake(0, 0, jxh_screenWidth(), top + headerHeight + height + 114 + 12);
- [self->_broadcastView makeConstraints:^(JXHConstraintMaker *make) {
- make.height.update(height);
- }];
- [self->_tableVC.tableView reloadData];
- }];
- [_headerView addSubview:_broadcastView];
- [_broadcastView makeConstraints:^(JXHConstraintMaker *make) {
- make.top.equalTo(backgroundView.bottom);
- make.leading.and.trailing.equalTo(0);
- make.height.equalTo(0);
- }];
-
- UIView *buttonView = UIView.new;
- buttonView.backgroundColor = spsb_FFFFFF_color(1.f);
- [_headerView addSubview:buttonView];
- [buttonView makeConstraints:^(JXHConstraintMaker *make) {
- make.top.equalTo(self->_broadcastView.bottom);
- make.leading.and.trailing.equalTo(0);
- make.height.equalTo(114);
- }];
-
- NSArray *titleArray = @[@"在线客服", @"咨询热线", @"留言反馈"];
- NSArray *imageArray = @[jxh_getImage(kefu), jxh_getImage(rexian), jxh_getImage(liuyan)];
- JXHCenterButton *tempButton = nil;
- for (NSInteger i = 0; i < 3; i ++) {
- JXHCenterButton *button = [JXHCenterButton convenienceWithAxis:JXHCenterButtonAxisVertical interval:10 font:spsb_font(14) target:self action:@selector(headerButtonAction:)];
- [button setTitle:titleArray[i] titleColor:spsb_333333_color() image:imageArray[i] backgroundImage:nil state:JXHButtonControlStateNormal | JXHButtonControlStateHighlighted];
- button.tag = SPSBConsultationHeaderActionTypeCustomerService + i;
- [buttonView addSubview:button];
- [button makeConstraints:^(JXHConstraintMaker *make) {
- make.top.and.bottom.equalTo(0);
- make.width.equalTo(jxh_screenWidth() / 3);
- if (tempButton) {
- make.leading.equalTo(tempButton.trailing);
- } else {
- make.leading.equalTo(0);
- }
- }];
-
- tempButton = button;
-
- if (i == 0) {
- _tipsView = spsb_createNumberTipsViewWithTag(10000);
- [buttonView addSubview:_tipsView];
- [_tipsView makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(button.jxh_icon.trailing).offset(-10);
- make.top.equalTo(15);
- }];
- }
- }
-
- UIView *view = UIView.new;
- view.backgroundColor = spsb_F5F5F5_color();
- [_headerView addSubview:view];
- [view makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.and.trailing.equalTo(0);
- make.top.equalTo(buttonView.bottom);
- make.bottom.equalTo(0);
- }];
- }
- - (void)setNavigationBar {
- self.spsb_barBackButton.hidden = true;
- [self setBackButtonAndTitleColorIsWhite:false];
- self.spsb_navigationBar.backgroundColor = spsb_FFFFFF_color(1.f);
- self.spsb_navigationBar.alpha = 0;
- }
- - (void)judgeNavigationBarWithOffset:(CGFloat)offset {
- self.spsb_navigationBar.alpha = offset * 0.025;
- if (self.spsb_navigationBar.alpha > 0.5) {
- self.spsb_isLightContent = false;
- } else {
- self.spsb_isLightContent = true;
- }
- }
- @end
|