Commit 86f6849e219311dd4f5b8bc1c2189df7b03946eb

Authored by liushiyu
1 parent f16a8aa8

0.0.4

CNLiveCommunitModule.podspec
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 8
9 Pod::Spec.new do |s| 9 Pod::Spec.new do |s|
10 s.name = 'CNLiveCommunitModule' 10 s.name = 'CNLiveCommunitModule'
11 - s.version = '0.0.3' 11 + s.version = '0.0.4'
12 s.summary = 'A short description of CNLiveCommunitModule.' 12 s.summary = 'A short description of CNLiveCommunitModule.'
13 13
14 # This description is used to generate tags and improve search results. 14 # This description is used to generate tags and improve search results.
CNLiveCommunitModule/Assets/CNLiveCommunitModule.bundle/c_community_service_location.png 0 → 100644

564 Bytes

CNLiveCommunitModule/Assets/CNLiveCommunitModule.bundle/c_community_service_location@2x.png 0 → 100644

1.23 KB

CNLiveCommunitModule/Assets/CNLiveCommunitModule.bundle/c_community_service_location@3x.png 0 → 100644

2.29 KB

CNLiveCommunitModule/Classes/Core/CNLiveCommunitHeader.h
@@ -58,6 +58,6 @@ @@ -58,6 +58,6 @@
58 58
59 59
60 static NSString *const kCNLiveCommuntyNBhdIdIdentifier = @"kCNLiveCommuntyNBhdIdIdentifier"; 60 static NSString *const kCNLiveCommuntyNBhdIdIdentifier = @"kCNLiveCommuntyNBhdIdIdentifier";
61 - 61 +static NSString *const kCNLiveCommuntyNBhdNameIdentifier = @"kCNLiveCommuntyNBhdNameIdentifier";
62 62
63 #endif /* CNLiveCommunitHeader_h */ 63 #endif /* CNLiveCommunitHeader_h */
CNLiveCommunitModule/Classes/Core/CNLiveCommunitModuleProtocol.h
@@ -13,10 +13,10 @@ NS_ASSUME_NONNULL_BEGIN @@ -13,10 +13,10 @@ NS_ASSUME_NONNULL_BEGIN
13 13
14 /// 获取主工程的WebView 14 /// 获取主工程的WebView
15 /// @param webUrl url 15 /// @param webUrl url
16 --(UIViewController *)pushWebViewWithMainProjectWithWebUrl:(NSString *)webUrl; 16 +-(UIViewController *)pushWebViewWithMainProjectWithWebUrl:(NSString *)webUrl type:(NSString *)type;
17 17
18 /// 用主工程的webView打开 18 /// 用主工程的webView打开
19 -/// @param webUrl url 19 +/// @param paramDict url
20 -(void)pushWebViewWithMainProjectWithParamDict:(NSDictionary *)paramDict; 20 -(void)pushWebViewWithMainProjectWithParamDict:(NSDictionary *)paramDict;
21 21
22 /// 调用工程中支付功能 22 /// 调用工程中支付功能
CNLiveCommunitModule/Classes/Core/CNLiveCommuntyModule.m
@@ -39,9 +39,11 @@ @@ -39,9 +39,11 @@
39 NSString * nbhdId = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:kCNLiveCommuntyNBhdIdIdentifier]; 39 NSString * nbhdId = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:kCNLiveCommuntyNBhdIdIdentifier];
40 if ([nbhdId isNotBlank]) { 40 if ([nbhdId isNotBlank]) {
41 CNLiveCommuntViewController * homeVC = [[CNLiveCommuntViewController alloc] initWithNBhdId:nbhdId]; 41 CNLiveCommuntViewController * homeVC = [[CNLiveCommuntViewController alloc] initWithNBhdId:nbhdId];
  42 + homeVC.hidesBottomBarWhenPushed = YES;
42 [[CNLiveCommuntTools cCommunt_currentViewController].navigationController pushViewController:homeVC animated:YES]; 43 [[CNLiveCommuntTools cCommunt_currentViewController].navigationController pushViewController:homeVC animated:YES];
43 }else{ 44 }else{
44 CNLiveCommuntyHomeListViewController * homeListVC = [[CNLiveCommuntyHomeListViewController alloc] init]; 45 CNLiveCommuntyHomeListViewController * homeListVC = [[CNLiveCommuntyHomeListViewController alloc] init];
  46 + homeListVC.hidesBottomBarWhenPushed = YES;
45 [[CNLiveCommuntTools cCommunt_currentViewController].navigationController pushViewController:homeListVC animated:YES]; 47 [[CNLiveCommuntTools cCommunt_currentViewController].navigationController pushViewController:homeListVC animated:YES];
46 } 48 }
47 } 49 }
CNLiveCommunitModule/Classes/Model/CNLiveCommuntyHomeModel.h
@@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN @@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
18 @property (nonatomic, copy) NSString *idStr; 18 @property (nonatomic, copy) NSString *idStr;
19 @property (nonatomic, copy) NSString *cmsPageId; 19 @property (nonatomic, copy) NSString *cmsPageId;
20 @property (nonatomic, copy) NSString *cmsPageType; 20 @property (nonatomic, copy) NSString *cmsPageType;
  21 +@property (nonatomic, copy) NSString *cmsPageUrl;
