Commit 40a8c565e85a3a2f228680fed9b73ba165d92b9f

Authored by 王军波
1 parent 5ef3a431

加载数据

LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -190,6 +190,8 @@
190 190 D29E81ED1E88DC5B008C9906 /* PriChatCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D29E81EC1E88DC5B008C9906 /* PriChatCell.m */; };
191 191 D2A089E81E89FA720071412C /* LVCUGCLivePlayerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089E71E89FA720071412C /* LVCUGCLivePlayerCell.m */; };
192 192 D2A089EB1E8A09CB0071412C /* LVCUGCLivePlayerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089EA1E8A09CB0071412C /* LVCUGCLivePlayerModel.m */; };
  193 + D2A089EE1E8A336A0071412C /* LiveLIstService.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089ED1E8A336A0071412C /* LiveLIstService.m */; };
  194 + D2A089F11E8A41120071412C /* LVCUGCLiveListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089F01E8A41120071412C /* LVCUGCLiveListModel.m */; };
193 195 D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A803071E80BD6F009D6F1C /* TopToolView.m */; };
194 196 D2B2ED7A1E88F90C00F7538A /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2D236B21E88F8E600B7C517 /* CNLiveChatManager.framework */; };
195 197 D2B2ED7B1E88F90C00F7538A /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D2D236B21E88F8E600B7C517 /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
... ... @@ -617,6 +619,10 @@
617 619 D2A089E71E89FA720071412C /* LVCUGCLivePlayerCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLivePlayerCell.m; sourceTree = "<group>"; };
618 620 D2A089E91E8A09CB0071412C /* LVCUGCLivePlayerModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLivePlayerModel.h; sourceTree = "<group>"; };
619 621 D2A089EA1E8A09CB0071412C /* LVCUGCLivePlayerModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLivePlayerModel.m; sourceTree = "<group>"; };
  622 + D2A089EC1E8A336A0071412C /* LiveLIstService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiveLIstService.h; sourceTree = "<group>"; };
  623 + D2A089ED1E8A336A0071412C /* LiveLIstService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LiveLIstService.m; sourceTree = "<group>"; };
  624 + D2A089EF1E8A41120071412C /* LVCUGCLiveListModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLiveListModel.h; sourceTree = "<group>"; };
  625 + D2A089F01E8A41120071412C /* LVCUGCLiveListModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLiveListModel.m; sourceTree = "<group>"; };
620 626 D2A803061E80BD6F009D6F1C /* TopToolView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopToolView.h; sourceTree = "<group>"; };
621 627 D2A803071E80BD6F009D6F1C /* TopToolView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopToolView.m; sourceTree = "<group>"; };
622 628 D2B2ED7E1E88FC5200F7538A /* LVCUGCLiveEndView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLiveEndView.h; sourceTree = "<group>"; };
... ... @@ -737,6 +743,8 @@
737 743 81A4831F1E88F4BF0097A80A /* LVCProgramModel.m */,
738 744 81A482FF1E88B0130097A80A /* LVCChatRoomModel.h */,
739 745 81A483001E88B0130097A80A /* LVCChatRoomModel.m */,
  746 + D2A089EF1E8A41120071412C /* LVCUGCLiveListModel.h */,
  747 + D2A089F01E8A41120071412C /* LVCUGCLiveListModel.m */,
740 748 D2A089E91E8A09CB0071412C /* LVCUGCLivePlayerModel.h */,
741 749 D2A089EA1E8A09CB0071412C /* LVCUGCLivePlayerModel.m */,
742 750 );
... ... @@ -1633,6 +1641,8 @@
1633 1641 81A483161E88BED00097A80A /* LVCTVLiveViewController.m */,
1634 1642 81A483181E88E19C0097A80A /* LVCMoreProgramViewController.h */,
1635 1643 81A483191E88E19C0097A80A /* LVCMoreProgramViewController.m */,
  1644 + D2A089EC1E8A336A0071412C /* LiveLIstService.h */,
  1645 + D2A089ED1E8A336A0071412C /* LiveLIstService.m */,
