Commit d112636d17a19eba0cf0bee45522bb83912c9dee

Authored by yanglingyu
1 parent d860b452

与主工程跳转交互

CNLiveCServiceModule/Classes/Manager/CNLiveCServiceManagerBridge.h
@@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger , CNCServiceJumpType) { @@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger , CNCServiceJumpType) {
21 * @param type type 21 * @param type type
22 * @param param 参数 22 * @param param 参数
23 */ 23 */
24 -- (void)jumpControllerType:(CNCServiceJumpType)type param:(NSDictionary *)param controller:(UIViewController *)controller; 24 +- (void)jumpControllerType:(CNCServiceJumpType)type param:(NSDictionary *_Nullable)param controller:(UIViewController *_Nullable)controller;
25 @end 25 @end
26 26
27 NS_ASSUME_NONNULL_BEGIN 27 NS_ASSUME_NONNULL_BEGIN
@@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN @@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
31 @property (nonatomic, strong) id<CNLiveCServiceProtocol> protocol; 31 @property (nonatomic, strong) id<CNLiveCServiceProtocol> protocol;
32 32
33 + (instancetype) shareManager; 33 + (instancetype) shareManager;
  34 ++ (UIViewController *)viewControllerFromView:(UIView *)view;
34 35
35 /** 36 /**
36 * 服务号跳转 37 * 服务号跳转
@@ -40,7 +41,31 @@ NS_ASSUME_NONNULL_BEGIN @@ -40,7 +41,31 @@ NS_ASSUME_NONNULL_BEGIN
40 * @param to to 41 * @param to to
41 * @param shopType shopType 42 * @param shopType shopType
42 */ 43 */
43 -+ (void) jumpServiceController:(NSString *)serviceId type:(NSString *)type to:(NSString *)to shopType:(NSString *)shopType controller:(UIViewController *)controller; 44 ++ (void)jumpServiceController:(NSString *)serviceId
  45 + type:(NSString *)type
  46 + to:(NSString *)to
  47 + shopType:(NSString *)shopType
  48 + controller:(UIViewController *)controller;
  49 +/**
  50 + * 服务号跳转
  51 + *
  52 + * @param type type
  53 + * @param param 参数
  54 + */
  55 ++ (void)jumpViewControllerType:(CNCServiceJumpType)type
  56 + param:(NSDictionary *)param
  57 + controller:(UIViewController *)controller;
  58 +/**
  59 + *服务号跳转
  60 + *@param goodsId 商品id
  61 + */
  62 ++ (void)jumpGoodsViewController:(NSString *)goodsId
  63 + controller:(UIViewController *)controller;
  64 +/**
  65 + *服务号跳转
  66 + *@param contentId 服务id
  67 + */
  68 ++ (void)jumpGetPageOtherVC:(NSString *)contentId controller:(UIViewController *)controller;
44 @end 69 @end
45 70
46 NS_ASSUME_NONNULL_END 71 NS_ASSUME_NONNULL_END
CNLiveCServiceModule/Classes/Manager/CNLiveCServiceManagerBridge.m
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 // 6 //
7 7
8 #import "CNLiveCServiceManagerBridge.h" 8 #import "CNLiveCServiceManagerBridge.h"
  9 +#import "CNLiveServicePresent.h"
9 10
10 @implementation CNLiveCServiceManagerBridge 11 @implementation CNLiveCServiceManagerBridge
11 + (instancetype)shareManager{ 12 + (instancetype)shareManager{
@@ -37,6 +38,36 @@ @@ -37,6 +38,36 @@
37 @"to":to, 38 @"to":to,
38 @"shopType":shopType, 39 @"shopType":shopType,
39 }; 40 };
40 - [[CNLiveCServiceManagerBridge shareManager].protocol jumpControllerType:jumpType param:param controller:controller]; 41 + [CNLiveCServiceManagerBridge jumpViewControllerType:jumpType param:param controller:controller];
  42 +}
  43 ++ (void)jumpGoodsViewController:(NSString *)goodsId controller:(UIViewController *)controller
  44 +{
  45 + NSDictionary *param = @{
  46 + @"goodsId":goodsId,
  47 + };
  48 + [CNLiveCServiceManagerBridge jumpViewControllerType:CNCServiceJumpTypeGoods param:param controller:controller];
  49 +}
  50 ++ (void)jumpGetPageOtherVC:(NSString *)contentId controller:(UIViewController *)controller{
  51 + [QMUITips showLoadingInView:controller.view];
  52 + [CNLiveServicePresent loadServiceInfoServiceId:contentId result:^(CNLiveSearchModel * _Nonnull model) {
  53 + [QMUITips hideAllTips];
  54 + [CNLiveCServiceManagerBridge jumpServiceController:model.id type:model.type to:model.to shopType:model.shopType controller:controller];
  55 + } error:^{
  56 + [QMUITips hideAllTips];
  57 + }];
  58 +}
  59 ++ (void)jumpViewControllerType:(CNCServiceJumpType)type param:(NSDictionary *)param controller:(UIViewController *)controller{
  60 +
  61 + [[CNLiveCServiceManagerBridge shareManager].protocol jumpControllerType:type param:param controller:controller];
  62 +}
  63 +
  64 ++ (UIViewController *)viewControllerFromView:(UIView *)view {
  65 + for (UIView *next = [view superview]; next; next = next.superview) {
  66 + UIResponder *nextResponder = [next nextResponder];
  67 + if ([nextResponder isKindOfClass:[UIViewController class]]) {
  68 + return (UIViewController *)nextResponder;
  69 + }
  70 + }
  71 + return nil;
41 } 72 }
42 @end 73 @end
CNLiveCServiceModule/Classes/Manager/CNLiveCServicePCH.h
@@ -22,5 +22,6 @@ @@ -22,5 +22,6 @@
22 #import <CNLiveCustomControl/CNLiveCustomControl.h> 22 #import <CNLiveCustomControl/CNLiveCustomControl.h>
23 #import <SDCycleScrollView/SDCycleScrollView.h> 23 #import <SDCycleScrollView/SDCycleScrollView.h>
24 #import <QMUIKit/QMUIKit.h> 24 #import <QMUIKit/QMUIKit.h>
  25 +#import "CNLiveCServiceManagerBridge.h"
