Commit f96206afeb566d7fae6f190e741de9789c9e628d

Authored by yanglingyu
1 parent f2c34735

0.8.3视频号原生化

Showing 26 changed files with 577 additions and 30 deletions
CNLiveVideoClassifyKit.podspec
... ... @@ -8,7 +8,7 @@
8 8  
9 9 Pod::Spec.new do |s|
10 10 s.name = 'CNLiveVideoClassifyKit'
11   - s.version = '0.8.2'
  11 + s.version = '0.8.3'
12 12 s.summary = '视讯头部一二级菜单组件'
13 13  
14 14 # This description is used to generate tags and improve search results.
... ...
CNLiveVideoClassifyKit/Assets/CNLiveVideoClassifyKit.xcassets/Witness/witness_video_type.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "图层 4@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "图层 4@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
... ...
CNLiveVideoClassifyKit/Assets/CNLiveVideoClassifyKit.xcassets/Witness/witness_video_type.imageset/图层 4@2x.png 0 → 100644

3.47 KB

CNLiveVideoClassifyKit/Assets/CNLiveVideoClassifyKit.xcassets/Witness/witness_video_type.imageset/图层 4@3x.png 0 → 100644

6.85 KB

CNLiveVideoClassifyKit/Assets/CNLiveVideoClassifyKit.xcassets/classify/classify_person.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "个人主页@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "个人主页@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
... ...
CNLiveVideoClassifyKit/Assets/CNLiveVideoClassifyKit.xcassets/classify/classify_person.imageset/个人主页@2x.png 0 → 100644

1.77 KB

CNLiveVideoClassifyKit/Assets/CNLiveVideoClassifyKit.xcassets/classify/classify_person.imageset/个人主页@3x.png 0 → 100644

2.96 KB

CNLiveVideoClassifyKit/Assets/CNLiveVideoClassifyKit.xcassets/classify/classify_search.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "搜索@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "搜索@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
... ...
CNLiveVideoClassifyKit/Assets/CNLiveVideoClassifyKit.xcassets/classify/classify_search.imageset/搜索@2x.png 0 → 100644

1.74 KB

CNLiveVideoClassifyKit/Assets/CNLiveVideoClassifyKit.xcassets/classify/classify_search.imageset/搜索@3x.png 0 → 100644

2.98 KB

