Commit 3f88980e1678435c7371cc92faf1c2d44229e2ff

Authored by yanglingyu
1 parent 8351c338

增加融媒体联盟

CNLiveCServiceModule/Classes/Model/CNLiveSearchModel.h
... ... @@ -61,6 +61,7 @@ NS_ASSUME_NONNULL_BEGIN
61 61  
62 62 @interface CNLiveSearchHotsModel : NSObject
63 63 @property (nonatomic, copy) NSString *title;
  64 +@property (nonatomic, copy) NSString *subTitle;
64 65 @property (nonatomic, strong) NSArray *lists;
65 66 @property (nonatomic, assign) CGFloat cellHeight;
66 67 ///布局
... ...
CNLiveCServiceModule/Classes/Present/CNLiveServicePresent.m
... ... @@ -52,7 +52,7 @@ static const CGFloat margin = 15;
52 52 {
53 53 CNLiveSearchHotsModel *model1 = nil;
54 54 if (hots && hots.count > 0) {
55   - model1 = [CNLiveServicePresent dealDataSource:hots title:@"热度推荐" cellHeight:0 itemSize:CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 80)showNum:0];
  55 + model1 = [CNLiveServicePresent dealDataSource:hots title:@"热度推荐" subtitle:@"" cellHeight:0 itemSize:CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 80)showNum:0];
56 56 }
57 57  
58 58 NSMutableArray *array2 = [NSMutableArray array];
... ... @@ -95,64 +95,63 @@ static const CGFloat margin = 15;
95 95 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/servingApi/servingPage") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
96 96 CNLiveServiceModel * model = [CNLiveServiceModel mj_objectWithKeyValues:responseObject[@"data"]];
97 97 CNLiveSearchHotsModel *categoryModel = nil;
  98 + NSMutableArray *dataArray = [NSMutableArray array];
98 99 if (model.categories&&[model.categories isKindOfClass:[NSArray class]] && model.categories.count>0) {
99 100 CGFloat cellheight = 160;
100 101 if (model.categories.count <= 4) {
101 102 cellheight = 80;
102 103 }
103   - categoryModel = [CNLiveServicePresent dealDataSource:model.categories title:@"" cellHeight:cellheight itemSize:CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 70)showNum:8];
  104 + categoryModel = [CNLiveServicePresent dealDataSource:model.categories title:@"" subtitle:@"" cellHeight:cellheight itemSize:CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 70)showNum:8];
  105 + if (categoryModel) {
  106 + [dataArray addObject:categoryModel];
  107 + }
104 108 }
105 109 CNLiveSearchHotsModel *serviceModel = nil;
106   - CNLiveSearchHotsModel *mediaModel = nil;
107   - CNLiveSearchHotsModel *chineseModel = nil;
108 110 if (model.allList && model.allList.count > 0) {
109 111 for (NSDictionary *dic in model.allList) {
110   - if ([dic[@"name"] isEqualToString:@"中国服务号"]) {
  112 + @autoreleasepool {
  113 + CGFloat cellheight = 0;
  114 + NSInteger showNum = 0;
  115 + NSString *title = dic[@"name"];
  116 + NSString *subTitle = @"";
  117 + CGSize itemSize = CGSizeMake(0, 0);
111 118 NSArray *lists = dic[@"list"];
112   - if (lists &&[lists isKindOfClass:[NSArray class]] && lists.count > 0) {
113   - CGFloat cellheight = 160;
114   - if (lists.count <= 2) {
115   - cellheight = 90;
116   - }
117   - serviceModel = [CNLiveServicePresent dealDataSource:lists title:dic[@"name"] cellHeight:cellheight itemSize:CGSizeMake((KScreenWidth - 3*margin -10)/2, 60) showNum:4];
  119 + NSString *showTitle = dic[@"category"][@"showTitle"];
  120 + if (![showTitle isKindOfClass:[NSNull class]] && !showTitle.boolValue) {
  121 + title = @"";
118 122 }
119   - }
120   -
121   - if ([dic[@"name"] isEqualToString:@"中国媒体号"]) {
122   - NSArray *lists = dic[@"list"];
123   - if (lists &&[lists isKindOfClass:[NSArray class]] && lists.count > 0) {
124   - CGFloat cellheight = 190;
125   - if (lists.count <= 4) {
126   - cellheight = 105;
127   - }
128   - mediaModel = [CNLiveServicePresent dealDataSource:lists title:dic[@"name"] cellHeight:cellheight itemSize:CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 70) showNum:8];
  123 + if ([dic[@"name"] isEqualToString:@"中国服务号"]) {
  124 + cellheight = 160;
  125 + if (lists.count <= 2) {
  126 + cellheight = 90;
  127 + }
  128 + showNum = 4;
  129 + itemSize = CGSizeMake((KScreenWidth - 3*margin -10)/2, 60);
  130 + }else if ([dic[@"name"] isEqualToString:@"中国媒体号"] || [dic[@"name"] isEqualToString:@"中国网中国号"]) {
  131 + cellheight = 190;
  132 + if (lists.count <= 4) {
  133 + cellheight = 105;
  134 + }
  135 + showNum = 8;
  136 + itemSize = CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 70);
  137 + }else{
  138 + cellheight = 105;
  139 + showNum = 4;
  140 + itemSize = CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 70);
  141 + subTitle = dic[@"category"][@"subTitle"];
129 142 }
130   - }
131   - if ([dic[@"name"] isEqualToString:@"中国网中国号"]) {
132   - NSArray *lists = dic[@"list"];
133 143 if (lists &&[lists isKindOfClass:[NSArray class]] && lists.count > 0) {
134   - CGFloat cellheight = 190;
135   - if (lists.count <= 4) {
136   - cellheight = 105;
137   - }
138   - chineseModel = [CNLiveServicePresent dealDataSource:lists title:dic[@"name"] cellHeight:cellheight itemSize:CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 70) showNum:8];
  144 + serviceModel = [CNLiveServicePresent dealDataSource:dic[@"list"] title:title subtitle:subTitle cellHeight:cellheight itemSize:itemSize showNum:showNum];
  145 + }
  146 + if (serviceModel) {
  147 + [dataArray addObject:serviceModel];
139 148 }
140 149 }
  150 +
141 151 }
142 152 }
143   - NSMutableArray *dataArray = [NSMutableArray array];
144   - if (categoryModel) {
145   - [dataArray addObject:categoryModel];
146   - }
147   - if (serviceModel) {
148   - [dataArray addObject:serviceModel];
149   - }
150   - if (mediaModel) {
151   - [dataArray addObject:mediaModel];
152   - }
153   - if (chineseModel) {
154   - [dataArray addObject:chineseModel];
155   - }
  153 +
  154 +