25 26
26 #endif /* CNLiveCServicePCH_h */ 27 #endif /* CNLiveCServicePCH_h */
CNLiveCServiceModule/Classes/Model/CNLiveServiceModel.h
@@ -114,7 +114,7 @@ NS_ASSUME_NONNULL_BEGIN @@ -114,7 +114,7 @@ NS_ASSUME_NONNULL_BEGIN
114 @property (nonatomic, copy) NSString *linkType; 114 @property (nonatomic, copy) NSString *linkType;
115 @property (nonatomic, copy) NSString *moreType; 115 @property (nonatomic, copy) NSString *moreType;
116 116
117 -@property (nonatomic, strong) NSArray <CnLivePageContentModel *> *contents; 117 +@property (nonatomic, strong) NSArray *contents;
118 118
119 @end 119 @end
120 NS_ASSUME_NONNULL_END 120 NS_ASSUME_NONNULL_END
CNLiveCServiceModule/Classes/Present/CNLiveServicePresent.h
@@ -55,6 +55,8 @@ NS_ASSUME_NONNULL_BEGIN @@ -55,6 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
55 @param serviceId 服务对应Id,全部服务为@“” 55 @param serviceId 服务对应Id,全部服务为@“”
56 */ 56 */
57 + (void)loadAllServiceWithServiceId:(NSString *)serviceId page:(NSString *)page result:(void (^) (NSArray * dataArray, BOOL isLastPage)) succeed error:(void(^)(void))failure; 57 + (void)loadAllServiceWithServiceId:(NSString *)serviceId page:(NSString *)page result:(void (^) (NSArray * dataArray, BOOL isLastPage)) succeed error:(void(^)(void))failure;
  58 +
  59 ++ (void)loadServiceInfoServiceId:(NSString *)serviceId result:(void (^) (CNLiveSearchModel * model)) succeed error:(void(^)(void))failure;
58 @end 60 @end
59 61
60 NS_ASSUME_NONNULL_END 62 NS_ASSUME_NONNULL_END
CNLiveCServiceModule/Classes/Present/CNLiveServicePresent.m
@@ -348,4 +348,24 @@ static const CGFloat margin = 15; @@ -348,4 +348,24 @@ static const CGFloat margin = 15;
348 348
349 }]; 349 }];
350 } 350 }
  351 +
  352 ++ (void)loadServiceInfoServiceId:(NSString *)serviceId result:(nonnull void (^)(CNLiveSearchModel * _Nonnull))succeed error:(void(^)(void))failure
  353 +{
  354 + NSDictionary * params = @{@"sid": CNUserShareModelUid ? CNUserShareModelUid : @"",
  355 + @"serviceId":serviceId
  356 + };
  357 +
  358 + [CNLiveNetworking setAllowRequestDefaultArgument:YES];
  359 + [CNLiveNetworking setupShowDataResult:NO];
  360 + [CNLiveNetworking setupShowResult:YES];
  361 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/contentApi/getServiceInfo") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  362 + CNLiveSearchModel *model = [CNLiveSearchModel mj_objectWithKeyValues:responseObject[@"data"]];
  363 + if (model) {
  364 + !succeed?:succeed(model);
  365 + }else{
  366 + [QMUITips showError:error.localizedDescription inView:AppKeyWindow hideAfterDelay:3];
  367 + !failure?:failure();
  368 + }
  369 + }];
  370 +}