21 @property (nonatomic, copy) NSString *type; 22 @property (nonatomic, copy) NSString *type;
22 @property (nonatomic, copy) NSString *columnName; 23 @property (nonatomic, copy) NSString *columnName;
23 @property (nonatomic, copy) NSString *columnImgUncheck; 24 @property (nonatomic, copy) NSString *columnImgUncheck;
@@ -33,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN @@ -33,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
33 @property (nonatomic, copy) NSString *columnImg; 34 @property (nonatomic, copy) NSString *columnImg;
34 @property (nonatomic, copy) NSString *idStr; 35 @property (nonatomic, copy) NSString *idStr;
35 @property (nonatomic, copy) NSString *type; 36 @property (nonatomic, copy) NSString *type;
  37 +@property (nonatomic, copy) NSString *cmsPageUrl;
36 @property (nonatomic, copy) NSString *cmsPageId; 38 @property (nonatomic, copy) NSString *cmsPageId;
37 @property (nonatomic, copy) NSString *cmsPageType; 39 @property (nonatomic, copy) NSString *cmsPageType;
38 @property (nonatomic, copy) NSString *columnName; 40 @property (nonatomic, copy) NSString *columnName;
@@ -77,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN @@ -77,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
77 @property (nonatomic, copy) NSString *age; 79 @property (nonatomic, copy) NSString *age;
78 /**0未缴费 1已缴费*/ 80 /**0未缴费 1已缴费*/
79 @property (nonatomic, copy) NSString *paymentStatus; 81 @property (nonatomic, copy) NSString *paymentStatus;
80 -/**自己定义 0未开始 1进行中 2已结束 3待评价 4退款*/ 82 +/**活动状态 0草稿 1活动已发布 2活动已取消*/
81 @property (nonatomic, copy) NSString *status; 83 @property (nonatomic, copy) NSString *status;
82 @property (nonatomic, copy) NSString *createUser; 84 @property (nonatomic, copy) NSString *createUser;
83 @property (nonatomic, copy) NSString *handworkName; 85 @property (nonatomic, copy) NSString *handworkName;
CNLiveCommunitModule/Classes/Model/CNLiveCommuntyHomeModel.m
@@ -28,6 +28,14 @@ MJCodingImplementation @@ -28,6 +28,14 @@ MJCodingImplementation
28 [self.titles addObject:[subDict stringValueForKey:@"columnName" default:@""]]; 28 [self.titles addObject:[subDict stringValueForKey:@"columnName" default:@""]];
29 } 29 }
30 } 30 }
  31 +#ifdef DEBUG
  32 + if ([property.name isEqualToString:@"cmsPageUrl"]) {
  33 + if (oldValue == nil || [oldValue isKindOfClass:NSNull.class]) {
  34 + oldValue = @"https://www.baidu.com";
  35 + }
  36 + }
  37 +#else
  38 +#endif
