Commit 6b5bdb4658e50a5599b498ae99e51be80c1de870

Authored by yanglingyu
1 parent 308cbb07

发布会预告接口修改

CNLiveScioLive/Pages/Header/UrlMacro.h
... ... @@ -45,7 +45,7 @@
45 45 //#define tuwen(id) [NSString stringWithFormat:@"http://www.scio.gov.cn:9095/video/JsonDataFromGXW.aspx/JsonDataFromGXW.aspx?type=Doc&DocID=%d",id]
46 46 #define tuwen(id) [NSString stringWithFormat:@"http://www.scio.gov.cn:9095/video/JsonDataFromGXW.aspx?type=Doc&DocID=%d",id]
47 47  
48   -#define yugao @"http://www.scio.gov.cn:9095/video/JsonDataFromGXW.aspx?type=DocList&Top=1&ChannelID=20490"
  48 +#define FORECAST @"http://app.phonemovie.cnlive.com/gxb/api/"
49 49 #define yugaoliebiao @"http://www.scio.gov.cn:9095/video/JsonDataFromGXW.aspx?type=DocList&ChannelID=20490"
50 50 //#define newsdetail(id) [NSString stringWithFormat:@"http://www.scio.gov.cn:9095/video/JsonDataFromGXW.aspx/JsonDataFromGXW.aspx?type=Doc&DocID=%d",id]
51 51  
... ...
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldArticleDetailViewController.m
... ... @@ -89,7 +89,7 @@
89 89 }
90 90 - (void)getDetailsData {
91 91 // 详情数据
92   - NSDictionary *parameters = @{@"params":[NSString stringWithFormat:@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"type\":\"article\",\"id\":\"%@\"}", _dictionary[@"cmsContentId"]]};
  92 + NSDictionary *parameters = @{@"params":[NSString stringWithFormat:@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"type\":\"program\",\"id\":\"%@\"}", _dictionary[@"cmsContentId"]]};
93 93 AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
94 94 [manager POST:@"http://app.phonemovie.cnlive.com/gxb/api/programDetail"
95 95 parameters:parameters headers:nil
... ...
CNLiveScioLive/Pages/Live/Controller/CNLiveViewController.m
... ... @@ -19,7 +19,7 @@
19 19  
20 20 @interface CNLiveViewController ()<UITableViewDelegate,UITableViewDataSource>{
21 21 NSArray *_newsArray;
22   -
  22 + NSDictionary *_dictionary;
23 23 }
24 24 @property (nonatomic, strong) UITableView *tableView;
25 25 @property (nonatomic, strong) CNLiveHeaderView *header;
... ... @@ -145,11 +145,32 @@ static NSString *indicatorTableViewCell = @&quot;CNLiveIndicatorTableViewCell&quot;;
145 145  
146 146 }];
147 147 }
148   -
  148 +- (void)loadYGData {
  149 + NSString *strUrl = @"http://app.phonemovie.cnlive.com/gxb/api/cataloglatest";
  150 + //NSLog(@"%@",strUrl);
  151 + NSString *categoryId = [NSString stringWithFormat:@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"categoryId\":\"wz/fbhgg/\",\"page\":\"1\",\"pageSize\":\"1\"}"];
  152 + //NSLog(@"%@",categoryId);
  153 + if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
  154 + [AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")];
  155 + return;
  156 + }
  157 + NSDictionary *parameters = @{@"params":categoryId};
  158 + AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
  159 + [manager POST:strUrl parameters:parameters headers:nil progress:^(NSProgress * _Nonnull uploadProgress) {} success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *responseObject) {
  160 + // 请求成功,解析数据
  161 + self->_dictionary = [NSDictionary dictionaryWithDictionary:responseObject];
  162 + }
  163 + failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
  164 + // 请求失败
  165 + [AlertViewTool showHUDViewText:CustomStr(@"ServerBusy")];
  166 +
  167 + }];
  168 +}