CNLiveVideoClassifyKit/Classes/CNVideoList/Controller/CNVideoListsDetailController.h 0 → 100644
  1 +//
  2 +// CNVideoListsDetailController.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by iOS on 2023/1/29.
  6 +//
  7 +typedef NS_ENUM(NSUInteger , CNVideoDetailType) {
  8 + CNVideoDetailTypeFollowd = 0, //关注页
  9 + CNVideoDetailTypeRecommoned = 1, //推荐页
  10 +};
  11 +#import <CNLiveBusinessBaseModule/CNLiveBusinessBaseModule.h>
  12 +
  13 +NS_ASSUME_NONNULL_BEGIN
  14 +
  15 +@interface CNVideoListsDetailController : CNCommonViewController<JXCategoryListContentViewDelegate>
  16 +/// 初始化
  17 +/// @param type 页面类型
  18 +- (instancetype)initWithPageType:(CNVideoDetailType)type;
  19 +@end
  20 +
  21 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/CNVideoList/Controller/CNVideoListsDetailController.m 0 → 100644
  1 +//
  2 +// CNVideoListsDetailController.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by iOS on 2023/1/29.
  6 +//
  7 +
  8 +#import "CNVideoListsDetailController.h"
  9 +#import "CNWitnessSearchPresent.h"
  10 +#import "CNWitnessSearchVideoCell.h"
  11 +#import "CNWitnessSearchModel.h"
  12 +#import "CNCollectionViewLayout.h"
  13 +#import "CNLiveListManager.h"
  14 +#import "CNVideoListsPresent.h"
  15 +#import "CNVideoListsModel.h"
  16 +
  17 +static NSString *const CNWitnessSearchVideoCellID = @"CNWitnessSearchVideoCell";
  18 +
  19 +@interface CNVideoListsDetailController ()<UICollectionViewDelegate,UICollectionViewDataSource,CNWaterFallLayoutDelegate>
  20 +@property (nonatomic, assign)CNVideoDetailType type;
  21 +@property (nonatomic, strong)NSString *ts;
  22 +@property (nonatomic, strong)UICollectionView *collectionView;
  23 +@property (nonatomic, assign)NSInteger page;//请求页数
  24 +@property (nonatomic, strong)NSMutableArray *dataSource;
  25 +@property (nonatomic, strong)NSMutableArray *videoIDArray;
  26 +
  27 +@end
  28 +
  29 +@implementation CNVideoListsDetailController
  30 +
  31 +- (void)requestData{
  32 + if (![CNLiveNetworking isNetworking] && self.dataSource.count == 0) {
  33 + self.collectionView.mj_footer.hidden = YES;
  34 + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"dd_wlcw"] text:@"网络开小差了,刷新试试" detailText:@"" buttonTitle:@" 刷新 " buttonAction:@selector(requestData)];
  35 + [self setCNAPIErrorEmptyView];
  36 + return;
  37 + }
  38 + weakself
  39 + [QMUITips showLoadingInView:self.view];
  40 + [CNWitnessSearchPresent requestSearchVideoListWithTS:self.ts type:self.type == CNVideoDetailTypeRecommoned ?@"1":@"2" searchType:1 tagId:@"" keyword:@"" page:self.page responseBlock:^(NSArray *dataArray, BOOL isLastPage, NSString *error) {
  41 + [QMUITips hideAllTips];
  42 + [weakSelf.collectionView.mj_footer endRefreshing];
  43 + [weakSelf.collectionView.mj_header endRefreshing];
  44 + if (error) {
  45 + if (weakSelf.page == 1) {
  46 + weakSelf.collectionView.mj_footer.hidden = YES;
  47 + [weakSelf showEmptyViewWithImage:[UIImage loadBundleImage:@"wufalianjie"] text:@"接口开小差了,试试重新请求" detailText:@"" buttonTitle:@" 重试 " buttonAction:@selector(requestData)];
  48 + [weakSelf setCNAPIErrorEmptyView];
  49 + return;
  50 + }
  51 + [QMUITips showWithText:error inView:self.view hideAfterDelay:1.5];
  52 + return;
  53 + }
  54 + if (weakSelf.page == 1 && dataArray == 0) {
  55 + weakSelf.collectionView.mj_footer.hidden = YES;
  56 + [weakSelf showEmptyViewWithImage:[UIImage loadBundleImage:@"zw_zt"] text:@"未搜索到相关内容哦" detailText:@"" buttonTitle:NULL buttonAction:NULL];
  57 + [weakSelf setCNAPIErrorEmptyView];
  58 + return;
  59 + }
  60 + weakSelf.collectionView.mj_footer.hidden = NO;
  61 + if (isLastPage) {
  62 + [weakSelf.collectionView.mj_footer endRefreshingWithNoMoreData];
  63 + }
  64 + [self.emptyView removeFromSuperview];
  65 + [self.dataSource addObjectsFromArray:dataArray];
  66 + [dataArray enumerateObjectsUsingBlock:^(CNWitnessSearchDetailModel *model, NSUInteger idx, BOOL * _Nonnull stop) {
  67 + [weakSelf.videoIDArray addObject:model.pid];
  68 + }];
  69 + [self.collectionView reloadData];
  70 + }];
  71 +}
  72 +- (void)requestGetpage{
  73 + weakself
  74 + [CNVideoListsPresent getDataWithPageId:@"2843" completionBlock:^(CNVideoListsModel * _Nonnull model) {
  75 + [weakSelf.videoIDArray insertObject:model.blockId atIndex:0];
  76 + CNWitnessSearchDetailModel *videoModel = [[CNWitnessSearchDetailModel alloc] init];
  77 + videoModel.title = model.blockName;
  78 + videoModel.poster = model.blockIcon;
  79 + videoModel.isHorizontalScreen = 0;
  80 + videoModel.pid = model.blockId;
  81 + videoModel.hidenPerson = YES;
  82 + [weakSelf.dataSource insertObject:videoModel atIndex:0];
  83 + [weakSelf.collectionView reloadData];
  84 + }];
  85 +}
  86 +- (void)dealloc
  87 +{
  88 + [[NSNotificationCenter defaultCenter] removeObserver:self];
  89 + NSLog(@"CNWitnessSearchDetailController++++++销毁了");
  90 +}
  91 +- (instancetype)initWithPageType:(CNVideoDetailType)type
  92 +{
  93 + if (self = [super init]) {
  94 + self.type = type;
  95 + self.page = 1;
  96 + }
  97 + return self;
  98 +}
  99 +
  100 +- (void)viewDidLoad {
  101 + [super viewDidLoad];
  102 + [self requestData];
  103 + if (self.type == CNVideoDetailTypeRecommoned) {
  104 + [self requestGetpage];
  105 + }
  106 + [self.view addSubview:self.collectionView];
  107 + [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  108 + make.top.bottom.right.left.equalTo(self.view);
  109 + }];
  110 + //点赞
  111 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoChangeWithParam:) name:@"WjjWitnessLikeStatusNotification" object:nil];
  112 + //关注
  113 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoFocuseChange:) name:@"WjjAttentionUserStatusToJSNotification" object:nil];
  114 + //评论
  115 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoCommentsChange:) name:WjjWitnessCommentNumberUpdateNotification object:nil];
  116 + //分享
  117 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoShareChange:) name:WjjWitnessShareNotification object:nil];
  118 + //收藏
  119 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoCollectChange:) name:WjjWitnessCollectStatusNotification object:nil];
  120 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlaySuccess:) name:WjjVideoPaySuccessNotification object:nil];
  121 +
  122 +}
  123 +- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
  124 + return YES;
  125 +}
  126 +#pragma mark - KVO||Notification
  127 +- (void)videoCollectChange:(NSNotification *)noti{
  128 + NSString *pid = [noti.userInfo objectForKey:@"contentId"];
  129 + if ([self.videoIDArray containsObject:pid]) {
  130 + NSInteger index = [self.videoIDArray indexOfObject:pid];
  131 + CNWitnessSearchDetailModel *model = self.dataSource[index];
  132 + NSString *selected = [noti.userInfo objectForKey:@"selected"];
  133 + model.tool.collectioned = [selected isEqualToString:@"true"];
  134 + if (model.tool.collectioned) {
  135 + model.tool.collectionNum += 1;
  136 + }else{
  137 + model.tool.collectionNum -= 1;
  138 + }
  139 + }
  140 +}
  141 +- (void)videoShareChange:(NSNotification *)noti{
  142 + NSString *pid = [noti.userInfo objectForKey:@"contentId"];
  143 + if ([self.videoIDArray containsObject:pid]) {
  144 + NSInteger index = [self.videoIDArray indexOfObject:pid];
  145 + CNWitnessSearchDetailModel *model = self.dataSource[index];
  146 + model.tool.shareNum += 1;
  147 + }
  148 +}
  149 +- (void)videoCommentsChange:(NSNotification *)noti{
  150 + NSString *pid = [noti.userInfo objectForKey:@"contentId"];
  151 + if ([self.videoIDArray containsObject:pid]) {
  152 + NSInteger index = [self.videoIDArray indexOfObject:pid];
  153 + CNWitnessSearchDetailModel *model = self.dataSource[index];
  154 + model.tool.commentsNum = [noti.userInfo stringForKey:@"number"].integerValue;
  155 + }
  156 +}
  157 +- (void)videoFocuseChange:(NSNotification *)noti{
  158 + NSString *pid = [noti.userInfo objectForKey:@"contentId"];
  159 + if ([self.videoIDArray containsObject:pid]) {
  160 + NSInteger index = [self.videoIDArray indexOfObject:pid];
  161 + CNWitnessSearchDetailModel *model = self.dataSource[index];
  162 + NSString *focused = [noti.userInfo objectForKey:@"focused"];
  163 + model.icon.focused = [focused isEqualToString:@"true"];
  164 + }
  165 +}
  166 +- (void)videoChangeWithParam:(NSNotification *)noti{
  167 + if ([noti.userInfo boolForKey:@"isCurrent"]) {
  168 + return;
  169 + }
  170 + NSString *pid = [noti.userInfo objectForKey:@"contentId"];
  171 + if ([self.videoIDArray containsObject:pid]) {
  172 + NSInteger index = [self.videoIDArray indexOfObject:pid];
  173 + NSString *selected = [noti.userInfo objectForKey:@"selected"];
  174 + NSString *likesNumber = [noti.userInfo objectForKey:@"likesNum"];
  175 + CNWitnessSearchDetailModel *model = self.dataSource[index];
  176 + model.tool.liked = [selected isEqualToString:@"true"];
  177 + model.tool.likesNum = likesNumber.integerValue;
  178 + [self.collectionView reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:index inSection:0]]];
  179 + }
  180 +}
  181 +- (void)videoPlaySuccess:(NSNotification *)noti{
  182 + NSString *productId = [noti.userInfo objectForKey:@"productId"];
  183 + [self.dataSource enumerateObjectsUsingBlock:^(CNWitnessSearchDetailModel *detailModel, NSUInteger idx, BOOL * _Nonnull stop) {
  184 + if ([detailModel.product.productId isEqualToString:productId]) {
  185 + detailModel.product.check = @"1";
  186 + }
  187 + }];
  188 +}
  189 +#pragma mark - UICollectionViewDelegate
  190 +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  191 + CNWitnessSearchDetailModel *model = self.dataSource[indexPath.row];
  192 + if (model.hidenPerson) {
  193 + [CNVideoListsPresent getBlockContentsWithBlockId:model.pid completionBlock:^(NSArray * _Nonnull array, NSString * _Nonnull errorStr) {
  194 + if (errorStr) {
  195 + [QMUITips showWithText:errorStr];
  196 + return;
  197 + }
  198 + [CNLiveClassifyJumpBridge openVideoPlayerVCWithCurrentIndex:@"0" dataList:array];
  199 + }];
  200 + }else{
  201 + CNWitnessSearchDetailModel *recommendModel = self.dataSource[0];
  202 + if (recommendModel.hidenPerson){
  203 + [self.dataSource removeFirstObject];
  204 + }
  205 + NSArray *dicArray = [NSDictionary mj_keyValuesArrayWithObjectArray:self.dataSource];
  206 + [CNLiveClassifyJumpBridge openVideoPlayerVCWithCurrentIndex:[NSString stringWithFormat:@"%ld",indexPath.row] dataList:dicArray.copy];
  207 + }
  208 +}
  209 +#pragma mark - UICollectionViewDataSource
  210 +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  211 + return self.dataSource.count;
  212 +}
  213 +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  214 + CNWitnessSearchVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNWitnessSearchVideoCellID forIndexPath:indexPath];
  215 + cell.model = self.dataSource[indexPath.row];
  216 + return cell;
  217 +
  218 +}
  219 +#pragma mark - CNWaterFallLayoutDelegate
  220 +//通过代理得到每个item 的一个高度
  221 +- (CGFloat)collectionViewLayout:(CNCollectionViewLayout*)layout heightAtIndexPath:(NSIndexPath*)indexPath{
  222 + CNWitnessSearchDetailModel *model = self.dataSource[indexPath.row];
  223 + CGFloat oneHeight = [@"北" heightForFont:UIFontMake(15) width:(kScreenWidth-33)/2-20];
  224 + CGFloat totalHeight = [model.title heightForFont:UIFontMake(15) width:(kScreenWidth-33)/2-20];
  225 + if (totalHeight > oneHeight *2) {
  226 + totalHeight = oneHeight *2;
  227 + }
  228 + if (model.hidenPerson) {
  229 + return 270 + totalHeight;
  230 + }
  231 + if (model.isHorizontalScreen == 1) {
  232 + return 192 + totalHeight;
  233 + }
  234 + else{
  235 + return 290 + totalHeight;
  236 + }
  237 +}
  238 +
  239 +#pragma mark - Getting
  240 +- (UICollectionView *)collectionView
  241 +{
  242 + if (!_collectionView) {
  243 + CNCollectionViewLayout *layout = [[CNCollectionViewLayout alloc] init];
  244 + layout.delegate = self;
  245 + layout.colCount = 2;
  246 + layout.colSpace = 9;
  247 + layout.lineSpace = 9;
  248 + layout.sectionInsets = UIEdgeInsetsMake(12, 12, 0, 12);
  249 + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  250 + _collectionView.backgroundColor = UIColorWhite;
  251 + _collectionView.delegate = self;
  252 + _collectionView.dataSource = self;
  253 + _collectionView.showsVerticalScrollIndicator = NO;
  254 + [_collectionView registerClass:[CNWitnessSearchVideoCell class] forCellWithReuseIdentifier:CNWitnessSearchVideoCellID];
  255 + weakself
  256 + _collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  257 + weakSelf.page ++;
  258 + [weakSelf requestData];
  259 + }];
  260 + _collectionView.mj_header = [CNLiveRefreshHeader headerWithRefreshingBlock:^{
  261 + [weakSelf.dataSource removeAllObjects];
  262 + [weakSelf.videoIDArray removeAllObjects];
  263 + [weakSelf requestData];
  264 + if (weakSelf.type == CNVideoDetailTypeRecommoned) {
  265 + [weakSelf requestGetpage];
  266 + }
  267 + }];
  268 + }
  269 + return _collectionView;
  270 +}
  271 +- (NSMutableArray *)dataSource
  272 +{
  273 + if (!_dataSource) {
  274 + _dataSource = [NSMutableArray array];
  275 + }
  276 + return _dataSource;
  277 +}
  278 +- (NSMutableArray *)videoIDArray{
  279 + if (!_videoIDArray) {
  280 + _videoIDArray = [NSMutableArray array];
  281 + }
  282 + return _videoIDArray;
  283 +}
  284 +#pragma mark - JXCategoryListContentViewDelegate
  285 +- (UIView *)listView{
  286 + return self.view;
  287 +}
  288 +
  289 +@end