31 return oldValue; 39 return oldValue;
32 } 40 }
33 @end 41 @end
@@ -40,7 +48,18 @@ MJCodingImplementation @@ -40,7 +48,18 @@ MJCodingImplementation
40 { 48 {
41 return @{@"idStr":@"id"}; 49 return @{@"idStr":@"id"};
42 } 50 }
43 - 51 +- (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property
  52 +{
  53 +#ifdef DEBUG
  54 + if ([property.name isEqualToString:@"cmsPageUrl"]) {
  55 + if (oldValue == nil || [oldValue isKindOfClass:NSNull.class]) {
  56 + oldValue = @"https://www.baidu.com";
  57 + }
  58 + }
  59 +#else
  60 +#endif
  61 + return oldValue;
  62 +}
44 @end 63 @end
45 64
46 65
CNLiveCommunitModule/Classes/ViewController/CNLiveCommuntActiviViewController.h
@@ -9,14 +9,11 @@ @@ -9,14 +9,11 @@
9 9
10 NS_ASSUME_NONNULL_BEGIN 10 NS_ASSUME_NONNULL_BEGIN
11 11
12 -typedef enum : NSUInteger {  
13 - CNLiveCommuntActiviShowTypeLive,//显示视讯列表界面内容  
14 - CNLiveCommuntActiviShowTypeWeb//使用内置网页  
15 -} CNLiveCommuntActiviShowType;  
16 -  
17 @interface CNLiveCommuntActiviViewController : DSBaseViewController<JXCategoryListContentViewDelegate> 12 @interface CNLiveCommuntActiviViewController : DSBaseViewController<JXCategoryListContentViewDelegate>
18 13
19 - 14 +/// 初始化网页界面显示
  15 +/// @param webUrl 内容URL
  16 +- (instancetype)initWithWebUrl:(NSString *)webUrl isRootVC:(BOOL)isRootVC Type:(NSString *)type;
20 @end 17 @end
21 18
22 NS_ASSUME_NONNULL_END 19 NS_ASSUME_NONNULL_END
CNLiveCommunitModule/Classes/ViewController/CNLiveCommuntActiviViewController.m
@@ -8,35 +8,119 @@ @@ -8,35 +8,119 @@
8 #import "CNLiveCommuntActiviViewController.h" 8 #import "CNLiveCommuntActiviViewController.h"
9 9
10 @interface CNLiveCommuntActiviViewController () 10 @interface CNLiveCommuntActiviViewController ()
11 -@property (nonatomic, assign) CNLiveCommuntActiviShowType showType; 11 +@property (nonatomic, strong) WKWebView *webView;
  12 +@property (nonatomic, copy) NSString *webUrl;
  13 +@property (nonatomic, assign) BOOL isLoading;
  14 +@property (nonatomic, assign) BOOL isRootVC;
  15 +@property (nonatomic, copy) NSString * type;
12 @end 16 @end
13 17
14 @implementation CNLiveCommuntActiviViewController 18 @implementation CNLiveCommuntActiviViewController
15 19
16 -- (instancetype)initWithShowType:(CNLiveCommuntActiviShowType)showType 20 +- (instancetype)initWithWebUrl:(NSString *)webUrl isRootVC:(BOOL)isRootVC Type:(NSString *)type
17 { 21 {
18 self = [super init]; 22 self = [super init];
19 if (self) { 23 if (self) {
20 - _showType = showType; 24 + _isRootVC = isRootVC;
  25 + _webUrl = webUrl;
  26 + _isRootVC = isRootVC;
  27 + _type = type;
21 } 28 }
22 return self; 29 return self;
23 } 30 }
24 - 31 +- (void)dealloc
  32 +{
  33 + UIViewController *vc = self.childViewControllers[0];
  34 + if (([self searchProperties:[vc class] string:@"webView"] || [self searchProperties:[vc.superclass class] string:@"webView"])&&[vc valueForKey:@"webView"]&&[[vc valueForKey:@"webView"] isKindOfClass:[WKWebView class]]) {
  35 + WKWebView *webView = (WKWebView *)[vc valueForKey:@"webView"];
  36 + if ([webView.scrollView valueForKey:@"mj_header"]) {
  37 + id header = [webView.scrollView valueForKey:@"mj_header"];
  38 + [header removeObserver:self forKeyPath:@"state"];
  39 + }
  40 + }
  41 +}
25 42
26 - (void)viewDidLoad { 43 - (void)viewDidLoad {
27 [super viewDidLoad]; 44 [super viewDidLoad];
28 // Do any additional setup after loading the view. 45 // Do any additional setup after loading the view.
29 - UIViewController *subVC = [UIViewController new];  
30 - if (self.showType == CNLiveCommuntActiviShowTypeLive) {  
31 - subVC = [[CNLiveCommuntyModule shareInstance].protocol pushWebViewWithMainProjectWithWebUrl:@"https://www.baidu.com"];  
32 - }  
33 - if (self.showType == CNLiveCommuntActiviShowTypeWeb) {  
34 - subVC = [[CNLiveCommuntyModule shareInstance].protocol pushWebViewWithMainProjectWithWebUrl:@"https://gitee.com"];  
35 - } 46 + UIViewController *subVC = [[CNLiveCommuntyModule shareInstance].protocol pushWebViewWithMainProjectWithWebUrl:self.webUrl type:self.type];
36 [self.view addSubview:subVC.view]; 47 [self.view addSubview:subVC.view];
37 [self addChildViewController:subVC]; 48 [self addChildViewController:subVC];
38 [subVC didMoveToParentViewController:self]; 49 [subVC didMoveToParentViewController:self];
39 50
  51 + if (self.isRootVC) {
  52 + [subVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
  53 + make.top.mas_equalTo(kNavigationBarHeight);
  54 + make.left.bottom.right.mas_equalTo(self.view);
  55 + }];
  56 + }
  57 +
  58 +
  59 + UIViewController *vc = self.childViewControllers[0];
  60 + if (([self searchProperties:[vc class] string:@"webView"]||[self searchProperties:[vc.superclass class] string:@"webView"]) && [vc valueForKey:@"webView"] && [[vc valueForKey:@"webView"] isKindOfClass:[WKWebView class]]) {
  61 + self.webView = (WKWebView *)[vc valueForKey:@"webView"];
  62 + [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
  63 + if (self.isRootVC) {
  64 + make.top.mas_equalTo(kNavigationBarHeight);
  65 + }else{
  66 + make.top.mas_equalTo(self.view);
  67 + }
  68 + make.left.bottom.right.mas_equalTo(self.view);
  69 + }];
  70 + if (!self.isLoading) [self.webView.scrollView.mj_header beginRefreshing];
  71 + if ([self.webView.scrollView valueForKey:@"mj_header"]) {
  72 + id header = [self.webView.scrollView valueForKey:@"mj_header"];
  73 + [header addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:nil];
  74 + }
  75 + }
  76 + if (self.isRootVC) [self initNav];
  77 +}
  78 +
  79 +-(void)initNav
  80 +{
  81 + self.topNavView.backgroundColor = [UIColor whiteColor];
  82 + self.topLine.backgroundColor = [UIColor whiteColor];
  83 +
  84 + DSNavButton * searchBtn = [[DSNavButton alloc] initWithImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communit_back"]];
  85 + [searchBtn addTarget:self action:@selector(leftNavBtnAction) forControlEvents:UIControlEventTouchUpInside];
  86 + self.leftNavBtns = @[searchBtn];
  87 +}
  88 +
  89 +-(void)leftNavBtnAction
  90 +{
  91 + [self.navigationController popViewControllerAnimated:YES];
  92 +}
  93 +
  94 +- (BOOL)searchProperties:(Class)cls string:(NSString *)key
  95 +{
  96 + unsigned int count;
  97 + objc_property_t *properties = class_copyPropertyList(cls, &count);
  98 + for (int i = 0; i < count; i++) {
  99 + objc_property_t property = properties[i];
  100 + const char *cName = property_getName(property);
  101 + NSString *name = [NSString stringWithCString:cName encoding:NSUTF8StringEncoding];
  102 + if ([name isEqualToString:key]) {
  103 + return YES;
  104 + }
  105 + }
  106 + return NO;
  107 +}
  108 +
  109 +#pragma mark - KVO
  110 +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
  111 +{
  112 + NSLog(@"%@:%@",object,change);
  113 + if ([keyPath isEqualToString:@"state"]) {
  114 + NSString *state = change[NSKeyValueChangeNewKey];
  115 + if (state.integerValue == 1) {
  116 + [self performSelector:@selector(delayAction) afterDelay:1];
  117 + }else{
  118 + self.isLoading = YES;
  119 + }
  120 + }
  121 +}
  122 +- (void)delayAction{
  123 + self.isLoading = NO;
40 } 124 }
41 125
42 - (UIView *)listView { 126 - (UIView *)listView {
CNLiveCommunitModule/Classes/ViewController/CNLiveCommuntConsuViewController.m
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 // 6 //
7 7
8 #import "CNLiveCommuntConsuViewController.h" 8 #import "CNLiveCommuntConsuViewController.h"
9 - 9 +#import "CNLiveCommuntServiceViewController.h"
10 static NSInteger const kCNLiveSectionTitleHeight = 44;//标题显示 10 static NSInteger const kCNLiveSectionTitleHeight = 44;//标题显示
11 11
12 @interface CNLiveCommuntConsuViewController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate> 12 @interface CNLiveCommuntConsuViewController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
@@ -106,18 +106,14 @@ static NSInteger const kCNLiveSectionTitleHeight = 44;//标题显示 @@ -106,18 +106,14 @@ static NSInteger const kCNLiveSectionTitleHeight = 44;//标题显示
106 if ([homeModel.type isEqualToString:@"2"]) {//公益活动 106 if ([homeModel.type isEqualToString:@"2"]) {//公益活动
107 [_viewControllers addObject:[[CNLiveCommuntListViewController alloc] initWithShowType:CNLiveCommuntListShowTypeHome NBhdId:self.nbhdId]]; 107 [_viewControllers addObject:[[CNLiveCommuntListViewController alloc] initWithShowType:CNLiveCommuntListShowTypeHome NBhdId:self.nbhdId]];
108 }else{ 108 }else{
109 - if ([homeModel.cmsPageType isEqualToString:@"1"]) {//调用H5  
110 - [_viewControllers addObject:[[CNLiveCommuntActiviViewController alloc] init]];  
111 - }  
112 if ([homeModel.cmsPageType isEqualToString:@"4"]) {//调用视讯 109 if ([homeModel.cmsPageType isEqualToString:@"4"]) {//调用视讯
113 - [_viewControllers addObject:[[CNLiveCommuntActiviViewController alloc] init]];  
114 - }  
115 -#ifdef DEBUG  
116 - if (![homeModel.cmsPageType isNotBlank]) {  
117 - [_viewControllers addObject:[[CNLiveCommuntActiviViewController alloc] init]]; 110 + CNLiveCommuntServiceViewController * vc = [[CNLiveCommuntServiceViewController alloc] initWithHomeSubModel:homeModel isRootVC:NO isShowLocation:NO];
  111 + vc.title = homeModel.columnName;
  112 + vc.view.backgroundColor = [UIColor whiteColor];
  113 + [_viewControllers addObject:vc];
  114 + }else{
  115 + [_viewControllers addObject:[[CNLiveCommuntActiviViewController alloc] initWithWebUrl:[homeModel.cmsPageUrl isNotBlank]?homeModel.cmsPageUrl:@"" isRootVC:NO Type:homeModel.cmsPageType]];
118 } 116 }
119 -#else  
120 -#endif  
121 } 117 }
122 } 118 }
123 } 119 }
CNLiveCommunitModule/Classes/ViewController/CNLiveCommuntServiceViewController.h
@@ -9,8 +9,9 @@ @@ -9,8 +9,9 @@
9 9
10 NS_ASSUME_NONNULL_BEGIN 10 NS_ASSUME_NONNULL_BEGIN
11 11
12 -@interface CNLiveCommuntServiceViewController : DSBaseViewController  
13 - 12 +@interface CNLiveCommuntServiceViewController : DSBaseViewController<JXCategoryListContentViewDelegate>
  13 +- (instancetype)initWithHomeModel:(CNLiveCommuntyHomeModel *)homeModel isRootVC:(BOOL)isRootVC isShowLocation:(BOOL)isShowLocation;
  14 +- (instancetype)initWithHomeSubModel:(CNLiveCommuntySubHomeModel *)homeSubModel isRootVC:(BOOL)isRootVC isShowLocation:(BOOL)isShowLocation;