156 155 if (model) {
157 156 !result?:result(dataArray.copy,model.hots);
158 157 }else{
... ... @@ -162,7 +161,7 @@ static const CGFloat margin = 15;
162 161 }];
163 162 }
164 163  
165   -+ (CNLiveSearchHotsModel *) dealDataSource:(NSArray *)array title:(NSString *)title cellHeight:(CGFloat)cellHeight itemSize:(CGSize) size showNum:(NSInteger)num{
  164 ++ (CNLiveSearchHotsModel *) dealDataSource:(NSArray *)array title:(NSString *)title subtitle:(NSString *)subTitle cellHeight:(CGFloat)cellHeight itemSize:(CGSize) size showNum:(NSInteger)num{
166 165 NSMutableArray *categories = [NSMutableArray array];
167 166 NSMutableArray *squreArray = [NSMutableArray array];
168 167 for (int i = 0; i< array.count ;i++ ) {
... ... @@ -177,6 +176,7 @@ static const CGFloat margin = 15;
177 176 if (num != 0 && (i != 0 || array.count == 1) &&((i + 1)%num == 0 || i == array.count - 1)) {
178 177 NSDictionary *category = @{
179 178 @"title":title,
  179 + @"subTitle":subTitle,
180 180 @"lists":categories.copy,
181 181 @"cellHeight":@(cellHeight),
182 182 @"layout":@{
... ... @@ -192,6 +192,7 @@ static const CGFloat margin = 15;
192 192 if (categories && num !=0 && categories.count == 0) {
193 193 NSDictionary *category = @{
194 194 @"title":title,
  195 + @"subTitle":subTitle,
195 196 @"lists":squreArray.copy,
196 197 @"cellHeight":@(cellHeight),
197 198 @"layout":@{
... ... @@ -204,6 +205,7 @@ static const CGFloat margin = 15;
204 205 }
205 206 NSDictionary *category = @{
206 207 @"title":title,
  208 + @"subTitle":subTitle,
207 209 @"lists":categories.copy,
208 210 @"cellHeight":@(cellHeight),
209 211 @"layout":@{
... ...
CNLiveCServiceModule/Classes/View/CNLiveCycleCell.m
... ... @@ -63,7 +63,7 @@ static NSString *CNServiceOrLookID = @&quot;CNLiveServiceOrLookCell&quot;;
63 63 }
64 64 #pragma mark - UICollectionViewDataSource
65 65 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
66   - if ([self.model.title isEqualToString:@""]) {
  66 + if ([self.model.title isEqualToString:@""] && [self.model.subTitle isEqualToString:@""]) {
67 67 return self.dataSource.count + 2;
68 68 }
69 69 return self.dataSource.count;
... ... @@ -110,7 +110,7 @@ static NSString *CNServiceOrLookID = @&quot;CNLiveServiceOrLookCell&quot;;
110 110 if ([_model.title isEqual:@"中国服务号"]) {
111 111 return UIEdgeInsetsMake(10, 5, 10, 5);
112 112 }
113   - if ([_model.title isEqual:@""]) {
  113 + if ([_model.title isEqual:@""] || ![_model.subTitle isEqualToString:@""]) {
114 114 return UIEdgeInsetsMake(5, 0, 5, 0);
115 115 }
116 116 if ([_model.title isEqual:@"大家都在用"]) {
... ...
CNLiveCServiceModule/Classes/View/CNLiveCycleView.m
... ... @@ -47,7 +47,7 @@ static NSString *CNCycleCellID = @&quot;CNCycleCellID&quot;;
47 47 {
48 48 _model = model;
49 49 self.dataSource = model.lists;
50   - if ([model.title isEqualToString:@"中国媒体号"]||[model.title isEqualToString:@"中国网中国号"]) {
  50 + if ([model.title isEqualToString:@"中国媒体号"]||[model.title isEqualToString:@"中国网中国号"] || (model.subTitle && ![model.subTitle isEqualToString:@""])) {
51 51 self.collectionView.backgroundColor = CNLiveColorWithHexString(@"#F9FAFB");
52 52 self.collectionView.layer.cornerRadius = 5.66;
53 53 }else
... ...
CNLiveCServiceModule/Classes/View/CNLiveServiceChinasCell.m
... ... @@ -9,6 +9,7 @@
9 9 #import "CNLiveCycleView.h"
10 10  
11 11 @interface CNLiveServiceChinasCell()
  12 +@property (nonatomic, strong) UILabel *subTitle;
12 13 @property (nonatomic, strong) CNLiveCycleView *cycleView;
13 14 @end
14 15  
... ... @@ -17,6 +18,7 @@
17 18 {
18 19 self = [super initWithFrame:frame];
19 20 if (self) {
  21 + [self.contentView addSubview:self.subTitle];
20 22 [self.contentView addSubview:self.cycleView];
21 23 [self makeSubViewsLayout];
22 24 }
... ... @@ -24,6 +26,12 @@
24 26 }
25 27 - (void)makeSubViewsLayout
26 28 {
  29 + [self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
  30 + make.top.equalTo(self);
  31 + make.left.equalTo(self.contentView).offset(15);
  32 + make.right.equalTo(self.contentView).offset(-15);
  33 + make.height.offset(20);
  34 + }];
27 35 [self.cycleView mas_makeConstraints:^(MASConstraintMaker *make) {
28 36 make.top.bottom.equalTo(self.contentView);
29 37 make.left.equalTo(self.contentView).offset(15);
... ... @@ -34,16 +42,44 @@
34 42 - (void)setModel:(CNLiveSearchHotsModel *)model
35 43 {
36 44 _model = model;
  45 + if (model.subTitle && ![model.subTitle isEqualToString:@""]) {
  46 + self.subTitle.hidden = NO;
  47 + self.subTitle.text = model.subTitle;
  48 + [self.cycleView mas_remakeConstraints:^(MASConstraintMaker *make) {
  49 + make.top.equalTo(self.subTitle.mas_bottom);
  50 + make.bottom.equalTo(self);
  51 + make.left.equalTo(self.contentView).offset(15);
  52 + make.right.equalTo(self.contentView).offset(-15);
  53 + }];
  54 + }else{
  55 + self.subTitle.hidden = YES;
  56 + [self.cycleView mas_remakeConstraints:^(MASConstraintMaker *make) {
  57 + make.top.bottom.equalTo(self);
  58 + make.left.equalTo(self.contentView).offset(15);
  59 + make.right.equalTo(self.contentView).offset(-15);
  60 + }];
  61 + }
37 62 _cycleView.model = model;
38 63 _cycleView.localizationImageNamesGroup = model.lists;
39 64  
40 65 }
  66 +- (UILabel *)subTitle
  67 +{
  68 + if (!_subTitle) {
  69 + _subTitle = [[UILabel alloc] init];
  70 + _subTitle.font = UIFontMake(14);
  71 + _subTitle.textColor = UIColorHex(#333333);
  72 + _subTitle.backgroundColor = UIColorHex(#FCFDFD);
  73 + }
  74 + return _subTitle;
  75 +}
41 76 - (CNLiveCycleView *)cycleView
42 77 {
43 78 if (!_cycleView) {
44 79 _cycleView = [[CNLiveCycleView alloc] initWithFrame:CGRectZero];
45 80 _cycleView.autoScroll = NO;
46 81 _cycleView.showPageControl = YES;
  82 +
47 83 _cycleView.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;
48 84 _cycleView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
49 85 _cycleView.hidesForSinglePage = YES;
... ...