Commit bbf0d3a061296f7856c4aba74566fc12e197bb52

Authored by zhangxiaowen
1 parent 0a024ba9

no message

CNLiveCollectionModule.podspec
... ... @@ -89,4 +89,7 @@ TODO: 网家家-我的模块.
89 89 #类别
90 90 s.dependency 'CNLiveCategory'
91 91  
  92 + #
  93 + s.dependency 'CNLiveCustomUI'
  94 +
92 95 end
... ...
CNLiveCollectionModule/Classes/Controller/CNLiveCollectionController.m
... ... @@ -8,9 +8,16 @@
8 8  
9 9 #import "CNLiveCollectionController.h"
10 10 #import "QMUIKit.h"
  11 +#import "MJExtension.h"
11 12 #import <Masonry/Masonry.h>
12 13 #import <SDWebImage/SDWebImage.h>
13 14 #import "CNLiveCategory.h"
  15 +#import "CNLiveNetworking.h"
  16 +#import "CNLiveEnvironment.h"
  17 +#import "CNUserInfoManager.h"
  18 +
  19 +#import "CNLiveRefreshHeader.h"
  20 +#import "CNLiveRrfreshFooter.h"
14 21  
15 22 #import "CNLiveCollectionNavigationBar.h"
16 23 #import "CNLiveCollectionCell.h"
... ... @@ -22,15 +29,71 @@
22 29 @property (nonatomic, strong) UITableView *tableView;
23 30 @property (nonatomic, strong) NSMutableArray *data;
24 31  
  32 +@property (nonatomic, assign) NSInteger pageNo;
  33 +@property (nonatomic, assign) BOOL isRefreshing;
  34 +
25 35 @end
26 36  
27 37 @implementation CNLiveCollectionController
28 38 static const NSInteger margin = 20;
29 39 static const CGFloat timeValue = 1.5;
30 40 #pragma mark - 数据
31   -- (void)getData{
  41 +- (void)loadData{
  42 + NSDictionary *params = @{
  43 + @"pageSize":@"10",
  44 + @"pageNo":[NSString stringWithFormat:@"%ld",_pageNo],
  45 + @"appId":AppId,
  46 + @"plat":@"i",
  47 + @"sid":CNUserShareModel.uid};
  48 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  49 + [QMUITips showLoadingInView:self.view];
  50 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNDarenCollectListDataSourceUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  51 + [QMUITips hideAllTipsInView:self.view];
  52 + [self hideEmptyView];
  53 +
  54 + if (error) {
  55 + if (self.data.count == 0) {
  56 + if (error.code == -1001||error.code == -1003||error.code == -1009) {
  57 + [self showEmptyViewWithImage:[UIImage imageNamed:@"dd_wlcw"] text:@"无法连接网络" detailText:@"别紧张,试试看刷新页面~" buttonTitle:@" 重试 " buttonAction:@selector(loadData)];
  58 + [self setCNAPIErrorEmptyView];
  59 + self.tableView.mj_footer.hidden = self.data.count == 0;
  60 + }
  61 + }
  62 + return;
  63 + }
  64 + [self.tableView.mj_header endRefreshing];
  65 + [self.tableView.mj_footer endRefreshing];
  66 + if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"0"]) {
  67 + _isRefreshing = NO;
  68 + _pageNo++;
  69 + NSArray *arr = [CNLiveCollectionModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"][@"list"]];
  70 + [self.data addObjectsFromArray:arr];
  71 + if (arr.count < 10) {
  72 + [self.tableView.mj_footer endRefreshingWithNoMoreData];
  73 +
  74 + } else {
  75 + [self.tableView.mj_footer endRefreshing];
  76 +
  77 + }
  78 + }
  79 +
  80 + if (self.data.count == 0) {//显示empty
  81 + [self showEmptyViewWithImage:[UIImage imageNamed:@"zhuangtai_kong"] text:@"您现在没有相关内容哦" detailText:@"" buttonTitle:@"" buttonAction:nil];
  82 + [self setCNNoDataEmptyView];
  83 + self.tableView.tableFooterView = nil;
  84 + }
  85 + self.tableView.mj_footer.hidden = self.data.count == 0;
  86 + [self.tableView reloadData];
  87 +
  88 + }];