1636 1646 );
1637 1647 path = Controller;
1638 1648 sourceTree = "<group>";
... ... @@ -1885,6 +1895,7 @@
1885 1895 8130911E1E84C0F0005F0BFF /* LVCMessage.m in Sources */,
1886 1896 D23696841E7FC6A900E4BF71 /* chatListCell.m in Sources */,
1887 1897 D2029CAF1E6EADE10027CD92 /* MJRefreshStateHeader.m in Sources */,
  1898 + D2A089EE1E8A336A0071412C /* LiveLIstService.m in Sources */,
1888 1899 D2029C941E6EADE10027CD92 /* UIRefreshControl+AFNetworking.m in Sources */,
1889 1900 D2029C911E6EADE10027CD92 /* UIButton+AFNetworking.m in Sources */,
1890 1901 D2029C931E6EADE10027CD92 /* UIProgressView+AFNetworking.m in Sources */,
... ... @@ -1956,6 +1967,7 @@
1956 1967 D2029C991E6EADE10027CD92 /* MJFoundation.m in Sources */,
1957 1968 D2575C461E76857100E3A8FC /* LVCAnimationManager.m in Sources */,
1958 1969 D2029C8A1E6EADE10027CD92 /* AFURLRequestSerialization.m in Sources */,
  1970 + D2A089F11E8A41120071412C /* LVCUGCLiveListModel.m in Sources */,
1959 1971 D2029D041E6EAE2E0027CD92 /* UILabel+ContentSize.m in Sources */,
1960 1972 D25530031E79115100DF38A5 /* AnimQueueManager.m in Sources */,
1961 1973 D2029C871E6EADE10027CD92 /* AFHTTPSessionManager.m in Sources */,
... ...
LiveVideoCloud/LiveVideoCloud/Classes/SDK/AFNetworking/AFURLResponseSerialization.m
... ... @@ -223,7 +223,7 @@ static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingO
223 223 return nil;
224 224 }
225 225  
226   - self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
  226 + self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", @"text/plain", nil];
227 227  
228 228 return self;
229 229 }
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCUGCLiveListController.m
... ... @@ -7,7 +7,8 @@
7 7 //
8 8  
9 9 #import "LVCUGCLiveListController.h"
10   -#import "CommonCrypto/CommonDigest.h"
  10 +#import "LiveLIstService.h"
  11 +#import "LVCUGCLiveListModel.h"
