123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- //
- // SPSBStartPageViewController.m
- // 我的社保
- //
- // Created by shanp on 2021/4/20.
- //
- #import "SPSBStartPageViewController.h"
- #import "AppDelegate+SPSBRootViewController.h"
- #import <JXHSystemShortcut.h>
- #import "SPSBUIGeneralHeader.h"
- #import "SPSBNotificationDelegateManager.h"
- #import "SPSBOpenADManager.h"
- #import "SPSBKeyProfile.h"
- #import "SPSBGuideViewController.h"
- @interface SPSBStartPageViewController ()<SPSBNotificationDelegate> {
- bool _isFirst;
- }
- @end
- @implementation SPSBStartPageViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- _isFirst = true;
- [self setupUI];
- }
- - (void)dealloc {
- spsb_removeNotificationKey(SPSBOpenAdNotificationKey);
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- if (_isFirst) {
- _isFirst = false;
- } else {
- [jxh_appDelegate() showHomePage];
- return;
- }
- bool needJudge = [self judgeVersion];
- if (!needJudge) {
- return;
- }
- switch (spsb_openADManager().spsb_switchStatus) {
- case SPSBOpenAdSwitchStatusForbid: {
- [jxh_appDelegate() showHomePage];
- }
- break;
- case SPSBOpenAdSwitchStatusUnknow: {
- spsb_setNotificationKey(SPSBOpenAdNotificationKey);
- [self performSelector:@selector(removeOpenAD) withObject:nil afterDelay:1];
- }
- break;
-
- default: [self judgeOpenAD];
- break;
- }
- }
- #pragma mark - JUDGE VERSION
- - (bool)judgeVersion {
- if (![jxh_userDefaults() objectForKey:SPSBAppInsideVersion]) {
- [self setAppInsideVerson];
- [self creatGuidanceView];
- return false;
- } else {
- //首页提示展示
- if ([[jxh_userDefaults() objectForKey:SPSBAppInsideVersion] integerValue] < 25 && SPSBCurrentVersion == 25) {
- NSMutableDictionary *dic = [[jxh_userDefaults() objectForKey:SPSBTipsMark] mutableCopy];
- dic[@"home"] = @"1";
- [jxh_userDefaults() setObject:dic forKey:SPSBTipsMark];
- [self setAppInsideVerson];
- [jxh_appDelegate() changeTabBarType:SPSBTabBarTypeHome];
- return false;
- } else if ([[jxh_userDefaults() objectForKey:SPSBAppInsideVersion] integerValue] < SPSBCurrentVersion) {
- //每次更新都展示引导页
- [self setAppInsideVerson];
- [self creatGuidanceView];
- return false;
- } else {
- [self setAppInsideVerson];
- return true;
- }
-
- }
- }
- - (void)setAppInsideVerson {
- [jxh_userDefaults() setObject:[NSString localizedStringWithFormat:@"%ld", (long)SPSBCurrentVersion] forKey:SPSBAppInsideVersion];
- [jxh_userDefaults() synchronize];
- }
- - (void)judgeOpenAD {
- if (spsb_openADManager().spsb_switchStatus == SPSBOpenAdSwitchStatusOn) {
- [self setOpenAD];
- } else {
- [jxh_appDelegate() showHomePage];
- }
- }
- - (void)setOpenAD {
- [spsb_openADManager() showAD];
- }
- - (void)removeOpenAD {
- dispatch_main_async_safe(^{
- [jxh_appDelegate() showHomePage];
- });
-
- }
- #pragma mark - SPSBNotificationDelegate
- - (void)spsb_gotOpenAdData {
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(removeOpenAD) object:nil];
- [self judgeOpenAD];
- }
- #pragma mark - GuidanceView
- - (void)creatGuidanceView {
- SPSBGuideViewController *guideViewController = SPSBGuideViewController.new;
- guideViewController.modalPresentationStyle = UIModalPresentationCustom;
- @weakify(self)
- guideViewController.spsb_nextAction = ^{
- @strongify(self)
- [jxh_appDelegate() showHomePage];
- [self dismissViewControllerAnimated:false completion:nil];
- };
- [self presentViewController:guideViewController animated:false completion:^{
- }];
- }
- #pragma mark - UI
- - (void)setupUI {
- UIImageView *imageView = [[UIImageView alloc] initWithImage:jxh_getImage(startpage)];
- imageView.contentMode = UIViewContentModeScaleAspectFit;
- [self.view addSubview:imageView];
- [imageView makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.and.trailing.equalTo(0);
- make.centerY.equalTo(self.view);
- make.height.equalTo(1200);
- }];
-
-
- imageView = [[UIImageView alloc] initWithImage:jxh_getImage(star_page_bottom)];
- [self.view addSubview:imageView];
- [imageView makeConstraints:^(JXHConstraintMaker *make) {
- make.centerX.equalTo(self.view);
- make.bottom.equalTo(-44);
- }];
- }
- @end
|