Steven 3 miesięcy temu
rodzic
commit
f2c380a8a8

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher.xcodeproj/xcshareddata/xcschemes/KulexiuForTeacher.xcscheme

@@ -53,7 +53,7 @@
       </Testables>
    </TestAction>
    <LaunchAction
-      buildConfiguration = "TEST"
+      buildConfiguration = "DEV"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       launchStyle = "0"

+ 103 - 361
KulexiuForTeacher/KulexiuForTeacher/Module/Home/Controller/HomeViewController.m

@@ -34,12 +34,10 @@
 #import "KSHomeButton.h"
 #import "HomeNewHeadView.h"
 
-#import "HomeAlbumView.h"
+#import "HomeNewAlbumView.h"
 #import "HomeAlbumModel.h"
 #import "HomeHotAlbumCell.h"
 
-#import "HomeHotMusicView.h"
-#import "HomeHotMusicCollectionCell.h"
 
 #import "HomeBannerView.h"
 #import <UIButton+WebCache.h>
@@ -49,9 +47,6 @@
 #import "HomeAuthAlertView.h"
 #import "KSAwardAlertView.h"
 
-#import "HomeNewMusicView.h"
-#import "HomeRecommendMusicView.h"
-#import "HomeMusicModel.h"
 
 #import "HomeDragButton.h"
 #import "ToneTuningViewController.h"
@@ -63,6 +58,9 @@
 #import "HomeMusicSheetLayout.h"
 #import "MinePageViewController.h"
 
+#import "HomeMusicPageView.h"
+#import "HomeStatisticsView.h"
+
 #define COLLECTION_WIDTH ((NSInteger)(IS_IPAD ? KPortraitWidth * 0.7 : KPortraitWidth * 0.83))
 #define COLLECTION_HEIGHT (320)
 
@@ -97,7 +95,7 @@
 
 @property (nonatomic, assign) BOOL isFirstLoad;
 
-@property (nonatomic, strong) HomeAlbumView *albumView;
+@property (nonatomic, strong) HomeNewAlbumView *albumView;
 @property (nonatomic, strong) NSMutableArray *albumArray;  // 热门专辑
 @property (nonatomic, strong) UICollectionView *albumCollectionView; // 专辑容器
 @property (nonatomic, assign) CGFloat albumViewHeight; // album 高度
@@ -106,22 +104,6 @@
 
 @property (nonatomic, strong) RecentCourseModel *recentCourseModel;
 
-// 热门曲目
-@property (nonatomic, strong) HomeHotMusicView *hotMusicView;
-@property (nonatomic, strong) UICollectionView *musicCollectionView; // 曲谱容器
-@property (nonatomic, assign) CGFloat hotMusicHeight; // music 高度
-
-// 推荐曲目
-@property (nonatomic, strong) HomeRecommendMusicView *recommendMusicView;
-@property (nonatomic, strong) UICollectionView *recommendMusicCollectionView; // 曲谱容器
-@property (nonatomic, strong) NSMutableArray *recommendMusicArray; // 曲谱数据
-@property (nonatomic, assign) CGFloat recommendMusicViewHeight; // music 高度
-
-// 最新曲目
-@property (nonatomic, strong) HomeNewMusicView *newestMusicView;
-@property (nonatomic, strong) UICollectionView *newestMusicCollectionView; // 曲谱容器
-@property (nonatomic, strong) NSMutableArray *newestMusicArray; // 曲谱数据
-@property (nonatomic, assign) CGFloat newestMusicViewHeight; // music 高度
 
 @property (nonatomic, strong) HomeAuthAlertView *authAlertView;
 
@@ -136,6 +118,14 @@
 // 机构名称
 @property (nonatomic, strong) HomeTenantView *tenantNameView;
 
+@property (nonatomic, strong) HomeMusicPageView *musicPageView;
+
+@property (nonatomic, assign) CGFloat musicPageViewHeight;
+
+@property (nonatomic, strong) HomeStatisticsView *statisticsView;
+
+@property (nonatomic, assign) CGFloat statisticsViewHeight;
+
 @end
 
 @implementation HomeViewController
@@ -259,7 +249,6 @@
     [self refreshButtonView];
     [self refreshCourseView:self.recentCourseModel];
     [self refreshAlbumView];