32 89  
33 90 }
  91 +- (void)loadMoreData{
  92 + if(!_isRefreshing){
  93 + _isRefreshing = YES;
  94 + [self loadData];
  95 + }
  96 +}
34 97  
35 98 #pragma mark - 生命周期
36 99 - (void)viewWillAppear:(BOOL)animated{
... ... @@ -46,7 +109,9 @@ static const CGFloat timeValue = 1.5;
46 109 else {
47 110 self.automaticallyAdjustsScrollViewInsets = NO;
48 111 }
49   - [self getData];
  112 + _pageNo = 1;
  113 + _isRefreshing = NO;
  114 + [self loadData];
50 115 [self createSubViews];
51 116 }
52 117  
... ... @@ -74,8 +139,8 @@ static const CGFloat timeValue = 1.5;
74 139 #pragma mark - 代理
75 140 #pragma mark - UITableViewDelegate
76 141 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
77   - CNLiveCollectionModel *model = self.data[indexPath.row];
78   - return model.height;
  142 +// CNLiveCollectionModel *model = self.data[indexPath.row];
  143 + return 120.0;
79 144 }
80 145  
81 146 #pragma mark - UITableViewDataSource
... ... @@ -165,7 +230,7 @@ static const CGFloat timeValue = 1.5;
165 230 }
166 231 - (UITableView *)tableView{
167 232 if(!_tableView){
168   - _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop-50) style:UITableViewStylePlain];
  233 + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop) style:UITableViewStylePlain];
169 234 _tableView.delegate = self;
170 235 _tableView.dataSource = self;
171 236 _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
... ... @@ -174,6 +239,14 @@ static const CGFloat timeValue = 1.5;
174 239 _tableView.estimatedSectionHeaderHeight = 0;
175 240 _tableView.estimatedSectionFooterHeight = 0;
176 241 [_tableView registerClass:[CNLiveCollectionCell class] forCellReuseIdentifier:kCNLiveCollectionCell];
  242 + _tableView.mj_header = [CNLiveRefreshHeader headerWithRefreshingBlock:^{
  243 + _pageNo = 1;
  244 + [self loadData];
  245 +
  246 + }];
  247 + _tableView.mj_footer = [CNLiveRrfreshFooter footerWithRefreshingBlock:^{
  248 + [self loadMoreData];
  249 + }];
177 250 }
178 251 return _tableView;
179 252 }
... ...
CNLiveCollectionModule/Classes/Model/CNLiveCollectionModel.h
... ... @@ -16,19 +16,39 @@ typedef NS_ENUM(NSInteger, CNLiveCollectionCellType) {
16 16 CNLiveCollectionCellVideo = 3,
17 17 };
18 18  
19   -@interface CNLiveCollectionModel : NSObject
20   -@property (nonatomic, copy) NSString *name;
21   -@property (nonatomic, copy) NSString *pic;
  19 +@interface CNLiveIcon
  20 +
  21 +@property (nonatomic, copy) NSString *userId;
  22 +@property (nonatomic, copy) NSString *nickName;
  23 +@property (nonatomic, copy) NSString *extInfo;
  24 +@property (nonatomic, copy) NSString *image;
22 25  
23   -@property (nonatomic, copy) NSString *style;
  26 +@property (nonatomic, copy) NSString *state;
  27 +@property (nonatomic, copy) NSString *fansCount;
  28 +@property (nonatomic, copy) NSString *orderCount;
24 29  
25   -@property (nonatomic, strong) NSArray *titles;
26   -@property (nonatomic, strong) NSArray *images;
  30 +@end
27 31  
28   -@property (nonatomic, assign) CNLiveCollectionCellType type;
  32 +@interface CNLiveCollectionModel : NSObject