... ...
CNLiveVideoClassifyKit/Classes/CNVideoList/Model/CNVideoListsModel.h 0 → 100644
  1 +//
  2 +// CNVideoListsModel.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by iOS on 2023/1/31.
  6 +//
  7 +
  8 +#import <Foundation/Foundation.h>
  9 +
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@interface CNVideoListsModel : NSObject
  13 +@property (nonatomic, copy) NSString *blockId;
  14 +@property (nonatomic, copy) NSString *blockName;
  15 +@property (nonatomic, copy) NSString *moreUrl;
  16 +@property (nonatomic, copy) NSString *contentType;
  17 +@property (nonatomic, copy) NSString *time;
  18 +@property (nonatomic, copy) NSString *type;
  19 +@property (nonatomic, copy) NSString *background;
  20 +@property (nonatomic, copy) NSString *blockIcon;
  21 +@property (nonatomic, copy) NSString *showType;
  22 +@property (nonatomic, copy) NSString *rowNum;
  23 +@property (nonatomic, copy) NSString *blockSubTitle;
  24 +@property (nonatomic, copy) NSString *linkType;
  25 +@property (nonatomic, copy) NSString *moreType;
  26 +
  27 +@property (nonatomic, strong) NSArray *contents;
  28 +
  29 +@end
  30 +
  31 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/CNVideoList/Model/CNVideoListsModel.m 0 → 100644
  1 +//
  2 +// CNVideoListsModel.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by iOS on 2023/1/31.
  6 +//
  7 +
  8 +#import "CNVideoListsModel.h"
  9 +
  10 +@implementation CNVideoListsModel
  11 +
  12 +@end