351 @end 371 @end
CNLiveCServiceModule/Classes/View/CNLiveGoodsOrVideoHeaderView.m
@@ -53,6 +53,11 @@ @@ -53,6 +53,11 @@
53 make.centerY.equalTo(self); 53 make.centerY.equalTo(self);
54 }]; 54 }];
55 } 55 }
  56 +#pragma mark - Action
  57 +- (void)moreButtonClick
  58 +{
  59 + [CNLiveCServiceManagerBridge jumpServiceController:_pageModel.blockId type:_pageModel.moreType to:_pageModel.moreUrl shopType:_pageModel.showType controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]];
  60 +}
56 61
57 #pragma mark - Setting&&Getting 62 #pragma mark - Setting&&Getting
58 - (void)setPageModel:(CNliveServicePageModel *)pageModel 63 - (void)setPageModel:(CNliveServicePageModel *)pageModel
@@ -119,6 +124,7 @@ @@ -119,6 +124,7 @@
119 [_moreBtn setTitleColor:CNLiveColorWithHexString(@"#999695") forState:UIControlStateNormal]; 124 [_moreBtn setTitleColor:CNLiveColorWithHexString(@"#999695") forState:UIControlStateNormal];
120 _moreBtn.titleLabel.font = UIFontMake(12); 125 _moreBtn.titleLabel.font = UIFontMake(12);
121 _moreBtn.imagePosition = QMUIButtonImagePositionRight; 126 _moreBtn.imagePosition = QMUIButtonImagePositionRight;
  127 + [_moreBtn addTarget:self action:@selector(moreButtonClick) forControlEvents:UIControlEventTouchUpInside];
122 } 128 }
123 return _moreBtn; 129 return _moreBtn;
124 } 130 }
CNLiveCServiceModule/Classes/View/CNLiveRecommendCell.m
@@ -29,7 +29,12 @@ static NSString *CNVideoRecommendCellID = @&quot;CNLiveVideoRecommendCell&quot;; @@ -29,7 +29,12 @@ static NSString *CNVideoRecommendCellID = @&quot;CNLiveVideoRecommendCell&quot;;
29 } 29 }
30 #pragma mark - UICollectionViewDelegate 30 #pragma mark - UICollectionViewDelegate
31 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ 31 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
32 - 32 + if ([_model.blockName isEqualToString:@"精品音频"]){
  33 + [CNLiveCServiceManagerBridge jumpViewControllerType:CNCServiceJumpTypeVideo param:self.model.contents[indexPath.row] controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]];
  34 + }else{
  35 + CnLivePageContentModel *model = [CnLivePageContentModel mj_objectWithKeyValues:self.model.contents[indexPath.row]];
  36 + [CNLiveCServiceManagerBridge jumpGoodsViewController:model.contentId controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]];
  37 + }
33 } 38 }
34 #pragma mark - UICollectionViewDataSource 39 #pragma mark - UICollectionViewDataSource
35 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 40 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
CNLiveCServiceModule/Classes/View/CNLiveServiceEpiCell.m
@@ -67,7 +67,8 @@ static NSString *CNServiceOrLookID = @&quot;CNLiveServiceOrLookCell&quot;; @@ -67,7 +67,8 @@ static NSString *CNServiceOrLookID = @&quot;CNLiveServiceOrLookCell&quot;;
67 } 67 }
68 #pragma mark - UICollectionViewDelegate 68 #pragma mark - UICollectionViewDelegate
69 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ 69 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
70 - 70 + CnLivePageContentModel *model = [CnLivePageContentModel mj_objectWithKeyValues:self.model.contents[indexPath.row]];
  71 + [CNLiveCServiceManagerBridge jumpGetPageOtherVC:model.contentId controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]];
