Commit ed7a62724dab39dc31114b41c1c316321fb7662f

Authored by yinqiaojuan
1 parent 64362e47

0.0.3修改外部数据传输失败

CNLiveWitnessVideoModule.podspec
... ... @@ -8,7 +8,7 @@
8 8  
9 9 Pod::Spec.new do |s|
10 10 s.name = 'CNLiveWitnessVideoModule'
11   - s.version = '0.0.2'
  11 + s.version = '0.0.3'
12 12 s.summary = '目击者视频播放功能'
13 13  
14 14 # This description is used to generate tags and improve search results.
... ...
CNLiveWitnessVideoModule/Classes/Controller/CNBWitnessListController.m
... ... @@ -56,23 +56,42 @@ NSString * const kIdentifier = @"CNBWitnessListCell";
56 56 if (self = [super init]) {
57 57 _dataSource = [NSMutableArray array];
58 58 _type = type;
59   - _isHaveNext = @"1";
60   - _pageIndex = pageNum + 1;
61   - NSArray *list = data[@"witnessBeans"];
62   - if ([type isEqualToString:@"0"]) {
63   - _pageSize = 10;
64   - _currentPlayIndex = currentIndex;
65   - for (NSDictionary *dic in list) {
66   - CNBWitnessListModel *witnessModel = [CNBWitnessListModel mj_objectWithKeyValues:dic];
67   - [_dataSource addObject:witnessModel];
  59 + _pageSize = 10;
  60 + if (data && [data isKindOfClass:[NSDictionary class]] && data.count > 0) { //如果上一个页面传的有数据,且数据上传证据
  61 + if ([[data allKeys] containsObject:@"witnessBeans"] && data[@"witnessBeans"] && [data[@"witnessBeans"] isKindOfClass:[NSArray class]]) {
  62 + NSArray *list = data[@"witnessBeans"];
  63 + if (list.count > 0) {
  64 +
  65 + if ([type isEqualToString:@"0"]) {
  66 + if (currentIndex > list.count) {
  67 + _currentPlayIndex = 0;
  68 + }else {
  69 + _currentPlayIndex = currentIndex;
  70 + }
  71 + for (NSDictionary *dic in list) {
  72 + CNBWitnessListModel *witnessModel = [CNBWitnessListModel mj_objectWithKeyValues:dic];
  73 + [_dataSource addObject:witnessModel];
  74 + }
  75 + }else {
  76 + NSDictionary *dic = list[currentIndex];
  77 + CNBWitnessListModel *witnessModel = [CNBWitnessListModel mj_objectWithKeyValues:dic];
  78 + [_dataSource addObject:witnessModel];
  79 + _currentPlayIndex = 0;
  80 + }
  81 + _pageIndex = pageNum + 1;
  82 + _isHaveNext = @"1";
  83 + }else {
  84 + _isRefreshHeader = YES;
  85 + _pageIndex = pageNum;
  86 + }
  87 + }else {
  88 + _isRefreshHeader = YES;
  89 + _pageIndex = pageNum;
68 90 }
69 91 }else {
70   - NSDictionary *dic = list[currentIndex];
71   - CNBWitnessListModel *witnessModel = [CNBWitnessListModel mj_objectWithKeyValues:dic];
72   - [_dataSource addObject:witnessModel];
73   - _currentPlayIndex = 0;
  92 + _isRefreshHeader = YES;
  93 + _pageIndex = pageNum;
74 94 }
75   -
76 95 }
77 96 return self;
78 97 }
... ... @@ -95,28 +114,29 @@ NSString * const kIdentifier = @"CNBWitnessListCell";
95 114 }
96 115 - (void)viewDidLoad {
97 116 [super viewDidLoad];
98   - if (self.dataSource.count > 0) {
99   - if ([self.type isEqualToString:@"0"]) {
100   - self.toSid = ((CNBWitnessListModel *)[self.dataSource objectAtIndex:self.currentPlayIndex]).icon.sid;
101   - }else {
102   - self.toSid = ((CNBWitnessListModel *)self.dataSource[self.currentPlayIndex]).contentSid;
103   - }
104   -
105   - }
106 117 [self setLeftButton];
107 118 [self setBackgroundImage];
108 119 [self.view addSubview:self.tableView];
109 120 _isLightContentStatusBar = YES;
110 121 if (self.dataSource.count> 0) {
  122 + if ([self.type isEqualToString:@"0"]) {
  123 + self.toSid = ((CNBWitnessListModel *)[self.dataSource objectAtIndex:self.currentPlayIndex]).icon.sid;
  124 + self.tableView.mj_header = [CNLiveRefreshHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshVideoList)];
  125 + self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(getMoreVideoList)];
  126 + }else {
  127 + self.toSid = ((CNBWitnessListModel *)self.dataSource[self.currentPlayIndex]).contentSid;
  128 + }
