|
@@ -17,6 +17,7 @@
|
|
|
#import "UserInfoManager.h"
|
|
|
#import "TenantTicketAlert.h"
|
|
|
#import "AppDelegate+AppService.h"
|
|
|
+#import "TenantAlbumModel.h"
|
|
|
|
|
|
@interface TenantDarkViewController ()<TYCyclePagerViewDelegate, TYCyclePagerViewDataSource>
|
|
|
|
|
@@ -44,6 +45,10 @@
|
|
|
|
|
|
@property (nonatomic, assign) BOOL isFirstLoad;
|
|
|
|
|
|
+@property (nonatomic, assign) NSInteger tenantAlbumStatus; // 专辑状态
|
|
|
+
|
|
|
+@property (nonatomic, strong) NSMutableArray *sourceArray; // 分类数据
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation TenantDarkViewController
|
|
@@ -68,9 +73,9 @@
|
|
|
self.isFirstLoad = NO;
|
|
|
[self requestTrackAuth];
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
- (void)requestTrackAuth {
|
|
|
|
|
|
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
@@ -79,6 +84,7 @@
|
|
|
|
|
|
|
|
|
- (void)requestSource {
|
|
|
+ [self requestUserInfo];
|
|
|
[self requestData];
|
|
|
[self requsetTicket];
|
|
|
dispatch_group_notify(self.requestGroup, dispatch_get_main_queue(), ^{
|
|
@@ -86,8 +92,16 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+- (void)requestUserInfo {
|
|
|
+ dispatch_group_enter(self.requestGroup);
|
|
|
+ [USER_MANAGER queryUserInfoCallback:^(UserInfo * _Nonnull userInfo) {
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
+ self.mineInfo = userInfo;
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
- (void)ticketCheck:(NSInteger)count {
|
|
|
- if (self.hasShowTipsView == NO) {
|
|
|
+ if (self.hasShowTipsView == YES) {
|
|
|
return;
|
|
|
}
|
|
|
AppDelegate *appDelegate = [AppDelegate shareAppDelegate];
|
|
@@ -133,10 +147,46 @@
|
|
|
}
|
|
|
|
|
|
- (void)requestData {
|
|
|
+
|
|
|
dispatch_group_enter(self.requestGroup);
|
|
|
- [USER_MANAGER queryUserInfoCallback:^(UserInfo * _Nonnull userInfo) {
|
|
|
+ [KSNetworkingManager userTenantAlbumRecordRequest:KS_POST success:^(NSDictionary * _Nonnull dic) {
|
|
|
dispatch_group_leave(self.requestGroup);
|
|
|
- self.mineInfo = userInfo;
|
|
|
+ if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
|
|
|
+ NSDictionary *parm = [dic ks_dictionaryValueForKey:@"data"];
|
|
|
+ self.tenantAlbumStatus = [parm ks_integerValueForKey:@"tenantAlbumStatus"];
|
|
|
+ NSInteger subjectCount = [parm ks_integerValueForKey:@"subjectCounts"];
|
|
|
+ NSInteger musicCount = [parm ks_integerValueForKey:@"musicCounts"];
|
|
|
+ NSInteger ensembleCount = [parm ks_integerValueForKey:@"ensembleCounts"];
|
|
|
+ NSMutableArray *sourceArray = [NSMutableArray array];
|
|
|
+ NSMutableArray *aniArray = [NSMutableArray array];
|
|
|
+ if (subjectCount > 0) {
|
|
|
+ TenantAlbumModel *model = [[TenantAlbumModel alloc] init];
|
|
|
+ model.subjectType = @"SUBJECT";
|
|
|
+ [sourceArray addObject:model];
|
|
|
+ [aniArray addObject:@"subject_Ani.json"];
|
|
|
+ }
|
|
|
+ if (musicCount > 0) {
|
|
|
+ TenantAlbumModel *model = [[TenantAlbumModel alloc] init];
|
|
|
+ model.subjectType = @"MUSIC";
|
|
|
+ [sourceArray addObject:model];
|
|
|
+ [aniArray addObject:@"singleMusic_Ani.json"];
|
|
|
+ }
|
|
|
+ if (ensembleCount > 0) {
|
|
|
+ TenantAlbumModel *model = [[TenantAlbumModel alloc] init];
|
|
|
+ model.subjectType = @"ENSEMBLE";
|
|
|
+ [sourceArray addObject:model];
|
|
|
+ [aniArray addObject:@"mutiMusic_Ani.json"];
|
|
|
+ }
|
|
|
+ self.sourceArray = [NSMutableArray arrayWithArray:sourceArray];
|
|
|
+ self.animationNameArray = [NSMutableArray arrayWithArray:aniArray];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
+
|
|
|
}];
|
|
|
}
|
|
|
|
|
@@ -151,7 +201,7 @@
|
|
|
}
|
|
|
- (void)refreshView {
|
|
|
self.navView.tenantName.text = [NSString returnNoNullStringWithString:self.mineInfo.tenantName];
|
|
|
- if (self.mineInfo.tenantAlbumStatus == 0) {
|
|
|
+ if (self.tenantAlbumStatus == 0) {
|
|
|
[self showEmptyView];
|
|
|
}
|
|
|
else {
|
|
@@ -212,10 +262,12 @@
|
|
|
|
|
|
#pragma mark ------ TYCyclePagerViewDataSource
|
|
|
- (NSInteger)numberOfItemsInPagerView:(TYCyclePagerView *)pageView {
|
|
|
- if (self.mineInfo && self.mineInfo.tenantAlbumStatus > 0) {
|
|
|
- return 3;
|
|
|
+ if (self.tenantAlbumStatus > 0) {
|
|
|
+ return self.sourceArray.count;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return 0;
|
|
|
}
|
|
|
- return 0;
|
|
|
}
|
|
|
|
|
|
- (__kindof UICollectionViewCell *)pagerView:(TYCyclePagerView *)pagerView cellForItemAtIndex:(NSInteger)index {
|
|
@@ -236,9 +288,11 @@
|
|
|
CGFloat searchHeight = [TenantDarkSearhView getViewHeight];
|
|
|
CGFloat height = (KPortraitHeight - navHeight - searchHeight - kTabBarHeight - 16);
|
|
|
TYCyclePagerViewLayout *layout = [[TYCyclePagerViewLayout alloc] init];
|
|
|
+ CGFloat width = height / 571 * 296;
|
|
|
layout.itemSize = CGSizeMake(height/571*296, height);
|
|
|
layout.itemSpacing = 16.0f;
|
|
|
layout.layoutType = TYCyclePagerTransformLayoutLinear;
|
|
|
+ layout.sectionInset = UIEdgeInsetsMake(0, (KPortraitWidth - width) / 2.0f, 0, (KPortraitWidth - width) / 2.0f);
|
|
|
return layout;;
|
|
|
}
|
|
|
|
|
@@ -250,16 +304,9 @@
|
|
|
[self.navigationController pushViewController:ctrl animated:YES];
|
|
|
}
|
|
|
else { // 跳转到对应页面
|
|
|
- NSString *subjectType = @"";
|
|
|
- if (index == 0) {
|
|
|
- subjectType = @"SUBJECT";
|
|
|
- }
|
|
|
- else if (index == 1) {
|
|
|
- subjectType = @"MUSIC";
|
|
|
- }
|
|
|
- else {
|
|
|
- subjectType = @"ENSEMBLE";
|
|
|
- }
|
|
|
+ TenantAlbumModel *model = self.sourceArray[index];
|
|
|
+ NSString *subjectType = model.subjectType;
|
|
|
+
|
|
|
KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
|
|
|
webCtrl.url = [NSString stringWithFormat:@"%@/#/train-list?subjectType=%@", TENANT_WEBHOST,subjectType];
|
|
|
[self.navigationController pushViewController:webCtrl animated:YES];
|
|
@@ -279,7 +326,7 @@
|
|
|
#pragma mark --- lazying
|
|
|
- (NSMutableArray *)animationNameArray {
|
|
|
if (!_animationNameArray) {
|
|
|
- _animationNameArray = [NSMutableArray arrayWithArray:@[@"subject_Ani.json",@"singleMusic_Ani.json",@"mutiMusic_Ani.json"]];
|
|
|
+ _animationNameArray = [NSMutableArray array];
|
|
|
}
|
|
|
return _animationNameArray;
|
|
|
}
|
|
@@ -287,9 +334,9 @@
|
|
|
if (!_pagerView) {
|
|
|
_pagerView = [[TYCyclePagerView alloc] init];
|
|
|
_pagerView.backgroundColor = [UIColor clearColor];
|
|
|
- _pagerView.isInfiniteLoop = YES;
|
|
|
+ _pagerView.isInfiniteLoop = NO;
|
|
|
|
|
|
- _pagerView.reloadDataNeedResetIndex = YES;
|
|
|
+ _pagerView.reloadDataNeedResetIndex = NO;
|
|
|
_pagerView.delegate = self;
|
|
|
_pagerView.dataSource = self;
|
|
|
[_pagerView registerNib:[UINib nibWithNibName:@"TenantHomeSubjectListCell" bundle:nil] forCellWithReuseIdentifier:@"TenantHomeSubjectListCell"];
|