11 12  
12 13 @interface LVCUGCLiveListController ()
13 14  
... ... @@ -24,67 +25,19 @@
24 25  
25 26 - (void)loadData {
26 27  
27   - NSInteger time = [[NSDate date] timeIntervalSince1970];
28   - NSString *timeString = [NSString stringWithFormat:@"%ld", (long)time];
29   - NSMutableDictionary *parameter=[@{@"platform_id": [NSBundle mainBundle].bundleIdentifier,
30   - @"timestamp": timeString,
31   - @"appId": AppId} mutableCopy];
32   - NSString *string = [NSString stringWithFormat:@"%@&key=%@", [self sortParameters:parameter], AppKey];
33   - NSString *signString = [[self sha1:string] uppercaseString];
34   - [parameter setObject:signString forKey:@"sign"];
35   -
36   - [[AFHTTPSessionManager manager] GET:@"http://api.cnlive.com/open/api2/live_epg/sp/activityList4App" parameters:parameter progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
  28 + [LiveLIstService getLiveListWithHandler:^(id data, NSError *error) {
37 29  
38   - NSLog(@"%@",responseObject);
  30 + if (error) {
  31 + NSLog(@"error:%@",error);
  32 + return ;
  33 + }
  34 + NSLog(@"data%@",data);
39 35  
40   - } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
  36 + LVCUGCLiveListModel *model = [LVCUGCLiveListModel modelWithDic:data];
41 37  
42   - NSLog(@"%@",error);
  38 + NSLog(@"%@",model.activityList);
43 39 }];
44   -
45   -}
46 40  
47   -//sha1加密
48   -- (NSString*)sha1:(NSString *)string
49   -{
50   - NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
51   -
52   - uint8_t digest[CC_SHA1_DIGEST_LENGTH];
53   -
54   - CC_SHA1(data.bytes, data.length, digest);
55   -
56   - NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
57   -
58   - for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
59   - [output appendFormat:@"%02x", digest[i]];
60   -
61   - while ([[output substringToIndex:1] isEqualToString:@"0"]) {
62   - output = [[NSMutableString alloc] initWithString:[output substringFromIndex:1]];
63   - }
64   -
65   - return output;
66   -}
67   -//参数排序
68   -- (NSString *)sortParameters:(NSDictionary*)parameters
69   -{
70   - //对所有传入参数按照字段名的 ASCII 码从小到大排序
71   - NSArray *keyArr=[parameters allKeys];
72   - NSArray *arr = [keyArr sortedArrayUsingSelector:@selector(compare:)];
73   -
74   - NSMutableString *string1 = [[NSMutableString alloc]init];
75   - for (int i=0; i<arr.count; i++) {
76   -
77   - NSString *parametersString = parameters[[arr objectAtIndex:i]];
78   - if (parametersString.length > 0) {
79   - [string1 appendString:[NSString stringWithFormat:@"%@=%@&",[arr objectAtIndex:i],parameters[[arr objectAtIndex:i]]]];
80   - }
81   - }
82   -
83   - if (string1.length > 0) {
84   - [string1 deleteCharactersInRange:NSMakeRange(string1.length-1, 1)];
85   - }
86   -
87   - return string1;
88 41 }
89 42  
90 43 - (void)didReceiveMemoryWarning {
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LiveLIstService.h 0 → 100644
  1 +//
  2 +// LiveLIstService.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/3/28.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "HttpService.h"
  10 +
  11 +@interface LiveLIstService : HttpService
  12 ++ (NSURLSessionDataTask *)getLiveListWithHandler:(completionHandler)handler;
  13 +
  14 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LiveLIstService.m 0 → 100644
  1 +//
  2 +// LiveLIstService.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/3/28.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LiveLIstService.h"
  10 +#import "CommonCrypto/CommonDigest.h"
  11 +
  12 +@implementation LiveLIstService
  13 +
  14 ++ (NSURLSessionDataTask *)getLiveListWithHandler:(completionHandler)handler
  15 +{
  16 + NSInteger time = [[NSDate date] timeIntervalSince1970];
  17 + NSString *timeString = [NSString stringWithFormat:@"%ld", (long)time];
  18 + NSMutableDictionary *parameter=[@{@"platform_id": [NSBundle mainBundle].bundleIdentifier,
  19 + @"timestamp": timeString,
  20 + @"appId": @"60_irn9edco29"} mutableCopy];
  21 + NSString *string = [NSString stringWithFormat:@"%@&key=%@", [self sortParameters:parameter], @"69fe70bda67e059286ad509d9f5377f815955645b52f94"];
  22 + NSString *signString = [[self sha1:string] uppercaseString];
  23 + [parameter setObject:signString forKey:@"sign"];
  24 +
  25 + NSMutableDictionary *params = parameter.mutableCopy;
  26 + completionHandler compleionHandler = ^(id data,NSError *error) {
  27 + handler(data,error);
  28 + };
  29 + return [[HttpService service] sendRequestWithHttpMethod:E_HTTP_REQUEST_METHOD_GET URLPath:[ZXServerUrl getLiveListURL] parameters:params completionHandler:compleionHandler];
  30 +}
  31 +
  32 +//sha1加密
  33 ++ (NSString*)sha1:(NSString *)string
  34 +{
  35 + NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
  36 +
  37 + uint8_t digest[CC_SHA1_DIGEST_LENGTH];
  38 +
  39 + CC_SHA1(data.bytes, data.length, digest);
  40 +
  41 + NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
  42 +
  43 + for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
  44 + [output appendFormat:@"%02x", digest[i]];
  45 +
  46 + while ([[output substringToIndex:1] isEqualToString:@"0"]) {
  47 + output = [[NSMutableString alloc] initWithString:[output substringFromIndex:1]];
  48 + }
  49 +
  50 + return output;
  51 +}
  52 +//参数排序
  53 ++ (NSString *)sortParameters:(NSDictionary*)parameters
  54 +{
  55 + //对所有传入参数按照字段名的 ASCII 码从小到大排序
  56 + NSArray *keyArr=[parameters allKeys];
  57 + NSArray *arr = [keyArr sortedArrayUsingSelector:@selector(compare:)];
  58 +
  59 + NSMutableString *string1 = [[NSMutableString alloc]init];
  60 + for (int i=0; i<arr.count; i++) {
  61 +
  62 + NSString *parametersString = parameters[[arr objectAtIndex:i]];
  63 + if (parametersString.length > 0) {
  64 + [string1 appendString:[NSString stringWithFormat:@"%@=%@&",[arr objectAtIndex:i],parameters[[arr objectAtIndex:i]]]];
  65 + }
  66 + }
  67 +
  68 + if (string1.length > 0) {
  69 + [string1 deleteCharactersInRange:NSMakeRange(string1.length-1, 1)];
  70 + }
  71 +
  72 + return string1;
  73 +}
  74 +
  75 +
  76 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Model/LVCUGCLiveListModel.h 0 → 100644
  1 +//
  2 +// LVCUGCLiveListModel.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/3/28.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "BaseModel.h"
  10 +
  11 +@class LVCUGCLivePlayerModel;
  12 +@interface LVCUGCLiveListModel : BaseModel
  13 +
  14 +@property (nonatomic ,copy) NSString * _Nullable totalCount;
  15 +@property (nonatomic ,copy) NSString * _Nullable nextCursor;
  16 +@property (nonatomic ,copy) NSArray <LVCUGCLivePlayerModel *> * _Nullable activityList;
  17 +@property (nonatomic ,copy) NSString * _Nullable preCursor;
  18 +
  19 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Model/LVCUGCLiveListModel.m 0 → 100644
  1 +//
  2 +// LVCUGCLiveListModel.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/3/28.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCUGCLiveListModel.h"
  10 +
  11 +@implementation LVCUGCLiveListModel
  12 +
  13 +- (void)loadModel
  14 +{
  15 + [super loadModel];
  16 +
  17 + [LVCUGCLiveListModel mj_setupObjectClassInArray:^NSDictionary *{
  18 + return @{@"activityList":@"LVCUGCLivePlayerModel"};
  19 + // return @{@"list":[SearchRecomListModel class]};二选一
  20 + }];
  21 +}
  22 +
  23 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Model/LVCUGCLivePlayerModel.h
... ... @@ -7,7 +7,21 @@
7 7 //
8 8  
9 9 #import <Foundation/Foundation.h>
  10 +#import "BaseModel.h"
10 11  
11   -@interface LVCUGCLivePlayerModel : NSObject
  12 +@interface LVCUGCLivePlayerModel : BaseModel
  13 +
  14 +@property (nonatomic ,copy) NSString * _Nullable startTime;
  15 +@property (nonatomic ,copy) NSString * _Nullable isHorizontalScreen;
  16 +@property (nonatomic ,copy) NSString * _Nullable activityId;
  17 +@property (nonatomic ,copy) NSString * _Nullable createTime;
  18 +@property (nonatomic ,copy) NSString * _Nullable coverImgUrl;
  19 +@property (nonatomic ,copy) NSString * _Nullable channelId;
  20 +@property (nonatomic ,copy) NSString * _Nullable activityStatus;
  21 +@property (nonatomic ,copy) NSString * _Nullable rates;
  22 +@property (nonatomic ,copy) NSString * _Nullable activityCategory;
  23 +@property (nonatomic ,copy) NSString * _Nullable endTime;
  24 +@property (nonatomic ,copy) NSString * _Nullable extensions;
  25 +@property (nonatomic ,copy) NSString * _Nullable activityName;
12 26  
13 27 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Model/LVCUGCLivePlayerModel.m
... ... @@ -10,4 +10,10 @@
10 10  
11 11 @implementation LVCUGCLivePlayerModel
12 12  
  13 +- (void)loadModel
  14 +{
  15 + [super loadModel];
  16 +
  17 +}
  18 +
13 19 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCLivePlayerCell.h
... ... @@ -8,6 +8,7 @@
8 8  
9 9 #import <UIKit/UIKit.h>
10 10 #import "LVCUGCPlayerLoadingView.h"
  11 +#import "LVCUGCLivePlayerModel.h"
11 12  
12 13 @interface LVCUGCLivePlayerCell : UICollectionViewCell
13 14  
... ... @@ -15,4 +16,6 @@
15 16  
16 17 @property (nonatomic, strong) CNLiveMoviePlayerController *player; // 播放器
17 18  
  19 +@property (nonatomic, strong) LVCUGCLivePlayerModel *model;
  20 +
18 21 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCLivePlayerCell.m
... ... @@ -22,6 +22,15 @@
22 22 return self;
23 23 }
24 24  
  25 +#pragma mark - SetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  26 +- (void)setModel:(LVCUGCLivePlayerModel *)model {
  27 +
  28 + if (_model != model) {
  29 + _model = model;
  30 + }
  31 +
  32 +}
  33 +