... ...
CNLiveVideoClassifyKit/Classes/CNVideoList/Present/CNVideoListsPresent.h 0 → 100644
  1 +//
  2 +// CNVideoListsPresent.h
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by iOS on 2023/1/31.
  6 +//
  7 +
  8 +#import <Foundation/Foundation.h>
  9 +@class CNVideoListsModel;
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNVideoListsPresent : NSObject
  14 ++ (void)getDataWithPageId:(NSString *)pageId completionBlock:(void(^)(CNVideoListsModel *model))response;
  15 ++ (void)getBlockContentsWithBlockId:(NSString *)blockId completionBlock:(void(^)(NSArray *array,NSString *errorStr))response;
  16 +@end
  17 +
  18 +NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/CNVideoList/Present/CNVideoListsPresent.m 0 → 100644
  1 +//
  2 +// CNVideoListsPresent.m
  3 +// CNLiveVideoClassifyKit
  4 +//
  5 +// Created by iOS on 2023/1/31.
  6 +//
  7 +
  8 +#import "CNVideoListsPresent.h"
  9 +#import "CNVideoListsModel.h"
  10 +
  11 +@implementation CNVideoListsPresent
  12 ++ (void)getDataWithPageId:(NSString *)pageId completionBlock:(void(^)(CNVideoListsModel *model))response{
  13 +
  14 + NSDictionary *params = @{@"pageId":@"2843",//@"2843",@"38"
  15 + @"userId":CNUserShareModel.uid};
  16 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  17 + [CNLiveNetworking setupShowDataResult:YES];//是否只要data字段数据
  18 + [CNLiveNetworking setupShowResult:YES];
  19 + //http://cmstest.cnlive.com:8768/contentApi/getPage?pageId=38&userId=353417
  20 + //http://cms.cnlive.com:8768/ CNGetClassifyPageUrl
  21 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNGetClassifyPageUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  22 + if (responseObject && [responseObject isKindOfClass:[NSArray class]]) {
  23 + CNVideoListsModel *model = [CNVideoListsModel mj_objectWithKeyValues:responseObject[0]];
  24 + if (response) {
  25 + response(model);
  26 + }
  27 + }
  28 + }];
  29 +}
  30 ++ (void)getBlockContentsWithBlockId:(NSString *)blockId completionBlock:(nonnull void (^)(NSArray * _Nonnull, NSString * _Nonnull))response{
  31 + NSDictionary *params = @{
  32 + @"blockId": @"9",
  33 + @"userId":CNUserShareModel.uid?CNUserShareModel.uid:@"",
  34 + @"type":@"1",
  35 + @"page":@"1",
  36 + @"pageSize":@"10"
  37 + };
  38 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  39 + [CNLiveNetworking setupShowDataResult:NO];
  40 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/contentApi/getBlockContents") Param:params CacheType:NO CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  41 + NSString*errorMessage = nil;
  42 + NSArray *array = nil;
  43 + if (error) {
  44 + errorMessage = @"服务器连接错误,请稍后再试";
  45 + }else{
  46 + if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
  47 + NSDictionary *data = responseObject[@"data"];
  48 + if (data && [data isKindOfClass:[NSDictionary class]]) {
  49 + NSArray *dataArray = data[@"list"];
  50 + if (dataArray &&[dataArray isKindOfClass:[NSArray class]]) {
  51 + array = dataArray;
  52 + }
  53 + }
  54 + }
  55 + if (!array) {
  56 + errorMessage = @"数据错误,请确定为最新版本";
  57 + }
  58 + }
  59 + if (response) {
  60 + response(array,errorMessage);
  61 + }
  62 + }];
  63 +}
  64 +@end