29 33  
30   -@property (nonatomic, assign) CGFloat height;
31   -@property (nonatomic, assign) CGFloat margin;
  34 +@property (nonatomic, copy) NSString *itemId;
  35 +@property (nonatomic, copy) NSString *img;
  36 +@property (nonatomic, strong) CNLiveIcon *icon;
  37 +@property (nonatomic, copy) NSString *imagePath;
  38 +@property (nonatomic, copy) NSString *thumbnailPath;
  39 +@property (nonatomic, copy) NSString *videoImg;
  40 +@property (nonatomic, copy) NSString *text;
  41 +@property (nonatomic, copy) NSString *videoId;
  42 +@property (nonatomic, copy) NSString *videoPlayUrl;
  43 +@property (nonatomic, copy) NSString *collectionId;
  44 +@property (nonatomic, copy) NSString *type;
  45 +@property (nonatomic, assign) NSInteger time;
  46 +@property (nonatomic, copy) NSString *collectionType;
  47 +@property (nonatomic, copy) NSString * shareUrl;
  48 +@property (nonatomic, copy) NSString *channelName;
  49 +@property (nonatomic, copy) NSString *contentId;
  50 +
  51 +@property (nonatomic, copy) NSMutableAttributedString *attributedString;
32 52  
33 53 @end
34 54  
... ...
CNLiveCollectionModule/Classes/Model/CNLiveCollectionModel.m
... ... @@ -9,53 +9,12 @@
9 9 #import "CNLiveCollectionModel.h"
10 10  
11 11 @implementation CNLiveCollectionModel
12   -static const NSInteger margin = 10;
  12 +//static const NSInteger margin = 10;
13 13  
14   -- (CNLiveCollectionCellType)type{
15   - if([self.style isEqualToString:@"1"]){
16   - return CNLiveCollectionCellTextOnly;
17   - }
18   - else if([self.style isEqualToString:@"2"]){
19   - return CNLiveCollectionCellImageOnly;
20   -
21   - }
22   - else if([self.style isEqualToString:@"3"]){
23   - return CNLiveCollectionCellImageText;
24   -
25   - }
26   - else if([self.style isEqualToString:@"3"]){
27   - return CNLiveCollectionCellVideo;
28   -
29   - }
30   - return CNLiveCollectionCellTextOnly;
31   -}
32   -
33   -- (CGFloat)height{
34   - CGFloat titleHeight = 50;
35   - CGFloat btnHeight = 60;
36   -
37   - //文字
38   - if(self.type == CNLiveCollectionCellTextOnly){
39   - return 2*margin+titleHeight+btnHeight+margin;
40   - }
41   - //图片
42   - else if(self.type == CNLiveCollectionCellImageOnly){
43   - return 2*margin+titleHeight+ceilf(self.titles.count/4.0)*(btnHeight+margin);
44   -
45   - }
46   - //视频
47   - else if(self.type == CNLiveCollectionCellImageText){
48   - // 电票的高度 80
49   - return 2*margin+titleHeight+80+margin;
50   -
51   - }
52   - //视频
53   - else if(self.type == CNLiveCollectionCellVideo){
54   - // 电票的高度 80
55   - return 2*margin+titleHeight+80+margin;
56   -
57   - }
58   - return 0.0000001f;
59   -}
  14 +//+ (NSDictionary *)mj_objectClassInArray{
  15 +// return @{
  16 +// @"icon" : @"CNLiveIcon"
  17 +// };
  18 +//}