25 34 #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26 35 - (LVCUGCPlayerLoadingView *)loadingView {
27 36  
... ...
LiveVideoCloud/LiveVideoCloud/UtilKits/ServerUrl/ZXServerUrl.h
... ... @@ -27,4 +27,6 @@
27 27 /** 搜索页内容 */
28 28 + (NSString *)getSearchContentURL;
29 29  
  30 +/** 直播列表 */
  31 ++ (NSString *)getLiveListURL;
30 32 @end
... ...
LiveVideoCloud/LiveVideoCloud/UtilKits/ServerUrl/ZXServerUrl.m
... ... @@ -9,7 +9,7 @@
9 9 #import "ZXServerUrl.h"
10 10  
11 11 #ifdef DEBUG
12   -static NSString *serverBaseURL = @"http://120.92.4.46:8080";//通用测试æœåŠ¡å™¨åŸŸå
  12 +static NSString *serverBaseURL = @"http://api.cnlive.com";//通用测试æœåŠ¡å™¨åŸŸå
13 13 static NSString *serverChatBaseURL = @"http://120.92.4.46:8081";//èŠå¤©æµ‹è¯•æœåŠ¡å™¨åŸŸå
14 14 #else
15 15 static NSString *serverBaseURL = @"https://perapi.svipmovie.com";//é€šç”¨æ­£å¼æœåŠ¡å™¨åŸŸå
... ... @@ -23,6 +23,8 @@ static NSString *serverChatBaseURL = @&quot;https://perapi.svipmovie1.com&quot;;//èŠå¤©æ­
23 23 /** æœç´¢é¡µå†…容 */
24 24 static NSString *g_SearchContentURL = @"/from/huntKeyWordApi/huntKeyWords.do";//@"api/findMessage";//å‘现消æ¯
25 25  
  26 +/** 直播列表 */
  27 +static NSString *g_LiveListURL = @"/open/api2/live_epg/sp/activityList4App";
26 28  
27 29  
28 30 @implementation ZXServerUrl
... ... @@ -53,4 +55,10 @@ static NSString *g_SearchContentURL = @&quot;/from/huntKeyWordApi/huntKeyWords.do&quot;;//
53 55 return [NSString stringWithFormat:@"%@%@", serverBaseURL, g_SearchContentURL];
54 56 }
55 57  
  58 +/** 直播列表 */
  59 ++ (NSString *)getLiveListURL
  60 +{
  61 + return [NSString stringWithFormat:@"%@%@", serverBaseURL, g_LiveListURL];
  62 +}
  63 +
56 64 @end
... ...