... ...
CNLiveVideoClassifyKit/Classes/ClassifyCategory/Header/CNLivevideoClassifyPCH.h
... ... @@ -7,6 +7,30 @@
7 7  
8 8 #ifndef CNLivevideoClassifyPCH_h
9 9 #define CNLivevideoClassifyPCH_h
  10 +//关注
  11 +#ifndef WjjAttentionUserStatusToJSNotification
  12 +#define WjjAttentionUserStatusToJSNotification @"WjjAttentionUserStatusToJSNotification"
  13 +#endif
  14 +//评论
  15 +#ifndef WjjWitnessCommentNumberUpdateNotification
  16 +#define WjjWitnessCommentNumberUpdateNotification @"WjjWitnessCommentNumberUpdateNotification"
  17 +#endif
  18 +//分享
  19 +#ifndef WjjWitnessShareNotification
  20 +#define WjjWitnessShareNotification @"WjjWitnessShareNotification"
  21 +#endif
  22 +//点赞
  23 +#ifndef WjjWitnessLikeStatusNotification
  24 +#define WjjWitnessLikeStatusNotification @"WjjWitnessLikeStatusNotification"
  25 +#endif
  26 +//收藏
  27 +#ifndef WjjWitnessCollectStatusNotification
  28 +#define WjjWitnessCollectStatusNotification @"WjjWitnessCollectStatusNotification"
  29 +#endif
  30 +//付费视频
  31 +#ifndef WjjVideoPaySuccessNotification
  32 +#define WjjVideoPaySuccessNotification @"WjjVideoPaySuccessNotification"
  33 +#endif