71 } 72 }
72 #pragma mark - UICollectionViewDataSource 73 #pragma mark - UICollectionViewDataSource
73 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 74 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
CNLiveCServiceModule/Classes/ViewController/CNLiveAllServiceVC.m
@@ -109,7 +109,7 @@ static NSString *HistoryFootID = @&quot;UICollectionFooterView&quot;; @@ -109,7 +109,7 @@ static NSString *HistoryFootID = @&quot;UICollectionFooterView&quot;;
109 CNLiveSearchHotsModel *model = self.dataSource[indexPath.section]; 109 CNLiveSearchHotsModel *model = self.dataSource[indexPath.section];
110 CNLiveSearchModel *model1 = [CNLiveSearchModel mj_objectWithKeyValues:model.lists[indexPath.row]]; 110 CNLiveSearchModel *model1 = [CNLiveSearchModel mj_objectWithKeyValues:model.lists[indexPath.row]];
111 [CNLiveServicePresent usedServiceWithServingId:model1.id]; 111 [CNLiveServicePresent usedServiceWithServingId:model1.id];
112 - 112 + [CNLiveCServiceManagerBridge jumpServiceController:model1.id type:model1.type to:model1.to shopType:model1.shopType controller:self];
113 } 113 }
114 #pragma mark - UICollectionViewDataSource 114 #pragma mark - UICollectionViewDataSource
115 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 115 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
CNLiveCServiceModule/Classes/ViewController/CNLiveMyServicesVC.m
@@ -100,7 +100,7 @@ static NSString *HotListCellID = @&quot;HotListCellID&quot;; @@ -100,7 +100,7 @@ static NSString *HotListCellID = @&quot;HotListCellID&quot;;
100 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ 100 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
101 101
102 CNLiveSearchModel *model1 = self.dataSource[indexPath.row]; 102 CNLiveSearchModel *model1 = self.dataSource[indexPath.row];
103 -#warning 跳转 103 + [CNLiveCServiceManagerBridge jumpServiceController:model1.id type:model1.type to:model1.to shopType:model1.shopType controller:self];
104 104
105 } 105 }
106 #pragma mark - UICollectionViewDataSource 106 #pragma mark - UICollectionViewDataSource
CNLiveCServiceModule/Classes/ViewController/CNLiveServiceSearchVC.m
@@ -164,7 +164,8 @@ static NSString *HistoryFootID = @&quot;HistoryFootID&quot;; @@ -164,7 +164,8 @@ static NSString *HistoryFootID = @&quot;HistoryFootID&quot;;
164 return 75; 164 return 75;
165 } 165 }
166 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 166 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
167 -#warning 跳转 167 + CNLiveSearchModel *model = self.dataListArr[indexPath.row];
  168 + [CNLiveCServiceManagerBridge jumpServiceController:model.id type:model.type to:model.to shopType:model.shopType controller:self];
168 } 169 }
169 #pragma mark - UITableViewDataSource 170 #pragma mark - UITableViewDataSource
170 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 171 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
@@ -182,7 +183,7 @@ static NSString *HistoryFootID = @&quot;HistoryFootID&quot;; @@ -182,7 +183,7 @@ static NSString *HistoryFootID = @&quot;HistoryFootID&quot;;
182 CNLiveSearchHotsModel *model = self.hDataSources[indexPath.section]; 183 CNLiveSearchHotsModel *model = self.hDataSources[indexPath.section];
183 if ([model.title isEqualToString:@"热度推荐"]) { 184 if ([model.title isEqualToString:@"热度推荐"]) {
184 CNLiveSearchModel *model1 = model.lists[indexPath.row]; 185 CNLiveSearchModel *model1 = model.lists[indexPath.row];
185 -#warning 跳转 186 + [CNLiveCServiceManagerBridge jumpServiceController:model1.id type:model1.type to:model1.to shopType:model1.shopType controller:self];
186 }else 187 }else
187 { 188 {
188 CNLiveHistoryModel *model1 = model.lists[indexPath.row]; 189 CNLiveHistoryModel *model1 = model.lists[indexPath.row];
Example/CNLiveCServiceModule/Base.lproj/CNLiveCServiceModuleImpl.h
@@ -7,10 +7,11 @@ @@ -7,10 +7,11 @@
7 // 7 //
8 8
9 #import <Foundation/Foundation.h> 9 #import <Foundation/Foundation.h>
  10 +#import <CNLiveCServiceModule/CNLiveCServiceManagerBridge.h>
10 11
11 NS_ASSUME_NONNULL_BEGIN 12 NS_ASSUME_NONNULL_BEGIN
12 13
13 -@interface CNLiveCServiceModuleImpl : NSObject 14 +@interface CNLiveCServiceModuleImpl : NSObject<CNLiveCServiceProtocol>
14 15
15 @end 16 @end
16 17
Example/CNLiveCServiceModule/Base.lproj/CNLiveCServiceModuleImpl.m
@@ -9,5 +9,7 @@ @@ -9,5 +9,7 @@
9 #import "CNLiveCServiceModuleImpl.h" 9 #import "CNLiveCServiceModuleImpl.h"
10 10
11 @implementation CNLiveCServiceModuleImpl 11 @implementation CNLiveCServiceModuleImpl
12 - 12 +- (void)jumpControllerType:(CNCServiceJumpType)type param:(NSDictionary *_Nullable)param controller:(UIViewController *)controller{
  13 +
  14 +}
13 @end 15 @end