-    [self refreshMusicView];
 
     // 刷新排序
     if (self.isCheck) {
@@ -532,7 +521,7 @@
 
 - (void)refreshAlbumView {
     if (self.albumArray.count) {
-        self.albumViewHeight = [HomeAlbumView getViewHeight];
+        self.albumViewHeight = [HomeNewAlbumView getViewHeight];
         self.albumView.hidden = NO;
     }
     else {
@@ -545,91 +534,6 @@
     [self.albumCollectionView reloadData];
 }
 
-- (void)requestHomeMusicMessage {
-    dispatch_group_enter(self.requestGroup);
-    [KSNetworkingManager homeAppMusicSheetRequest:KS_POST version:[USER_MANAGER getCurrentVersion] subjectIds:[NSString stringWithFormat:@"%.0f",self.mineInfo.defaultSubject] success:^(NSDictionary * _Nonnull dic) {
-        dispatch_group_leave(self.requestGroup);
-        if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
-            NSDictionary *result = [dic ks_dictionaryValueForKey:@"data"];
-            NSArray *hotMusicSheet = [result ks_arrayValueForKey:@"hotMusicSheet"]; // 热门曲目
-            NSMutableArray *hotArray = [NSMutableArray array];
-            for (NSDictionary *parm in hotMusicSheet) {
-                HomeMusicModel *model = [[HomeMusicModel alloc] initWithDictionary:parm];
-                [hotArray addObject:model];
-            }
-            self.dataArray = [NSMutableArray arrayWithArray:hotArray];
-            
-            NSArray *newMusicSheet = [result ks_arrayValueForKey:@"newMusicSheet"]; // 最新曲目
-            NSMutableArray *newMusicArray = [NSMutableArray array];
-            for (NSDictionary *parm in newMusicSheet) {
-                HomeMusicModel *model = [[HomeMusicModel alloc] initWithDictionary:parm];
-                [newMusicArray addObject:model];
-            }
-            self.newestMusicArray = [NSMutableArray arrayWithArray:newMusicArray];
-            
-            NSArray *topMusicSheet = [result ks_arrayValueForKey:@"topMusicSheet"]; // 推荐曲目
-            NSMutableArray *topMusicArray = [NSMutableArray array];
-            for (NSDictionary *parm in topMusicSheet) {
-                HomeMusicModel *model = [[HomeMusicModel alloc] initWithDictionary:parm];
-                [topMusicArray addObject:model];
-            }
-            self.recommendMusicArray = [NSMutableArray arrayWithArray:topMusicArray];
-        }
-        else {
-            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
-        }
-    } faliure:^(NSError * _Nonnull error) {
-        dispatch_group_leave(self.requestGroup);
-    }];
-}
-
-
-
-
-- (void)refreshMusicView {
-    
-    if (self.recommendMusicArray.count) {
-        self.recommendMusicViewHeight = [HomeHotMusicView getViewHeight];
-        self.recommendMusicView.hidden = NO;
-    }
-    else {
-        self.recommendMusicViewHeight = CGFLOAT_MIN;
-        self.recommendMusicView.hidden = YES;
-    }
-    
-    [self.recommendMusicView mas_updateConstraints:^(MASConstraintMaker *make) {
-        make.height.mas_equalTo(self.recommendMusicViewHeight);
-    }];
-    [self.recommendMusicCollectionView reloadData];
-    
-    if (self.newestMusicArray.count) {
-        self.newestMusicViewHeight = [HomeHotMusicView getViewHeight];
-        self.newestMusicView.hidden = NO;
-    }
-    else {
-        self.newestMusicViewHeight = CGFLOAT_MIN;
-        self.newestMusicView.hidden = YES;
-    }
-    
-    [self.newestMusicView mas_updateConstraints:^(MASConstraintMaker *make) {
-        make.height.mas_equalTo(self.newestMusicViewHeight);
-    }];
-    [self.newestMusicCollectionView reloadData];
-    
-    if (self.dataArray.count) {
-        self.hotMusicHeight = [HomeHotMusicView getViewHeight];
-        self.hotMusicView.hidden = NO;
-    }
-    else {
-        self.hotMusicHeight = CGFLOAT_MIN;
-        self.hotMusicView.hidden = YES;
-    }
-    [self.hotMusicView mas_updateConstraints:^(MASConstraintMaker *make) {
-        make.height.mas_equalTo(self.hotMusicHeight);
-    }];
-    [self.musicCollectionView reloadData];
-}
-
 - (void)configUI {
     CGFloat navHeight = [HomeNavView getViewHeight];
     [self.view addSubview:self.navView];
@@ -722,38 +626,33 @@
     self.headBgView.layer.cornerRadius = 18.0f;
     self.headBgView.layer.maskedCorners = kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner;
     
-    [self.scrollView addSubview:self.albumView];
-    self.albumViewHeight = [HomeAlbumView getViewHeight];
-    [self.albumView mas_makeConstraints:^(MASConstraintMaker *make) {
+    // 统计
+    [self.scrollView addSubview:self.statisticsView];
+    self.statisticsViewHeight = CGFLOAT_MIN;
+    [self.statisticsView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.right.mas_equalTo(self.view);
         make.top.mas_equalTo(self.headBgView.mas_bottom);
-        make.height.mas_equalTo(self.albumViewHeight);
+        make.height.mas_equalTo(self.statisticsViewHeight);
     }];
+    self.statisticsView.hidden = YES;
     
-    [self.scrollView addSubview:self.recommendMusicView];
-    CGFloat recommendMusicHeadHeight = [HomeRecommendMusicView getViewHeight];
-    [self.recommendMusicView mas_makeConstraints:^(MASConstraintMaker *make) {
+    [self.scrollView addSubview:self.albumView];
+    self.albumViewHeight = [HomeNewAlbumView getViewHeight];
+    [self.albumView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.right.mas_equalTo(self.view);
-        make.top.mas_equalTo(self.albumView.mas_bottom);
-        make.height.mas_equalTo(recommendMusicHeadHeight);
+        make.top.mas_equalTo(self.statisticsView.mas_bottom);
+        make.height.mas_equalTo(self.albumViewHeight);
     }];
     
-    [self.scrollView addSubview:self.newestMusicView];
-    CGFloat newMusicHeight = [HomeNewMusicView getViewHeight];
-    [self.newestMusicView mas_makeConstraints:^(MASConstraintMaker *make) {
+    [self.scrollView addSubview:self.musicPageView];
+    self.musicPageViewHeight = [HomeMusicPageView getViewHeight];
+    [self.musicPageView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.right.mas_equalTo(self.view);
-        make.top.mas_equalTo(self.recommendMusicView.mas_bottom);
-        make.height.mas_equalTo(newMusicHeight);
+        make.top.mas_equalTo(self.albumView.mas_bottom);
+        make.height.mas_equalTo(self.musicPageViewHeight);
+        make.bottom.mas_equalTo(self.scrollView.mas_bottom);
     }];
     
-    [self.scrollView addSubview:self.hotMusicView];
-    CGFloat musicHeadHeight = [HomeHotMusicView getViewHeight];
-    [self.hotMusicView mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.right.mas_equalTo(self.view);
-        make.top.mas_equalTo(self.newestMusicView.mas_bottom);
-        make.height.mas_equalTo(musicHeadHeight);
-        make.bottom.mas_equalTo(self.scrollView.mas_bottom).offset(-10);
-    }];
 }
 
 
@@ -769,7 +668,6 @@
     [self requestRecentCourse];
     [self requestNotice];
     [self requestAlbumSource];
-    [self requestHomeMusicMessage];
     [self requestAwardMessage];
     
     dispatch_group_notify(self.requestGroup, dispatch_get_main_queue(), ^{
@@ -1161,72 +1059,14 @@
 }
 
 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
-    if (collectionView == self.albumCollectionView) {
-        return self.albumArray.count;
-    }
-    else if (collectionView == self.recommendMusicCollectionView) {
-        NSInteger lastRowCount = (self.recommendMusicArray.count % 4) > 0 ? 1 : 0;
-        NSInteger count = self.recommendMusicArray.count / 4 + lastRowCount;
-        return count;
-    }
-    else if (collectionView == self.newestMusicCollectionView) {
-        NSInteger lastRowCount = (self.newestMusicArray.count % 4) > 0 ? 1 : 0;
-        NSInteger count = self.newestMusicArray.count / 4 + lastRowCount;
-        return count;
-    }
-    else {
-        NSInteger lastRowCount = (self.dataArray.count % 4) > 0 ? 1 : 0;
-        NSInteger count = self.dataArray.count / 4 + lastRowCount;
-        return count;
-    }
+    return self.albumArray.count;
 }
 
 - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
-    if (collectionView == self.albumCollectionView) {
-        HomeAlbumModel *model = self.albumArray[indexPath.item];
-        HomeHotAlbumCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotAlbumCell" forIndexPath:indexPath];
-        [cell configWithAlbumModel:model];
-        return cell;
-    }
-    else if (collectionView == self.recommendMusicCollectionView) {
-        NSMutableArray *songArray = [NSMutableArray array];
-        NSInteger length = indexPath.item * 4 + 4 > self.recommendMusicArray.count ? self.recommendMusicArray.count - indexPath.item * 4: 4;
-        NSRange range = NSMakeRange(indexPath.item * 4, length);
-        
-        songArray = [NSMutableArray arrayWithArray:[self.recommendMusicArray subarrayWithRange:range]];
-        HomeHotMusicCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotMusicCollectionCell" forIndexPath:indexPath];
-        MJWeakSelf;
-        [cell configWithSourceArray:songArray callback:^(NSString * _Nonnull songId) {
-            [weakSelf displaySongDetail:songId];
-        }];
-        return cell;
-    }
-    else if (collectionView == self.newestMusicCollectionView) {
-        NSMutableArray *songArray = [NSMutableArray array];
-        NSInteger length = indexPath.item * 4 + 4 > self.newestMusicArray.count ? self.newestMusicArray.count - indexPath.item * 4: 4;
-        NSRange range = NSMakeRange(indexPath.item * 4, length);
-        
-        songArray = [NSMutableArray arrayWithArray:[self.newestMusicArray subarrayWithRange:range]];
-        HomeHotMusicCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotMusicCollectionCell" forIndexPath:indexPath];
-        MJWeakSelf;
-        [cell configWithSourceArray:songArray callback:^(NSString * _Nonnull songId) {
-            [weakSelf displaySongDetail:songId];
-        }];
-        return cell;
-    }
-    else {
-        NSMutableArray *songArray = [NSMutableArray array];
-        NSInteger length = indexPath.item * 4 + 4 > self.dataArray.count ? self.dataArray.count - indexPath.item * 4: 4;
-        NSRange range = NSMakeRange(indexPath.item * 4, length);
-        
-        songArray = [NSMutableArray arrayWithArray:[self.dataArray subarrayWithRange:range]];
-        HomeHotMusicCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotMusicCollectionCell" forIndexPath:indexPath];
-        MJWeakSelf;
-        [cell configWithSourceArray:songArray callback:^(NSString * _Nonnull songId) {
-            [weakSelf displaySongDetail:songId];
-        }];
-        return cell;
-    }
+    HomeAlbumModel *model = self.albumArray[indexPath.item];
+    HomeHotAlbumCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotAlbumCell" forIndexPath:indexPath];
+    [cell configWithAlbumModel:model];
+    return cell;
 }
 
 
@@ -1251,9 +1091,9 @@
 }
 
 #pragma mark ----- 专辑
-- (HomeAlbumView *)albumView {
+- (HomeNewAlbumView *)albumView {
     if (!_albumView) {
-        _albumView = [HomeAlbumView shareInstance];
+        _albumView = [HomeNewAlbumView sharedInstance];
         MJWeakSelf;
         [_albumView homeAlbumMore:^{
             [weakSelf moreAlbumDetail];
@@ -1305,169 +1145,6 @@
     [self.navigationController pushViewController:ctrl animated:YES];
 }
 
-#pragma mark --- 推荐曲目
-- (HomeRecommendMusicView *)recommendMusicView {
-    if (!_recommendMusicView) {
-        _recommendMusicView = [HomeRecommendMusicView shareInstance];
-        MJWeakSelf;
-        [_recommendMusicView homeMusicMore:^{
-            [weakSelf moreRecommendMusic];
-        }];
-        [_recommendMusicView.musicContentView addSubview:self.recommendMusicCollectionView];
-        [self.recommendMusicCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.left.right.bottom.top.mas_equalTo(_recommendMusicView.musicContentView);
-        }];
-    }
-    return _recommendMusicView;
-}
-
-- (UICollectionView *)recommendMusicCollectionView {
-    if (!_recommendMusicCollectionView) {
-        HomeMusicSheetLayout *layout = [[HomeMusicSheetLayout alloc] initWithSectionInset:UIEdgeInsetsMake(0, 14, 0, 14) andMiniLineSapce:10 andMiniInterItemSpace:10 andItemSize:CGSizeMake(COLLECTION_WIDTH, COLLECTION_HEIGHT)];
-
-        _recommendMusicCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
-        _recommendMusicCollectionView.backgroundColor = [UIColor clearColor];
-        _recommendMusicCollectionView.delegate = self;
-        _recommendMusicCollectionView.dataSource = self;
-        _recommendMusicCollectionView.showsVerticalScrollIndicator = NO;
-        _recommendMusicCollectionView.showsHorizontalScrollIndicator = NO;
-        _recommendMusicCollectionView.bounces = NO;
-        if (@available(iOS 11.0, *)) {
-            _recommendMusicCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
-        } else {
-            // Fallback on earlier versions
-            if (@available(iOS 13.0, *)) {
-                _recommendMusicCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
-            } else {
-                // Fallback on earlier versions
-            }
-        }
-        [_recommendMusicCollectionView registerNib:[UINib nibWithNibName:@"HomeHotMusicCollectionCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotMusicCollectionCell"];
-    }
-    return _recommendMusicCollectionView;
-}
-
-- (NSMutableArray *)recommendMusicArray {
-    if (!_recommendMusicArray) {
-        _recommendMusicArray  = [NSMutableArray array];
-    }
-    return _recommendMusicArray;
-}
-
-- (void)moreRecommendMusic {
-    KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
-    ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-list"];
-    [self.navigationController pushViewController:ctrl animated:YES];
-}
-
-#pragma mark ---- 最新曲目
-- (HomeNewMusicView *)newestMusicView {
-    if (!_newestMusicView) {
-        if (!_newestMusicView) {
-            _newestMusicView = [HomeNewMusicView shareInstance];
-            MJWeakSelf;
-            [_newestMusicView homeMusicMore:^{
-                [weakSelf moreNewMusic];
-            }];
-            [_newestMusicView.musicContentView addSubview:self.newestMusicCollectionView];
-            [self.newestMusicCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
-                make.left.right.bottom.top.mas_equalTo(_newestMusicView.musicContentView);
-            }];
-        }
-        return _newestMusicView;
-    }
-    return _newestMusicView;
-}
-
-- (UICollectionView *)newestMusicCollectionView {
-    if (!_newestMusicCollectionView) {
-        HomeMusicSheetLayout *layout = [[HomeMusicSheetLayout alloc] initWithSectionInset:UIEdgeInsetsMake(0, 14, 0, 14) andMiniLineSapce:10 andMiniInterItemSpace:10 andItemSize:CGSizeMake(COLLECTION_WIDTH, COLLECTION_HEIGHT)];
-
-        _newestMusicCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
-        _newestMusicCollectionView.backgroundColor = [UIColor clearColor];
-        _newestMusicCollectionView.delegate = self;
-        _newestMusicCollectionView.dataSource = self;
-        _newestMusicCollectionView.showsVerticalScrollIndicator = NO;
-        _newestMusicCollectionView.showsHorizontalScrollIndicator = NO;
-        _newestMusicCollectionView.bounces = NO;
-        if (@available(iOS 11.0, *)) {
-            _newestMusicCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
-        } else {
-            // Fallback on earlier versions
-            if (@available(iOS 13.0, *)) {
-                _newestMusicCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
-            } else {
-                // Fallback on earlier versions
-            }
-        }
-        [_newestMusicCollectionView registerNib:[UINib nibWithNibName:@"HomeHotMusicCollectionCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotMusicCollectionCell"];
-    }
-    return _newestMusicCollectionView;
-}
-
-- (NSMutableArray *)newestMusicArray {
-    if (!_newestMusicArray) {
-        _newestMusicArray = [NSMutableArray array];
-    }
-    return _newestMusicArray;
-}
-
-- (void)moreNewMusic {
-    KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
-    ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-list"];
-    [self.navigationController pushViewController:ctrl animated:YES];
-}
-
-
-#pragma mark ---- 更多曲目
-- (HomeHotMusicView *)hotMusicView {
-    if (!_hotMusicView) {
-        _hotMusicView = [HomeHotMusicView shareInstance];
-        MJWeakSelf;
-        [_hotMusicView homeMusicMore:^{
-            [weakSelf moreHotMusic];
-        }];
-        [_hotMusicView.musicContentView addSubview:self.musicCollectionView];
-        [self.musicCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.left.right.bottom.top.mas_equalTo(_hotMusicView.musicContentView);
-        }];
-    }
-    return _hotMusicView;
-}
-
-
-- (void)moreHotMusic {
-    KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
-    ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-list"];
-    [self.navigationController pushViewController:ctrl animated:YES];
-}
-
-- (UICollectionView *)musicCollectionView {
-    if (!_musicCollectionView) {
-        HomeMusicSheetLayout *layout = [[HomeMusicSheetLayout alloc] initWithSectionInset:UIEdgeInsetsMake(0, 14, 0, 14) andMiniLineSapce:10 andMiniInterItemSpace:10 andItemSize:CGSizeMake(COLLECTION_WIDTH, COLLECTION_HEIGHT)];
-
-        _musicCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
-        _musicCollectionView.backgroundColor = [UIColor clearColor];
-        _musicCollectionView.delegate = self;
-        _musicCollectionView.dataSource = self;
-        _musicCollectionView.showsVerticalScrollIndicator = NO;
-        _musicCollectionView.showsHorizontalScrollIndicator = NO;
-        _musicCollectionView.bounces = NO;
-        if (@available(iOS 11.0, *)) {
-            _musicCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
-        } else {
-            // Fallback on earlier versions
-            if (@available(iOS 13.0, *)) {
-                _musicCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
-            } else {
-                // Fallback on earlier versions
-            }
-        }
-        [_musicCollectionView registerNib:[UINib nibWithNibName:@"HomeHotMusicCollectionCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotMusicCollectionCell"];
-    }
-    return _musicCollectionView;
-}
-
 
 - (HomeBannerView *)bannerView {
     if (!_bannerView) {
@@ -1599,6 +1276,71 @@
     }
     return _tenantNameView;
 }
+
+- (HomeMusicPageView *)musicPageView {
+    if (!_musicPageView) {
+        _musicPageView = [HomeMusicPageView sharedInstance];
+        MJWeakSelf;
+        [_musicPageView pageActionCallback:^(HOME_MUSIC_TAG action) {
+            [weakSelf musicPageAction:action];
+        }];
+    }
+    return _musicPageView;
+}
+
+- (void)musicPageAction:(HOME_MUSIC_TAG)action {
+    NSString *pageType = @"";
+    switch (action) {
+        case HOME_MUSIC_TAG_RECOMMEND:
+        {
+            pageType = @"?type=TOP";
+        }
+            break;
+        case HOME_MUSIC_TAG_HOT:
+        {
+            pageType = @"?type=HOT";
+        }
+            break;
+        case HOME_MUSIC_TAG_NEW:
+        {
+            pageType = @"?type=NEW";
+        }
+            break;
+        case HOME_MUSIC_TAG_MORE:
+        {
+            pageType = @""; // 全部
+        }
+            break;
+        default:
+            pageType = @"";
+            break;
+    }
+    KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
+    ctrl.url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/music-list", pageType];
+    [self.navigationController pushViewController:ctrl animated:YES];
+}
+
+- (HomeStatisticsView *)statisticsView {
+    if (!_statisticsView) {
+        _statisticsView = [HomeStatisticsView sharedInstance];
+        _statisticsView.naviController = self.navigationController;
+        MJWeakSelf;
+        [_statisticsView configWebViewRefreshCallback:^(CGFloat viewHeight) {
+            [weakSelf refreshStatisticView:viewHeight];
+        }];
+    }
+    return _statisticsView;
+}
+
+- (void)refreshStatisticView:(CGFloat)viewHeight {
+    self.statisticsView.hidden = NO;
+    self.statisticsViewHeight = viewHeight;
+    [self.statisticsView mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.left.right.mas_equalTo(self.view);
+        make.top.mas_equalTo(self.headBgView.mas_bottom).offset(12);
+        make.height.mas_equalTo(self.statisticsViewHeight);
+    }];
+}
 /*
 #pragma mark - Navigation
 

+ 49 - 5
KulexiuForTeacher/KulexiuForTeacher/Module/Home/HomeStatistics/HomeStatisticsView.m

@@ -11,6 +11,7 @@
 #import "KSBaseWKWebViewController.h"
 #import "KSWebLoadRefreshView.h"
 #import <AuthChallengeManager.h>
+#import "UserInfoManager.h"
 
 @interface HomeStatisticsView ()<WKUIDelegate,WKNavigationDelegate,WKScriptMessageHandler,UIScrollViewDelegate>
 
@@ -26,7 +27,8 @@
 @implementation HomeStatisticsView
 
 + (instancetype)sharedInstance {
-    HomeStatisticsView *view = [[[NSBundle mainBundle] loadNibNamed:@"HomeStatisticsView" owner:nil options:nil] firstObject];
+    HomeStatisticsView *view = [[HomeStatisticsView alloc] initWithFrame:CGRectZero];
+    view.backgroundColor = [UIColor clearColor];
     return view;
 }
 
@@ -35,7 +37,7 @@
     if (callback) {
         self.callback = callback;
     }
-    self.url = [NSString stringWithFormat:@"%@%@",WEBHOST,@"/#/home-echarts"];
+    _url = [NSString stringWithFormat:@"%@%@",WEBHOST,@"/#/home-statistics"];
     [self addSubview:self.myWebView];
     [self.myWebView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.right.mas_equalTo(self);
@@ -66,6 +68,24 @@
     [self.myWebView loadRequest:request];
 }
 
+- (NSString *)url {
+    if (_url) {
+        if ([_url containsString:@"Authorization="]) {
+            NSRange range = [_url rangeOfString:@"Authorization="];
+            if (range.location != NSNotFound) {
+                _url = [_url substringToIndex:range.location-1];
+            }
+        }
+        NSString *sepectString = [_url containsString:@"?"] ? @"&" : @"?";
+        NSString *tokenStr = UserDefault(TokenKey);
+        if (![NSString isEmptyString:tokenStr]) {
+            NSString *token = [[NSString stringWithFormat:@"Authorization=%@ %@", UserDefault(Token_type), tokenStr] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
+            _url = [NSString stringWithFormat:@"%@%@%@",_url, sepectString, token];
+        }
+    }
+    return _url;
+}
+
 - (NSDictionary *)convertJsonStringToNSDictionary:(NSString *)jsonString {
     if (jsonString == nil) {
         return nil;
@@ -107,9 +127,31 @@
 
         [self.naviController pushViewController:detailCtrl animated:YES];
     }
-//    else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@""]) { // 下载文件
-//        
-//    }
+    else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"getVersion"]) {
+        NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
+        NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
+        [parm setValue:@"getVersion" forKey:@"api"];
+        NSMutableDictionary *content = [NSMutableDictionary dictionary];
+        [content setValue:[USER_MANAGER getCurrentVersion] forKey:@"version"];
+        [content setValue:[valueDic ks_stringValueForKey:@"uuid"] forKey:@"uuid"];
+        [sendParm setValue:content forKey:@"content"];
+        [self postMessage:sendParm];
+    }
+    else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"getToken"]) {
+        NSMutableDictionary *valueDic = [NSMutableDictionary dictionaryWithDictionary:[parm ks_dictionaryValueForKey:@"content"]];
+        [valueDic setValue:UserDefault(Token_type) forKey:@"tokenType"];
+        [valueDic setValue:UserDefault(TokenKey) forKey:@"accessToken"];
+        NSMutableDictionary *sendParm = [NSMutableDictionary dictionaryWithDictionary:parm];
+        [sendParm setValue:valueDic forKey:@"content"];
+        [self postMessage:sendParm];
+    }
+    else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"homeStatisticsHeight"]) { // 高度
+        NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
+        CGFloat height = [valueDic ks_intValueForKey:@"height"];
+        if (self.callback) {
+            self.callback(height);
+        }
+    }
 }
 
 
@@ -138,6 +180,7 @@
         preferences.javaScriptCanOpenWindowsAutomatically = YES;
         config.preferences = preferences;
         _myWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:config];
+        _myWebView.backgroundColor = [UIColor clearColor];
         _myWebView.UIDelegate = self;
         _myWebView.navigationDelegate = self;
         _myWebView.scrollView.bounces = NO;
@@ -147,6 +190,7 @@
         _myWebView.scrollView.showsVerticalScrollIndicator = NO;
         _myWebView.scrollView.showsHorizontalScrollIndicator = NO;
         _myWebView.scrollView.delegate = self;
+        _myWebView.scrollView.scrollEnabled = NO;
     }
     return _myWebView;
 }

+ 27 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Home/View/HomeMusicPageView/HomeMusicPageView.m

@@ -27,6 +27,33 @@
     }
 }
 
+// 更多
+- (IBAction)moreMusic:(id)sender {
+    if (self.callback) {
+        self.callback(HOME_MUSIC_TAG_MORE);
+    }
+}
+// 推荐
+- (IBAction)recommendMusic:(id)sender {
+    if (self.callback) {
+        self.callback(HOME_MUSIC_TAG_RECOMMEND);
+    }
+}
+
+// 热门
+- (IBAction)hotMusic:(id)sender {
+    if (self.callback) {
+        self.callback(HOME_MUSIC_TAG_HOT);
+    }
+}
+
+- (IBAction)newMusic:(id)sender {
+    if (self.callback) {
+        self.callback(HOME_MUSIC_TAG_NEW);
+    }
+}
+
+
 + (CGFloat)getViewHeight {
     CGFloat imageWidth = (KPortraitWidth - 14 * 2 - 12 * 2 - 10 * 2) / 3.0f;
     CGFloat imageHeight = imageWidth / 101.0f * 92.0f;

+ 36 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Home/View/HomeMusicPageView/HomeMusicPageView.xib

@@ -54,6 +54,9 @@
                                 <constraint firstAttribute="height" constant="30" id="Wfu-nR-rKi"/>
                             </constraints>
                             <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                            <connections>
+                                <action selector="moreMusic:" destination="iN0-l3-epB" eventType="touchUpInside" id="fki-pb-0Q9"/>
+                            </connections>
                         </button>
                         <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="home_music_icon" translatesAutoresizingMaskIntoConstraints="NO" id="nbK-4M-Pq7">
                             <rect key="frame" x="12" y="13" width="18" height="18"/>
@@ -73,13 +76,24 @@
                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="home_recommend_music" translatesAutoresizingMaskIntoConstraints="NO" id="FxH-IH-4qd">
                                     <rect key="frame" x="0.0" y="0.0" width="101" height="92"/>
                                 </imageView>
+                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cJb-QJ-rt1">
+                                    <rect key="frame" x="0.0" y="0.0" width="101" height="92"/>
+                                    <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                    <connections>
+                                        <action selector="recommendMusic:" destination="iN0-l3-epB" eventType="touchUpInside" id="S0C-lF-paP"/>
+                                    </connections>
+                                </button>
                             </subviews>
                             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                             <constraints>
+                                <constraint firstAttribute="bottom" secondItem="cJb-QJ-rt1" secondAttribute="bottom" id="4FF-3l-H3w"/>
+                                <constraint firstItem="cJb-QJ-rt1" firstAttribute="leading" secondItem="biR-35-QOg" secondAttribute="leading" id="LH3-SF-Prv"/>
                                 <constraint firstItem="FxH-IH-4qd" firstAttribute="top" secondItem="biR-35-QOg" secondAttribute="top" id="Pr2-fS-9rf"/>
                                 <constraint firstAttribute="trailing" secondItem="FxH-IH-4qd" secondAttribute="trailing" id="STk-1K-UE5"/>
                                 <constraint firstItem="FxH-IH-4qd" firstAttribute="leading" secondItem="biR-35-QOg" secondAttribute="leading" id="bf0-qJ-cau"/>
+                                <constraint firstItem="cJb-QJ-rt1" firstAttribute="top" secondItem="biR-35-QOg" secondAttribute="top" id="fvR-14-e7s"/>
                                 <constraint firstAttribute="width" secondItem="biR-35-QOg" secondAttribute="height" multiplier="101:92" id="m1C-qf-M5D"/>
+                                <constraint firstAttribute="trailing" secondItem="cJb-QJ-rt1" secondAttribute="trailing" id="xbn-F3-cuQ"/>
                                 <constraint firstAttribute="bottom" secondItem="FxH-IH-4qd" secondAttribute="bottom" id="zlb-UD-Kps"/>
                             </constraints>
                         </view>
@@ -89,12 +103,23 @@
                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="home_hot_music" translatesAutoresizingMaskIntoConstraints="NO" id="fhQ-N6-QVv">
                                     <rect key="frame" x="0.0" y="0.0" width="101" height="92"/>
                                 </imageView>
+                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NgJ-z9-vXs">
+                                    <rect key="frame" x="0.0" y="0.0" width="101" height="92"/>
+                                    <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                    <connections>
+                                        <action selector="hotMusic:" destination="iN0-l3-epB" eventType="touchUpInside" id="Dui-Mo-Ous"/>
+                                    </connections>
+                                </button>
                             </subviews>
                             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                             <constraints>
+                                <constraint firstAttribute="trailing" secondItem="NgJ-z9-vXs" secondAttribute="trailing" id="EeK-X5-crA"/>
                                 <constraint firstAttribute="width" secondItem="aKe-lV-Gxm" secondAttribute="height" multiplier="101:92" id="Hxn-yJ-JUp"/>
                                 <constraint firstAttribute="trailing" secondItem="fhQ-N6-QVv" secondAttribute="trailing" id="I67-HH-Wmm"/>
+                                <constraint firstItem="NgJ-z9-vXs" firstAttribute="top" secondItem="aKe-lV-Gxm" secondAttribute="top" id="KVB-mA-y1d"/>
+                                <constraint firstAttribute="bottom" secondItem="NgJ-z9-vXs" secondAttribute="bottom" id="LKX-0b-Ar8"/>
                                 <constraint firstItem="fhQ-N6-QVv" firstAttribute="leading" secondItem="aKe-lV-Gxm" secondAttribute="leading" id="Rzb-J3-heH"/>
+                                <constraint firstItem="NgJ-z9-vXs" firstAttribute="leading" secondItem="aKe-lV-Gxm" secondAttribute="leading" id="U2N-hL-mEK"/>
                                 <constraint firstItem="fhQ-N6-QVv" firstAttribute="top" secondItem="aKe-lV-Gxm" secondAttribute="top" id="qWD-Jk-e8m"/>
                                 <constraint firstAttribute="bottom" secondItem="fhQ-N6-QVv" secondAttribute="bottom" id="rtI-Tb-8oY"/>
                             </constraints>
@@ -105,13 +130,24 @@
                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="home_newest_music" translatesAutoresizingMaskIntoConstraints="NO" id="Hom-x6-dld">
                                     <rect key="frame" x="0.0" y="0.0" width="101" height="92"/>
                                 </imageView>
+                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4o4-S4-qi3">
+                                    <rect key="frame" x="0.0" y="0.0" width="101" height="92"/>
+                                    <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                    <connections>
+                                        <action selector="newMusic:" destination="iN0-l3-epB" eventType="touchUpInside" id="EAb-R8-uUQ"/>
+                                    </connections>
+                                </button>
                             </subviews>
                             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                             <constraints>
                                 <constraint firstAttribute="width" secondItem="jKd-mQ-8sh" secondAttribute="height" multiplier="101:92" id="AJD-jL-7xh"/>
+                                <constraint firstItem="4o4-S4-qi3" firstAttribute="leading" secondItem="jKd-mQ-8sh" secondAttribute="leading" id="H5T-FT-U3H"/>
+                                <constraint firstItem="4o4-S4-qi3" firstAttribute="top" secondItem="jKd-mQ-8sh" secondAttribute="top" id="JuA-bg-vsj"/>
                                 <constraint firstAttribute="bottom" secondItem="Hom-x6-dld" secondAttribute="bottom" id="U1H-IQ-zDz"/>
+                                <constraint firstAttribute="bottom" secondItem="4o4-S4-qi3" secondAttribute="bottom" id="cNj-N8-oxw"/>
                                 <constraint firstAttribute="trailing" secondItem="Hom-x6-dld" secondAttribute="trailing" id="dAA-yu-6j1"/>
                                 <constraint firstItem="Hom-x6-dld" firstAttribute="leading" secondItem="jKd-mQ-8sh" secondAttribute="leading" id="qak-qJ-lBb"/>
+                                <constraint firstAttribute="trailing" secondItem="4o4-S4-qi3" secondAttribute="trailing" id="weW-h1-7QW"/>
                                 <constraint firstItem="Hom-x6-dld" firstAttribute="top" secondItem="jKd-mQ-8sh" secondAttribute="top" id="y5i-Xk-YeN"/>
                             </constraints>
                         </view>