10 34  
11 35 #import <JXCategoryView/JXCategoryTitleImageView.h>
12 36 #import <CNLiveBaseKit/CNLiveBaseKit.h>
... ...
CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.h
... ... @@ -28,6 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
28 28 /// 用户信息变动,修改关注状态
29 29 /// @param jsonStr 返回参数
30 30 + (void)personMessageChange:(NSString *)jsonStr;
  31 +/// 跳转短视频列表页
  32 ++ (void)pushVideoLists;
31 33 @end
32 34  
33 35 NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.m
... ... @@ -9,6 +9,7 @@
9 9 #import "CNLiveClassifySegmentController.h"
10 10 #import "CNWitnessSearchViewController.h"
11 11 #import "CNWitnessSearchModel.h"
  12 +#import "CNVideoListsController.h"
12 13  
13 14 @interface CNLiveListManager()
14 15 {
... ... @@ -59,4 +60,8 @@
59 60 {
60 61 [CNLiveListManager shareListManager].personMessage = [jsonStr mj_JSONObject];
61 62 }
  63 ++ (void)pushVideoLists{
  64 + CNVideoListsController *vc = [[CNVideoListsController alloc] init];
  65 + [[BaseAppDelegate sharedAppDelegate] pushViewController:vc];
  66 +}
62 67 @end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/Model/CNWitnessSearchModel.h
... ... @@ -94,6 +94,7 @@ NS_ASSUME_NONNULL_BEGIN
94 94 @property (nonatomic, strong)NSDictionary *block;
95 95 @property (nonatomic, strong)CNAmuseContentProductModel *product;
96 96  
  97 +@property (nonatomic, assign)BOOL hidenPerson;//隐藏用户信息
97 98 @end
98 99  
99 100 NS_ASSUME_NONNULL_END
... ...
CNLiveVideoClassifyKit/Classes/SearchView/Present/CNWitnessSearchPresent.h
... ... @@ -30,7 +30,7 @@
30 30 /// @param keyword 搜索关键词
31 31 /// @param page 页数
32 32 /// @param responseBlock 返回
33   -+ (void)requestSearchVideoListWithTS:(NSString *)ts searchType:(NSInteger)searchType tagId:(NSString *)tagId keyword:(NSString *)keyword page:(NSInteger)page responseBlock:(void (^)(NSArray *dataArray ,BOOL isLastPage, NSString *error))responseBlock;
  33 ++ (void)requestSearchVideoListWithTS:(NSString *)ts type:(NSString *)type searchType:(NSInteger)searchType tagId:(NSString *)tagId keyword:(NSString *)keyword page:(NSInteger)page responseBlock:(void (^)(NSArray *dataArray ,BOOL isLastPage, NSString *error))responseBlock;
34 34 /// 视频点赞
35 35 /// @param pid 未知
36 36 /// @param contentSid 未知
... ...
CNLiveVideoClassifyKit/Classes/SearchView/Present/CNWitnessSearchPresent.m
... ... @@ -56,13 +56,13 @@
56 56 return modelArray;
57 57 }
58 58  
59   -+ (void)requestSearchVideoListWithTS:(NSString *)ts searchType:(NSInteger)searchType tagId:(NSString *)tagId keyword:(NSString *)keyword page:(NSInteger)page responseBlock:(void (^)(NSArray *, BOOL, NSString *))responseBlock{
  59 ++ (void)requestSearchVideoListWithTS:(NSString *)ts type:(NSString *)type searchType:(NSInteger)searchType tagId:(NSString *)tagId keyword:(NSString *)keyword page:(NSInteger)page responseBlock:(void (^)(NSArray *, BOOL, NSString *))responseBlock{
60 60 NSDictionary *params = @{
61 61 @"ts":ts?ts:@"",
62 62 @"userId":CNUserShareModelUid,
63 63 @"keyword":keyword?keyword:@"",
64 64 @"searchType":@(searchType),
65   - @"type":@"1",
  65 + @"type":type,
66 66 @"tagId":tagId?tagId:@"",
67 67 @"page":@(page),
68 68 @"pageSize":@(10)
... ...
CNLiveVideoClassifyKit/Classes/SearchView/View/CNWitnessSearchVideoCell.m
... ... @@ -18,6 +18,7 @@
18 18 @property (nonatomic, strong)UIImageView *authInfoImage;
19 19 @property (nonatomic, strong)UILabel *nameLabel;
20 20 @property (nonatomic, strong)QMUIButton *likeBtn;
  21 +@property (nonatomic, strong)UIImageView *typeImageView;
21 22 @end
22 23  
23 24 @implementation CNWitnessSearchVideoCell
... ... @@ -31,6 +32,7 @@
31 32 [self.bgView addSubview:self.authInfoImage];
32 33 [self.bgView addSubview:self.nameLabel];
33 34 [self.bgView addSubview:self.likeBtn];
  35 + [self.bgView addSubview:self.typeImageView];
34 36 [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
35 37 make.top.bottom.left.right.equalTo(self.contentView);
36 38 }];
... ... @@ -38,6 +40,10 @@
38 40 make.top.left.right.equalTo(self.contentView);
39 41 make.height.mas_equalTo(242);
40 42 }];
  43 + [self.typeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  44 + make.right.top.equalTo(self.contentView);
  45 + make.width.height.mas_equalTo(29);
  46 + }];