149 169 - (void)loadUpData{
150 170 _pageNo = 1;
151 171 if(!_isRefreshing){
152 172 _isRefreshing = YES;
  173 + [self loadYGData];
153 174 [self loadData];
154 175 if(!_isLoaded){
155 176 [self getData];
... ... @@ -186,7 +207,7 @@ static NSString *indicatorTableViewCell = @&quot;CNLiveIndicatorTableViewCell&quot;;
186 207 _isRefreshing = NO;
187 208 _isLoaded = NO;
188 209 [self loadData];
189   -
  210 + [self loadYGData];
190 211 [self.view addSubview:self.tableView];
191 212 self.tableView.tableHeaderView = self.header;
192 213 __weak typeof(self) weakSelf = self;
... ... @@ -366,6 +387,7 @@ static NSString *indicatorTableViewCell = @&quot;CNLiveIndicatorTableViewCell&quot;;
366 387 }else if (indexPath.section == 1){
367 388 //查看发布会预告
368 389 TopNoticeViewController *vc = [[TopNoticeViewController alloc] init];
  390 + vc.forecaseDic = _dictionary;
369 391 vc.hidesBottomBarWhenPushed = YES;
370 392 [self.navigationController pushViewController:vc animated:YES];
371 393 return;
... ...
CNLiveScioLive/Pages/Live/Controller/TopNoticeViewController.h
... ... @@ -10,6 +10,6 @@
10 10 #import "CNLiveBaseViewController.h"
11 11 @interface TopNoticeViewController : CNLiveBaseViewController<WKNavigationDelegate>{
12 12 WKWebView *_webView;
13   - NSDictionary *_dictionary;
14 13 }
  14 +@property (nonatomic , strong) NSDictionary *forecaseDic;
15 15 @end
... ...
CNLiveScioLive/Pages/Live/Controller/TopNoticeViewController.m
... ... @@ -11,6 +11,10 @@
11 11 //#import <ShareSDK/ShareSDK.h>
12 12  
13 13 @interface TopNoticeViewController ()<WKNavigationDelegate>
  14 +{
  15 + NSDictionary *headerDic;
  16 + NSDictionary *bodyDic;
  17 +}
14 18 @property (nonatomic, strong) NSArray *fontArray;
15 19 @property (nonatomic, assign) NSInteger fontIndex;
16 20  
... ... @@ -18,7 +22,7 @@
18 22  
19 23 @implementation TopNoticeViewController
20 24 #pragma mark - Data
21   -- (void)loadTrailerData {
  25 +-(void)loadHeaderData{
22 26 if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
23 27 [AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")];
24 28 return;
... ... @@ -27,21 +31,52 @@
27 31  
28 32 AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
29 33 manager.responseSerializer = [AFHTTPResponseSerializer serializer];
30   - [manager POST:yugao parameters:nil headers:nil progress:^(NSProgress * _Nonnull uploadProgress) {} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject){
  34 + NSString *josnParameters = [NSString stringWithFormat:@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"cmsContentId\":\"%@\"}",self.forecaseDic[@"programs"][0][@"cmsContentId"]];
  35 + NSLog(@"%@",josnParameters);
  36 + NSDictionary *parameters = @{@"params":josnParameters
  37 + };
  38 + NSString *urlStr = [NSString stringWithFormat:@"%@%@",FORECAST,@"programByContentId"];
  39 + [manager POST:urlStr parameters:parameters headers:nil progress:^(NSProgress * _Nonnull uploadProgress) {} success:^(NSURLSessionDataTask * _Nonnull task, id responseObject) {
31 40 [AlertViewTool hideHUDView];
32 41 // 请求成功,解析数据
33 42 NSString * jsonString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
34 43 NSLog(@"jsonString == %@",jsonString);
35   - NSArray *arr = [jsonString objectFromJSONString];
36   - NSDictionary *dic = [arr objectAtIndex:0];
37 44  
38   -// NSString* htmlHeader = [[NSString alloc] initWithFormat:@"<html><p><font style=\"font-size:20px;\"><strong>%@</strong></font><br>%@</p><body>",[dic objectForKey:@"Tittle"],[dic objectForKey:@"PublishDateTime"]];
39   - NSString* htmlHeader = [[NSString alloc] initWithFormat:@"<html><p><font style=\"font-size:20px;\"><strong>%@</strong></font><br>%@</p><style type=\"text/css\"> img{width: 100%% !important; height: auto !important;}</style><body>",[dic objectForKey:@"Tittle"],[dic objectForKey:@"PublishDateTime"]];
  45 + NSDictionary *dic = [jsonString objectFromJSONString];
  46 + self -> headerDic = dic[@"program"];
  47 +
  48 + [self loadWebView];
40 49  
41   - NSString* htmlBody = [dic objectForKey:@"Content"];
42   - NSString* htmlFooter = @"</body></html>";
43   - NSString* strHtml = [[NSString alloc] initWithFormat:@"%@%@%@",htmlHeader,htmlBody,htmlFooter];
44   - [self->_webView loadHTMLString:strHtml baseURL:nil];
  50 + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
  51 + // 请求失败
  52 + NSLog(@"%@", [error localizedDescription]);
  53 + [AlertViewTool hideHUDView];
  54 + [AlertViewTool showHUDViewText:CustomStr(@"ServerBusy")];
  55 +
  56 + }];
  57 +}
  58 +- (void)loadBodyData {
  59 + if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
  60 + [AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")];
  61 + return;
  62 + }
  63 + [AlertViewTool showHUDView];
  64 +
  65 + AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
  66 + manager.responseSerializer = [AFHTTPResponseSerializer serializer];
  67 + NSString *josnParameters = [NSString stringWithFormat:@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"type\":\"program\",\"id\":\"%@\"}",self.forecaseDic[@"programs"][0][@"cmsContentId"]];
  68 + NSLog(@"%@",josnParameters);
  69 + NSDictionary *parameters = @{@"params":josnParameters
  70 + };
  71 + NSString *urlStr = [NSString stringWithFormat:@"%@%@",FORECAST,@"programDetail"];
  72 + [manager POST:urlStr parameters:parameters headers:nil progress:^(NSProgress * _Nonnull uploadProgress) {} success:^(NSURLSessionDataTask * _Nonnull task, id responseObject) {
  73 + [AlertViewTool hideHUDView];
  74 + // 请求成功,解析数据
  75 + NSString * jsonString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
  76 + NSLog(@"jsonString == %@",jsonString);
  77 +
  78 + self->bodyDic = [jsonString objectFromJSONString];
  79 + [self loadWebView];
45 80  
46 81 } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
47 82 // 请求失败
... ... @@ -51,33 +86,18 @@
51 86  
52 87 }];
53 88 }
  89 +- (void)loadWebView
  90 +{
  91 + if (headerDic && bodyDic) {
  92 + NSString* htmlHeader = [[NSString alloc] initWithFormat:@"<html><p><font style=\"font-size:20px;\"><strong>%@</strong></font><br>%@</p><style type=\"text/css\"> img{width: 100%% !important; height: auto !important;}</style><body>",[headerDic objectForKey:@"title"],[headerDic objectForKey:@"publishDate"]];
54 93  
55   -- (void)loadData {
56   - NSString *strUrl = @"http://app.phonemovie.cnlive.com/gxb/api/cataloglatest";
57   - //NSLog(@"%@",strUrl);
58   - NSString *categoryId = [NSString stringWithFormat:@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"categoryId\":\"wz/fbhgg/\",\"page\":\"1\",\"pageSize\":\"1\"}"];
59   - //NSLog(@"%@",categoryId);
60   - if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
61   - [AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")];
62   - return;
63   - }
64   - NSDictionary *parameters = @{@"params":categoryId};
65   - AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
66   - [manager POST:strUrl parameters:parameters headers:nil progress:^(NSProgress * _Nonnull uploadProgress) {} success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *responseObject) {
67   - // 请求成功,解析数据
68   - self->_dictionary = [NSDictionary dictionaryWithDictionary:responseObject];
69   - dispatch_async(dispatch_get_main_queue(), ^{
70   - [self loadShareView];
71   - });
72   -
73   - }
74   - failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
75   - // 请求失败
76   - [AlertViewTool showHUDViewText:CustomStr(@"ServerBusy")];
77   -
78   - }];
  94 + NSString* htmlBody = [bodyDic objectForKey:@"content"];
  95 + NSString* htmlFooter = @"</body></html>";
  96 + NSString* strHtml = [[NSString alloc] initWithFormat:@"%@%@%@",htmlHeader,htmlBody,htmlFooter];
  97 + [self->_webView loadHTMLString:strHtml baseURL:nil];
  98 + }
  99 +
79 100 }
80   -
81 101 - (void)viewDidLoad {
82 102 [super viewDidLoad];
83 103 self.view.backgroundColor = [UIColor whiteColor];
... ... @@ -86,8 +106,9 @@
86 106 _fontIndex = [[NSUserDefaults standardUserDefaults] integerForKey:@"FontSize"];
87 107  
88 108 [self setUpNavigationBar];
89   - [self loadTrailerData];
90   - [self loadData];
  109 + [self loadHeaderData];
  110 + [self loadBodyData];
  111 + [self loadShareView];
91 112 [self setUpUI];
92 113  
93 114 }
... ... @@ -155,7 +176,7 @@
155 176 //收藏按钮
156 177 UIButton *isFavoriteButton = [UIButton buttonWithType:UIButtonTypeCustom];
157 178 isFavoriteButton.tag = 20000;
158   - TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary[@"programs"][0]];
  179 + TableData *notice = [[TableData alloc] initWithJSONDictionary:_forecaseDic[@"programs"][0]];
159 180 BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice];
160 181 if (isIn) {
161 182 [isFavoriteButton setImage:[UIImage imageNamed:@"cnlive_isfavorited"] forState:UIControlStateNormal];
... ... @@ -199,7 +220,7 @@
199 220 [_webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '140%'" completionHandler:nil];
200 221 }
201 222 } else if (20000 == btn.tag) {
202   - TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary[@"programs"][0]];
  223 + TableData *notice = [[TableData alloc] initWithJSONDictionary:_forecaseDic[@"programs"][0]];
203 224 BOOL isIn = [[DBAction sharedDBAction] isInTable:[User_Defaults objectForKey:Language_Local] notice:notice];
204 225 if (!isIn) {
205 226 BOOL isInsert = [[DBAction sharedDBAction] insertTable:[User_Defaults objectForKey:Language_Local] notice:notice];
... ... @@ -215,10 +236,10 @@
215 236 }
216 237 }
217 238 } else if (30000 == btn.tag) {
218   - NSString *img = [NSString stringWithFormat:@"%@",_dictionary[@"programs"][0][@"img"]];
219   - NSString *title = [NSString stringWithFormat:@"%@",_dictionary[@"programs"][0][@"title"]];
220   - NSString *text = [NSString stringWithFormat:@"%@",!_dictionary[@"programs"][0][@"desc"]||[_dictionary[@"programs"][0][@"desc"] isEqualToString:@""]?title:_dictionary[@"programs"][0][@"desc"]];
221   - NSString *url = [NSString stringWithFormat:@"%@",_dictionary[@"programs"][0][@"pageUrl"]];
  239 + NSString *img = [NSString stringWithFormat:@"%@",_forecaseDic[@"programs"][0][@"img"]];
  240 + NSString *title = [NSString stringWithFormat:@"%@",_forecaseDic[@"programs"][0][@"title"]];
  241 + NSString *text = [NSString stringWithFormat:@"%@",!_forecaseDic[@"programs"][0][@"desc"]||[_forecaseDic[@"programs"][0][@"desc"] isEqualToString:@""]?title:_forecaseDic[@"programs"][0][@"desc"]];
  242 + NSString *url = [NSString stringWithFormat:@"%@",_forecaseDic[@"programs"][0][@"pageUrl"]];
222 243 [[TemplateShareManager manager] shareImage:img title:title text:text url:url controller:self];
223 244 return;
224 245  
... ...