Files
featherVoice/QXLive/Base/QXAppStartViewController.m
2026-01-04 14:01:30 +08:00

185 lines
7.6 KiB
Objective-C

//
// QXAppStartViewController.m
// QXLive
//
// Created by 启星 on 2025/8/12.
//
#import "QXAppStartViewController.h"
#import "AppDelegate.h"
#import "TUIChatConfig.h"
#import "OpenUDID.h"
#import "QXManagerMqtt.h"
@interface QXAppStartViewController ()
@property (nonatomic,strong)UIImageView *bgImaegView;
@property (nonatomic,assign)BOOL isNeedChangeServer;
@end
@implementation QXAppStartViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.bgImaegView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.bgImaegView.image = [UIImage imageNamed:@"app_start_yusheng"];;
self.bgImaegView.contentMode = UIViewContentModeScaleAspectFill;
[self.view addSubview:self.bgImaegView];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appStartNetWork) name:noticeUserLogin object:nil];
if ([QXRequset shareInstance].AFNetWorkStatus == AFNetworkReachabilityStatusReachableViaWWAN || [QXRequset shareInstance].AFNetWorkStatus == AFNetworkReachabilityStatusReachableViaWiFi) {
[self getAppTheme];
}
}
-(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
// [[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(void)appStartNetWork{
[self getAppTheme];
}
/**
@property (nonatomic,strong)NSString *icon_sy_select;
@property (nonatomic,strong)NSString *icon_sy_notselect;
@property (nonatomic,strong)NSString *icon_dt_select;
@property (nonatomic,strong)NSString *icon_dt_notselect;
@property (nonatomic,strong)NSString *icon_xx_select;
@property (nonatomic,strong)NSString *icon_xx_notselect;
@property (nonatomic,strong)NSString *icon_wd_select;
@property (nonatomic,strong)NSString *icon_wd_notselect;
*/
-(void)getAppTheme{
NSString *server = QXGlobal.shareGlobal.currentServer;
NSString *themeUrl = [NSString stringWithFormat:@"%@%@",server,QXAppTheme];
[[QXRequset shareInstance] getWithUrl:themeUrl parameters:@{} needCache:NO success:^(id responseObject) {
[QXConfig defaultConfig];
QXTabbarModel *tabbarIndex1 = QXConfig.shared.tabbarArray[0];
QXTabbarModel *tabbarIndex2 = QXConfig.shared.tabbarArray[1];
QXTabbarModel *tabbarIndex3 = QXConfig.shared.tabbarArray[2];
QXTabbarModel *tabbarIndex4 = QXConfig.shared.tabbarArray[3];
id object = responseObject[@"data"];
NSInteger is_open = 0;
if ([object isKindOfClass:[NSDictionary class]]) {
is_open = [responseObject[@"data"][@"is_open"] integerValue];
}
if (is_open == 1) {
tabbarIndex1.normalImage = @"icon_sy_notselect";
tabbarIndex1.selectedImage = @"icon_sy_select";
tabbarIndex2.normalImage = @"icon_dt_notselect";
tabbarIndex2.selectedImage = @"icon_dt_select";
tabbarIndex3.normalImage = @"icon_xx_notselect";
tabbarIndex3.selectedImage = @"icon_xx_select";
tabbarIndex4.normalImage = @"icon_wd_notselect";
tabbarIndex4.selectedImage = @"icon_wd_select";
QXThemeModel *model = [[QXThemeModel alloc] init];
model.app_home_bg = @"bg_dark";
model.logo_shouye = @"logo_shouye";
model.bg_rmfj = @"bg_rmfj";
model.bg_wdfj = @"bg_wdfj";
model.bg_phb = @"bg_phb";
model.bg_gfgg = @"bg_gfgg";
model.bg_xiaoxi = @"bg_xiaoxi";
model.bg_phb = @"bg_phb";
model.button_qwg = @"button_qwg";
model.bg_light = @"bg_light";
model.icon_wdjz = @"icon_wdjz";
model.icon_dj = @"icon_dj";
model.icon_gxzb = @"icon_gxzb";
model.icon_wdbb = @"icon_wdbb";
model.icon_bzzx = @"icon_bzzx";
model.icon_yq = @"icon_yq";
model.icon_rw = @"icon_rw";
model.icon_yjfk = @"icon_yjfk";
model.icon_gskf = @"icon_gskf";
model.icon_gsrz = @"icon_gsrz";
model.icon_wdgd = @"icon_wdgd";
model.icon_sz = @"icon_sz";
model.tabbarSelectedColor = @"#FF3700";
QXConfig.shared.model =model;
}
// QXThemeModel *model = [QXThemeModel yy_modelWithJSON:responseObject[@"data"]];
// if (model.theme_color && model.theme_color.length > 0) {
// QXConfig.shared.themeColor = [UIColor colorWithHexString:model.theme_color];
// }
//
// if (model.btn_text_color && model.btn_text_color.length > 0) {
// QXConfig.shared.btnTextColor = [UIColor colorWithHexString:model.btn_text_color];
// }
// if (model.app_bg && model.app_bg.length > 0) {
// QXConfig.shared.backgroundImage = model.app_bg;
// }
//
//
// if (model.home_nor && model.home_nor.length > 0) {
// tabbarIndex1.normalImage = model.home_nor;
// }
// if (model.home_sel && model.home_sel.length > 0) {
// tabbarIndex1.selectedImage = model.home_sel;
// }
//
// if (model.find_nor && model.find_nor.length > 0) {
// tabbarIndex2.normalImage = model.find_nor;
// }
// if (model.find_sel && model.find_sel.length > 0) {
// tabbarIndex2.selectedImage = model.find_sel;
// }
//
// if (model.msg_nor && model.msg_nor.length > 0) {
// tabbarIndex3.normalImage = model.msg_nor;
// }
// if (model.msg_sel && model.msg_sel.length > 0) {
// tabbarIndex3.selectedImage = model.msg_sel;
// }
//
// if (model.mine_nor && model.mine_nor.length > 0) {
// tabbarIndex4.normalImage = model.mine_nor;
// }
// if (model.mine_sel && model.mine_sel.length > 0) {
// tabbarIndex4.selectedImage = model.mine_sel;
// }
QXConfig.shared.tabbarArray = @[tabbarIndex1,tabbarIndex2,tabbarIndex3,tabbarIndex4];
AppDelegate *delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
[delegate changeRootViewControllerIsTabbar];
BOOL api_version = [responseObject[@"api_version"] boolValue];
TUIChatConfig.defaultConfig.isAppStore = api_version;
[QXGlobal shareGlobal].isAppStore = api_version;
NSString *clientId = [OpenUDID value];
[[QXManagerMqtt sharedInstance] bindWithUserName:@"public" password:@"" cliendId:clientId isSSL:NO];
NSLog(@"请求成功");
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
NSLog(@"请求失败");
[self alertNetworkError];
QXGlobal.shareGlobal.currentServer = RServerUrl;
QXGlobal.shareGlobal.currentH5Server = RH5ServerUrl;
QXGlobal.shareGlobal.isNeedChangeServer = YES;
}];
}
-(void)loginSuccess{
[self getAppTheme];
}
-(void)alertNetworkError{
MJWeakSelf
UIAlertController *al = [UIAlertController alertControllerWithTitle:@"网络错误" message:@"" preferredStyle:(UIAlertControllerStyleAlert)];
[al addAction:[UIAlertAction actionWithTitle:@"重试" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
[weakSelf getAppTheme];
}]];
[self presentViewController:al animated:YES completion:nil];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end