41 47 [self.playImage mas_makeConstraints:^(MASConstraintMaker *make) {
42 48 make.top.equalTo(self.contentView).offset(9);
43 49 make.right.equalTo(self.contentView).offset(-9);
... ... @@ -129,6 +135,19 @@
129 135 [self.authInfoImage sd_setImageWithURL:[NSURL URLWithString:authModel.icon]];
130 136 }
131 137 [self.likeBtn sizeToFit];
  138 + self.playImage.hidden = self.logoImage.hidden = self.authInfoImage.hidden = self.likeBtn.hidden = self.nameLabel.hidden = model.hidenPerson;
  139 + self.typeImageView.hidden = !model.hidenPerson;
  140 + if (model.hidenPerson) {
  141 + [self.videoImage mas_updateConstraints:^(MASConstraintMaker *make) {
  142 + make.top.equalTo(self.contentView).offset(3);
  143 + make.right.equalTo(self.contentView).offset(-3);
  144 + }];
  145 + }else{
  146 + [self.videoImage mas_updateConstraints:^(MASConstraintMaker *make) {
  147 + make.top.equalTo(self.contentView);
  148 + make.right.equalTo(self.contentView);
  149 + }];
  150 + }
132 151 }
133 152 #pragma mark - Getting
134 153 - (UIView *)bgView{
... ... @@ -211,4 +230,11 @@
211 230 }
212 231 return _likeBtn;
213 232 }
  233 +- (UIImageView *)typeImageView{
  234 + if (!_typeImageView) {
  235 + _typeImageView = [[UIImageView alloc] initWithImage:[UIImage loadBundleImage:@"witness_video_type"]];
  236 +
  237 + }
  238 + return _typeImageView;
  239 +}