14 @end 15 @end
15 16
16 NS_ASSUME_NONNULL_END 17 NS_ASSUME_NONNULL_END
CNLiveCommunitModule/Classes/ViewController/CNLiveCommuntServiceViewController.m
@@ -10,20 +10,102 @@ @@ -10,20 +10,102 @@
10 10
11 #define kGNCOLGRIDVIEWID @"GNCOLGRIDVIEWID" 11 #define kGNCOLGRIDVIEWID @"GNCOLGRIDVIEWID"
12 12
13 -@interface CNLiveCommuntServiceViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>  
14 -@property (nonatomic, strong) UICollectionView * collectionView;  
15 - 13 +@interface CNLiveCommuntServiceViewController ()
  14 +@property (nonatomic, strong) CNLiveCommuntyHomeModel * homeModel;
  15 +@property (nonatomic, strong) CNLiveCommuntySubHomeModel * homeSubModel;
  16 +@property (nonatomic, assign) BOOL isRootVC;
  17 +@property (nonatomic, assign) BOOL isLoading;
  18 +@property (nonatomic, assign) BOOL isShowLocation;
16 @end 19 @end
17 20
18 @implementation CNLiveCommuntServiceViewController 21 @implementation CNLiveCommuntServiceViewController
19 22
  23 +- (instancetype)initWithHomeModel:(CNLiveCommuntyHomeModel *)homeModel isRootVC:(BOOL)isRootVC isShowLocation:(BOOL)isShowLocation
  24 +{
  25 + self = [super init];
  26 + if (self) {
  27 + _isShowLocation = isShowLocation;
  28 + _isRootVC = isRootVC;
  29 + _homeModel = homeModel;
  30 + _isRootVC = isRootVC;
  31 + }
  32 + return self;
  33 +}
  34 +- (instancetype)initWithHomeSubModel:(CNLiveCommuntySubHomeModel *)homeSubModel isRootVC:(BOOL)isRootVC isShowLocation:(BOOL)isShowLocation
  35 +{
  36 + self = [super init];
  37 + if (self) {
  38 + _isShowLocation = isShowLocation;
  39 + _isRootVC = isRootVC;
  40 + _homeSubModel = homeSubModel;
  41 + _isRootVC = isRootVC;
  42 + }
  43 + return self;
  44 +}
  45 +