60 19  
61 20 @end
... ...
CNLiveCollectionModule/Classes/View/CNLiveCollectionCell.m
... ... @@ -81,6 +81,7 @@ static const NSInteger margin = 10;
81 81 #pragma mark - Data
82 82 - (void)setModel:(CNLiveCollectionModel *)model{
83 83 _model = model;
  84 + [_leftImage sd_setImageWithURL:[NSURL URLWithString:model.imagePath] placeholderImage:nil];
84 85  
85 86 }
86 87 - (void)awakeFromNib {
... ...
Example/CNLiveCollectionModule.xcodeproj/project.pbxproj
... ... @@ -352,6 +352,7 @@
352 352 "${BUILT_PRODUCTS_DIR}/CNLiveCategory/CNLiveCategory.framework",
353 353 "${BUILT_PRODUCTS_DIR}/CNLiveCollectionModule/CNLiveCollectionModule.framework",
354 354 "${BUILT_PRODUCTS_DIR}/CNLiveCommonClass/CNLiveCommonClass.framework",
  355 + "${BUILT_PRODUCTS_DIR}/CNLiveCustomUI/CNLiveCustomUI.framework",
355 356 "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework",
356 357 "${BUILT_PRODUCTS_DIR}/CNLiveManager/CNLiveManager.framework",
357 358 "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework",
... ... @@ -362,6 +363,7 @@
362 363 "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework",
363 364 "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework",
364 365 "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework",
  366 + "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework",
365 367 );
366 368 name = "[CP] Embed Pods Frameworks";
367 369 outputPaths = (
... ... @@ -371,6 +373,7 @@
371 373 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCategory.framework",
372 374 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCollectionModule.framework",
373 375 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonClass.framework",
  376 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCustomUI.framework",
374 377 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework",
375 378 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveManager.framework",
376 379 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework",
... ... @@ -381,6 +384,7 @@
381 384 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework",
382 385 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework",
383 386 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
  387 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework",
384 388 );
385 389 runOnlyForDeploymentPostprocessing = 0;
386 390 shellPath = /bin/sh;
... ...
Example/CNLiveCollectionModule/CNLIVEAppDelegate.m
... ... @@ -10,13 +10,31 @@
10 10 #import "CNLiveCollectionController.h"
11 11 #import "CNLiveEnvironment.h"
12 12 #import "CNUserInfoManager.h"
  13 +#import "CNLiveNetworking.h"
13 14  
14 15 @implementation CNLIVEAppDelegate
  16 +- (void)networkParamAction{
  17 + NSMutableDictionary * mDict = [[NSMutableDictionary alloc] init];
  18 + [mDict setValue:@"10514405" forKey:@"loginSid"];
15 19  
  20 + [mDict setValue:BundleId forKey:@"platform_id"];
  21 +
  22 + [mDict setValue:[[[[UIDevice currentDevice] identifierForVendor] UUIDString] stringByReplacingOccurrencesOfString:@"-" withString:@""] forKey:@"uuid"];
  23 + [mDict setValue:@"i" forKey:@"plat"];
  24 + [mDict setValue:@"1.7.8.19.10.30.15"forKey:@"ver"];
  25 + [mDict setObject:AppId forKey:@"appId"];
  26 + [CNLiveNetworking setupDefaultParam:mDict];
  27 + [CNLiveNetworking setupShowResult:NO];
  28 + [CNLiveNetworking setupSignKey:APPKey];
  29 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  30 + [CNLiveNetworking setResponseSerializerType:CNLiveResponseSerializerJSON];
  31 +
  32 +}
16 33 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
17 34 {
18 35 // Override point for customization after application launch.
19   - [CNLiveEnvironmentManager setEnvironment:CNLiveProductionAppStore];
  36 + [CNLiveEnvironmentManager setEnvironment:CNLiveDebugAppStore];
  37 + [self networkParamAction];
20 38 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];//UIScreen mainScreen].bounds个人理解获取屏幕的硬件信息然后设置尺寸大小
21 39 CNLiveCollectionController *vc = [[CNLiveCollectionController alloc] init];
22 40 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
... ...
Example/CNLiveCollectionModule/CNLiveCollectionModule-Info.plist
... ... @@ -2,6 +2,11 @@
2 2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 3 <plist version="1.0">
4 4 <dict>
  5 + <key>NSAppTransportSecurity</key>
  6 + <dict>
  7 + <key>NSAllowsArbitraryLoads</key>
  8 + <true/>
  9 + </dict>
5 10 <key>CFBundleDevelopmentRegion</key>
6 11 <string>en</string>
7 12 <key>CFBundleDisplayName</key>
... ...