VideoDetailPresent.m 3.52 KB
//
//  VideoDetailPresent.m
//  CNLiveScioLive
//
//  Created by CNLive on 2021/2/25.
//  Copyright © 2021 CNLive. All rights reserved.
//

#import "VideoDetailPresent.h"

@implementation VideoDetailPresent

-(void)requestProgram:(NSString *)reportId
{
    if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
        [AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")];
        return;
    }
    NSString *strUrl = REQUESTURL(@"gxb/api/programDetail");
    NSLog(@"%@",strUrl);
    NSString *categoryId = [NSString stringWithFormat:@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"type\":\"program\",\"id\":\"%@\"}",reportId];
    NSLog(@"%@",categoryId);
    NSDictionary *parameters = @{@"params":categoryId};
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strUrl
       parameters:parameters headers:nil
         progress:^(NSProgress * _Nonnull uploadProgress) {}
          success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              // 请求成功,解析数据
              NSLog(@"%@", responseObject);
              NSDictionary *_dic = [NSDictionary dictionaryWithDictionary:responseObject];
              if ([_dic[@"errorCode"] isEqualToString:@"0"]) {
                  NSString *content = _dic[@"content"];
                      CNMessageSend(self.currentView, ProgramDelegate, programDetail:content);
                  
              } else {
                  [AlertViewTool showHUDViewText:_dic[@"errorMessage"]];
              }
          }
          failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
              // 请求失败
              NSLog(@"%@", [error localizedDescription]);
              [SVProgressHUD dismiss];
              [AlertViewTool showHUDAddedToView:AppKeyWindow text:CustomStr(@"ServerBusy")];
          }];
}
- (void)loadRelatedInformation:(NSString *)reportId {
    if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
        [AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")];
        return;
    }
    NSString *strUrl = REQUESTURL(@"gxb/api/programRelative");
    NSLog(@"%@",strUrl);
    NSString *categoryId = [NSString stringWithFormat:@"{\"plat\":\"i\",\"version\":\"5.0\",\"appid\":\"gxb\",\"cmsContentId\":\"%@\"}",reportId];
    NSLog(@"%@",categoryId);
    NSDictionary *parameters = @{@"params":categoryId};
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strUrl
       parameters:parameters headers:nil
         progress:^(NSProgress * _Nonnull uploadProgress) {}
          success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              // 请求成功,解析数据
              NSLog(@"%@", responseObject);
              NSDictionary *_dic = [NSDictionary dictionaryWithDictionary:responseObject];
              if ([_dic[@"errorCode"] isEqualToString:@"0"]) {
                  NSArray *array = _dic[@"programs"];
                  CNMessageSend(self.currentView, ProgramDelegate, reloadWithData:array);
              } else {
                  [AlertViewTool showHUDViewText:_dic[@"errorMessage"]];
              }
          }
          failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
              // 请求失败
              NSLog(@"%@", [error localizedDescription]);
              [SVProgressHUD dismiss];
              [AlertViewTool showHUDAddedToView:AppKeyWindow text:CustomStr(@"ServerBusy")];
          }];
}
@end