20 - (void)viewDidLoad { 46 - (void)viewDidLoad {
21 [super viewDidLoad]; 47 [super viewDidLoad];
22 // Do any additional setup after loading the view. 48 // Do any additional setup after loading the view.
23 self.view.backgroundColor = [UIColor whiteColor]; 49 self.view.backgroundColor = [UIColor whiteColor];
24 - [self initNav]; 50 +
  51 + NSString * cmsPageId = self.homeModel?self.homeModel.cmsPageId:self.homeSubModel.cmsPageId;
  52 + NSString * cmsColumnId = self.homeModel?self.homeModel.cmsColumnId:self.homeSubModel.cmsColumnId;
  53 + NSString * cmsPageUrl = self.homeModel?self.homeModel.cmsPageUrl:self.homeSubModel.cmsPageUrl;
  54 +
  55 + UIViewController * subVC = [[CNLiveCommuntyModule shareInstance].protocol pushLiveViewWithMainProjectWithPageId:cmsPageId ChannelName:self.homeModel.cmsColumnName ChannelId:cmsColumnId WebUrl:cmsPageUrl];
  56 + [self.view addSubview:subVC.view];
  57 + [self addChildViewController:subVC];
  58 + [subVC didMoveToParentViewController:self];
  59 +
  60 + if (self.isRootVC) {
  61 + [subVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
  62 + make.top.mas_equalTo(kNavigationBarHeight);
  63 + make.left.bottom.right.mas_equalTo(self.view);
  64 + }];
  65 + }
25 66
26 -// [self.view addSubview:self.collectionView]; 67 + UIViewController *vc = self.childViewControllers[0];
  68 + if ([self searchProperties:[vc class] string:@"collectionView"]&&[vc valueForKey:@"collectionView"] && [[vc valueForKey:@"collectionView"] isKindOfClass:[UICollectionView class]]){
  69 + UICollectionView *collectionView = (UICollectionView *)[vc valueForKey:@"collectionView"];
  70 + if (!self.isLoading) [collectionView.mj_header beginRefreshing];
  71 + if ([collectionView valueForKey:@"mj_header"]) {
  72 + id header = [collectionView valueForKey:@"mj_header"];
  73 + [header addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:nil];
  74 + }
  75 + }
  76 +
  77 + if (self.isRootVC) [self initNav];
  78 +}
  79 +- (BOOL)searchProperties:(Class)cls string:(NSString *)key
  80 +{
  81 + unsigned int count;
  82 + objc_property_t *properties = class_copyPropertyList(cls, &count);
  83 + for (int i = 0; i < count; i++) {
  84 + objc_property_t property = properties[i];
  85 + const char *cName = property_getName(property);
  86 + NSString *name = [NSString stringWithCString:cName encoding:NSUTF8StringEncoding];
  87 + if ([name isEqualToString:key]) {
  88 + return YES;
  89 + }
  90 + }
  91 + return NO;
  92 +}
  93 +
  94 +#pragma mark - KVO
  95 +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
  96 +{
  97 + NSLog(@"%@:%@",object,change);
  98 + if ([keyPath isEqualToString:@"state"]) {
  99 + NSString *state = change[NSKeyValueChangeNewKey];
  100 + if (state.integerValue == 1) {
  101 + [self performSelector:@selector(delayAction) afterDelay:1];
  102 + }else{
  103 + self.isLoading = YES;
  104 + }
  105 + }
  106 +}
  107 +- (void)delayAction{
  108 + self.isLoading = NO;
27 } 109 }
28 -(void)initNav 110 -(void)initNav
29 { 111 {
@@ -33,28 +115,25 @@ @@ -33,28 +115,25 @@
33 DSNavButton * searchBtn = [[DSNavButton alloc] initWithImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communit_back"]]; 115 DSNavButton * searchBtn = [[DSNavButton alloc] initWithImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_communit_back"]];
34 [searchBtn addTarget:self action:@selector(leftNavBtnAction) forControlEvents:UIControlEventTouchUpInside]; 116 [searchBtn addTarget:self action:@selector(leftNavBtnAction) forControlEvents:UIControlEventTouchUpInside];
35 self.leftNavBtns = @[searchBtn]; 117 self.leftNavBtns = @[searchBtn];
  118 +
  119 + if (self.isShowLocation) {
  120 + NSString * name = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:kCNLiveCommuntyNBhdNameIdentifier];
  121 + DSNavButton * rightBtn = [[DSNavButton alloc] initWithImage:[CNLiveCommuntTools cCommunt_setImageWithName:@"c_community_service_location"] imageSize:CGSizeMake(15, 15) title:name font:[UIFont systemFontOfSize:10] titleColor:UIColorHex(#333333) imagePosition:DSImagePositionLeft];
  122 + rightBtn.size = CGSizeMake(80, self.topNavViewHeight - kStatusHeight);
  123 + [rightBtn addTarget:self action:@selector(rightNavBtnAction) forControlEvents:UIControlEventTouchUpInside];
  124 + self.rightNavBtns = @[rightBtn];
  125 + }
  126 +}
  127 +-(void)rightNavBtnAction
  128 +{
  129 + CNLiveCommuntyHomeListViewController * listView = [[CNLiveCommuntyHomeListViewController alloc] init];
  130 + [[self displayViewController] dsPushViewController:listView animated:YES];
36 } 131 }
37 -(void)leftNavBtnAction 132 -(void)leftNavBtnAction
38 { 133 {
39 [self.navigationController popViewControllerAnimated:YES]; 134 [self.navigationController popViewControllerAnimated:YES];
40 } 135 }
41 -#pragma mark =  
42 -//- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section  
43 -//{  
44 -//  
45 -//}  
46 -#pragma mark =  
47 --(UICollectionView *)collectionView  
48 -{  
49 - if (!_collectionView) {  
50 - UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc] init];  
51 - layout.itemSize = CGSizeMake(SCREEN_WIDTH/4, SCREEN_WIDTH/4);  
52 - _collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];  
53 - _collectionView.delegate = self;  
54 - _collectionView.dataSource = self;  
55 - _collectionView.showsVerticalScrollIndicator = NO;  
56 - [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:kGNCOLGRIDVIEWID];  
57 - }  
58 - return _collectionView; 136 +- (UIView *)listView {
  137 + return self.view;
59 } 138 }
60 @end 139 @end
CNLiveCommunitModule/Classes/ViewController/CNLiveCommuntViewController.m
@@ -70,20 +70,32 @@ @@ -70,20 +70,32 @@
70 [weakSelf addChildViewController:vc noralImage:[subDict objectForKey:@"nomal"] selectImage:[subDict objectForKey:@"select"]]; 70 [weakSelf addChildViewController:vc noralImage:[subDict objectForKey:@"nomal"] selectImage:[subDict objectForKey:@"select"]];
71 }else{ 71 }else{
72 if ([homeModel.type isEqualToString:@"3"]) {//生活服务界面 原生 72 if ([homeModel.type isEqualToString:@"3"]) {//生活服务界面 原生
73 - CNLiveCommuntServiceViewController * vc = [[CNLiveCommuntServiceViewController alloc] init]; 73 + CNLiveCommuntServiceViewController * vc = [[CNLiveCommuntServiceViewController alloc] initWithHomeModel:homeModel isRootVC:YES isShowLocation:YES];
74 vc.title = homeModel.columnName; 74 vc.title = homeModel.columnName;
75 - vc.view.backgroundColor = [UIColor cyanColor]; 75 + vc.view.backgroundColor = [UIColor whiteColor];
  76 + [weakSelf addChildViewController:vc noralImage:[subDict objectForKey:@"nomal"] selectImage:[subDict objectForKey:@"select"]];
  77 + }
  78 + if ([homeModel.type isEqualToString:@"2"]) {
  79 + CNLiveCommuntListViewController * vc = [[CNLiveCommuntListViewController alloc] initWithShowType:CNLiveCommuntListShowTypeHome NBhdId:homeModel.idStr];
  80 + vc.title = homeModel.columnName;
  81 + vc.view.backgroundColor = [UIColor whiteColor];
76 [weakSelf addChildViewController:vc noralImage:[subDict objectForKey:@"nomal"] selectImage:[subDict objectForKey:@"select"]]; 82 [weakSelf addChildViewController:vc noralImage:[subDict objectForKey:@"nomal"] selectImage:[subDict objectForKey:@"select"]];
77 } 83 }
78 - if ([homeModel.type isEqualToString:@"2"] && [homeModel.cmsPageType isEqualToString:@"1"]) {//调用主工程H5界面  
79 - CNLiveCommuntActiviViewController * vc = [[CNLiveCommuntActiviViewController alloc] init];  
80 - vc.title = @"调用主工程H5界面"; 84 + if (![homeModel.type isNotBlank] && [homeModel.cmsPageType isNotBlank] && ![homeModel.cmsPageType isEqualToString:@"4"]) {
  85 + CNLiveCommuntActiviViewController * vc = [[CNLiveCommuntActiviViewController alloc] initWithWebUrl:homeModel.cmsPageUrl isRootVC:YES Type:homeModel.cmsPageType];
  86 + vc.title = homeModel.columnName;
81 vc.view.backgroundColor = [UIColor whiteColor]; 87 vc.view.backgroundColor = [UIColor whiteColor];
82 [weakSelf addChildViewController:vc noralImage:[subDict objectForKey:@"nomal"] selectImage:[subDict objectForKey:@"select"]]; 88 [weakSelf addChildViewController:vc noralImage:[subDict objectForKey:@"nomal"] selectImage:[subDict objectForKey:@"select"]];
83 } 89 }
84 - if ([homeModel.type isEqualToString:@"2"] && [homeModel.cmsPageType isEqualToString:@"4"]) {//调用主工程中的视讯界面 并进行传参  
85 - CNLiveCommuntActiviViewController * vc = [[CNLiveCommuntActiviViewController alloc] init];  
86 - vc.title = @"调用主工程中的视讯界面 并进行传参"; 90 + if (![homeModel.type isNotBlank] && [homeModel.cmsPageType isEqualToString:@"4"]) {
  91 + CNLiveCommuntServiceViewController * vc = [[CNLiveCommuntServiceViewController alloc] initWithHomeModel:homeModel isRootVC:YES isShowLocation:NO];
  92 + vc.title = homeModel.columnName;
  93 + vc.view.backgroundColor = [UIColor whiteColor];
  94 + [weakSelf addChildViewController:vc noralImage:[subDict objectForKey:@"nomal"] selectImage:[subDict objectForKey:@"select"]];
  95 + }
  96 + if (![homeModel.type isNotBlank] && ![homeModel.cmsPageType isNotBlank] && [homeModel.cmsPageUrl isNotBlank]) {
  97 + CNLiveCommuntActiviViewController * vc = [[CNLiveCommuntActiviViewController alloc] initWithWebUrl:homeModel.cmsPageUrl isRootVC:YES Type:@"1"];
  98 + vc.title = homeModel.columnName;
87 vc.view.backgroundColor = [UIColor whiteColor]; 99 vc.view.backgroundColor = [UIColor whiteColor];
88 [weakSelf addChildViewController:vc noralImage:[subDict objectForKey:@"nomal"] selectImage:[subDict objectForKey:@"select"]]; 100 [weakSelf addChildViewController:vc noralImage:[subDict objectForKey:@"nomal"] selectImage:[subDict objectForKey:@"select"]];
89 } 101 }
CNLiveCommunitModule/Classes/ViewController/CNLiveCommuntyHomeListViewController.m
@@ -126,11 +126,26 @@ @@ -126,11 +126,26 @@
126 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 126 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
127 { 127 {
128 CNLiveCommuntyHomeListModel * listModel = self.dataSource[indexPath.row]; 128 CNLiveCommuntyHomeListModel * listModel = self.dataSource[indexPath.row];
129 - [[NSUserDefaults standardUserDefaults] setObject:listModel.idStr forKey:kCNLiveCommuntyNBhdIdIdentifier];  
130 - [[NSUserDefaults standardUserDefaults] synchronize];  
131 - CNLiveCommuntViewController * homeView = [[CNLiveCommuntViewController alloc] initWithNBhdId:listModel.idStr];  
132 - [self.navigationController pushViewController:homeView animated:YES];  
133 -  
134 - 129 + if (listModel && [listModel.idStr isNotBlank]) {
  130 + NSMutableArray * tempArray = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers];
  131 + for (UIViewController * vc in self.navigationController.viewControllers) {
  132 + if ([vc isKindOfClass:CNLiveCommuntyHomeListViewController.class]) {
  133 + [tempArray removeObject:vc];
  134 + break;
  135 + }
  136 + if ([vc isKindOfClass:CNLiveCommuntViewController.class]) {
  137 + [tempArray removeObject:vc];
  138 + break;
  139 + }
  140 + }
  141 + self.navigationController.viewControllers = tempArray;
  142 +
  143 + [[NSUserDefaults standardUserDefaults] setObject:listModel.idStr forKey:kCNLiveCommuntyNBhdIdIdentifier];
  144 + [[NSUserDefaults standardUserDefaults] synchronize];
  145 + [[NSUserDefaults standardUserDefaults] setObject:listModel.name forKey:kCNLiveCommuntyNBhdNameIdentifier];
  146 + [[NSUserDefaults standardUserDefaults] synchronize];
  147 + CNLiveCommuntViewController * homeView = [[CNLiveCommuntViewController alloc] initWithNBhdId:listModel.idStr];
  148 + [self.navigationController pushViewController:homeView animated:YES];
  149 + }
135 } 150 }
136 @end 151 @end
CNLiveCommunitModule/Classes/ViewModel/CNLiveCommuntViewModel.m
@@ -59,18 +59,25 @@ @@ -59,18 +59,25 @@
59 [CNLiveNetworking setupShowResult:YES]; 59 [CNLiveNetworking setupShowResult:YES];
60 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNCCommuntHomeListContentURL Param:@{@"nbhdId":[nbhdId isNotBlank]?nbhdId:@""} CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { 60 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNCCommuntHomeListContentURL Param:@{@"nbhdId":[nbhdId isNotBlank]?nbhdId:@""} CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
61 [QMUITips hideAllTipsInView:[CNLiveCommuntTools cCommunt_currentViewController].view]; 61 [QMUITips hideAllTipsInView:[CNLiveCommuntTools cCommunt_currentViewController].view];
62 - [CNLiveCommuntViewModel communty_chooseRequestWithResponseObject:responseObject Error:error isData:YES CompleterBlock:^(id responseObject) {  
63 - if (responseObject) {  
64 - NSMutableArray * tempArray = [CNLiveCommuntyHomeModel mj_objectArrayWithKeyValuesArray:responseObject]; 62 + [CNLiveCommuntViewModel communty_chooseRequestWithResponseObject:responseObject Error:error isData:NO CompleterBlock:^(id responseObject) {
  63 + if (responseObject && [[responseObject numberValueForKey:@"errorCode" default:@1] isEqualToNumber:@0]) {
  64 + NSMutableArray * tempArray = [CNLiveCommuntyHomeModel mj_objectArrayWithKeyValuesArray:[responseObject objectForKey:@"data"]];
65 [CNLiveRespCacheManager cachePathWithObject:responseObject FileName:CNCCommuntHomeListContentURL]; 65 [CNLiveRespCacheManager cachePathWithObject:responseObject FileName:CNCCommuntHomeListContentURL];
66 if (tempArray.count > 0 && completerBlock) completerBlock(tempArray); 66 if (tempArray.count > 0 && completerBlock) completerBlock(tempArray);
67 }else{ 67 }else{
68 - id resp = [CNLiveRespCacheManager objectCacheWithFileName:CNCCommuntHomeListContentURL];  
69 - NSMutableArray * tempArray = [CNLiveCommuntyHomeModel mj_objectArrayWithKeyValuesArray:resp];  
70 - if (tempArray.count > 0) {  
71 - if (completerBlock) completerBlock(tempArray); 68 + if (![[responseObject numberValueForKey:@"errorCode" default:@1] isEqualToNumber:@100062]) {
  69 + id resp = [CNLiveRespCacheManager objectCacheWithFileName:CNCCommuntHomeListContentURL];
  70 + NSMutableArray * tempArray = [CNLiveCommuntyHomeModel mj_objectArrayWithKeyValuesArray:resp];
  71 + if (tempArray.count > 0) {
  72 + if (completerBlock) completerBlock(tempArray);
  73 + }else{
  74 + if (completerBlock) completerBlock(nil);
  75 + }
72 }else{ 76 }else{
73 - if (completerBlock) completerBlock(nil); 77 + [QMUITips showError:[responseObject stringValueForKey:@"errorMessage" default:@""] inView:[CNLiveCommuntTools cCommunt_currentViewController].view hideAfterDelay:2];
  78 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  79 + [[self displayViewController] dsPopViewControllerAnimated:YES];
  80 + });
74 } 81 }
75 } 82 }
76 }]; 83 }];
Example/CNLiveCommunitModule/CNLiveCommunitModuleImpl.m
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 @implementation CNLiveCommunitModuleImpl 11 @implementation CNLiveCommunitModuleImpl
12 /// 获取主工程的WebView 12 /// 获取主工程的WebView
13 /// @param webUrl url 13 /// @param webUrl url
14 --(UIViewController *)pushWebViewWithMainProjectWithWebUrl:(NSString *)webUrl 14 +-(UIViewController *)pushWebViewWithMainProjectWithWebUrl:(NSString *)webUrl type:(NSString *)type
15 { 15 {
16 CNLIVEMainViewController * VC = [[CNLIVEMainViewController alloc] initWithUrl:webUrl]; 16 CNLIVEMainViewController * VC = [[CNLIVEMainViewController alloc] initWithUrl:webUrl];
17 return VC; 17 return VC;
@@ -26,6 +26,13 @@ @@ -26,6 +26,13 @@
26 NSLog(@"调用支付相关参数 orderId=>%@ price=>%@ body=>%@",orderId,price,body); 26 NSLog(@"调用支付相关参数 orderId=>%@ price=>%@ body=>%@",orderId,price,body);
27 } 27 }
28 28
  29 +/// 用主工程的webView打开
  30 +/// @param paramDict url
  31 +-(void)pushWebViewWithMainProjectWithParamDict:(NSDictionary *)paramDict
  32 +{
  33 +
  34 +}
  35 +
29 /// 获取主工程的视讯相关界面逻辑 36 /// 获取主工程的视讯相关界面逻辑
30 /// @param pageId 界面id 37 /// @param pageId 界面id
31 /// @param channelName 频道名 38 /// @param channelName 频道名