111 129 [_tableView reloadData];
112 130 [_tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.currentPlayIndex inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
113 131 [self playIndex:self.currentPlayIndex isAutoPlay:YES];
  132 + }else {
  133 + if ([self.type isEqualToString:@"0"]) {
  134 + self.pageIndex = 1;
  135 + self.currentPlayIndex = 0;
  136 + [self loadWitnessData:self.pageIndex];
  137 + }
  138 +
114 139 }
115   - if ([self.type isEqualToString:@"0"]) {
116   - self.tableView.mj_header = [CNLiveRefreshHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshVideoList)];
117   - self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(getMoreVideoList)];
118   - }
119   -
120 140 }
121 141 #pragma mark -添加关闭按钮
122 142 - (void)setLeftButton {
... ... @@ -213,8 +233,8 @@ NSString * const kIdentifier = @"CNBWitnessListCell";
213 233 if (!strongSelf) {
214 234 return ;
215 235 }
216   - [strongSelf.tableView.mj_footer isRefreshing];
217   - [strongSelf.tableView.mj_header isRefreshing];
  236 + [strongSelf.tableView.mj_footer endRefreshing];
  237 + [strongSelf.tableView.mj_header endRefreshing];
218 238 strongSelf.isHaveNext = isHaveNext;
219 239 if ([isHaveNext isEqualToString:@"1"]) {
220 240 strongSelf.pageIndex ++;
... ...
CNLiveWitnessVideoModule/Classes/ViewModel/CNBWitnessListViewModel.m
... ... @@ -12,6 +12,7 @@
12 12 #import "CNBWitnessListModel.h"
13 13 #import "MJExtension.h"
14 14 #import <QMUIKit/QMUIKit.h>
  15 +#import "CNUserInfoManager.h"
15 16 #define CNBWitnessAppKeyWindow ([UIApplication sharedApplication].delegate).window
16 17 @implementation CNBWitnessListViewModel
17 18 + (void)getWitnessListDataTosid:(NSString *)toSid page:(NSInteger)page pageSize:(NSInteger)pageSize successBlock:(void(^)(NSMutableArray *dataArray,NSString *isHaveNext))successBlock failureBlock:(void (^)(NSError *error))failureBlock {
... ... @@ -19,13 +20,13 @@
19 20 NSString *url = @"";
20 21 NSDictionary *param = [NSDictionary dictionary];
21 22 param = @{
22   - @"toSid" :CNLiveStringIsEmpty(toSid)? @"":toSid,
  23 + @"toSid" :CNLiveStringIsEmpty(toSid)?CNUserShareModelUid:toSid,
23 24 @"pageNo" :[NSString stringWithFormat:@"%ld",page],
24 25 @"pageSize" :[NSString stringWithFormat:@"%ld",pageSize],
25 26 @"type":@"0",
26 27 @"reviewStatus":@"1"
27 28 };
28   - https://apiwjjtest.cnlive.com/Daren/bWitness/getBWitnessList.action
  29 + https://apiwjjtest.cnlive.com/Daren/bWitness/getBWitnessList.action
29 30 url = cn_API_Host(@"/Daren/bWitness/getBWitnessList.action");
30 31 [CNLiveNetworking setAllowRequestDefaultArgument:YES];
31 32 [CNLiveNetworking setupShowDataResult:NO];
... ...
Example/CNLiveWitnessVideoModule/CNLIVEAppDelegate.m
... ... @@ -33,6 +33,7 @@ static NSString * uuid;
33 33 [mDict setValue:@"i" forKey:@"plat"];
34 34 [mDict setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"ver"];
35 35 [mDict setObject:AppId forKey:@"appId"];
  36 + [mDict setObject:@"10511059" forKey:@"sid"];
36 37 [CNLiveNetworking setupDefaultParam:mDict];
37 38 [CNLiveNetworking setupShowResult:NO];
38 39 [CNLiveNetworking setupSignKey:APPKey];
... ...
Example/CNLiveWitnessVideoModule/CNLIVEViewController.m
... ... @@ -74,7 +74,7 @@
74 74 // CNBWitnessListController *vc = [[CNBWitnessListController alloc]initControllerWithData:self.data currentIndex:indexPath.row pageNum:1 type:@"0"];
75 75 // [self.navigationController pushViewController:vc animated:YES];
76 76 id <CNBWitnessVideoPlayProtocol>service = [[BeeHive shareInstance]createService:@protocol(CNBWitnessVideoPlayProtocol)];
77   - [service pushToWitnessVideoController:self.data currentIndex:indexPath.row pageNum:1 type:@"0"];
  77 + [service pushToWitnessVideoController:self.data currentIndex:12 pageNum:1 type:@"0"];
78 78 }
79 79 - (void)getWitnessListDataTosid:(NSString *)toSid page:(NSInteger)page pageSize:(NSInteger)pageSize type:(NSString *)type {
80 80 NSString *url = @"";
... ... @@ -83,7 +83,9 @@
83 83 param = @{
84 84 @"toSid" :CNLiveStringIsEmpty(toSid)? @"":toSid,
85 85 @"pageNo" :[NSString stringWithFormat:@"%ld",page],
86   - @"pageSize" :[NSString stringWithFormat:@"%ld",pageSize]
  86 + @"pageSize" :[NSString stringWithFormat:@"%ld",pageSize],
  87 + @"type":@"0",
  88 + @"reviewStatus":@"1"
87 89 };
88 90 url = cn_API_Host(@"/Daren/bWitness/getBWitnessList.action");
89 91  
... ...
Example/CNLiveWitnessVideoModule/main.m
... ... @@ -7,11 +7,13 @@
7 7 //
8 8  
9 9 @import UIKit;
  10 +#import <CNLiveEnvironment/CNLiveEnvironment.h>
10 11 #import "CNLIVEAppDelegate.h"
11 12  
12 13 int main(int argc, char * argv[])
13 14 {
14 15 @autoreleasepool {
  16 + [CNLiveEnvironmentManager setAppType:CNLiveAppTypeBLive environmentType:CNLiveDebugAppStore];
15 17 return UIApplicationMain(argc, argv, nil, NSStringFromClass([CNLIVEAppDelegate class]));
16 18 }
17 19 }
... ...