214 240 @end
... ...
CNLiveVideoClassifyKit/Classes/SearchView/ViewController/CNWitnessSearchDetailController.m
... ... @@ -12,30 +12,7 @@
12 12 #import "CNWitnessSearchModel.h"
13 13 #import "CNCollectionViewLayout.h"
14 14 #import "CNLiveListManager.h"
15   -//关注
16   -#ifndef WjjAttentionUserStatusToJSNotification
17   -#define WjjAttentionUserStatusToJSNotification @"WjjAttentionUserStatusToJSNotification"
18   -#endif
19   -//评论
20   -#ifndef WjjWitnessCommentNumberUpdateNotification
21   -#define WjjWitnessCommentNumberUpdateNotification @"WjjWitnessCommentNumberUpdateNotification"
22   -#endif
23   -//分享
24   -#ifndef WjjWitnessShareNotification
25   -#define WjjWitnessShareNotification @"WjjWitnessShareNotification"
26   -#endif
27   -//点赞
28   -#ifndef WjjWitnessLikeStatusNotification
29   -#define WjjWitnessLikeStatusNotification @"WjjWitnessLikeStatusNotification"
30   -#endif
31   -//收藏
32   -#ifndef WjjWitnessCollectStatusNotification
33   -#define WjjWitnessCollectStatusNotification @"WjjWitnessCollectStatusNotification"
34   -#endif
35   -//付费视频
36   -#ifndef WjjVideoPaySuccessNotification
37   -#define WjjVideoPaySuccessNotification @"WjjVideoPaySuccessNotification"
38   -#endif
  15 +
39 16 static NSString *const CNWitnessSearchVideoCellID = @"CNWitnessSearchVideoCell";
40 17 static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell";
41 18 @interface CNWitnessSearchDetailController ()<UICollectionViewDelegate,UICollectionViewDataSource,CNWaterFallLayoutDelegate,UIGestureRecognizerDelegate>
... ... @@ -58,7 +35,7 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell
58 35 }
59 36 weakself
60 37 [QMUITips showLoadingInView:self.view];
61   - [CNWitnessSearchPresent requestSearchVideoListWithTS:self.ts searchType:self.type + 1 tagId:self.tagId keyword:self.searchStr page:self.page responseBlock:^(NSArray *dataArray, BOOL isLastPage, NSString *error) {
  38 + [CNWitnessSearchPresent requestSearchVideoListWithTS:self.ts type:@"1" searchType:self.type + 1 tagId:self.tagId keyword:self.searchStr page:self.page responseBlock:^(NSArray *dataArray, BOOL isLastPage, NSString *error) {
62 39 [QMUITips hideAllTips];
63 40 [weakSelf.collectionView.mj_footer endRefreshing];
64 41 if (error) {
... ...
Example/CNLiveVideoClassifyKit.xcodeproj/project.pbxproj
... ... @@ -198,6 +198,7 @@
198 198 6003F5B5195388D20070C39A /* Tests */ = {
199 199 isa = PBXGroup;
200 200 children = (
  201 + 81D25E332984C11200809E7A /* View */,
201 202 6003F5BB195388D20070C39A /* Tests.m */,
202 203 6003F5B6195388D20070C39A /* Supporting Files */,
203 204 );
... ... @@ -235,6 +236,13 @@
235 236 path = Pods;
236 237 sourceTree = "<group>";
237 238 };
  239 + 81D25E332984C11200809E7A /* View */ = {
  240 + isa = PBXGroup;
  241 + children = (
  242 + );
  243 + path = View;
  244 + sourceTree = "<group>";
  245 + };
238 246 /* End PBXGroup section */
239 247  
240 248 /* Begin PBXNativeTarget section */
... ...
Example/CNLiveVideoClassifyKit/CNLIVEViewController.m
... ... @@ -45,7 +45,7 @@
45 45 [BHConfig set:ChannelsSelectFirst value:@"0"];
46 46 [CNTools GetClassifyChannelsUrlsAndSave];
47 47 self.title = @"首页";
48   - segArr = @[@"分类",@"搜索",@"搜索文字"];
  48 + segArr = @[@"分类",@"搜索",@"搜索文字",@"短视频"];
49 49 [self.view addSubview:self.collectionView];
50 50 }
51 51 -(void)viewDidAppear:(BOOL)animated
... ... @@ -85,6 +85,9 @@
85 85 [CNLiveListManager pushWitnessSearchVCWithSearchStr:@{@"tagId":@"1",@"tagName":@"爆料"}];
86 86 }
87 87 break;
  88 + case 3:{
  89 + [CNLiveListManager pushVideoLists];
  90 + }break;
88 91 default:
89 92 break;
90 93 }
... ...