Commit d860b452bedc820bdf8e25883933621ed3d3fc81
1 parent
3644363e
提交
Showing
99 changed files
with
4369 additions
and
11 deletions
CNLiveCServiceModule.podspec
| ... | ... | @@ -31,12 +31,26 @@ TODO: Add long description of the pod here. |
| 31 | 31 | s.ios.deployment_target = '10.0' |
| 32 | 32 | |
| 33 | 33 | s.source_files = 'CNLiveCServiceModule/Classes/**/*' |
| 34 | - | |
| 35 | - # s.resource_bundles = { | |
| 36 | - # 'CNLiveCServiceModule' => ['CNLiveCServiceModule/Assets/*.png'] | |
| 37 | - # } | |
| 34 | + s.prefix_header_contents = '#import "CNLiveCServicePCH.h"' | |
| 35 | + s.resources = 'CNLiveCServiceModule/Assets/CNServiceBundle.bundle' | |
| 36 | + | |
| 38 | 37 | |
| 39 | - # s.public_header_files = 'Pod/Classes/**/*.h' | |
| 38 | + s.public_header_files = 'Pod/Classes/Manager/*.h' | |
| 40 | 39 | # s.frameworks = 'UIKit', 'MapKit' |
| 41 | 40 | # s.dependency 'AFNetworking', '~> 2.3' |
| 41 | + s.dependency 'CNLiveNewTripartiteManagement/SDCycleScrollView' | |
| 42 | + s.dependency 'CNLiveNewTripartiteManagement/Masonry' | |
| 43 | + s.dependency 'CNLiveNewTripartiteManagement/MJExtension' | |
| 44 | + s.dependency 'CNLiveNewTripartiteManagement/SDWebImage' | |
| 45 | + s.dependency 'CNLiveNewTripartiteManagement/MJRefresh' | |
| 46 | + s.dependency 'CNLiveNewTripartiteManagement/SDCycleScrollView' | |
| 47 | + s.dependency 'CNLiveNewTripartiteManagement/QMUIKit' | |
| 48 | + s.dependency 'CNLiveCommonCategory' | |
| 49 | + s.dependency 'CNLiveBaseKit' | |
| 50 | + s.dependency 'CNLiveBusinessBaseModule' | |
| 51 | + s.dependency 'CNLiveRequestBastKit' | |
| 52 | + s.dependency 'CNLiveUserManagement' | |
| 53 | + s.dependency 'CNLiveEnvironment' | |
| 54 | + s.dependency 'CNLiveCustomControl' | |
| 55 | + | |
| 42 | 56 | end | ... | ... |
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/Root.plist
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| 3 | +<plist version="1.0"> | |
| 4 | +<dict> | |
| 5 | + <key>StringsTable</key> | |
| 6 | + <string>Root</string> | |
| 7 | + <key>PreferenceSpecifiers</key> | |
| 8 | + <array> | |
| 9 | + <dict> | |
| 10 | + <key>Type</key> | |
| 11 | + <string>PSGroupSpecifier</string> | |
| 12 | + <key>Title</key> | |
| 13 | + <string>Group</string> | |
| 14 | + </dict> | |
| 15 | + <dict> | |
| 16 | + <key>Type</key> | |
| 17 | + <string>PSTextFieldSpecifier</string> | |
| 18 | + <key>Title</key> | |
| 19 | + <string>Name</string> | |
| 20 | + <key>Key</key> | |
| 21 | + <string>name_preference</string> | |
| 22 | + <key>DefaultValue</key> | |
| 23 | + <string></string> | |
| 24 | + <key>IsSecure</key> | |
| 25 | + <false/> | |
| 26 | + <key>KeyboardType</key> | |
| 27 | + <string>Alphabet</string> | |
| 28 | + <key>AutocapitalizationType</key> | |
| 29 | + <string>None</string> | |
| 30 | + <key>AutocorrectionType</key> | |
| 31 | + <string>No</string> | |
| 32 | + </dict> | |
| 33 | + <dict> | |
| 34 | + <key>Type</key> | |
| 35 | + <string>PSToggleSwitchSpecifier</string> | |
| 36 | + <key>Title</key> | |
| 37 | + <string>Enabled</string> | |
| 38 | + <key>Key</key> | |
| 39 | + <string>enabled_preference</string> | |
| 40 | + <key>DefaultValue</key> | |
| 41 | + <true/> | |
| 42 | + </dict> | |
| 43 | + <dict> | |
| 44 | + <key>Type</key> | |
| 45 | + <string>PSSliderSpecifier</string> | |
| 46 | + <key>Key</key> | |
| 47 | + <string>slider_preference</string> | |
| 48 | + <key>DefaultValue</key> | |
| 49 | + <real>0.5</real> | |
| 50 | + <key>MinimumValue</key> | |
| 51 | + <integer>0</integer> | |
| 52 | + <key>MaximumValue</key> | |
| 53 | + <integer>1</integer> | |
| 54 | + <key>MinimumValueImage</key> | |
| 55 | + <string></string> | |
| 56 | + <key>MaximumValueImage</key> | |
| 57 | + <string></string> | |
| 58 | + </dict> | |
| 59 | + </array> | |
| 60 | + <key>ApplicationGroupContainerIdentifier</key> | |
| 61 | + <string></string> | |
| 62 | +</dict> | |
| 63 | +</plist> | ... | ... |
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/en.lproj/Root.strings
0 → 100644
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/listen@2x.png
0 → 100644
793 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/listen@3x.png
0 → 100644
1.21 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/object_more@2x.png
0 → 100644
443 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/object_more@3x.png
0 → 100644
583 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/pagecontrol_no@2x.png
0 → 100644
295 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/pagecontrol_no@3x.png
0 → 100644
389 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/pagecontrol_yes@2x.png
0 → 100644
331 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/pagecontrol_yes@3x.png
0 → 100644
408 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_enter@2x.png
0 → 100644
220 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_enter@3x.png
0 → 100644
262 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_failure@2x.png
0 → 100644
77.7 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_failure@3x.png
0 → 100644
144 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_hot@2x.png
0 → 100644
1.98 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_hot@3x.png
0 → 100644
2.55 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_mine@2x.png
0 → 100644
2.57 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_mine@3x.png
0 → 100644
4.06 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_more@2x.png
0 → 100644
2.1 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_more@3x.png
0 → 100644
3.62 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_noMsg@2x.png
0 → 100644
64.8 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_noMsg@3x.png
0 → 100644
125 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_noNet@2x.png
0 → 100644
80.9 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_noNet@3x.png
0 → 100644
151 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_right@2x.png
0 → 100644
602 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_right@3x.png
0 → 100644
973 Bytes
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_search@2x.png
0 → 100644
1.31 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_search@3x.png
0 → 100644
2.19 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_top@2x.png
0 → 100644
20.2 KB
CNLiveCServiceModule/Assets/CNServiceBundle.bundle/service_top@3x.png
0 → 100644
55.1 KB
CNLiveCServiceModule/Classes/Category/UIImage+CNBundleOrGredient.h
0 → 100644
| 1 | +// | |
| 2 | +// UIImage+CNBundleOrGredient.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/22. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | + | |
| 10 | +NS_ASSUME_NONNULL_BEGIN | |
| 11 | + | |
| 12 | +@interface UIImage (CNBundleOrGredient) | |
| 13 | + | |
| 14 | +// 创建一张渐变色图片 | |
| 15 | ++ (UIImage *)gradientImageWithColors:(NSArray *)colors rect:(CGRect)rect; | |
| 16 | ++(UIImage *)loadBundleImage:(NSString *)imageName; | |
| 17 | + | |
| 18 | +@end | |
| 19 | + | |
| 20 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/Category/UIImage+CNBundleOrGredient.m
0 → 100644
| 1 | +// | |
| 2 | +// UIImage+CNBundleOrGredient.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/22. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "UIImage+CNBundleOrGredient.h" | |
| 9 | + | |
| 10 | +@implementation UIImage (CNBundleOrGredient) | |
| 11 | ++(UIImage *)loadBundleImage:(NSString *)imageName | |
| 12 | +{ | |
| 13 | + NSBundle *bundle = [NSBundle bundleForClass:NSClassFromString(@"CNLiveServiceVC")]; | |
| 14 | + NSURL *url = [bundle URLForResource:@"CNServiceBundle" withExtension:@"bundle"]; | |
| 15 | + NSBundle *targetBundle = [NSBundle bundleWithURL:url]; | |
| 16 | + UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil]; | |
| 17 | + return image; | |
| 18 | +} | |
| 19 | +// 创建一张渐变色图片 | |
| 20 | ++ (UIImage *)gradientImageWithColors:(NSArray *)colors rect:(CGRect)rect{ | |
| 21 | + if (!colors.count || CGRectEqualToRect(rect, CGRectZero)) { | |
| 22 | + return nil; | |
| 23 | + } | |
| 24 | + | |
| 25 | + CAGradientLayer *gradientLayer = [CAGradientLayer layer]; | |
| 26 | + | |
| 27 | + gradientLayer.frame = rect; | |
| 28 | + gradientLayer.startPoint = CGPointMake(0, 0); | |
| 29 | + gradientLayer.endPoint = CGPointMake(0, 1); | |
| 30 | + NSMutableArray *mutColors = [NSMutableArray arrayWithCapacity:colors.count]; | |
| 31 | + for (UIColor *color in colors) { | |
| 32 | + [mutColors addObject:(__bridge id)color.CGColor]; | |
| 33 | + } | |
| 34 | + gradientLayer.colors = [NSArray arrayWithArray:mutColors]; | |
| 35 | + | |
| 36 | + UIGraphicsBeginImageContextWithOptions(gradientLayer.frame.size, gradientLayer.opaque, 0); | |
| 37 | + [gradientLayer renderInContext:UIGraphicsGetCurrentContext()]; | |
| 38 | + UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext(); | |
| 39 | + UIGraphicsEndImageContext(); | |
| 40 | + return outputImage; | |
| 41 | +} | |
| 42 | +@end | ... | ... |
CNLiveCServiceModule/Classes/Manager/CNLiveCServiceManagerBridge.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCServiceManagerBridge.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/12/2. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <Foundation/Foundation.h> | |
| 9 | + | |
| 10 | +typedef NS_ENUM(NSInteger , CNCServiceJumpType) { | |
| 11 | + CNCServiceJumpTypeService, //服务内容跳转逻辑 | |
| 12 | + CNCServiceJumpTypeGoods, //商品详情页 | |
| 13 | + CNCServiceJumpTypeVideo //音频文件 | |
| 14 | +}; | |
| 15 | + | |
| 16 | +@protocol CNLiveCServiceProtocol <NSObject> | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 服务号跳转 | |
| 20 | + * | |
| 21 | + * @param type type | |
| 22 | + * @param param 参数 | |
| 23 | + */ | |
| 24 | +- (void)jumpControllerType:(CNCServiceJumpType)type param:(NSDictionary *)param controller:(UIViewController *)controller; | |
| 25 | +@end | |
| 26 | + | |
| 27 | +NS_ASSUME_NONNULL_BEGIN | |
| 28 | + | |
| 29 | +@interface CNLiveCServiceManagerBridge : NSObject | |
| 30 | + | |
| 31 | +@property (nonatomic, strong) id<CNLiveCServiceProtocol> protocol; | |
| 32 | + | |
| 33 | ++ (instancetype) shareManager; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * 服务号跳转 | |
| 37 | + * | |
| 38 | + * @param serviceId 服务号id | |
| 39 | + * @param type type | |
| 40 | + * @param to to | |
| 41 | + * @param shopType shopType | |
| 42 | + */ | |
| 43 | ++ (void) jumpServiceController:(NSString *)serviceId type:(NSString *)type to:(NSString *)to shopType:(NSString *)shopType controller:(UIViewController *)controller; | |
| 44 | +@end | |
| 45 | + | |
| 46 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/Manager/CNLiveCServiceManagerBridge.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCServiceManagerBridge.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/12/2. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveCServiceManagerBridge.h" | |
| 9 | + | |
| 10 | +@implementation CNLiveCServiceManagerBridge | |
| 11 | ++ (instancetype)shareManager{ | |
| 12 | + static dispatch_once_t onceToken; | |
| 13 | + static CNLiveCServiceManagerBridge *bridge = nil; | |
| 14 | + dispatch_once(&onceToken, ^{ | |
| 15 | + bridge = [[CNLiveCServiceManagerBridge alloc] init]; | |
| 16 | + }); | |
| 17 | + return bridge; | |
| 18 | +} | |
| 19 | +- (instancetype)init | |
| 20 | +{ | |
| 21 | + self = [super init]; | |
| 22 | + if (self) { | |
| 23 | + Class class = NSClassFromString(@"CNLiveCServiceModuleImpl"); | |
| 24 | + self.protocol = [class new]; | |
| 25 | + } | |
| 26 | + return self; | |
| 27 | +} | |
| 28 | + | |
| 29 | ++ (void)jumpServiceController:(NSString *)serviceId type:(NSString *)type to:(NSString *)to shopType:(NSString *)shopType controller:(UIViewController *)controller | |
| 30 | +{ | |
| 31 | + [CNLiveCServiceManagerBridge jumpServiceType:CNCServiceJumpTypeService service:serviceId type:type to:to shopType:shopType controller:controller]; | |
| 32 | +} | |
| 33 | ++ (void)jumpServiceType:(CNCServiceJumpType)jumpType service:(NSString *)serviceId type:(NSString *)type to:(NSString *)to shopType:(NSString *)shopType controller:(UIViewController *)controller{ | |
| 34 | + NSDictionary *param = @{ | |
| 35 | + @"serviceId":serviceId, | |
| 36 | + @"type":type, | |
| 37 | + @"to":to, | |
| 38 | + @"shopType":shopType, | |
| 39 | + }; | |
| 40 | + [[CNLiveCServiceManagerBridge shareManager].protocol jumpControllerType:jumpType param:param controller:controller]; | |
| 41 | +} | |
| 42 | +@end | ... | ... |
CNLiveCServiceModule/Classes/Manager/CNLiveCServicePCH.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCServicePCH.h | |
| 3 | +// Pods | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/22. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#ifndef CNLiveCServicePCH_h | |
| 9 | +#define CNLiveCServicePCH_h | |
| 10 | + | |
| 11 | +#import "UIImage+CNBundleOrGredient.h" | |
| 12 | +#import <CNLiveCommonCategory/UIColor+CNLiveExtension.h> | |
| 13 | +#import <CNLiveBaseKit/CNLiveBaseKit.h> | |
| 14 | +#import <Masonry/Masonry.h> | |
| 15 | +#import <CNLiveBusinessBaseModule/CNLiveBusinessBaseModule.h> | |
| 16 | +#import <CNLiveRequestBastKit/CNLiveNetworking.h> | |
| 17 | +#import <CNLiveUserManagement/CNUserInfoManager.h> | |
| 18 | +#import <CNLiveEnvironment/CNLiveEnvironment.h> | |
| 19 | +#import <MJExtension/MJExtension.h> | |
| 20 | +#import <SDWebImage/SDWebImage.h> | |
| 21 | +#import <MJRefresh/MJRefresh.h> | |
| 22 | +#import <CNLiveCustomControl/CNLiveCustomControl.h> | |
| 23 | +#import <SDCycleScrollView/SDCycleScrollView.h> | |
| 24 | +#import <QMUIKit/QMUIKit.h> | |
| 25 | + | |
| 26 | +#endif /* CNLiveCServicePCH_h */ | ... | ... |
CNLiveCServiceModule/Classes/Model/CNLiveSearchModel.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchModel.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/24. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <Foundation/Foundation.h> | |
| 9 | + | |
| 10 | +NS_ASSUME_NONNULL_BEGIN | |
| 11 | +@interface CNLiveLayoutModel : NSObject | |
| 12 | +@property (nonatomic, assign) CGFloat height; | |
| 13 | +@property (nonatomic, assign) CGFloat width; | |
| 14 | +@end | |
| 15 | + | |
| 16 | +@interface CNLiveSearchModel : NSObject | |
| 17 | +///搜索字符串 | |
| 18 | +@property (nonatomic, copy) NSString *searchStr; | |
| 19 | + | |
| 20 | +@property (nonatomic, copy) NSString *categoryId; | |
| 21 | +///应用id | |
| 22 | +@property (nonatomic,copy) NSString * id; | |
| 23 | +///名称 | |
| 24 | +@property (nonatomic,copy) NSString * title; | |
| 25 | + | |
| 26 | +///图标 | |
| 27 | +@property (nonatomic,copy) NSString * icon; | |
| 28 | +///描述 | |
| 29 | +@property (nonatomic,copy) NSString * desc; | |
| 30 | +/// | |
| 31 | +@property (nonatomic,copy) NSString * shop_ads_store_id; | |
| 32 | +/// | |
| 33 | +@property (nonatomic,copy) NSString * app_group_id; | |
| 34 | +///是否推荐 1推荐 0未 | |
| 35 | +@property (nonatomic,assign) BOOL hot; | |
| 36 | +///跳转规则 | |
| 37 | +@property (nonatomic,copy) NSString * type; | |
| 38 | +///跳转规则 | |
| 39 | +@property (nonatomic,copy) NSString * toType; | |
| 40 | +///跳转规则 | |
| 41 | +@property (nonatomic,copy) NSString * shopType; | |
| 42 | +///跳转规则 | |
| 43 | +@property (nonatomic,copy) NSString * to; | |
| 44 | +///是否收藏 1 收藏 0 未收藏 | |
| 45 | +@property (nonatomic,assign) BOOL is_cell; | |
| 46 | + | |
| 47 | +@property (nonatomic, copy) NSString * collection; | |
| 48 | + | |
| 49 | +@property (nonatomic, copy) NSString *tagId; // 4的时候说中国商城 type是21 | |
| 50 | + | |
| 51 | +/// | |
| 52 | +@property (nonatomic,copy) NSString * is_hot; | |
| 53 | +@property (nonatomic,copy) NSString * shop_type; | |
| 54 | +@property (nonatomic,copy) NSString * simg; | |
| 55 | +@end | |
| 56 | + | |
| 57 | +@interface CNLiveHistoryModel : NSObject | |
| 58 | + | |
| 59 | +@property (nonatomic, copy) NSString * title; | |
| 60 | +@end | |
| 61 | + | |
| 62 | +@interface CNLiveSearchHotsModel : NSObject | |
| 63 | +@property (nonatomic, copy) NSString *title; | |
| 64 | +@property (nonatomic, strong) NSArray *lists; | |
| 65 | +@property (nonatomic, assign) CGFloat cellHeight; | |
| 66 | +///布局 | |
| 67 | +@property (nonatomic, strong) CNLiveLayoutModel *layout; | |
| 68 | +@end | |
| 69 | + | |
| 70 | +NS_ASSUME_NONNULL_END | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | ... | ... |
CNLiveCServiceModule/Classes/Model/CNLiveSearchModel.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchModel.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/24. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveSearchModel.h" | |
| 9 | + | |
| 10 | +@implementation CNLiveSearchModel | |
| 11 | + | |
| 12 | +@end | |
| 13 | + | |
| 14 | +@implementation CNLiveHistoryModel | |
| 15 | + | |
| 16 | + | |
| 17 | +@end | |
| 18 | + | |
| 19 | +@implementation CNLiveLayoutModel | |
| 20 | + | |
| 21 | + | |
| 22 | +@end | |
| 23 | + | |
| 24 | +@implementation CNLiveSearchHotsModel | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | +@end | ... | ... |
CNLiveCServiceModule/Classes/Model/CNLiveServiceModel.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceModel.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/25. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <Foundation/Foundation.h> | |
| 9 | +#import "CNLiveSearchModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +//首页头部分类model | |
| 14 | +@interface CNCategoryModel : NSObject | |
| 15 | + | |
| 16 | +@property (nonatomic, copy) NSString * id; | |
| 17 | +@property (nonatomic, copy) NSString * title; | |
| 18 | +@property (nonatomic, copy) NSString * icon; | |
| 19 | +@property (nonatomic, copy) NSString * sort; | |
| 20 | +@property (nonatomic, strong)NSArray <CNLiveSearchModel*>* list; | |
| 21 | +@end | |
| 22 | +@interface CNLiveServiceModel : NSObject | |
| 23 | +/// 推荐服务号 | |
| 24 | +@property (nonatomic, strong) NSArray <CNLiveSearchModel*> * all; | |
| 25 | +/// 收藏服务号 | |
| 26 | +@property (nonatomic, strong) NSArray <CNLiveSearchModel*> * collect; | |
| 27 | +/// 历史服务号 | |
| 28 | +@property (nonatomic, strong) NSArray <CNLiveSearchModel*> * news; | |
| 29 | + | |
| 30 | +@property (nonatomic, strong) NSArray <CNLiveSearchModel*> * list; | |
| 31 | + | |
| 32 | +@property (nonatomic, strong) NSArray <CNLiveSearchHotsModel*> * allList; | |
| 33 | + | |
| 34 | +@property (nonatomic, strong) NSArray <CNCategoryModel*> * categories; | |
| 35 | + | |
| 36 | +@property (nonatomic, strong) NSArray <CNLiveSearchModel*> * hots; | |
| 37 | +@end | |
| 38 | + | |
| 39 | +@interface CnLivePageContentModel : NSObject | |
| 40 | + | |
| 41 | +@property (nonatomic, copy) NSString *address; | |
| 42 | +@property (nonatomic, copy) NSString *aproduct; | |
| 43 | +@property (nonatomic, copy) NSString *author; | |
| 44 | +@property (nonatomic, copy) NSString *channelId; | |
| 45 | +@property (nonatomic, copy) NSString *cmccActiveId; | |
| 46 | +@property (nonatomic, copy) NSString *colours; | |
| 47 | +@property (nonatomic, copy) NSString *contentId; | |
| 48 | +@property (nonatomic, copy) NSString *coordinate; | |
| 49 | +@property (nonatomic, copy) NSString *desc; | |
| 50 | +@property (nonatomic, copy) NSString *downloadType; | |
| 51 | +@property (nonatomic, copy) NSString *duration; | |
| 52 | +@property (nonatomic, copy) NSString *goods; | |
| 53 | +@property (nonatomic, copy) NSString *h5Url; | |
| 54 | +@property (nonatomic, copy) NSString *icon; | |
| 55 | +@property (nonatomic, copy) NSString *imageArray; | |
| 56 | +@property (nonatomic, copy) NSString *imageSize; | |
| 57 | +@property (nonatomic, copy) NSString *imageType; | |
| 58 | +@property (nonatomic, copy) NSString *isHorizontalScreen; | |
| 59 | +@property (nonatomic, copy) NSString *liveChannel; | |
| 60 | +@property (nonatomic, copy) NSString *liveType; | |
| 61 | +@property (nonatomic, copy) NSString *mediaImg; | |
| 62 | +@property (nonatomic, copy) NSString *model; | |
| 63 | +@property (nonatomic, copy) NSString *number; | |
| 64 | +@property (nonatomic, copy) NSString *pid; | |
| 65 | +@property (nonatomic, copy) NSString *poster; | |
| 66 | +@property (nonatomic, copy) NSString *predetermine; | |
| 67 | +@property (nonatomic, strong) NSDictionary *product; | |
| 68 | +@property (nonatomic, copy) NSString *publishTime; | |
| 69 | +@property (nonatomic, copy) NSString *s_showType; | |
| 70 | +@property (nonatomic, copy) NSString *s_to; | |
| 71 | +@property (nonatomic, copy) NSString *s_type; | |
| 72 | +@property (nonatomic, copy) NSString *shareUrl; | |
| 73 | +@property (nonatomic, copy) NSString *showType; | |
| 74 | +@property (nonatomic, copy) NSString *source; | |
| 75 | +@property (nonatomic, copy) NSString *spIcon; | |
| 76 | +@property (nonatomic, copy) NSString *spId; | |
| 77 | +@property (nonatomic, copy) NSString *spInfo; | |
| 78 | +@property (nonatomic, copy) NSString *spName; | |
| 79 | +@property (nonatomic, copy) NSString *spectators; | |
| 80 | +@property (nonatomic, copy) NSString *status; | |
| 81 | +@property (nonatomic, copy) NSString *subTitle; | |
| 82 | +@property (nonatomic, copy) NSString *tag; | |
| 83 | +@property (nonatomic, copy) NSString *tagName; | |
| 84 | +@property (nonatomic, copy) NSString *thirdUrl; | |
| 85 | +@property (nonatomic, copy) NSString *time; | |
| 86 | +@property (nonatomic, copy) NSString *title; | |
| 87 | +@property (nonatomic, copy) NSString *toType; | |
| 88 | +@property (nonatomic, copy) NSString *tool; | |
| 89 | +@property (nonatomic, copy) NSString *trailerId; | |
| 90 | +@property (nonatomic, copy) NSString *transverseImg; | |
| 91 | +@property (nonatomic, copy) NSString *verticalImg; | |
| 92 | +@property (nonatomic, copy) NSString *videoUrl; | |
| 93 | +@property (nonatomic, copy) NSString *weight; | |
| 94 | +@property (nonatomic, copy) NSString *witnessId; | |
| 95 | +@end | |
| 96 | + | |
| 97 | +@interface CNliveServicePageModel : NSObject | |
| 98 | +///布局 | |
| 99 | +@property (nonatomic, strong) CNLiveLayoutModel *layout; | |
| 100 | +@property (nonatomic, assign) CGFloat cellHeight; | |
| 101 | +@property (nonatomic, strong) NSArray <CnLivePageContentModel *> *rightLists; | |
| 102 | + | |
| 103 | +@property (nonatomic, copy) NSString *blockId; | |
| 104 | +@property (nonatomic, copy) NSString *blockName; | |
| 105 | +@property (nonatomic, copy) NSString *moreUrl; | |
| 106 | +@property (nonatomic, copy) NSString *contentType; | |
| 107 | +@property (nonatomic, copy) NSString *time; | |
| 108 | +@property (nonatomic, copy) NSString *type; | |
| 109 | +@property (nonatomic, copy) NSString *background; | |
| 110 | +@property (nonatomic, copy) NSString *blockIcon; | |
| 111 | +@property (nonatomic, copy) NSString *showType; | |
| 112 | +@property (nonatomic, copy) NSString *rowNum; | |
| 113 | +@property (nonatomic, copy) NSString *blockSubTitle; | |
| 114 | +@property (nonatomic, copy) NSString *linkType; | |
| 115 | +@property (nonatomic, copy) NSString *moreType; | |
| 116 | + | |
| 117 | +@property (nonatomic, strong) NSArray <CnLivePageContentModel *> *contents; | |
| 118 | + | |
| 119 | +@end | |
| 120 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/Model/CNLiveServiceModel.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceModel.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/25. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveServiceModel.h" | |
| 9 | + | |
| 10 | + | |
| 11 | +@implementation CNCategoryModel | |
| 12 | + | |
| 13 | +@end | |
| 14 | +@implementation CNLiveServiceModel | |
| 15 | ++ (NSDictionary *)mj_replacedKeyFromPropertyName { | |
| 16 | + return @{@"allList":@"newList"}; | |
| 17 | +} | |
| 18 | +@end | |
| 19 | +@implementation CnLivePageContentModel | |
| 20 | + | |
| 21 | +@end | |
| 22 | +@implementation CNliveServicePageModel | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | +@end | ... | ... |
CNLiveCServiceModule/Classes/Present/CNLiveServiceHistorySearch.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceHistorySearch.h | |
| 3 | +// CNLiveNetAdd | |
| 4 | +// | |
| 5 | +// Created by CNLive-zxw on 2020/7/15. | |
| 6 | +// Copyright © 2020 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <Foundation/Foundation.h> | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveServiceHistorySearch : NSObject | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * 服务号保存历史搜索 | |
| 17 | + * | |
| 18 | + */ | |
| 19 | ++ (void)saveHistorySearch:(NSMutableArray *)data; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * 获取服务号历史搜索 | |
| 23 | + * | |
| 24 | + * @return 内容 | |
| 25 | + */ | |
| 26 | ++ (NSMutableArray *)readHistorySearch; | |
| 27 | + | |
| 28 | +@end | |
| 29 | + | |
| 30 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/Present/CNLiveServiceHistorySearch.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceHistorySearch.m | |
| 3 | +// CNLiveNetAdd | |
| 4 | +// | |
| 5 | +// Created by CNLive-zxw on 2020/7/15. | |
| 6 | +// Copyright © 2020 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "CNLiveServiceHistorySearch.h" | |
| 10 | + | |
| 11 | +@implementation CNLiveServiceHistorySearch | |
| 12 | + | |
| 13 | ++ (void)saveHistorySearch:(NSMutableArray *)data { | |
| 14 | + NSString *Path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; | |
| 15 | + NSString *filePath = [Path stringByAppendingPathComponent:@"ServiceHistorySearch.data"]; | |
| 16 | + [NSKeyedArchiver archiveRootObject:data toFile:filePath]; | |
| 17 | +} | |
| 18 | + | |
| 19 | ++ (NSMutableArray *)readHistorySearch { | |
| 20 | + NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; | |
| 21 | + NSString *filePath = [path stringByAppendingPathComponent:@"ServiceHistorySearch.data"]; | |
| 22 | + //解档 | |
| 23 | + NSMutableArray *data = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; | |
| 24 | + return data; | |
| 25 | +} | |
| 26 | + | |
| 27 | +@end | ... | ... |
CNLiveCServiceModule/Classes/Present/CNLiveServicePresent.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServicePresent.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/24. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <Foundation/Foundation.h> | |
| 9 | +#import "CNLiveSearchModel.h" | |
| 10 | +#import "CNLiveServiceModel.h" | |
| 11 | + | |
| 12 | +NS_ASSUME_NONNULL_BEGIN | |
| 13 | + | |
| 14 | +@interface CNLiveServicePresent : NSObject | |
| 15 | +/** | |
| 16 | + 搜索服务号 | |
| 17 | + @param searchStr 搜索关键字 | |
| 18 | + @param page 当前页数 | |
| 19 | + */ | |
| 20 | ++ (void)searchServiceList:(NSString *)searchStr page:(NSString *)page result:(void (^) (NSArray <CNLiveSearchModel *> * dataArray, BOOL isLastPage)) succeed error:(void(^)(void))failure; | |
| 21 | +/** | |
| 22 | + 服务号首页数据请求 | |
| 23 | + */ | |
| 24 | ++ (void)requestServiceListResult:(void (^)(NSArray * dataArray,NSArray *hots))result error:(void(^)(void))failure; | |
| 25 | + | |
| 26 | +/** | |
| 27 | + 请求服务号出服务的内容 | |
| 28 | + */ | |
| 29 | ++ (void)requesrServiceGetPageResult:(void (^)(NSArray * dataArray))result error:(void(^)(void))failure; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + 处理搜索页热搜和搜索历史数据 | |
| 33 | + @param hots 热搜数组 | |
| 34 | + @param histories 搜索历史数组 | |
| 35 | + */ | |
| 36 | ++ (void)dealHots:(NSArray *)hots searchHistories:(NSArray *)histories results:(void (^) (NSArray * dataArray)) succeed; | |
| 37 | + | |
| 38 | +/** | |
| 39 | + 请求我的服务数据 | |
| 40 | + */ | |
| 41 | ++ (void)loadMyServicepage:(NSString *)page result:(void (^) (NSArray * dataArray)) succeed error:(void(^)(void))failure; | |
| 42 | + | |
| 43 | +/** | |
| 44 | + * 添加最近使用服务号 | |
| 45 | + * @param servingId 服务id | |
| 46 | + */ | |
| 47 | ++ (void)usedServiceWithServingId:(NSString *)servingId; | |
| 48 | + | |
| 49 | +/** | |
| 50 | + 清除最近使用的服务 | |
| 51 | + */ | |
| 52 | ++ (void)removeMyServiceResult:(void (^) (void)) succeed; | |
| 53 | +/** | |
| 54 | + 请求所有服务 | |
| 55 | + @param serviceId 服务对应Id,全部服务为@“” | |
| 56 | + */ | |
| 57 | ++ (void)loadAllServiceWithServiceId:(NSString *)serviceId page:(NSString *)page result:(void (^) (NSArray * dataArray, BOOL isLastPage)) succeed error:(void(^)(void))failure; | |
| 58 | +@end | |
| 59 | + | |
| 60 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/Present/CNLiveServicePresent.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServicePresent.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/24. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveServicePresent.h" | |
| 9 | + | |
| 10 | +static const CGFloat margin = 15; | |
| 11 | + | |
| 12 | +@implementation CNLiveServicePresent | |
| 13 | ++ (void)searchServiceList:(NSString *)searchStr page:(NSString *)page result:(nonnull void (^)(NSArray<CNLiveSearchModel *> * _Nonnull, BOOL))succeed error:(nonnull void (^)(void))failure | |
| 14 | +{ | |
| 15 | + | |
| 16 | + NSDictionary * params = @{ | |
| 17 | + @"sid":CNUserShareModelUid?CNUserShareModelUid:@"", | |
| 18 | + @"title":searchStr?searchStr:@"", | |
| 19 | + @"type":@"1", | |
| 20 | + @"page":page, | |
| 21 | + @"pageSize":@"10" | |
| 22 | + }; | |
| 23 | + [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | |
| 24 | + [CNLiveNetworking setupShowDataResult:NO]; | |
| 25 | + [CNLiveNetworking setupShowResult:YES]; | |
| 26 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/servingApi/search") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 27 | + if (responseObject&&[responseObject isKindOfClass:[NSDictionary class]]) { | |
| 28 | + NSString *lastPageStr = responseObject[@"data"][@"isLastPage"]; | |
| 29 | + BOOL isLastPage = lastPageStr.boolValue; | |
| 30 | + NSArray *listArr = responseObject[@"data"][@"list"]; | |
| 31 | + if (listArr&&[listArr isKindOfClass:[NSArray class]]) { | |
| 32 | + if (listArr.count == 0) { | |
| 33 | + !succeed?:succeed(listArr,isLastPage); | |
| 34 | + }else{ | |
| 35 | + NSMutableArray *dataArray = [NSMutableArray array]; | |
| 36 | + for (NSDictionary *dic in listArr) { | |
| 37 | + CNLiveSearchModel *model = [CNLiveSearchModel mj_objectWithKeyValues:dic]; | |
| 38 | + model.searchStr = searchStr; | |
| 39 | + [dataArray addObject:model]; | |
| 40 | + } | |
| 41 | + !succeed?:succeed(dataArray.copy,isLastPage); | |
| 42 | + } | |
| 43 | + } | |
| 44 | + }else{ | |
| 45 | + !failure?:failure(); | |
| 46 | + } | |
| 47 | + }]; | |
| 48 | +} | |
| 49 | + | |
| 50 | ++ (void)dealHots:(NSArray *)hots searchHistories:(NSArray *)histories results:(void (^)(NSArray * _Nonnull))succeed | |
| 51 | +{ | |
| 52 | + CNLiveSearchHotsModel *model1 = nil; | |
| 53 | + if (hots && hots.count > 0) { | |
| 54 | + model1 = [CNLiveServicePresent dealDataSource:hots title:@"热度推荐" cellHeight:0 itemSize:CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 80)showNum:0]; | |
| 55 | + } | |
| 56 | + | |
| 57 | + NSMutableArray *array2 = [NSMutableArray array]; | |
| 58 | + CNLiveSearchHotsModel *model2 = nil; | |
| 59 | + if (histories && histories.count > 0) { | |
| 60 | + for (NSDictionary *dic in histories) { | |
| 61 | + CNLiveHistoryModel *model = [CNLiveHistoryModel mj_objectWithKeyValues:dic]; | |
| 62 | + [array2 addObject:model]; | |
| 63 | + } | |
| 64 | + | |
| 65 | + NSDictionary *dic2 = @{ | |
| 66 | + @"title":@"历史搜索", | |
| 67 | + @"lists":array2, | |
| 68 | + @"type" :@(8), | |
| 69 | + @"layout": @{ | |
| 70 | + @"height":@(29), | |
| 71 | + @"width":@((SCREEN_WIDTH-4*margin)/3.0), | |
| 72 | + }, | |
| 73 | + }; | |
| 74 | + model2 = [CNLiveSearchHotsModel mj_objectWithKeyValues:dic2]; | |
| 75 | + } | |
| 76 | + | |
| 77 | + NSMutableArray *array3 = [NSMutableArray array]; | |
| 78 | + if (model1) { | |
| 79 | + [array3 addObject:model1]; | |
| 80 | + } | |
| 81 | + if (model2) { | |
| 82 | + [array3 addObject:model2]; | |
| 83 | + } | |
| 84 | + succeed(array3.copy); | |
| 85 | +} | |
| 86 | + | |
| 87 | ++ (void)requestServiceListResult:(void (^)(NSArray * _Nonnull, NSArray * _Nonnull))result error:(void (^)(void))failure{ | |
| 88 | + NSDictionary * params = @{@"sid": CNUserShareModelUid ? CNUserShareModelUid : @""}; | |
| 89 | + | |
| 90 | + [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | |
| 91 | + [CNLiveNetworking setupShowDataResult:NO]; | |
| 92 | + [CNLiveNetworking setupShowResult:YES]; | |
| 93 | + | |
| 94 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/servingApi/servingPage") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 95 | + CNLiveServiceModel * model = [CNLiveServiceModel mj_objectWithKeyValues:responseObject[@"data"]]; | |
| 96 | + CNLiveSearchHotsModel *categoryModel = nil; | |
| 97 | + if (model.categories&&[model.categories isKindOfClass:[NSArray class]] && model.categories.count>0) { | |
| 98 | + CGFloat cellheight = 160; | |
| 99 | + if (model.categories.count <= 4) { | |
| 100 | + cellheight = 80; | |
| 101 | + } | |
| 102 | + categoryModel = [CNLiveServicePresent dealDataSource:model.categories title:@"" cellHeight:cellheight itemSize:CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 70)showNum:8]; | |
| 103 | + } | |
| 104 | + CNLiveSearchHotsModel *serviceModel = nil; | |
| 105 | + CNLiveSearchHotsModel *mediaModel = nil; | |
| 106 | + CNLiveSearchHotsModel *chineseModel = nil; | |
| 107 | + if (model.allList && model.allList.count > 0) { | |
| 108 | + for (NSDictionary *dic in model.allList) { | |
| 109 | + if ([dic[@"name"] isEqualToString:@"中国服务号"]) { | |
| 110 | + NSArray *lists = dic[@"list"]; | |
| 111 | + if (lists &&[lists isKindOfClass:[NSArray class]] && lists.count > 0) { | |
| 112 | + CGFloat cellheight = 160; | |
| 113 | + if (lists.count <= 2) { | |
| 114 | + cellheight = 90; | |
| 115 | + } | |
| 116 | + serviceModel = [CNLiveServicePresent dealDataSource:lists title:dic[@"name"] cellHeight:cellheight itemSize:CGSizeMake((KScreenWidth - 3*margin -10)/2, 60) showNum:4]; | |
| 117 | + } | |
| 118 | + } | |
| 119 | + | |
| 120 | + if ([dic[@"name"] isEqualToString:@"中国媒体号"]) { | |
| 121 | + NSArray *lists = dic[@"list"]; | |
| 122 | + if (lists &&[lists isKindOfClass:[NSArray class]] && lists.count > 0) { | |
| 123 | + CGFloat cellheight = 190; | |
| 124 | + if (lists.count <= 4) { | |
| 125 | + cellheight = 105; | |
| 126 | + } | |
| 127 | + mediaModel = [CNLiveServicePresent dealDataSource:lists title:dic[@"name"] cellHeight:cellheight itemSize:CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 70) showNum:8]; | |
| 128 | + } | |
| 129 | + } | |
| 130 | + if ([dic[@"name"] isEqualToString:@"中国网中国号"]) { | |
| 131 | + NSArray *lists = dic[@"list"]; | |
| 132 | + if (lists &&[lists isKindOfClass:[NSArray class]] && lists.count > 0) { | |
| 133 | + CGFloat cellheight = 190; | |
| 134 | + if (lists.count <= 4) { | |
| 135 | + cellheight = 105; | |
| 136 | + } | |
| 137 | + chineseModel = [CNLiveServicePresent dealDataSource:lists title:dic[@"name"] cellHeight:cellheight itemSize:CGSizeMake((SCREEN_WIDTH-4*margin-3*margin)/4.0, 70) showNum:8]; | |
| 138 | + } | |
| 139 | + } | |
| 140 | + } | |
| 141 | + } | |
| 142 | + NSMutableArray *dataArray = [NSMutableArray array]; | |
| 143 | + if (categoryModel) { | |
| 144 | + [dataArray addObject:categoryModel]; | |
| 145 | + } | |
| 146 | + if (serviceModel) { | |
| 147 | + [dataArray addObject:serviceModel]; | |
| 148 | + } | |
| 149 | + if (mediaModel) { | |
| 150 | + [dataArray addObject:mediaModel]; | |
| 151 | + } | |
| 152 | + if (chineseModel) { | |
| 153 | + [dataArray addObject:chineseModel]; | |
| 154 | + } | |
| 155 | + if (model) { | |
| 156 | + !result?:result(dataArray.copy,model.hots); | |
| 157 | + }else{ | |
| 158 | + !failure?:failure(); | |
| 159 | + } | |
| 160 | + }]; | |
| 161 | +} | |
| 162 | + | |
| 163 | ++ (CNLiveSearchHotsModel *) dealDataSource:(NSArray *)array title:(NSString *)title cellHeight:(CGFloat)cellHeight itemSize:(CGSize) size showNum:(NSInteger)num{ | |
| 164 | + NSMutableArray *categories = [NSMutableArray array]; | |
| 165 | + NSMutableArray *squreArray = [NSMutableArray array]; | |
| 166 | + for (int i = 0; i< array.count ;i++ ) { | |
| 167 | + NSDictionary *dic = array[i]; | |
| 168 | + NSObject *model = nil; | |
| 169 | + if ([title isEqualToString:@""]) { | |
| 170 | + model = [CNCategoryModel mj_objectWithKeyValues:dic]; | |
| 171 | + }else{ | |
| 172 | + model = [CNLiveSearchModel mj_objectWithKeyValues:dic]; | |
| 173 | + } | |
| 174 | + [categories addObject:model]; | |
| 175 | + if (num != 0 && (i != 0 || array.count == 1) &&(i%(num-1) == 0 || i == array.count - 1)) { | |
| 176 | + NSDictionary *category = @{ | |
| 177 | + @"title":title, | |
| 178 | + @"lists":categories.copy, | |
| 179 | + @"cellHeight":@(cellHeight), | |
| 180 | + @"layout":@{ | |
| 181 | + @"width":@(size.width), | |
| 182 | + @"height":@(size.height) | |
| 183 | + } | |
| 184 | + }; | |
| 185 | + CNLiveSearchHotsModel *model = [CNLiveSearchHotsModel mj_objectWithKeyValues:category]; | |
| 186 | + [squreArray addObject:model]; | |
| 187 | + [categories removeAllObjects]; | |
| 188 | + } | |
| 189 | + } | |
| 190 | + if (categories && num !=0 && categories.count == 0) { | |
| 191 | + NSDictionary *category = @{ | |
| 192 | + @"title":title, | |
| 193 | + @"lists":squreArray.copy, | |
| 194 | + @"cellHeight":@(cellHeight), | |
| 195 | + @"layout":@{ | |
| 196 | + @"width":@(size.width), | |
| 197 | + @"height":@(size.height) | |
| 198 | + } | |
| 199 | + }; | |
| 200 | + CNLiveSearchHotsModel *model = [CNLiveSearchHotsModel mj_objectWithKeyValues:category]; | |
| 201 | + [categories addObject:model]; | |
| 202 | + } | |
| 203 | + NSDictionary *category = @{ | |
| 204 | + @"title":title, | |
| 205 | + @"lists":categories.copy, | |
| 206 | + @"cellHeight":@(cellHeight), | |
| 207 | + @"layout":@{ | |
| 208 | + @"width":@(size.width), | |
| 209 | + @"height":@(size.height) | |
| 210 | + } | |
| 211 | + }; | |
| 212 | + CNLiveSearchHotsModel *model = [CNLiveSearchHotsModel mj_objectWithKeyValues:category]; | |
| 213 | + return model; | |
| 214 | +} | |
| 215 | + | |
| 216 | ++ (void)requesrServiceGetPageResult:(void (^)(NSArray * _Nonnull))result error:(void (^)(void))failure | |
| 217 | +{ | |
| 218 | + NSDictionary * params = @{@"sid": CNUserShareModelUid ? CNUserShareModelUid : @"", | |
| 219 | + @"pageId":@"10" | |
| 220 | + }; | |
| 221 | + | |
| 222 | + [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | |
| 223 | + [CNLiveNetworking setupShowDataResult:NO]; | |
| 224 | + [CNLiveNetworking setupShowResult:YES]; | |
| 225 | + | |
| 226 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/contentApi/getPage") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 227 | + NSArray *array = responseObject[@"data"]; | |
| 228 | + NSMutableArray *dataArray = [NSMutableArray array]; | |
| 229 | + if (array &&[array isKindOfClass:[NSArray class]]) { | |
| 230 | + for (int i = 0;i < array.count;i ++) { | |
| 231 | + NSMutableDictionary *mDic = [[NSMutableDictionary alloc] initWithDictionary:array[i]]; | |
| 232 | + if ([mDic[@"blockName"] isEqualToString:@"疫情服务专区"]) { | |
| 233 | + [mDic setObject:array[i + 1][@"contents"] forKey:@"rightLists"]; | |
| 234 | + [mDic setObject:@(214*KScreenWidth/375 ) forKey:@"cellHeight"]; | |
| 235 | + }else if ([mDic[@"blockName"] isEqualToString:@"大家都在用"]){ | |
| 236 | + [mDic setObject:@(230*KScreenWidth/375 ) forKey:@"cellHeight"]; | |
| 237 | + }else if ([mDic[@"blockName"] isEqualToString:@"轮播"]){ | |
| 238 | + [mDic setObject:@(87*KScreenWidth/375) forKey:@"cellHeight"]; | |
| 239 | + }else if ([mDic[@"blockName"] isEqualToString:@"热销排行"]){ | |
| 240 | + [mDic setObject:@(90) forKey:@"cellHeight"]; | |
| 241 | + }else{ | |
| 242 | + [mDic setObject:@(170) forKey:@"cellHeight"]; | |
| 243 | + } | |
| 244 | + if (![mDic[@"blockName"] isEqualToString:@"疫情服务"]){ | |
| 245 | + CNliveServicePageModel *model = [CNliveServicePageModel mj_objectWithKeyValues:mDic]; | |
| 246 | + [dataArray addObject:model]; | |
| 247 | + } | |
| 248 | + } | |
| 249 | + if (array) { | |
| 250 | + !result?:result(dataArray.copy); | |
| 251 | + }else{ | |
| 252 | + !failure?:failure(); | |
| 253 | + } | |
| 254 | + } | |
| 255 | + }]; | |
| 256 | +} | |
| 257 | + | |
| 258 | ++ (void)loadMyServicepage:(NSString *)page result:(void (^)(NSArray * _Nonnull))succeed error:(void (^)(void))failure{ | |
| 259 | + NSDictionary * params = @{@"sid": CNUserShareModelUid ? CNUserShareModelUid : @"", | |
| 260 | + @"pageSize":@"10", | |
| 261 | + @"type":@"2", | |
| 262 | + @"page":page | |
| 263 | + | |
| 264 | + }; | |
| 265 | + | |
| 266 | + [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | |
| 267 | + [CNLiveNetworking setupShowDataResult:NO]; | |
| 268 | + [CNLiveNetworking setupShowResult:YES]; | |
| 269 | + | |
| 270 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/servingApi/servingList") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 271 | + CNLiveServiceModel * model = [CNLiveServiceModel mj_objectWithKeyValues:responseObject[@"data"]]; | |
| 272 | + NSMutableArray *array = [NSMutableArray array]; | |
| 273 | + for (NSDictionary *dic in model.categories) { | |
| 274 | + CNLiveSearchModel *searchModel = [CNLiveSearchModel mj_objectWithKeyValues:dic]; | |
| 275 | + [array addObject:searchModel]; | |
| 276 | + } | |
| 277 | + | |
| 278 | + if (model) { | |
| 279 | + !succeed?:succeed(array.copy); | |
| 280 | + }else{ | |
| 281 | + !failure?:failure(); | |
| 282 | + } | |
| 283 | + | |
| 284 | + }]; | |
| 285 | +} | |
| 286 | + | |
| 287 | ++ (void)usedServiceWithServingId:(NSString *)servingId{ | |
| 288 | + NSDictionary * params = @{@"sid": CNUserShareModelUid ? CNUserShareModelUid : @"", | |
| 289 | + @"servingId":servingId?servingId:@""}; | |
| 290 | + [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | |
| 291 | + [CNLiveNetworking setupShowDataResult:NO]; | |
| 292 | + [CNLiveNetworking setupShowResult:YES]; | |
| 293 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:cn_API_Classify(@"/servingApi/click") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 294 | + | |
| 295 | + }]; | |
| 296 | +} | |
| 297 | + | |
| 298 | ++ (void)removeMyServiceResult:(void (^) (void)) succeed{ | |
| 299 | + NSDictionary * params = @{@"sid": CNUserShareModelUid ? CNUserShareModelUid : @""}; | |
| 300 | + | |
| 301 | + [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | |
| 302 | + [CNLiveNetworking setupShowDataResult:NO]; | |
| 303 | + [CNLiveNetworking setupShowResult:YES]; | |
| 304 | + | |
| 305 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/servingApi/removeMyNewest") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 306 | + if (!error) { | |
| 307 | + succeed(); | |
| 308 | + } | |
| 309 | + }]; | |
| 310 | +} | |
| 311 | + | |
| 312 | ++ (void)loadAllServiceWithServiceId:(NSString *)serviceId page:(nonnull NSString *)page result:(nonnull void (^)(NSArray * _Nonnull, BOOL))succeed error:(void (^)(void))failure | |
| 313 | +{ | |
| 314 | + NSDictionary * params = @{@"sid": CNUserShareModelUid ? CNUserShareModelUid : @"", | |
| 315 | + @"categoryId":serviceId | |
| 316 | + }; | |
| 317 | + | |
| 318 | + [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | |
| 319 | + [CNLiveNetworking setupShowDataResult:NO]; | |
| 320 | + [CNLiveNetworking setupShowResult:YES]; | |
| 321 | + | |
| 322 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:cn_API_Classify(@"/servingApi/allCategory") Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 323 | + NSDictionary * dic = responseObject[@"data"]; | |
| 324 | + NSMutableArray *array = [NSMutableArray array]; | |
| 325 | + if (dic[@"list"]&&[dic[@"list"] isKindOfClass:[NSArray class]]) { | |
| 326 | + NSArray *list = dic[@"list"]; | |
| 327 | + | |
| 328 | + for (NSDictionary *dic in list) { | |
| 329 | + NSDictionary *dictionary = @{ | |
| 330 | + @"title":dic[@"title"], | |
| 331 | + @"lists":dic[@"list"], | |
| 332 | + @"layout":@{ | |
| 333 | + @"width":@((SCREEN_WIDTH-4*margin-3*margin)/4.0), | |
| 334 | + @"height":@(70) | |
| 335 | + } | |
| 336 | + }; | |
| 337 | + CNLiveSearchHotsModel *searchModel = [CNLiveSearchHotsModel mj_objectWithKeyValues:dictionary]; | |
| 338 | + [array addObject:searchModel]; | |
| 339 | + } | |
| 340 | + } | |
| 341 | + | |
| 342 | + if (dic) { | |
| 343 | + NSString *lastPage = dic[@"isLastPage"]; | |
| 344 | + !succeed?:succeed(array.copy,lastPage.boolValue); | |
| 345 | + }else{ | |
| 346 | + !failure?:failure(); | |
| 347 | + } | |
| 348 | + | |
| 349 | + }]; | |
| 350 | +} | |
| 351 | +@end | ... | ... |
CNLiveCServiceModule/Classes/ReplaceMe.m deleted
100644 → 0
CNLiveCServiceModule/Classes/View/CNLIveCategoryCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLIveCategoryCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/12/1. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveSearchModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLIveCategoryCell : UICollectionViewCell | |
| 14 | +@property (nonatomic ,strong) CNLiveSearchModel *model; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLIveCategoryCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLIveCategoryCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/12/1. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLIveCategoryCell.h" | |
| 9 | + | |
| 10 | +@interface CNLIveCategoryCell() | |
| 11 | +@property (nonatomic, strong) UIImageView *logoView; | |
| 12 | +@property (nonatomic, strong) UILabel *titleLabel; | |
| 13 | +@property (nonatomic, strong) UILabel *subTitle; | |
| 14 | +@property (nonatomic, strong) UIImageView *rightImage; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +@implementation CNLIveCategoryCell | |
| 18 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 19 | +{ | |
| 20 | + self = [super initWithFrame:frame]; | |
| 21 | + if (self) { | |
| 22 | + [self.contentView addSubview:self.logoView]; | |
| 23 | + [self.contentView addSubview:self.titleLabel]; | |
| 24 | + [self.contentView addSubview:self.subTitle]; | |
| 25 | + [self.contentView addSubview:self.rightImage]; | |
| 26 | + } | |
| 27 | + return self; | |
| 28 | +} | |
| 29 | +-(void)layoutSubviews | |
| 30 | +{ | |
| 31 | + [super layoutSubviews]; | |
| 32 | + [self.logoView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 33 | + make.left.equalTo(self.contentView).offset(15); | |
| 34 | + make.centerY.equalTo(self.contentView); | |
| 35 | + make.height.width.offset(40); | |
| 36 | + }]; | |
| 37 | + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 38 | + make.left.equalTo(self.logoView.mas_right).offset(12.5); | |
| 39 | + make.bottom.equalTo(self.logoView.mas_centerY).offset(-2); | |
| 40 | + make.right.equalTo(self.contentView); | |
| 41 | + }]; | |
| 42 | + [self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 43 | + make.right.equalTo(self).offset(-15); | |
| 44 | + make.width.height.offset(18); | |
| 45 | + make.centerY.equalTo(self); | |
| 46 | + }]; | |
| 47 | + [self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 48 | + make.left.equalTo(self.titleLabel); | |
| 49 | + make.top.equalTo(self.logoView.mas_centerY).offset(2); | |
| 50 | + make.right.equalTo(self.rightImage.mas_left).offset(-5); | |
| 51 | + }]; | |
| 52 | + | |
| 53 | +} | |
| 54 | + | |
| 55 | +#pragma mark - Setting&&Getting | |
| 56 | +- (void)setModel:(CNLiveSearchModel *)model | |
| 57 | +{ | |
| 58 | + _model = model; | |
| 59 | + [self.logoView sd_setImageWithURL:[NSURL URLWithString:model.icon]]; | |
| 60 | + self.titleLabel.text = model.title; | |
| 61 | + self.subTitle.text = model.desc; | |
| 62 | + [self layoutSubviews]; | |
| 63 | +} | |
| 64 | +- (UIImageView *)logoView{ | |
| 65 | + if (!_logoView) { | |
| 66 | + _logoView = [[UIImageView alloc] init]; | |
| 67 | + _logoView.clipsToBounds = YES; | |
| 68 | + _logoView.layer.cornerRadius = 22.5; | |
| 69 | + } | |
| 70 | + return _logoView; | |
| 71 | +} | |
| 72 | + | |
| 73 | +- (UILabel *)titleLabel | |
| 74 | +{ | |
| 75 | + if (!_titleLabel) { | |
| 76 | + _titleLabel = [[UILabel alloc] init]; | |
| 77 | + _titleLabel.font = UIFontMake(15); | |
| 78 | + _titleLabel.textColor = CNLiveColorWithHexString(@"#666666"); | |
| 79 | + _titleLabel.textAlignment = NSTextAlignmentLeft; | |
| 80 | + } | |
| 81 | + return _titleLabel; | |
| 82 | +} | |
| 83 | + | |
| 84 | +- (UILabel *)subTitle | |
| 85 | +{ | |
| 86 | + if (!_subTitle) { | |
| 87 | + _subTitle = [[UILabel alloc] init]; | |
| 88 | + _subTitle.textColor = CNLiveColorWithHexString(@"#A9A9A9"); | |
| 89 | + _subTitle.font = UIFontMake(12); | |
| 90 | + } | |
| 91 | + return _subTitle; | |
| 92 | +} | |
| 93 | + | |
| 94 | +- (UIImageView *)rightImage | |
| 95 | +{ | |
| 96 | + if (!_rightImage) { | |
| 97 | + _rightImage = [[UIImageView alloc] init]; | |
| 98 | + [_rightImage setImage:[UIImage loadBundleImage:@"service_right"]]; | |
| 99 | + } | |
| 100 | + return _rightImage; | |
| 101 | +} | |
| 102 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveChineServiceCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveChineServiceCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/29. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveSearchModel.h" | |
| 10 | +NS_ASSUME_NONNULL_BEGIN | |
| 11 | + | |
| 12 | +@interface CNLiveChineServiceCell : UICollectionViewCell | |
| 13 | +@property (nonatomic ,strong) CNLiveSearchModel *model; | |
| 14 | +@end | |
| 15 | + | |
| 16 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveChineServiceCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveChineServiceCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/29. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveChineServiceCell.h" | |
| 9 | +@interface CNLiveChineServiceCell() | |
| 10 | +@property (nonatomic, strong) UIImageView *logoView; | |
| 11 | +@property (nonatomic, strong) UILabel *titleLabel; | |
| 12 | +@property (nonatomic, strong) UILabel *subTitle; | |
| 13 | +@end | |
| 14 | +@implementation CNLiveChineServiceCell | |
| 15 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 16 | +{ | |
| 17 | + self = [super initWithFrame:frame]; | |
| 18 | + if (self) { | |
| 19 | + self.contentView.backgroundColor = CNLiveColorWithHexString(@"#F9FAFB"); | |
| 20 | + self.contentView.layer.cornerRadius = 5.66; | |
| 21 | + [self.contentView addSubview:self.logoView]; | |
| 22 | + [self.contentView addSubview:self.titleLabel]; | |
| 23 | + [self.contentView addSubview:self.subTitle]; | |
| 24 | + } | |
| 25 | + return self; | |
| 26 | +} | |
| 27 | +-(void)layoutSubviews | |
| 28 | +{ | |
| 29 | + [super layoutSubviews]; | |
| 30 | + [self.logoView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 31 | + make.left.equalTo(self.contentView).offset(15); | |
| 32 | + make.centerY.equalTo(self.contentView); | |
| 33 | + make.height.width.offset(45); | |
| 34 | + }]; | |
| 35 | + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 36 | + make.left.equalTo(self.logoView.mas_right).offset(3); | |
| 37 | + make.bottom.equalTo(self.logoView.mas_centerY).offset(-2); | |
| 38 | + make.right.equalTo(self.contentView); | |
| 39 | + }]; | |
| 40 | + [self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 41 | + make.left.equalTo(self.titleLabel); | |
| 42 | + make.top.equalTo(self.logoView.mas_centerY).offset(2); | |
| 43 | + make.right.equalTo(self.contentView).offset(-17); | |
| 44 | + }]; | |
| 45 | +} | |
| 46 | + | |
| 47 | +#pragma mark - Setting&&Getting | |
| 48 | +- (void)setModel:(CNLiveSearchModel *)model | |
| 49 | +{ | |
| 50 | + _model = model; | |
| 51 | + [self.logoView sd_setImageWithURL:[NSURL URLWithString:model.icon]]; | |
| 52 | + self.titleLabel.text = model.title; | |
| 53 | + self.subTitle.text = model.desc; | |
| 54 | + [self layoutSubviews]; | |
| 55 | +} | |
| 56 | +- (UIImageView *)logoView{ | |
| 57 | + if (!_logoView) { | |
| 58 | + _logoView = [[UIImageView alloc] init]; | |
| 59 | + _logoView.clipsToBounds = YES; | |
| 60 | + _logoView.layer.cornerRadius = 22.5; | |
| 61 | + } | |
| 62 | + return _logoView; | |
| 63 | +} | |
| 64 | + | |
| 65 | +- (UILabel *)titleLabel | |
| 66 | +{ | |
| 67 | + if (!_titleLabel) { | |
| 68 | + _titleLabel = [[UILabel alloc] init]; | |
| 69 | + _titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; | |
| 70 | + _titleLabel.font = UIFontMake(11); | |
| 71 | + _titleLabel.textColor = CNLiveColorWithHexString(@"#4A4A4A"); | |
| 72 | + _titleLabel.textAlignment = NSTextAlignmentLeft; | |
| 73 | + } | |
| 74 | + return _titleLabel; | |
| 75 | +} | |
| 76 | + | |
| 77 | +- (UILabel *)subTitle | |
| 78 | +{ | |
| 79 | + if (!_subTitle) { | |
| 80 | + _subTitle = [[UILabel alloc] init]; | |
| 81 | + _subTitle.textColor = CNLiveColorWithHexString(@"#A9A9A9"); | |
| 82 | + _subTitle.font = UIFontMake(10); | |
| 83 | + } | |
| 84 | + return _subTitle; | |
| 85 | +} | |
| 86 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveCycleActiveCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCycleActiveCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/30. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveServiceModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveCycleActiveCell : UICollectionViewCell | |
| 14 | +@property (nonatomic, strong) CNliveServicePageModel *model; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveCycleActiveCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCycleActiveCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/30. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveCycleActiveCell.h" | |
| 9 | +@interface CNLiveCycleActiveCell()<SDCycleScrollViewDelegate> | |
| 10 | + | |
| 11 | +@property (nonatomic, strong) SDCycleScrollView *cycleView; | |
| 12 | +@property (nonatomic, strong) UICollectionView *collectionView; | |
| 13 | +@end | |
| 14 | + | |
| 15 | +@implementation CNLiveCycleActiveCell | |
| 16 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 17 | +{ | |
| 18 | + self = [super initWithFrame:frame]; | |
| 19 | + if (self) { | |
| 20 | + [self.contentView addSubview:self.cycleView]; | |
| 21 | + self.collectionView.layer.cornerRadius = 9; | |
| 22 | + } | |
| 23 | + return self; | |
| 24 | +} | |
| 25 | +- (void)layoutSubviews | |
| 26 | +{ | |
| 27 | + [super layoutSubviews]; | |
| 28 | + [self.cycleView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 29 | + make.top.bottom.equalTo(self.contentView); | |
| 30 | + make.left.equalTo(self.contentView).offset(10); | |
| 31 | + make.right.equalTo(self.contentView).offset(-10); | |
| 32 | + }]; | |
| 33 | +} | |
| 34 | +#pragma mark - method | |
| 35 | +- (NSArray *)pickUpImageFromArray:(NSArray *)array{ | |
| 36 | + NSMutableArray *imageArr = [NSMutableArray array]; | |
| 37 | + for (NSDictionary *dic in array) { | |
| 38 | + CnLivePageContentModel *model = [CnLivePageContentModel mj_objectWithKeyValues:dic]; | |
| 39 | + [imageArr addObject:model.poster]; | |
| 40 | + } | |
| 41 | + return imageArr.copy; | |
| 42 | +} | |
| 43 | +#pragma mark - SDCycleScrollViewDelegate | |
| 44 | +- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{ | |
| 45 | + | |
| 46 | +} | |
| 47 | +#pragma mark - Setting&&Getting | |
| 48 | + | |
| 49 | +- (void)setModel:(CNliveServicePageModel *)model | |
| 50 | +{ | |
| 51 | + _model = model; | |
| 52 | + self.cycleView.imageURLStringsGroup = [self pickUpImageFromArray:model.contents]; | |
| 53 | + [self.cycleView reloadInputViews]; | |
| 54 | +} | |
| 55 | +- (SDCycleScrollView *)cycleView | |
| 56 | +{ | |
| 57 | + if (!_cycleView) { | |
| 58 | + _cycleView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:nil]; | |
| 59 | + _cycleView.layer.cornerRadius = 9; | |
| 60 | + _cycleView.infiniteLoop = YES; | |
| 61 | + _cycleView.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated; | |
| 62 | + _cycleView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter; | |
| 63 | + _cycleView.hidesForSinglePage = YES; | |
| 64 | + _cycleView.pageControlDotSize = CGSizeMake(4, 4); | |
| 65 | + } | |
| 66 | + return _cycleView; | |
| 67 | +} | |
| 68 | +- (UICollectionView *)collectionView | |
| 69 | +{ | |
| 70 | + if (!_collectionView) { | |
| 71 | + for (UIView *view in self.cycleView.subviews) { | |
| 72 | + if ([view isKindOfClass:[UICollectionView class]]) { | |
| 73 | + _collectionView = (UICollectionView *)view; | |
| 74 | + } | |
| 75 | + } | |
| 76 | + } | |
| 77 | + return _collectionView; | |
| 78 | +} | |
| 79 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveCycleCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCycleCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveSearchModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveCycleCell : UICollectionViewCell | |
| 14 | +@property (nonatomic, strong) CNLiveSearchHotsModel *model; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveCycleCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCycleCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveCycleCell.h" | |
| 9 | +#import "CNLiveSearchHotsCell.h" | |
| 10 | +#import "CNLiveMyServicesVC.h" | |
| 11 | +#import "CNLiveAllServiceVC.h" | |
| 12 | +#import "CNLiveServiceModel.h" | |
| 13 | +#import "CNLiveChineServiceCell.h" | |
| 14 | +#import "CNLiveServiceOrLookCell.h" | |
| 15 | + | |
| 16 | +@interface CNLiveCycleCell()<UICollectionViewDelegate,UICollectionViewDataSource> | |
| 17 | +@property (nonatomic, strong) UICollectionView *listCollectionView; | |
| 18 | +@property (nonatomic, strong) NSArray *dataSource; | |
| 19 | +@end | |
| 20 | + | |
| 21 | +static NSString *HotListCellID = @"HotListCellID"; | |
| 22 | +static NSString *ChineseServiceID = @"CNLiveChineServiceCell"; | |
| 23 | +static NSString *CNServiceOrLookID = @"CNLiveServiceOrLookCell"; | |
| 24 | + | |
| 25 | +@implementation CNLiveCycleCell | |
| 26 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 27 | +{ | |
| 28 | + self = [super initWithFrame:frame]; | |
| 29 | + if (self) { | |
| 30 | + [self.contentView addSubview:self.listCollectionView]; | |
| 31 | + } | |
| 32 | + return self; | |
| 33 | +} | |
| 34 | +- (void)layoutSubviews | |
| 35 | +{ | |
| 36 | + [super layoutSubviews]; | |
| 37 | + [self.listCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 38 | + make.top.left.right.bottom.equalTo(self); | |
| 39 | + }]; | |
| 40 | +} | |
| 41 | +#pragma mark - UICollectionViewDelegate | |
| 42 | +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 43 | + if (indexPath.row == self.dataSource.count) { | |
| 44 | + [CNLiveMyServicesVC myServiceVC]; | |
| 45 | + }else if (indexPath.row == self.dataSource.count + 1){ | |
| 46 | + [CNLiveAllServiceVC allServiceVCWithId:@"" title:@"全部服务"]; | |
| 47 | + }else{ | |
| 48 | + NSObject *model = self.dataSource[indexPath.row]; | |
| 49 | + if ([model isKindOfClass:[CNCategoryModel class]]) { | |
| 50 | + CNCategoryModel *categoryModel = (CNCategoryModel *)model; | |
| 51 | + [CNLiveAllServiceVC allServiceVCWithId:categoryModel.id title:categoryModel.title]; | |
| 52 | + } | |
| 53 | + } | |
| 54 | + | |
| 55 | +} | |
| 56 | +#pragma mark - UICollectionViewDataSource | |
| 57 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ | |
| 58 | + if ([self.model.title isEqualToString:@""]) { | |
| 59 | + return self.dataSource.count + 2; | |
| 60 | + } | |
| 61 | + return self.dataSource.count; | |
| 62 | +} | |
| 63 | + | |
| 64 | +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 65 | + if ([_model.title isEqualToString:@"中国服务号"]) { | |
| 66 | + CNLiveChineServiceCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ChineseServiceID forIndexPath:indexPath]; | |
| 67 | + cell.model = self.dataSource[indexPath.row]; | |
| 68 | + return cell; | |
| 69 | + }else if ([_model.title isEqual:@"大家都在用"]){ | |
| 70 | + CNLiveServiceOrLookCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNServiceOrLookID forIndexPath:indexPath]; | |
| 71 | + cell.model = self.dataSource[indexPath.row]; | |
| 72 | + cell.type = CNLiveCellShowTypeLook; | |
| 73 | + return cell; | |
| 74 | + }else{ | |
| 75 | + CNLiveSearchHotsCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:HotListCellID forIndexPath:indexPath]; | |
| 76 | + if (indexPath.row < self.dataSource.count) { | |
| 77 | + cell.model = self.dataSource[indexPath.row]; | |
| 78 | + | |
| 79 | + }else if (indexPath.row == self.dataSource.count){ | |
| 80 | + [cell.logoView setImage:[UIImage loadBundleImage:@"service_mine"]]; | |
| 81 | + cell.titleLabel.text = @"我的服务"; | |
| 82 | + [cell.titleLabel sizeToFit]; | |
| 83 | + [cell setNeedsLayout]; | |
| 84 | + }else{ | |
| 85 | + [cell.logoView setImage:[UIImage loadBundleImage:@"service_more"]]; | |
| 86 | + cell.titleLabel.text = @"更多服务"; | |
| 87 | + [cell.titleLabel sizeToFit]; | |
| 88 | + [cell setNeedsLayout]; | |
| 89 | + } | |
| 90 | + | |
| 91 | + return cell; | |
| 92 | + } | |
| 93 | +} | |
| 94 | +#pragma mark - UICollectionViewDelegateFlowLayout | |
| 95 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 96 | + if ([_model.title isEqualToString:@"大家都在用"]) { | |
| 97 | + return CGSizeMake(collectionView.width, (collectionView.height -40)/3); | |
| 98 | + } | |
| 99 | + return CGSizeMake(_model.layout.width, _model.layout.height); | |
| 100 | +} | |
| 101 | +- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ | |
| 102 | + if ([_model.title isEqual:@"中国服务号"]) { | |
| 103 | + return UIEdgeInsetsMake(10, 5, 10, 5); | |
| 104 | + } | |
| 105 | + if ([_model.title isEqual:@""]) { | |
| 106 | + return UIEdgeInsetsMake(5, 0, 5, 0); | |
| 107 | + } | |
| 108 | + if ([_model.title isEqual:@"大家都在用"]) { | |
| 109 | + return UIEdgeInsetsMake(15, 0, 0, 0); | |
| 110 | + } | |
| 111 | + return UIEdgeInsetsMake(15, 15, 0, 15); | |
| 112 | +} | |
| 113 | +#pragma mark - Setting&&Getting | |
| 114 | +-(void)setModel:(CNLiveSearchHotsModel *)model | |
| 115 | +{ | |
| 116 | + _model = model; | |
| 117 | + self.dataSource = model.lists; | |
| 118 | +} | |
| 119 | +- (void)setDataSource:(NSArray *)dataSource | |
| 120 | +{ | |
| 121 | + _dataSource = dataSource; | |
| 122 | + [self.listCollectionView reloadData]; | |
| 123 | +} | |
| 124 | +- (UICollectionView *)listCollectionView | |
| 125 | +{ | |
| 126 | + if (!_listCollectionView) { | |
| 127 | + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 128 | + layout.sectionFootersPinToVisibleBounds = YES; | |
| 129 | + layout.sectionHeadersPinToVisibleBounds = YES; | |
| 130 | + _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; | |
| 131 | + _listCollectionView.scrollEnabled = NO; | |
| 132 | + _listCollectionView.backgroundColor = kWhiteColor; | |
| 133 | + _listCollectionView.collectionViewLayout = layout; | |
| 134 | + _listCollectionView.delegate = self; | |
| 135 | + _listCollectionView.dataSource = self; | |
| 136 | + _listCollectionView.backgroundColor = kClearColor; | |
| 137 | + _listCollectionView.showsVerticalScrollIndicator = NO; | |
| 138 | + [_listCollectionView registerClass:[CNLiveSearchHotsCell class] forCellWithReuseIdentifier:HotListCellID]; | |
| 139 | + [_listCollectionView registerClass:[CNLiveChineServiceCell class] forCellWithReuseIdentifier:ChineseServiceID]; | |
| 140 | + [_listCollectionView registerClass:[CNLiveServiceOrLookCell class] forCellWithReuseIdentifier:CNServiceOrLookID]; | |
| 141 | + | |
| 142 | + } | |
| 143 | + return _listCollectionView; | |
| 144 | +} | |
| 145 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveCycleView.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCycleView.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <SDCycleScrollView/SDCycleScrollView.h> | |
| 9 | +#import "CNLiveSearchModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveCycleView : SDCycleScrollView | |
| 14 | +@property (nonatomic , strong) CNLiveSearchHotsModel *model; | |
| 15 | +@property (nonatomic , strong) NSArray *dataSource; | |
| 16 | +@end | |
| 17 | + | |
| 18 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveCycleView.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCycleView.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveCycleView.h" | |
| 9 | +#import "CNLiveCycleCell.h" | |
| 10 | + | |
| 11 | + | |
| 12 | +@interface CNLiveCycleView()<UICollectionViewDataSource> | |
| 13 | +@property (nonatomic, strong) UICollectionView *collectionView; | |
| 14 | +@end | |
| 15 | +static NSString *CNCycleCellID = @"CNCycleCellID"; | |
| 16 | +@implementation CNLiveCycleView | |
| 17 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 18 | +{ | |
| 19 | + self = [super initWithFrame:frame]; | |
| 20 | + if (self) { | |
| 21 | + self.backgroundColor = kClearColor; | |
| 22 | + self.collectionView.dataSource = self; | |
| 23 | + } | |
| 24 | + return self; | |
| 25 | +} | |
| 26 | + | |
| 27 | +- (void)layoutSubviews | |
| 28 | +{ | |
| 29 | + [super layoutSubviews]; | |
| 30 | + if ([_model.title isEqualToString:@""]) { | |
| 31 | + return; | |
| 32 | + } | |
| 33 | + | |
| 34 | + self.collectionView.frame = CGRectMake(0, 0, self.width, self.height - 20); | |
| 35 | +} | |
| 36 | +#pragma mark - UICollectionViewDataSource | |
| 37 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ | |
| 38 | + | |
| 39 | + return self.dataSource.count; | |
| 40 | +} | |
| 41 | + | |
| 42 | +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 43 | + | |
| 44 | + CNLiveCycleCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNCycleCellID forIndexPath:indexPath]; | |
| 45 | + CNLiveSearchHotsModel *model = self.dataSource[indexPath.row]; | |
| 46 | + cell.model = model; | |
| 47 | + return cell; | |
| 48 | +} | |
| 49 | +#pragma mark - Setting&&Getting | |
| 50 | +- (void)setModel:(CNLiveSearchHotsModel *)model | |
| 51 | +{ | |
| 52 | + _model = model; | |
| 53 | + self.dataSource = model.lists; | |
| 54 | + if ([model.title isEqualToString:@"中国媒体号"]||[model.title isEqualToString:@"中国网中国号"]) { | |
| 55 | + self.collectionView.backgroundColor = CNLiveColorWithHexString(@"#F9FAFB"); | |
| 56 | + self.collectionView.layer.cornerRadius = 5.66; | |
| 57 | + }else | |
| 58 | + { | |
| 59 | + self.collectionView.backgroundColor = kClearColor; | |
| 60 | + } | |
| 61 | +} | |
| 62 | +- (void)setDataSource:(NSArray *)dataSource | |
| 63 | +{ | |
| 64 | + _dataSource = dataSource; | |
| 65 | + [self.collectionView reloadData]; | |
| 66 | + | |
| 67 | +} | |
| 68 | +- (UICollectionView *)collectionView | |
| 69 | +{ | |
| 70 | + if (!_collectionView) { | |
| 71 | + for (UIView *view in self.subviews) { | |
| 72 | + if ([view isKindOfClass:[UICollectionView class]]) { | |
| 73 | + _collectionView = (UICollectionView *)view; | |
| 74 | + [_collectionView registerClass:[CNLiveCycleCell class] forCellWithReuseIdentifier:CNCycleCellID]; | |
| 75 | + _collectionView.backgroundColor = kClearColor; | |
| 76 | + } | |
| 77 | + } | |
| 78 | + } | |
| 79 | + return _collectionView; | |
| 80 | +} | |
| 81 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveGoodsOrVideoHeaderView.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveGoodsOrVideoHeaderView.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/12/1. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveServiceModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveGoodsOrVideoHeaderView : UICollectionReusableView | |
| 14 | +@property (nonatomic, strong) CNliveServicePageModel *pageModel; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveGoodsOrVideoHeaderView.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveGoodsOrVideoHeaderView.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/12/1. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveGoodsOrVideoHeaderView.h" | |
| 9 | + | |
| 10 | +@interface CNLiveGoodsOrVideoHeaderView () | |
| 11 | +@property (nonatomic, strong) UIImageView *LogoImage; | |
| 12 | +@property (nonatomic, strong) UILabel *titlelabel; | |
| 13 | +@property (nonatomic, strong) UILabel *subTitle; | |
| 14 | +@property (nonatomic, strong) QMUIButton *moreBtn; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +@implementation CNLiveGoodsOrVideoHeaderView | |
| 18 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 19 | +{ | |
| 20 | + self = [super initWithFrame:frame]; | |
| 21 | + if (self) { | |
| 22 | + self.backgroundColor = kWhiteColor; | |
| 23 | + [self addSubview:self.LogoImage]; | |
| 24 | + [self addSubview:self.titlelabel]; | |
| 25 | + [self addSubview:self.subTitle]; | |
| 26 | + [self addSubview:self.moreBtn]; | |
| 27 | + } | |
| 28 | + return self; | |
| 29 | +} | |
| 30 | +- (void)layoutSubviews | |
| 31 | +{ | |
| 32 | + [super layoutSubviews]; | |
| 33 | + | |
| 34 | + [self.LogoImage mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 35 | + make.left.equalTo(self).offset(15); | |
| 36 | + make.centerY.equalTo(self); | |
| 37 | + make.width.height.offset(16.5); | |
| 38 | + }]; | |
| 39 | + [self.titlelabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 40 | + if (!self.LogoImage.isHidden) { | |
| 41 | + make.left.equalTo(_LogoImage.mas_right).offset(5); | |
| 42 | + }else{ | |
| 43 | + make.left.equalTo(self).offset(15); | |
| 44 | + } | |
| 45 | + make.centerY.equalTo(self); | |
| 46 | + }]; | |
| 47 | + [self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 48 | + make.left.equalTo(self.titlelabel.mas_right).offset(8); | |
| 49 | + make.centerY.equalTo(self); | |
| 50 | + }]; | |
| 51 | + [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 52 | + make.right.equalTo(self).offset(-20); | |
| 53 | + make.centerY.equalTo(self); | |
| 54 | + }]; | |
| 55 | +} | |
| 56 | + | |
| 57 | +#pragma mark - Setting&&Getting | |
| 58 | +- (void)setPageModel:(CNliveServicePageModel *)pageModel | |
| 59 | +{ | |
| 60 | + _pageModel = pageModel; | |
| 61 | + self.titlelabel.text = pageModel.blockName; | |
| 62 | + [self.titlelabel sizeToFit]; | |
| 63 | + if (pageModel.blockSubTitle) { | |
| 64 | + self.subTitle.text = [NSString stringWithFormat:@"| %@",pageModel.blockSubTitle]; | |
| 65 | + [self.subTitle sizeToFit]; | |
| 66 | + } | |
| 67 | + if ([pageModel.blockName isEqualToString:@"热销排行"]) { | |
| 68 | + self.LogoImage.hidden = NO; | |
| 69 | + self.subTitle.hidden = NO; | |
| 70 | + UIColor *begin = CNLiveColorWithHexString(@"#FFF4F1"); | |
| 71 | + self.backgroundColor = [UIColor colorWithPatternImage:[UIImage gradientImageWithColors:@[begin,kWhiteColor] rect:self.bounds]]; | |
| 72 | + self.titlelabel.textColor = CNLiveColorWithHexString(@"#FA7256"); | |
| 73 | + }else{ | |
| 74 | + if ([pageModel.blockName isEqualToString:@"精品音频"]) { | |
| 75 | + self.moreBtn.hidden = YES; | |
| 76 | + }else{ | |
| 77 | + self.moreBtn.hidden = NO; | |
| 78 | + } | |
| 79 | + self.LogoImage.hidden = YES; | |
| 80 | + self.subTitle.hidden = YES; | |
| 81 | + self.backgroundColor = kWhiteColor; | |
| 82 | + _titlelabel.textColor = CNLiveColorWithHexString(@"#333333"); | |
| 83 | + } | |
| 84 | + [self setNeedsLayout]; | |
| 85 | +} | |
| 86 | +- (UIImageView *)LogoImage | |
| 87 | +{ | |
| 88 | + if (!_LogoImage) { | |
| 89 | + _LogoImage = [[UIImageView alloc] init]; | |
| 90 | + [_LogoImage setImage:[UIImage loadBundleImage:@"service_hot"]]; | |
| 91 | + _LogoImage.hidden = YES; | |
| 92 | + } | |
| 93 | + return _LogoImage; | |
| 94 | +} | |
| 95 | +- (UILabel *)titlelabel | |
| 96 | +{ | |
| 97 | + if (!_titlelabel) { | |
| 98 | + _titlelabel = [[UILabel alloc] init]; | |
| 99 | + _titlelabel.font = UIFontMake(17); | |
| 100 | + _titlelabel.textColor = CNLiveColorWithHexString(@"#999999"); | |
| 101 | + } | |
| 102 | + return _titlelabel; | |
| 103 | +} | |
| 104 | +- (UILabel *)subTitle | |
| 105 | +{ | |
| 106 | + if (!_subTitle) { | |
| 107 | + _subTitle = [[UILabel alloc] init]; | |
| 108 | + _subTitle.font = UIFontMake(12); | |
| 109 | + _subTitle.textColor = CNLiveColorWithHexString(@"#333333"); | |
| 110 | + } | |
| 111 | + return _subTitle; | |
| 112 | +} | |
| 113 | +- (QMUIButton *)moreBtn | |
| 114 | +{ | |
| 115 | + if (!_moreBtn) { | |
| 116 | + _moreBtn = [QMUIButton buttonWithType:UIButtonTypeCustom]; | |
| 117 | + [_moreBtn setImage:[UIImage loadBundleImage:@"object_more"] forState:UIControlStateNormal]; | |
| 118 | + [_moreBtn setTitle:@"更多" forState:UIControlStateNormal]; | |
| 119 | + [_moreBtn setTitleColor:CNLiveColorWithHexString(@"#999695") forState:UIControlStateNormal]; | |
| 120 | + _moreBtn.titleLabel.font = UIFontMake(12); | |
| 121 | + _moreBtn.imagePosition = QMUIButtonImagePositionRight; | |
| 122 | + } | |
| 123 | + return _moreBtn; | |
| 124 | +} | |
| 125 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveHotSaleCell.h
0 → 100644
CNLiveCServiceModule/Classes/View/CNLiveHotSaleCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveHotSaleCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveHotSaleCell.h" | |
| 9 | + | |
| 10 | +@implementation CNLiveHotSaleCell | |
| 11 | + | |
| 12 | +- (void)awakeFromNib { | |
| 13 | + [super awakeFromNib]; | |
| 14 | + // Initialization code | |
| 15 | +} | |
| 16 | + | |
| 17 | +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { | |
| 18 | + [super setSelected:selected animated:animated]; | |
| 19 | + | |
| 20 | + // Configure the view for the selected state | |
| 21 | +} | |
| 22 | + | |
| 23 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveMainSearch.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveMainSearch.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/22. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | + | |
| 10 | +NS_ASSUME_NONNULL_BEGIN | |
| 11 | + | |
| 12 | +typedef NS_ENUM(NSInteger, CNSearchViewShowType){ | |
| 13 | + CNSearchViewShowTypePush =1, //首页头部搜索 | |
| 14 | + CNSearchViewShowTypeSearch =2, //搜索页头部搜索 | |
| 15 | +}; | |
| 16 | + | |
| 17 | +typedef void(^SearchBlock)(NSString *searchStr); | |
| 18 | +typedef void(^ClearBlock)(void); | |
| 19 | + | |
| 20 | +@interface CNLiveMainSearch : UIView | |
| 21 | + | |
| 22 | +@property (nonatomic, strong) UITextField *searchField; | |
| 23 | +@property (nonatomic, copy) SearchBlock searchBlock;//搜索回调 | |
| 24 | +@property (nonatomic, copy) ClearBlock clearBlock; //清除输入内容回调 | |
| 25 | + | |
| 26 | +- (instancetype)initWithType:(CNSearchViewShowType)type; | |
| 27 | +@end | |
| 28 | + | |
| 29 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveMainSearch.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveMainSearch.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/22. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveMainSearch.h" | |
| 9 | +@interface CNLiveMainSearch()<UITextFieldDelegate> | |
| 10 | +@property (nonatomic, strong) UIImageView *searchImage; | |
| 11 | +@property (nonatomic, strong) UIView *lineView; | |
| 12 | +@property (nonatomic, assign) CNSearchViewShowType type; | |
| 13 | +@end | |
| 14 | +@implementation CNLiveMainSearch | |
| 15 | +- (instancetype)initWithType:(CNSearchViewShowType)type | |
| 16 | +{ | |
| 17 | + self = [super init]; | |
| 18 | + if (self) { | |
| 19 | + _type = type; | |
| 20 | + if (type == 1) { | |
| 21 | + self.backgroundColor = kWhiteColor; | |
| 22 | + self.layer.cornerRadius = 8; | |
| 23 | + }else | |
| 24 | + { | |
| 25 | + self.backgroundColor = CNLiveColorWithHexString(@"#F9F9F9"); | |
| 26 | + self.layer.cornerRadius = 16; | |
| 27 | + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)]; | |
| 28 | + [self addGestureRecognizer:tap]; | |
| 29 | + } | |
| 30 | + | |
| 31 | + [self addSubview:self.searchImage]; | |
| 32 | + [self addSubview:self.searchField]; | |
| 33 | + [self addSubview:self.lineView]; | |
| 34 | + } | |
| 35 | + return self; | |
| 36 | +} | |
| 37 | +- (void)layoutSubviews | |
| 38 | +{ | |
| 39 | + [super layoutSubviews]; | |
| 40 | + [self.searchImage mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 41 | + make.left.equalTo(self).offset(15); | |
| 42 | + make.width.offset(16); | |
| 43 | + make.height.offset(16); | |
| 44 | + make.centerY.equalTo(self); | |
| 45 | + }]; | |
| 46 | + [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 47 | + make.left.equalTo(self.searchImage.mas_right).offset(10); | |
| 48 | + make.width.offset(0.5); | |
| 49 | + make.height.offset(11); | |
| 50 | + make.centerY.equalTo(self); | |
| 51 | + }]; | |
| 52 | + [self.searchField mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 53 | + make.left.equalTo(self.lineView.mas_right).offset(10); | |
| 54 | + make.right.equalTo(self).offset(-5); | |
| 55 | + make.top.bottom.equalTo(self); | |
| 56 | + make.centerY.equalTo(self); | |
| 57 | + }]; | |
| 58 | +} | |
| 59 | +#pragma mark - Action | |
| 60 | +- (void)tapAction{ | |
| 61 | + [self.searchField becomeFirstResponder]; | |
| 62 | +} | |
| 63 | + | |
| 64 | +#pragma mark - UITextFieldDelegate | |
| 65 | +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{ | |
| 66 | + if ([textField.text isEqualToString:@""]&&[string isEqualToString:@" "]) { | |
| 67 | + return NO; | |
| 68 | + } | |
| 69 | + return YES; | |
| 70 | +} | |
| 71 | +- (BOOL)textFieldShouldClear:(UITextField *)textField{ | |
| 72 | + !self.clearBlock?:self.clearBlock(); | |
| 73 | + return YES; | |
| 74 | +} | |
| 75 | +- (BOOL)textFieldShouldReturn:(UITextField *)textField{ | |
| 76 | + if ([textField.text isEqualToString:@""] || !textField.text) { | |
| 77 | + [QMUITips showWithText:@"请输入服务号名称" inView:AppKeyWindow hideAfterDelay:1.5]; | |
| 78 | + return NO; | |
| 79 | + } | |
| 80 | + !self.searchBlock?:self.searchBlock(textField.text); | |
| 81 | + return YES; | |
| 82 | +} | |
| 83 | +#pragma mark - Setting&&Getting | |
| 84 | +- (UIImageView *)searchImage | |
| 85 | +{ | |
| 86 | + if (!_searchImage) { | |
| 87 | + _searchImage = [[UIImageView alloc] init]; | |
| 88 | + [_searchImage setImage:[UIImage loadBundleImage:@"service_search"]]; | |
| 89 | + } | |
| 90 | + return _searchImage; | |
| 91 | +} | |
| 92 | +- (UITextField *)searchField | |
| 93 | +{ | |
| 94 | + if (!_searchField) { | |
| 95 | + _searchField = [[UITextField alloc] init]; | |
| 96 | + if (_type == 1) { | |
| 97 | + _searchField.placeholder = @"搜索"; | |
| 98 | + _searchField.enabled = NO; | |
| 99 | + }else{ | |
| 100 | + _searchField.placeholder = @"输入服务号名称"; | |
| 101 | + _searchField.delegate = self; | |
| 102 | + } | |
| 103 | + _searchField.returnKeyType = UIReturnKeySearch; | |
| 104 | + _searchField.clearButtonMode = UITextFieldViewModeAlways; | |
| 105 | + _searchField.textColor = CNLiveColorWithHexString(@"#333333"); | |
| 106 | + _searchField.font = UIFontMake(14); | |
| 107 | + } | |
| 108 | + return _searchField; | |
| 109 | +} | |
| 110 | +- (UIView *)lineView | |
| 111 | +{ | |
| 112 | + if (!_lineView) { | |
| 113 | + _lineView = [[UIView alloc] init]; | |
| 114 | + _lineView.backgroundColor = CNLiveColorWithHexString(@"#333333"); | |
| 115 | + } | |
| 116 | + return _lineView; | |
| 117 | +} | |
| 118 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveRecommendCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveRecommendCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveServiceModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveRecommendCell : UICollectionViewCell | |
| 14 | +@property (nonatomic, strong) CNliveServicePageModel *model; | |
| 15 | + | |
| 16 | +@end | |
| 17 | + | |
| 18 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveRecommendCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveRecommendCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveRecommendCell.h" | |
| 9 | +#import "CNLiveVideoRecommendCell.h" | |
| 10 | +@interface CNLiveRecommendCell()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> | |
| 11 | +@property (nonatomic, strong) UICollectionView *listCollectionView; | |
| 12 | +@end | |
| 13 | +static NSString *CNVideoRecommendCellID = @"CNLiveVideoRecommendCell"; | |
| 14 | +@implementation CNLiveRecommendCell | |
| 15 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 16 | +{ | |
| 17 | + self = [super initWithFrame:frame]; | |
| 18 | + if (self) { | |
| 19 | + [self.contentView addSubview:self.listCollectionView]; | |
| 20 | + } | |
| 21 | + return self; | |
| 22 | +} | |
| 23 | +- (void)layoutSubviews | |
| 24 | +{ | |
| 25 | + [super layoutSubviews]; | |
| 26 | + [self.listCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 27 | + make.left.right.top.bottom.equalTo(self); | |
| 28 | + }]; | |
| 29 | +} | |
| 30 | +#pragma mark - UICollectionViewDelegate | |
| 31 | +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 32 | + | |
| 33 | +} | |
| 34 | +#pragma mark - UICollectionViewDataSource | |
| 35 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ | |
| 36 | + return self.model.contents.count; | |
| 37 | +} | |
| 38 | +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 39 | + | |
| 40 | + CNLiveVideoRecommendCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNVideoRecommendCellID forIndexPath:indexPath]; | |
| 41 | + if ([_model.blockName isEqualToString:@"热销排行"]) { | |
| 42 | + cell.type = CNLiveCellShowTypeHot; | |
| 43 | + }else if ([_model.blockName isEqualToString:@"精品音频"]){ | |
| 44 | + cell.type = CNLiveCellShowTypeVideo; | |
| 45 | + }else{ | |
| 46 | + cell.type = CNLiveCellShowTypeGoods; | |
| 47 | + } | |
| 48 | + cell.model = [CnLivePageContentModel mj_objectWithKeyValues:self.model.contents[indexPath.row]]; | |
| 49 | + | |
| 50 | + return cell; | |
| 51 | + | |
| 52 | +} | |
| 53 | +#pragma mark - UICollectionViewDelegateFlowLayout | |
| 54 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 55 | + if ([_model.blockName isEqualToString:@"热销排行"]) { | |
| 56 | + return CGSizeMake((collectionView.width -40)/4.5, _model.cellHeight); | |
| 57 | + } | |
| 58 | + return CGSizeMake((collectionView.width -40)/3, _model.cellHeight); | |
| 59 | +} | |
| 60 | +- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ | |
| 61 | + return UIEdgeInsetsMake(10, 10, 10, 10); | |
| 62 | +} | |
| 63 | +#pragma mark - Setting&&Getting | |
| 64 | +- (void)setModel:(CNliveServicePageModel *)model | |
| 65 | +{ | |
| 66 | + _model = model; | |
| 67 | + [self.listCollectionView reloadData]; | |
| 68 | +} | |
| 69 | +- (UICollectionView *)listCollectionView | |
| 70 | +{ | |
| 71 | + if (!_listCollectionView) { | |
| 72 | + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 73 | + layout.sectionFootersPinToVisibleBounds = NO; | |
| 74 | + layout.sectionHeadersPinToVisibleBounds = NO; | |
| 75 | + _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; | |
| 76 | + _listCollectionView.backgroundColor = kWhiteColor; | |
| 77 | + _listCollectionView.collectionViewLayout = layout; | |
| 78 | + _listCollectionView.delegate = self; | |
| 79 | + _listCollectionView.dataSource = self; | |
| 80 | + _listCollectionView.showsVerticalScrollIndicator = NO; | |
| 81 | + layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; | |
| 82 | + [_listCollectionView registerClass:[CNLiveVideoRecommendCell class] forCellWithReuseIdentifier:CNVideoRecommendCellID]; | |
| 83 | + | |
| 84 | + } | |
| 85 | + return _listCollectionView; | |
| 86 | +} | |
| 87 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveSearchHeaderView.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchHeaderView.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/26. | |
| 6 | +// | |
| 7 | + | |
| 8 | +typedef NS_ENUM(NSInteger, CNServiceHeaderType){ | |
| 9 | + CNServiceHeaderTypeSearch, //搜索页头部 | |
| 10 | + CNServiceHeaderTypeService, //首页头部 | |
| 11 | + CNServiceHeaderTypeCategoryId //搜索某个分类进入 | |
| 12 | +} ; | |
| 13 | + | |
| 14 | +#import <UIKit/UIKit.h> | |
| 15 | +#import "CNLiveSearchModel.h" | |
| 16 | +#import "CNLiveServiceModel.h" | |
| 17 | + | |
| 18 | +NS_ASSUME_NONNULL_BEGIN | |
| 19 | + | |
| 20 | +@interface CNLiveSearchHeaderView : UICollectionReusableView | |
| 21 | +@property (nonatomic, strong) CNLiveSearchHotsModel *model; | |
| 22 | + | |
| 23 | +@property (nonatomic, assign) CNServiceHeaderType type; | |
| 24 | +@end | |
| 25 | + | |
| 26 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveSearchHeaderView.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchHeaderView.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/26. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveSearchHeaderView.h" | |
| 9 | + | |
| 10 | +@interface CNLiveSearchHeaderView() | |
| 11 | +@property (nonatomic, strong) UIView *lineView; | |
| 12 | +@property (nonatomic, strong) UILabel *titlelabel; | |
| 13 | +@end | |
| 14 | + | |
| 15 | +@implementation CNLiveSearchHeaderView | |
| 16 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 17 | +{ | |
| 18 | + self = [super initWithFrame:frame]; | |
| 19 | + if (self) { | |
| 20 | + self.backgroundColor = kWhiteColor; | |
| 21 | + [self addSubview:self.lineView]; | |
| 22 | + [self addSubview:self.titlelabel]; | |
| 23 | + | |
| 24 | + } | |
| 25 | + return self; | |
| 26 | +} | |
| 27 | +- (void)layoutSubviews | |
| 28 | +{ | |
| 29 | + [super layoutSubviews]; | |
| 30 | + [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 31 | + make.left.equalTo(self); | |
| 32 | + make.centerY.equalTo(self); | |
| 33 | + make.width.offset(3); | |
| 34 | + make.height.offset(15); | |
| 35 | + }]; | |
| 36 | + | |
| 37 | + [self.titlelabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 38 | + make.left.equalTo(self).offset(15); | |
| 39 | + make.centerY.equalTo(self); | |
| 40 | + }]; | |
| 41 | + | |
| 42 | +} | |
| 43 | +#pragma mark - Setting&&Getting | |
| 44 | +- (void)setModel:(CNLiveSearchHotsModel *)model | |
| 45 | +{ | |
| 46 | + self.lineView.hidden = YES; | |
| 47 | + if (_type == CNServiceHeaderTypeService || _type == CNServiceHeaderTypeCategoryId) { | |
| 48 | + _titlelabel.textColor = CNLiveColorWithHexString(@"#333333"); | |
| 49 | + _titlelabel.font = UIFontMake(17); | |
| 50 | + }else{ | |
| 51 | + _titlelabel.font = UIFontMake(14); | |
| 52 | + _titlelabel.textColor = CNLiveColorWithHexString(@"#999999"); | |
| 53 | + } | |
| 54 | + self.backgroundColor = kWhiteColor; | |
| 55 | + _model = model; | |
| 56 | + if (_type == CNServiceHeaderTypeCategoryId) { | |
| 57 | + self.lineView.hidden = NO; | |
| 58 | + self.backgroundColor = [UIColor colorWithPatternImage:[UIImage gradientImageWithColors:@[CNLiveColorWithHexString(@"#FEF2E0"),kWhiteColor] rect:self.bounds]]; | |
| 59 | + NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@/正在使用",model.title]]; | |
| 60 | + [string addAttribute:NSFontAttributeName value:UIFontMake(12) range:NSMakeRange(0, string.length)]; | |
| 61 | + [string addAttribute:NSFontAttributeName value:UIFontMake(17) range:NSMakeRange(0, model.title.length)]; | |
| 62 | + [string addAttribute:NSStrokeColorAttributeName value:CNLiveColorWithHexString(@"#999999") range:NSMakeRange(0, string.length)]; | |
| 63 | + [string addAttribute:NSStrokeColorAttributeName value:CNLiveColorWithHexString(@"#4A4A4A") range:NSMakeRange(0, model.title.length)]; | |
| 64 | + self.titlelabel.attributedText = string; | |
| 65 | + }else{ | |
| 66 | + self.backgroundColor = kWhiteColor; | |
| 67 | + self.titlelabel.text = model.title; | |
| 68 | + } | |
| 69 | + [self.titlelabel sizeToFit]; | |
| 70 | + [self setNeedsLayout]; | |
| 71 | +} | |
| 72 | +- (UIView *)lineView | |
| 73 | +{ | |
| 74 | + if (!_lineView) { | |
| 75 | + _lineView = [[UIView alloc] init]; | |
| 76 | + _lineView.backgroundColor = CNLiveColorWithHexString(@"#F5A623"); | |
| 77 | + } | |
| 78 | + return _lineView; | |
| 79 | +} | |
| 80 | +- (UILabel *)titlelabel | |
| 81 | +{ | |
| 82 | + if (!_titlelabel) { | |
| 83 | + _titlelabel = [[UILabel alloc] init]; | |
| 84 | + _titlelabel.font = UIFontMake(14); | |
| 85 | + _titlelabel.textColor = CNLiveColorWithHexString(@"#999999"); | |
| 86 | + } | |
| 87 | + return _titlelabel; | |
| 88 | +} | |
| 89 | + | |
| 90 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveSearchHistoryCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchHistoryCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/26. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveSearchModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveSearchHistoryCell : UICollectionViewCell | |
| 14 | +@property (nonatomic ,strong) CNLiveHistoryModel *model; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveSearchHistoryCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchHistoryCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/26. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveSearchHistoryCell.h" | |
| 9 | + | |
| 10 | +@interface CNLiveSearchHistoryCell() | |
| 11 | +@property (nonatomic, strong) UILabel *history; | |
| 12 | +@end | |
| 13 | + | |
| 14 | +@implementation CNLiveSearchHistoryCell | |
| 15 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 16 | +{ | |
| 17 | + self = [super initWithFrame:frame]; | |
| 18 | + if (self) { | |
| 19 | + self.contentView.backgroundColor = CNLiveColorWithHexString(@"#F9F9F9"); | |
| 20 | + [self.contentView addSubview:self.history]; | |
| 21 | + } | |
| 22 | + return self; | |
| 23 | +} | |
| 24 | + | |
| 25 | +-(void)layoutSubviews | |
| 26 | +{ | |
| 27 | + [super layoutSubviews]; | |
| 28 | + [self.history mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 29 | + make.center.equalTo(self.contentView); | |
| 30 | + }]; | |
| 31 | +} | |
| 32 | + | |
| 33 | +#pragma mark - Setting&&Getting | |
| 34 | +- (void)setModel:(CNLiveHistoryModel *)model | |
| 35 | +{ | |
| 36 | + self.history.text = model.title; | |
| 37 | + [self.history sizeToFit]; | |
| 38 | + [self setNeedsLayout]; | |
| 39 | +} | |
| 40 | +- (UILabel *)history | |
| 41 | +{ | |
| 42 | + if (!_history) { | |
| 43 | + _history = [[UILabel alloc] init]; | |
| 44 | + _history.font = UIFontMake(12); | |
| 45 | + _history.textColor = CNLiveColorWithHexString(@"#4A4A4A"); | |
| 46 | + } | |
| 47 | + return _history; | |
| 48 | +} | |
| 49 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveSearchHotsCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchHotsCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/26. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveSearchModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveSearchHotsCell : UICollectionViewCell | |
| 14 | +@property (nonatomic, strong) UIImageView *logoView; | |
| 15 | +@property (nonatomic, strong) UILabel *titleLabel; | |
| 16 | +@property (nonatomic ,strong) CNLiveSearchModel *model; | |
| 17 | +@end | |
| 18 | + | |
| 19 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveSearchHotsCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchHotsCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/26. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveSearchHotsCell.h" | |
| 9 | + | |
| 10 | +@interface CNLiveSearchHotsCell() | |
| 11 | + | |
| 12 | +@end | |
| 13 | + | |
| 14 | +@implementation CNLiveSearchHotsCell | |
| 15 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 16 | +{ | |
| 17 | + self = [super initWithFrame:frame]; | |
| 18 | + if (self) { | |
| 19 | + [self.contentView addSubview:self.logoView]; | |
| 20 | + [self.contentView addSubview:self.titleLabel]; | |
| 21 | + } | |
| 22 | + return self; | |
| 23 | +} | |
| 24 | +-(void)layoutSubviews | |
| 25 | +{ | |
| 26 | + [super layoutSubviews]; | |
| 27 | + [self.logoView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 28 | + make.top.equalTo(self.contentView).offset(0); | |
| 29 | + make.centerX.equalTo(self.contentView); | |
| 30 | + make.height.width.offset(45); | |
| 31 | + }]; | |
| 32 | + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 33 | + make.top.equalTo(self.logoView.mas_bottom).offset(5); | |
| 34 | + make.centerX.equalTo(self.logoView); | |
| 35 | + make.width.equalTo(self.contentView); | |
| 36 | + }]; | |
| 37 | +} | |
| 38 | +#pragma mark - Setting&&Getting | |
| 39 | +- (void)setModel:(CNLiveSearchModel *)model | |
| 40 | +{ | |
| 41 | + _model = model; | |
| 42 | + [self.logoView sd_setImageWithURL:[NSURL URLWithString:model.icon]]; | |
| 43 | + self.titleLabel.text = model.title; | |
| 44 | + [self.titleLabel sizeToFit]; | |
| 45 | + [self layoutSubviews]; | |
| 46 | +} | |
| 47 | +- (UIImageView *)logoView{ | |
| 48 | + if (!_logoView) { | |
| 49 | + _logoView = [[UIImageView alloc] init]; | |
| 50 | + _logoView.clipsToBounds = YES; | |
| 51 | + _logoView.layer.cornerRadius = 22.5; | |
| 52 | + } | |
| 53 | + return _logoView; | |
| 54 | +} | |
| 55 | + | |
| 56 | +- (UILabel *)titleLabel | |
| 57 | +{ | |
| 58 | + if (!_titleLabel) { | |
| 59 | + _titleLabel = [[UILabel alloc] init]; | |
| 60 | + _titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; | |
| 61 | + _titleLabel.font = UIFontMake(11); | |
| 62 | + _titleLabel.textColor = CNLiveColorWithHexString(@"#4A4A4A"); | |
| 63 | + _titleLabel.textAlignment = NSTextAlignmentCenter; | |
| 64 | + } | |
| 65 | + return _titleLabel; | |
| 66 | +} | |
| 67 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveSearchHotsFooterView.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchHotsFooterView.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/26. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | + | |
| 10 | +NS_ASSUME_NONNULL_BEGIN | |
| 11 | +typedef void(^ClearBlock)(void); | |
| 12 | +@interface CNLiveSearchHotsFooterView : UICollectionReusableView | |
| 13 | + | |
| 14 | +@property (nonatomic, copy) ClearBlock clearBlock; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveSearchHotsFooterView.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchHotsFooterView.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/26. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveSearchHotsFooterView.h" | |
| 9 | + | |
| 10 | +@interface CNLiveSearchHotsFooterView() | |
| 11 | +@property (nonatomic, strong) UIView *line; | |
| 12 | +@property (nonatomic, strong) UIButton *clearBtn; | |
| 13 | +@end | |
| 14 | + | |
| 15 | +@implementation CNLiveSearchHotsFooterView | |
| 16 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 17 | +{ | |
| 18 | + self = [super initWithFrame:frame]; | |
| 19 | + if (self) { | |
| 20 | + self.backgroundColor = kWhiteColor; | |
| 21 | + [self addSubview:self.line]; | |
| 22 | + [self addSubview:self.clearBtn]; | |
| 23 | + } | |
| 24 | + return self; | |
| 25 | +} | |
| 26 | +- (void)layoutSubviews | |
| 27 | +{ | |
| 28 | + [super layoutSubviews]; | |
| 29 | + [self.line mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 30 | + make.top.equalTo(self); | |
| 31 | + make.left.equalTo(self).offset(15); | |
| 32 | + make.right.equalTo(self).offset(-15); | |
| 33 | + make.height.offset(0.5); | |
| 34 | + }]; | |
| 35 | + [self.clearBtn mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 36 | + make.top.equalTo(self.line).offset(15); | |
| 37 | + make.centerX.equalTo(self); | |
| 38 | + }]; | |
| 39 | +} | |
| 40 | +- (void)clearAction{ | |
| 41 | + !self.clearBlock?:self.clearBlock(); | |
| 42 | +} | |
| 43 | +#pragma mark - Getting | |
| 44 | +- (UIView *)line | |
| 45 | +{ | |
| 46 | + if (!_line) { | |
| 47 | + _line = [[UIView alloc] init]; | |
| 48 | + _line.backgroundColor = CNLiveColorWithHexString(@"#F2F2F2"); | |
| 49 | + } | |
| 50 | + return _line; | |
| 51 | +} | |
| 52 | +- (UIButton *)clearBtn | |
| 53 | +{ | |
| 54 | + if (!_clearBtn) { | |
| 55 | + _clearBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 56 | + [_clearBtn setTitle:@"清空记录" forState:UIControlStateNormal]; | |
| 57 | + [_clearBtn setTitleColor:CNLiveColorWithHexString(@"#00CD1E") forState:UIControlStateNormal]; | |
| 58 | + _clearBtn.titleLabel.font = UIFontMake(13); | |
| 59 | + [_clearBtn sizeToFit]; | |
| 60 | + [_clearBtn addTarget:self action:@selector(clearAction) forControlEvents:UIControlEventTouchUpInside]; | |
| 61 | + } | |
| 62 | + return _clearBtn; | |
| 63 | +} | |
| 64 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveSearchListCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchListCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/25. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveSearchModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveSearchListCell : UITableViewCell | |
| 14 | + | |
| 15 | +@property (nonatomic, strong) CNLiveSearchModel *model; | |
| 16 | +@end | |
| 17 | + | |
| 18 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveSearchListCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveSearchListCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/25. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveSearchListCell.h" | |
| 9 | + | |
| 10 | +@interface CNLiveSearchListCell() | |
| 11 | +@property (nonatomic, strong) UIImageView *logoView; | |
| 12 | +@property (nonatomic, strong) UILabel *titleLabel; | |
| 13 | +@property (nonatomic, strong) UIView *line; | |
| 14 | +@end | |
| 15 | + | |
| 16 | +@implementation CNLiveSearchListCell | |
| 17 | + | |
| 18 | +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier | |
| 19 | +{ | |
| 20 | + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; | |
| 21 | + if (self) { | |
| 22 | + self.selectionStyle = UITableViewCellSelectionStyleNone; | |
| 23 | + [self.contentView addSubview:self.logoView]; | |
| 24 | + [self.contentView addSubview:self.titleLabel]; | |
| 25 | + [self.contentView addSubview:self.line]; | |
| 26 | + } | |
| 27 | + return self; | |
| 28 | +} | |
| 29 | +- (void)layoutSubviews | |
| 30 | +{ | |
| 31 | + [self.logoView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 32 | + make.top.left.equalTo(self.contentView).offset(15); | |
| 33 | + make.height.width.offset(45); | |
| 34 | + }]; | |
| 35 | + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 36 | + make.left.equalTo(self.logoView.mas_right).offset(15); | |
| 37 | + make.centerY.equalTo(self.logoView); | |
| 38 | + }]; | |
| 39 | + [self.line mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 40 | + make.height.offset(0.5); | |
| 41 | + make.bottom.equalTo(self.contentView); | |
| 42 | + make.left.equalTo(self.titleLabel); | |
| 43 | + make.right.equalTo(self.contentView).offset(-15); | |
| 44 | + }]; | |
| 45 | +} | |
| 46 | +#pragma mark - Setting&&Getting | |
| 47 | +- (void)setModel:(CNLiveSearchModel *)model | |
| 48 | +{ | |
| 49 | + _model = model; | |
| 50 | + [self.logoView sd_setImageWithURL:[NSURL URLWithString:model.icon]]; | |
| 51 | + NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:model.title]; | |
| 52 | + NSRange range = [model.title rangeOfString:model.searchStr]; | |
| 53 | + UIColor *color = CNLiveColorWithHexString(@"#00CD1E"); | |
| 54 | + [attrString addAttribute:NSFontAttributeName value:UIFontMake(14) range:NSMakeRange(0, model.title.length)]; | |
| 55 | + [attrString addAttribute:NSForegroundColorAttributeName value:CNLiveColorWithHexString(@"#333333") range:NSMakeRange(0, model.title.length)]; | |
| 56 | + [attrString addAttribute:NSForegroundColorAttributeName value:color range:range]; | |
| 57 | + self.titleLabel.attributedText = attrString; | |
| 58 | + [self.titleLabel sizeToFit]; | |
| 59 | + [self setNeedsLayout]; | |
| 60 | +} | |
| 61 | +- (UIImageView *)logoView{ | |
| 62 | + if (!_logoView) { | |
| 63 | + _logoView = [[UIImageView alloc] init]; | |
| 64 | + _logoView.contentMode = UIViewContentModeScaleAspectFit; | |
| 65 | + } | |
| 66 | + return _logoView; | |
| 67 | +} | |
| 68 | + | |
| 69 | +- (UILabel *)titleLabel | |
| 70 | +{ | |
| 71 | + if (!_titleLabel) { | |
| 72 | + _titleLabel = [[UILabel alloc] init]; | |
| 73 | + } | |
| 74 | + return _titleLabel; | |
| 75 | +} | |
| 76 | +- (UIView *)line | |
| 77 | +{ | |
| 78 | + if (!_line) { | |
| 79 | + _line = [[UIView alloc] init]; | |
| 80 | + _line.backgroundColor = CNLiveColorWithHexString(@"#F2F2F2"); | |
| 81 | + } | |
| 82 | + return _line; | |
| 83 | +} | |
| 84 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveServiceChinasCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceChinasCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveSearchModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveServiceChinasCell : UICollectionViewCell | |
| 14 | +@property (nonatomic, strong)CNLiveSearchHotsModel *model; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveServiceChinasCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceChinasCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveServiceChinasCell.h" | |
| 9 | +#import "CNLiveCycleView.h" | |
| 10 | + | |
| 11 | +@interface CNLiveServiceChinasCell() | |
| 12 | +@property (nonatomic, strong) CNLiveCycleView *cycleView; | |
| 13 | +@end | |
| 14 | + | |
| 15 | +@implementation CNLiveServiceChinasCell | |
| 16 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 17 | +{ | |
| 18 | + self = [super initWithFrame:frame]; | |
| 19 | + if (self) { | |
| 20 | + [self.contentView addSubview:self.cycleView]; | |
| 21 | + } | |
| 22 | + return self; | |
| 23 | +} | |
| 24 | +-(void)layoutSubviews | |
| 25 | +{ | |
| 26 | + [super layoutSubviews]; | |
| 27 | + [self.cycleView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 28 | + make.top.bottom.equalTo(self.contentView); | |
| 29 | + make.left.equalTo(self.contentView).offset(15); | |
| 30 | + make.right.equalTo(self.contentView).offset(-15); | |
| 31 | + }]; | |
| 32 | +} | |
| 33 | +#pragma mark - Setting&&Getting | |
| 34 | +- (void)setModel:(CNLiveSearchHotsModel *)model | |
| 35 | +{ | |
| 36 | + _model = model; | |
| 37 | + _cycleView.model = model; | |
| 38 | + _cycleView.localizationImageNamesGroup = model.lists; | |
| 39 | + | |
| 40 | +} | |
| 41 | +- (CNLiveCycleView *)cycleView | |
| 42 | +{ | |
| 43 | + if (!_cycleView) { | |
| 44 | + _cycleView = [[CNLiveCycleView alloc] initWithFrame:CGRectZero]; | |
| 45 | + _cycleView.autoScroll = NO; | |
| 46 | + _cycleView.showPageControl = YES; | |
| 47 | + _cycleView.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated; | |
| 48 | + _cycleView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter; | |
| 49 | + _cycleView.hidesForSinglePage = YES; | |
| 50 | + _cycleView.currentPageDotImage = [UIImage loadBundleImage:@"pagecontrol_yes"]; | |
| 51 | + _cycleView.pageDotImage = [UIImage loadBundleImage:@"pagecontrol_no"]; | |
| 52 | + _cycleView.pageControlDotSize = CGSizeMake(4, 4); | |
| 53 | + } | |
| 54 | + return _cycleView; | |
| 55 | +} | |
| 56 | + | |
| 57 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveServiceEpiCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceEpiCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveServiceModel.h" | |
| 10 | + | |
| 11 | + | |
| 12 | +NS_ASSUME_NONNULL_BEGIN | |
| 13 | + | |
| 14 | +@interface CNLiveServiceEpiCell : UICollectionViewCell | |
| 15 | +@property (nonatomic, strong) CNliveServicePageModel *model; | |
| 16 | +@end | |
| 17 | + | |
| 18 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveServiceEpiCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceEpiCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveServiceEpiCell.h" | |
| 9 | +#import "CNLiveServiceOrLookCell.h" | |
| 10 | + | |
| 11 | +static NSString *CNServiceOrLookID = @"CNLiveServiceOrLookCell"; | |
| 12 | + | |
| 13 | +@interface CNLiveServiceEpiCell()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> | |
| 14 | +@property (nonatomic, strong) UIImageView *leftImageView; | |
| 15 | +@property (nonatomic, strong) UIButton *dynamicBtn; | |
| 16 | +@property (nonatomic, strong) UIButton *travelBtn; | |
| 17 | +@property (nonatomic, strong) UILabel*titleLabel; | |
| 18 | +@property (nonatomic, strong) UICollectionView *listCollectionView; | |
| 19 | + | |
| 20 | +@end | |
| 21 | + | |
| 22 | +@implementation CNLiveServiceEpiCell | |
| 23 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 24 | +{ | |
| 25 | + self = [super initWithFrame:frame]; | |
| 26 | + if (self) { | |
| 27 | + [self.contentView addSubview:self.leftImageView]; | |
| 28 | + [self.contentView addSubview:self.dynamicBtn]; | |
| 29 | + [self.contentView addSubview:self.travelBtn]; | |
| 30 | + [self.leftImageView addSubview:self.titleLabel]; | |
| 31 | + [self.leftImageView addSubview:self.listCollectionView]; | |
| 32 | + } | |
| 33 | + return self; | |
| 34 | +} | |
| 35 | + | |
| 36 | +- (void)layoutSubviews | |
| 37 | +{ | |
| 38 | + [super layoutSubviews]; | |
| 39 | + [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 40 | + make.top.equalTo(self.contentView); | |
| 41 | + make.left.equalTo(self.contentView).offset(10); | |
| 42 | + make.width.offset(221 *KScreenWidth/375); | |
| 43 | + make.height.offset(214 *KScreenWidth /375); | |
| 44 | + }]; | |
| 45 | + [self.dynamicBtn mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 46 | + make.top.equalTo(self.leftImageView); | |
| 47 | + make.right.equalTo(self.contentView).offset(-10); | |
| 48 | + make.width.offset(124 *KScreenWidth/375); | |
| 49 | + make.height.offset(102 *KScreenWidth /375); | |
| 50 | + }]; | |
| 51 | + [self.travelBtn mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 52 | + make.bottom.equalTo(self.leftImageView); | |
| 53 | + make.right.equalTo(self.dynamicBtn); | |
| 54 | + make.width.offset(124 *KScreenWidth/375); | |
| 55 | + make.height.offset(102 *KScreenWidth /375); | |
| 56 | + }]; | |
| 57 | + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 58 | + make.left.equalTo(self.leftImageView).offset(10); | |
| 59 | + make.top.equalTo(self.leftImageView).offset(15); | |
| 60 | + }]; | |
| 61 | + [self.listCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 62 | + make.bottom.equalTo(self.leftImageView).offset(-10); | |
| 63 | + make.left.equalTo(self.leftImageView).offset(10); | |
| 64 | + make.right.equalTo(self.leftImageView).offset(-10); | |
| 65 | + make.top.equalTo(self.titleLabel.mas_bottom).offset(15); | |
| 66 | + }]; | |
| 67 | +} | |
| 68 | +#pragma mark - UICollectionViewDelegate | |
| 69 | +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 70 | + | |
| 71 | +} | |
| 72 | +#pragma mark - UICollectionViewDataSource | |
| 73 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ | |
| 74 | + return self.model.contents.count; | |
| 75 | +} | |
| 76 | +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 77 | + | |
| 78 | + CNLiveServiceOrLookCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNServiceOrLookID forIndexPath:indexPath]; | |
| 79 | + cell.type = CNLiveCellShowTypeService; | |
| 80 | + cell.model = [CnLivePageContentModel mj_objectWithKeyValues:self.model.contents[indexPath.row]]; | |
| 81 | + | |
| 82 | + return cell; | |
| 83 | + | |
| 84 | +} | |
| 85 | +#pragma mark - UICollectionViewDelegateFlowLayout | |
| 86 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 87 | + return CGSizeMake(collectionView.width, (collectionView.height -10)/3); | |
| 88 | +} | |
| 89 | +- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ | |
| 90 | + return UIEdgeInsetsMake(0, 0, 0, 0); | |
| 91 | +} | |
| 92 | +#pragma mark - Setting&&Getting | |
| 93 | +- (void)setModel:(CNliveServicePageModel *)model | |
| 94 | +{ | |
| 95 | + _model = model; | |
| 96 | + [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:model.background]]; | |
| 97 | + CnLivePageContentModel *pageModel = [CnLivePageContentModel mj_objectWithKeyValues:model.rightLists[0]]; | |
| 98 | + [self.dynamicBtn sd_setImageWithURL:[NSURL URLWithString:pageModel.poster] forState:UIControlStateNormal]; | |
| 99 | + CnLivePageContentModel *pageModel1 = [CnLivePageContentModel mj_objectWithKeyValues:model.rightLists[1]]; | |
| 100 | + [self.travelBtn sd_setImageWithURL:[NSURL URLWithString:pageModel1.poster] forState:UIControlStateNormal]; | |
| 101 | + self.titleLabel.text = model.blockName; | |
| 102 | + [_titleLabel sizeToFit]; | |
| 103 | + [self setNeedsLayout]; | |
| 104 | + [self.listCollectionView reloadData]; | |
| 105 | +} | |
| 106 | +- (UIImageView *)leftImageView | |
| 107 | +{ | |
| 108 | + if (!_leftImageView) { | |
| 109 | + _leftImageView = [[UIImageView alloc] init]; | |
| 110 | + _leftImageView.userInteractionEnabled = YES; | |
| 111 | + } | |
| 112 | + return _leftImageView; | |
| 113 | +} | |
| 114 | + | |
| 115 | +- (UIButton *)dynamicBtn { | |
| 116 | + if (!_dynamicBtn) { | |
| 117 | + _dynamicBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 118 | + | |
| 119 | + } | |
| 120 | + return _dynamicBtn; | |
| 121 | +} | |
| 122 | +- (UIButton *)travelBtn | |
| 123 | +{ | |
| 124 | + if (!_travelBtn) { | |
| 125 | + _travelBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 126 | + } | |
| 127 | + return _travelBtn; | |
| 128 | +} | |
| 129 | +- (UILabel *)titleLabel | |
| 130 | +{ | |
| 131 | + if (!_titleLabel) { | |
| 132 | + _titleLabel = [[UILabel alloc] init]; | |
| 133 | + _titleLabel.font = UIFontMake(17); | |
| 134 | + _titleLabel.textColor = CNLiveColorWithHexString(@"#EB5039"); | |
| 135 | + } | |
| 136 | + return _titleLabel; | |
| 137 | +} | |
| 138 | +- (UICollectionView *)listCollectionView | |
| 139 | +{ | |
| 140 | + if (!_listCollectionView) { | |
| 141 | + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 142 | + layout.sectionFootersPinToVisibleBounds = YES; | |
| 143 | + layout.sectionHeadersPinToVisibleBounds = YES; | |
| 144 | + _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; | |
| 145 | + _listCollectionView.backgroundColor = kWhiteColor; | |
| 146 | + _listCollectionView.collectionViewLayout = layout; | |
| 147 | + _listCollectionView.delegate = self; | |
| 148 | + _listCollectionView.dataSource = self; | |
| 149 | + _listCollectionView.showsVerticalScrollIndicator = NO; | |
| 150 | + [_listCollectionView registerClass:[CNLiveServiceOrLookCell class] forCellWithReuseIdentifier:CNServiceOrLookID]; | |
| 151 | + | |
| 152 | + } | |
| 153 | + return _listCollectionView; | |
| 154 | +} | |
| 155 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveServiceLookCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceLookCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveServiceModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveServiceLookCell : UICollectionViewCell | |
| 14 | +@property (nonatomic, strong) CNliveServicePageModel *model; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveServiceLookCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceLookCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveServiceLookCell.h" | |
| 9 | +#import "CNLiveCycleView.h" | |
| 10 | + | |
| 11 | +@interface CNLiveServiceLookCell() | |
| 12 | +@property (nonatomic, strong) UIImageView *backImage; | |
| 13 | +@property (nonatomic, strong) UILabel *titleLabel; | |
| 14 | +@property (nonatomic, strong) UILabel *subTitlelabel; | |
| 15 | +@property (nonatomic, strong) CNLiveCycleView *cycleView; | |
| 16 | +@end | |
| 17 | + | |
| 18 | +@implementation CNLiveServiceLookCell | |
| 19 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 20 | +{ | |
| 21 | + self = [super initWithFrame:frame]; | |
| 22 | + if (self) { | |
| 23 | + [self.contentView addSubview:self.backImage]; | |
| 24 | + [self.backImage addSubview:self.titleLabel]; | |
| 25 | + [self.backImage addSubview:self.subTitlelabel]; | |
| 26 | + [self.backImage addSubview:self.cycleView]; | |
| 27 | + | |
| 28 | + } | |
| 29 | + return self; | |
| 30 | +} | |
| 31 | +- (void)layoutSubviews | |
| 32 | +{ | |
| 33 | + [super layoutSubviews]; | |
| 34 | + [self.backImage mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 35 | + make.top.bottom.equalTo(self.contentView); | |
| 36 | + make.left.equalTo(self.contentView).offset(10); | |
| 37 | + make.right.equalTo(self.contentView).offset(-10); | |
| 38 | + }]; | |
| 39 | + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 40 | + make.left.equalTo(self.backImage).offset(10); | |
| 41 | + make.top.equalTo(self.backImage).offset(15); | |
| 42 | + }]; | |
| 43 | + [self.subTitlelabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 44 | + make.left.equalTo(self.titleLabel.mas_right).offset(10); | |
| 45 | + make.bottom.equalTo(self.titleLabel); | |
| 46 | + }]; | |
| 47 | + [self.cycleView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 48 | + make.bottom.equalTo(self.backImage).offset(-10); | |
| 49 | + make.left.equalTo(self.backImage).offset(10); | |
| 50 | + make.right.equalTo(self.backImage).offset(-10); | |
| 51 | + make.top.equalTo(self.titleLabel.mas_bottom).offset(15); | |
| 52 | + }]; | |
| 53 | +} | |
| 54 | +#pragma mark - Method | |
| 55 | +- (NSArray *)sqereList:(NSArray *)array{ | |
| 56 | + NSMutableArray *dataArr = [NSMutableArray array]; | |
| 57 | + NSMutableArray *sqArr = [NSMutableArray array]; | |
| 58 | + for (int i = 0; i < array.count; i ++) { | |
| 59 | + NSDictionary *dic = array[i]; | |
| 60 | + CnLivePageContentModel *model = [CnLivePageContentModel mj_objectWithKeyValues:dic]; | |
| 61 | + [sqArr addObject:model]; | |
| 62 | + if ((i != 0 || array.count == 1) && (i%2 == 0 || i == array.count - 1)) { | |
| 63 | + NSDictionary *category = @{ | |
| 64 | + @"title":@"大家都在用", | |
| 65 | + @"lists":sqArr.copy, | |
| 66 | + @"layout":@{ | |
| 67 | + @"width":@(self.cycleView.width), | |
| 68 | + @"height":@((self.cycleView.height - 20)/3) | |
| 69 | + } | |
| 70 | + }; | |
| 71 | + CNLiveSearchHotsModel *model1 = [CNLiveSearchHotsModel mj_objectWithKeyValues:category]; | |
| 72 | + [dataArr addObject:model1]; | |
| 73 | + [sqArr removeAllObjects]; | |
| 74 | + } | |
| 75 | + } | |
| 76 | + return dataArr.copy; | |
| 77 | +} | |
| 78 | +#pragma mark - Setting&&Getting | |
| 79 | +- (void)setModel:(CNliveServicePageModel *)model | |
| 80 | +{ | |
| 81 | + _model = model; | |
| 82 | + [self.backImage sd_setImageWithURL:[NSURL URLWithString:model.background]]; | |
| 83 | + NSArray *dataArr = [self sqereList:model.contents]; | |
| 84 | + _cycleView.dataSource = dataArr; | |
| 85 | + _cycleView.localizationImageNamesGroup = dataArr; | |
| 86 | + self.titleLabel.text = model.blockName; | |
| 87 | + [self.titleLabel sizeToFit]; | |
| 88 | + self.subTitlelabel.text = model.blockSubTitle; | |
| 89 | + [self.subTitlelabel sizeToFit]; | |
| 90 | + [self setNeedsLayout]; | |
| 91 | +} | |
| 92 | +- (UIImageView *)backImage | |
| 93 | +{ | |
| 94 | + if (!_backImage) { | |
| 95 | + _backImage = [[UIImageView alloc] init]; | |
| 96 | + _backImage.userInteractionEnabled = YES; | |
| 97 | + } | |
| 98 | + return _backImage; | |
| 99 | +} | |
| 100 | +- (UILabel *)titleLabel | |
| 101 | +{ | |
| 102 | + if (!_titleLabel) { | |
| 103 | + _titleLabel = [[UILabel alloc] init]; | |
| 104 | + _titleLabel.font = UIFontMake(17); | |
| 105 | + _titleLabel.textColor = CNLiveColorWithHexString(@"#1F74E9"); | |
| 106 | + _titleLabel.textAlignment = NSTextAlignmentLeft; | |
| 107 | + } | |
| 108 | + return _titleLabel; | |
| 109 | +} | |
| 110 | +- (UILabel *)subTitlelabel | |
| 111 | +{ | |
| 112 | + if (!_subTitlelabel) { | |
| 113 | + _subTitlelabel = [[UILabel alloc] init]; | |
| 114 | + _subTitlelabel.font = UIFontMake(12); | |
| 115 | + _subTitlelabel.textColor = CNLiveColorWithHexString(@"#1F74E9"); | |
| 116 | + _subTitlelabel.textAlignment = NSTextAlignmentLeft; | |
| 117 | + } | |
| 118 | + return _subTitlelabel; | |
| 119 | +} | |
| 120 | +- (CNLiveCycleView *)cycleView | |
| 121 | +{ | |
| 122 | + if (!_cycleView) { | |
| 123 | + _cycleView = [[CNLiveCycleView alloc] initWithFrame:CGRectZero]; | |
| 124 | + _cycleView.layer.cornerRadius = 8; | |
| 125 | + _cycleView.backgroundColor = kWhiteColor; | |
| 126 | + _cycleView.autoScroll = NO; | |
| 127 | + _cycleView.showPageControl = YES; | |
| 128 | + _cycleView.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated; | |
| 129 | + _cycleView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter; | |
| 130 | + _cycleView.hidesForSinglePage = YES; | |
| 131 | + _cycleView.currentPageDotImage = [UIImage loadBundleImage:@"pagecontrol_yes"]; | |
| 132 | + _cycleView.pageDotImage = [UIImage loadBundleImage:@"pagecontrol_no"]; | |
| 133 | + _cycleView.pageControlDotSize = CGSizeMake(4, 4); | |
| 134 | + } | |
| 135 | + return _cycleView; | |
| 136 | +} | |
| 137 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveServiceOrLookCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceOrLookCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/30. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveServiceModel.h" | |
| 10 | + | |
| 11 | +typedef NS_ENUM(NSInteger ,CNLiveCellShowType) { | |
| 12 | + CNLiveCellShowTypeService, | |
| 13 | + CNLiveCellShowTypeLook, | |
| 14 | +}; | |
| 15 | + | |
| 16 | +NS_ASSUME_NONNULL_BEGIN | |
| 17 | + | |
| 18 | +@interface CNLiveServiceOrLookCell : UICollectionViewCell | |
| 19 | +@property (nonatomic, strong) CnLivePageContentModel *model; | |
| 20 | +@property (nonatomic, assign) CNLiveCellShowType type; | |
| 21 | +@end | |
| 22 | + | |
| 23 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveServiceOrLookCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceOrLookCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/30. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveServiceOrLookCell.h" | |
| 9 | +@interface CNLiveServiceOrLookCell() | |
| 10 | +@property (nonatomic, strong) UIImageView *logoImage; | |
| 11 | +@property (nonatomic, strong) UILabel *titleLabel; | |
| 12 | +@property (nonatomic, strong) UILabel *describe; | |
| 13 | +@property (nonatomic, strong) QMUIButton *rightBtn; | |
| 14 | +@end | |
| 15 | + | |
| 16 | +@implementation CNLiveServiceOrLookCell | |
| 17 | +- (instancetype)initWithFrame:(CGRect)frame{ | |
| 18 | + self = [super initWithFrame:frame]; | |
| 19 | + if (self) { | |
| 20 | + [self.contentView addSubview:self.logoImage]; | |
| 21 | + [self.contentView addSubview:self.titleLabel]; | |
| 22 | + [self.contentView addSubview:self.describe]; | |
| 23 | + [self.contentView addSubview:self.rightBtn]; | |
| 24 | + } | |
| 25 | + return self; | |
| 26 | +} | |
| 27 | +- (void)layoutSubviews{ | |
| 28 | + [super layoutSubviews]; | |
| 29 | + [self.logoImage mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 30 | + make.left.equalTo(self.contentView).offset(10); | |
| 31 | + make.centerY.equalTo(self.contentView); | |
| 32 | + make.height.width.offset(30); | |
| 33 | + }]; | |
| 34 | + [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 35 | + make.right.equalTo(self.contentView).offset(-10); | |
| 36 | + make.centerY.equalTo(self.logoImage); | |
| 37 | + make.width.offset(45); | |
| 38 | + make.height.offset(18); | |
| 39 | + }]; | |
| 40 | + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 41 | + make.left.equalTo(self.logoImage.mas_right).offset(10); | |
| 42 | + make.centerY.equalTo(self.logoImage); | |
| 43 | + }]; | |
| 44 | + [self.describe mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 45 | + make.left.equalTo(self.titleLabel.mas_right).offset(7); | |
| 46 | + make.centerY.equalTo(self.logoImage); | |
| 47 | + make.right.equalTo(self.rightBtn.mas_left).offset(-5); | |
| 48 | + }]; | |
| 49 | +} | |
| 50 | +#pragma mark - Setting&&getting | |
| 51 | +- (void)setModel:(CnLivePageContentModel *)model | |
| 52 | +{ | |
| 53 | + _model = model; | |
| 54 | + [self.logoImage sd_setImageWithURL:[NSURL URLWithString:model.poster]]; | |
| 55 | + self.titleLabel.text = model.title; | |
| 56 | + [self.titleLabel sizeToFit]; | |
| 57 | + self.describe.text = model.subTitle; | |
| 58 | + [self.describe sizeToFit]; | |
| 59 | + [self setNeedsLayout]; | |
| 60 | +} | |
| 61 | +- (void)setType:(CNLiveCellShowType)type | |
| 62 | +{ | |
| 63 | + _type = type; | |
| 64 | + if (type == CNLiveCellShowTypeService) { | |
| 65 | + self.describe.hidden = YES; | |
| 66 | + [self.rightBtn setImage:[UIImage loadBundleImage:@"service_right"] forState:UIControlStateNormal]; | |
| 67 | + }else{ | |
| 68 | + self.describe.hidden = NO; | |
| 69 | + self.rightBtn.layer.cornerRadius = 9; | |
| 70 | + [self.rightBtn setTitle:@"进入 " forState:UIControlStateNormal]; | |
| 71 | + [self.rightBtn setImage:[UIImage loadBundleImage:@"service_enter"] forState:UIControlStateNormal]; | |
| 72 | + self.rightBtn.backgroundColor = CNLiveColorWithHexString(@"#2C7EEE"); | |
| 73 | + } | |
| 74 | + [self setNeedsLayout]; | |
| 75 | +} | |
| 76 | +- (UIImageView *)logoImage{ | |
| 77 | + if (!_logoImage) { | |
| 78 | + _logoImage = [[UIImageView alloc] init]; | |
| 79 | + _logoImage.clipsToBounds = YES; | |
| 80 | + _logoImage.layer.cornerRadius = 15; | |
| 81 | + } | |
| 82 | + return _logoImage; | |
| 83 | +} | |
| 84 | +- (UILabel *)titleLabel | |
| 85 | +{ | |
| 86 | + if (!_titleLabel) { | |
| 87 | + _titleLabel = [[UILabel alloc] init]; | |
| 88 | + _titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; | |
| 89 | + _titleLabel.font = UIFontMake(13); | |
| 90 | + _titleLabel.textColor = CNLiveColorWithHexString(@"#333333"); | |
| 91 | + _titleLabel.textAlignment = NSTextAlignmentLeft; | |
| 92 | + } | |
| 93 | + return _titleLabel; | |
| 94 | +} | |
| 95 | +- (UILabel *)describe | |
| 96 | +{ | |
| 97 | + if (!_describe) { | |
| 98 | + _describe = [[UILabel alloc] init]; | |
| 99 | + _describe.lineBreakMode = NSLineBreakByTruncatingMiddle; | |
| 100 | + _describe.font = UIFontMake(10); | |
| 101 | + _describe.textColor = CNLiveColorWithHexString(@"#A9A9A9"); | |
| 102 | + _describe.textAlignment = NSTextAlignmentLeft; | |
| 103 | + } | |
| 104 | + return _describe; | |
| 105 | +} | |
| 106 | +- (QMUIButton *)rightBtn | |
| 107 | +{ | |
| 108 | + if (!_rightBtn) { | |
| 109 | + _rightBtn = [QMUIButton buttonWithType:UIButtonTypeCustom]; | |
| 110 | + _rightBtn.userInteractionEnabled = NO; | |
| 111 | + _rightBtn.titleLabel.font = UIFontMake(10); | |
| 112 | + _rightBtn.imagePosition = QMUIButtonImagePositionRight; | |
| 113 | + [_rightBtn setTitleColor:kWhiteColor forState:UIControlStateNormal]; | |
| 114 | + } | |
| 115 | + return _rightBtn; | |
| 116 | +} | |
| 117 | +@end | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveVideoRecommendCell.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveVideoRecommendCell.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNLiveServiceModel.h" | |
| 10 | + | |
| 11 | +typedef NS_ENUM(NSInteger ,CNLiveRecommendCellShowType) { | |
| 12 | + CNLiveCellShowTypeGoods, | |
| 13 | + CNLiveCellShowTypeHot, | |
| 14 | + CNLiveCellShowTypeVideo, | |
| 15 | +}; | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_BEGIN | |
| 18 | + | |
| 19 | +@interface CNLiveVideoRecommendCell : UICollectionViewCell | |
| 20 | +@property (nonatomic, strong) CnLivePageContentModel *model; | |
| 21 | +@property (nonatomic, assign) CNLiveRecommendCellShowType type; | |
| 22 | +@end | |
| 23 | + | |
| 24 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/View/CNLiveVideoRecommendCell.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveVideoRecommendCell.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/27. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveVideoRecommendCell.h" | |
| 9 | + | |
| 10 | +@interface CNLiveVideoRecommendCell() | |
| 11 | +@property (nonatomic, strong) UIImageView *logoImage; | |
| 12 | +@property (nonatomic, strong) UILabel *titleLabel; | |
| 13 | +@property (nonatomic, strong) UILabel *price; | |
| 14 | +@property (nonatomic, strong) UILabel *oldPrice; | |
| 15 | +@property (nonatomic, strong) UIButton *lookNum; | |
| 16 | + | |
| 17 | +@end | |
| 18 | + | |
| 19 | +@implementation CNLiveVideoRecommendCell | |
| 20 | +- (instancetype)initWithFrame:(CGRect)frame{ | |
| 21 | + self = [super initWithFrame:frame]; | |
| 22 | + if (self) { | |
| 23 | + [self.contentView addSubview:self.logoImage]; | |
| 24 | + [self.contentView addSubview:self.titleLabel]; | |
| 25 | + [self.contentView addSubview:self.price]; | |
| 26 | + [self.contentView addSubview:self.oldPrice]; | |
| 27 | + [self.contentView addSubview:self.lookNum]; | |
| 28 | + } | |
| 29 | + return self; | |
| 30 | +} | |
| 31 | +- (void)layoutSubviews{ | |
| 32 | + [super layoutSubviews]; | |
| 33 | + [self.logoImage mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 34 | + make.top.equalTo(self.contentView); | |
| 35 | + make.centerX.equalTo(self.contentView); | |
| 36 | + make.height.width.offset(_type == CNLiveCellShowTypeHot?65:96); | |
| 37 | + }]; | |
| 38 | + | |
| 39 | + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 40 | + make.top.equalTo(self.logoImage.mas_bottom).offset(10); | |
| 41 | + make.left.right.equalTo(self.logoImage); | |
| 42 | + }]; | |
| 43 | + [self.price mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 44 | + make.top.equalTo(_type == CNLiveCellShowTypeHot?self.logoImage.mas_bottom:self.titleLabel.mas_bottom).offset(5); | |
| 45 | + if (_type == CNLiveCellShowTypeHot) { | |
| 46 | + make.centerX.equalTo(self.contentView); | |
| 47 | + }else{ | |
| 48 | + make.left.equalTo(self.logoImage); | |
| 49 | + } | |
| 50 | + | |
| 51 | + | |
| 52 | + }]; | |
| 53 | + [self.oldPrice mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 54 | + make.left.equalTo(self.price.mas_right).offset(7); | |
| 55 | + make.bottom.equalTo(self.price); | |
| 56 | + }]; | |
| 57 | + [self.lookNum mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 58 | + make.left.equalTo(self.titleLabel); | |
| 59 | + make.bottom.equalTo(self.contentView).offset(-10); | |
| 60 | + }]; | |
| 61 | +} | |
| 62 | + | |
| 63 | +#pragma mark - Setting&&getting | |
| 64 | +- (void)setModel:(CnLivePageContentModel *)model | |
| 65 | +{ | |
| 66 | + self.titleLabel.hidden = YES; | |
| 67 | + self.price.hidden = YES; | |
| 68 | + self.titleLabel.numberOfLines = 1; | |
| 69 | + self.oldPrice.hidden = YES; | |
| 70 | + self.lookNum.hidden = YES; | |
| 71 | + [_logoImage sd_setImageWithURL:[NSURL URLWithString:model.poster]]; | |
| 72 | + if (_type == CNLiveCellShowTypeHot) { | |
| 73 | + self.price.hidden = NO; | |
| 74 | + NSError *error; | |
| 75 | + NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:[model.desc dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:&error]; | |
| 76 | + self.price.text = [NSString stringWithFormat:@"¥%@",dic[@"price"]]; | |
| 77 | + [self.price sizeToFit]; | |
| 78 | + }else if (_type == CNLiveCellShowTypeVideo){ | |
| 79 | + self.titleLabel.hidden = NO; | |
| 80 | + self.titleLabel.numberOfLines = 2; | |
| 81 | + self.lookNum.hidden = NO; | |
| 82 | + self.titleLabel.text = model.title; | |
| 83 | + NSString *num = model.spectators; | |
| 84 | + if (num.floatValue > 10000) { | |
| 85 | + num = [NSString stringWithFormat:@"%.1f",num.floatValue/10000]; | |
| 86 | + } | |
| 87 | + [self.lookNum setTitle:[NSString stringWithFormat:@"%@浏览",num] forState:UIControlStateNormal]; | |
| 88 | + }else{ | |
| 89 | + self.titleLabel.hidden = NO; | |
| 90 | + self.price.hidden = NO; | |
| 91 | + self.titleLabel.text = model.title; | |
| 92 | + NSError *error; | |
| 93 | + NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:[model.desc dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:&error]; | |
| 94 | + NSString *nowStr = dic[@"price"]; | |
| 95 | + NSMutableAttributedString *price = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"¥ %@",nowStr]]; | |
| 96 | + [price addAttribute:NSFontAttributeName value:UIFontMake(15) range:NSMakeRange(0, price.length)]; | |
| 97 | + [price addAttribute:NSFontAttributeName value:UIFontMake(10) range:NSMakeRange(0, 1)]; | |
| 98 | + self.price.attributedText = price; | |
| 99 | + | |
| 100 | + [self.price sizeToFit]; | |
| 101 | + NSString *oldStr = dic[@"prices"]; | |
| 102 | + | |
| 103 | + if (oldStr.floatValue > nowStr.floatValue) { | |
| 104 | + self.oldPrice.hidden = NO; | |
| 105 | + NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"¥%@",oldStr]]; | |
| 106 | + [string addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, string.length)]; | |
| 107 | + self.oldPrice.attributedText = string; | |
| 108 | + [self.oldPrice sizeToFit]; | |
| 109 | + } | |
| 110 | + | |
| 111 | + } | |
| 112 | + [self setNeedsLayout]; | |
| 113 | +} | |
| 114 | +- (UIImageView *)logoImage{ | |
| 115 | + if (!_logoImage) { | |
| 116 | + _logoImage = [[UIImageView alloc] init]; | |
| 117 | + _logoImage.clipsToBounds = YES; | |
| 118 | + _logoImage.layer.cornerRadius = 9; | |
| 119 | + } | |
| 120 | + return _logoImage; | |
| 121 | +} | |
| 122 | +- (UILabel *)titleLabel | |
| 123 | +{ | |
| 124 | + if (!_titleLabel) { | |
| 125 | + _titleLabel = [[UILabel alloc] init]; | |
| 126 | + _titleLabel.font = UIFontMake(12); | |
| 127 | + _titleLabel.textColor = CNLiveColorWithHexString(@"#333333"); | |
| 128 | + _titleLabel.textAlignment = NSTextAlignmentLeft; | |
| 129 | + } | |
| 130 | + return _titleLabel; | |
| 131 | +} | |
| 132 | +- (UILabel *)price | |
| 133 | +{ | |
| 134 | + if (!_price) { | |
| 135 | + _price = [[UILabel alloc] init]; | |
| 136 | + _price.lineBreakMode = NSLineBreakByTruncatingMiddle; | |
| 137 | + _price.font = UIFontMake(12); | |
| 138 | + _price.textColor = CNLiveColorWithHexString(@"#FC1541"); | |
| 139 | + _price.textAlignment = NSTextAlignmentLeft; | |
| 140 | + } | |
| 141 | + return _price; | |
| 142 | +} | |
| 143 | +- (UILabel *)oldPrice | |
| 144 | +{ | |
| 145 | + if (!_oldPrice) { | |
| 146 | + _oldPrice = [[UILabel alloc] init]; | |
| 147 | + _oldPrice.lineBreakMode = NSLineBreakByTruncatingMiddle; | |
| 148 | + _oldPrice.font = UIFontMake(9); | |
| 149 | + _oldPrice.textColor = CNLiveColorWithHexString(@"#B4B4B4"); | |
| 150 | + _oldPrice.textAlignment = NSTextAlignmentLeft; | |
| 151 | + } | |
| 152 | + return _oldPrice; | |
| 153 | +} | |
| 154 | + | |
| 155 | +- (UIButton *)lookNum | |
| 156 | +{ | |
| 157 | + if(!_lookNum){ | |
| 158 | + _lookNum = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 159 | + [_lookNum setImage:[UIImage loadBundleImage:@"listen"] forState:UIControlStateNormal]; | |
| 160 | + [_lookNum setTitleColor:CNLiveColorWithHexString(@"#9F9F9F") forState:UIControlStateNormal]; | |
| 161 | + _lookNum.titleLabel.font = UIFontMake(11); | |
| 162 | + } | |
| 163 | + return _lookNum; | |
| 164 | +} | |
| 165 | +@end | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveAllServiceVC.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveAllServiceVC.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/29. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <CNLiveBusinessBaseModule/CNLiveBusinessBaseModule.h> | |
| 9 | + | |
| 10 | +NS_ASSUME_NONNULL_BEGIN | |
| 11 | + | |
| 12 | +@interface CNLiveAllServiceVC : CNCommonViewController | |
| 13 | +- (instancetype)initWithServiceId:(NSString *)serviceId; | |
| 14 | ++ (instancetype)allServiceVCWithId:(NSString *)serviceId title:(NSString *)title; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveAllServiceVC.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveAllServiceVC.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/29. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveAllServiceVC.h" | |
| 9 | +#import "CNLiveServiceSearchVC.h" | |
| 10 | +#import "CNLiveSearchHotsCell.h" | |
| 11 | +#import "CNLiveSearchHeaderView.h" | |
| 12 | +#import "CNLiveServicePresent.h" | |
| 13 | +#import "CNLIveCategoryCell.h" | |
| 14 | + | |
| 15 | +static NSString *HotListCellID = @"CNLiveSearchHotsCell"; | |
| 16 | +static NSString *HotHeaderID = @"CNLiveSearchHeaderView"; | |
| 17 | +static NSString *CNCategoryCellID = @"CNLIveCategoryCell"; | |
| 18 | +static NSString *HistoryFootID = @"UICollectionFooterView"; | |
| 19 | + | |
| 20 | +@interface CNLiveAllServiceVC ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> | |
| 21 | +@property (nonatomic, strong) CNLiveNavigationBar *navigationBar; | |
| 22 | +@property (nonatomic, strong) UICollectionView *listCollectionView;//热搜/搜索历史列表 | |
| 23 | +@property (nonatomic, strong) NSArray *dataSource; | |
| 24 | +@property (nonatomic, strong) NSString *serviceId; | |
| 25 | +@property (nonatomic, assign) NSInteger page; | |
| 26 | + | |
| 27 | +@end | |
| 28 | + | |
| 29 | +@implementation CNLiveAllServiceVC | |
| 30 | + | |
| 31 | ++ (instancetype)allServiceVCWithId:(NSString *)serviceId title:(nonnull NSString *)title | |
| 32 | +{ | |
| 33 | + CNLiveAllServiceVC *vc = [[CNLiveAllServiceVC alloc] initWithServiceId:serviceId]; | |
| 34 | + vc.title = title; | |
| 35 | + [[BaseAppDelegate sharedAppDelegate] pushViewController:vc withBackTitle:@""]; | |
| 36 | + return vc; | |
| 37 | +} | |
| 38 | +- (void)requestService{ | |
| 39 | + if (![CNLiveNetworking isNetworking]) { | |
| 40 | + self.listCollectionView.mj_footer.hidden = YES; | |
| 41 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_noNet"] text:@"网络开小差了,刷新试试" detailText:nil buttonTitle:@" 刷新 " buttonAction:@selector(requestService)]; | |
| 42 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 43 | + [self setCNAPIErrorEmptyView]; | |
| 44 | + return; | |
| 45 | + } | |
| 46 | + weakself | |
| 47 | + [CNLiveServicePresent loadAllServiceWithServiceId:_serviceId page:[NSString stringWithFormat:@"%ld",_page] result:^(NSArray * _Nonnull dataArray, BOOL isLastPage) { | |
| 48 | + strongself | |
| 49 | + [self.listCollectionView.mj_footer endRefreshing]; | |
| 50 | + self.listCollectionView.mj_footer.hidden = NO; | |
| 51 | + | |
| 52 | + if (isLastPage) { | |
| 53 | + [self.listCollectionView.mj_footer endRefreshingWithNoMoreData]; | |
| 54 | + } | |
| 55 | + [self removeEmptyView]; | |
| 56 | + self.dataSource = dataArray; | |
| 57 | + [self.listCollectionView reloadData]; | |
| 58 | + }error:^{ | |
| 59 | + strongself | |
| 60 | + [self.listCollectionView.mj_footer endRefreshing]; | |
| 61 | + self.listCollectionView.mj_footer.hidden = YES; | |
| 62 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_failure"] text:@"加载失败,请点击重试" detailText:nil buttonTitle:@" 重试 " buttonAction:@selector(requestService)]; | |
| 63 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 64 | + [self setCNAPIErrorEmptyView]; | |
| 65 | + }]; | |
| 66 | +} | |
| 67 | +-(void)removeEmptyView | |
| 68 | +{ | |
| 69 | + [self.emptyView removeFromSuperview]; | |
| 70 | + self.emptyView = nil; | |
| 71 | +} | |
| 72 | +- (instancetype)initWithServiceId:(NSString *)serviceId | |
| 73 | +{ | |
| 74 | + self = [super init]; | |
| 75 | + if (self) { | |
| 76 | + _serviceId = serviceId; | |
| 77 | + } | |
| 78 | + return self; | |
| 79 | +} | |
| 80 | +- (void)viewDidLoad { | |
| 81 | + [super viewDidLoad]; | |
| 82 | + _page = 1; | |
| 83 | + [self requestService]; | |
| 84 | + self.view.backgroundColor = kWhiteColor; | |
| 85 | + [self.view addSubview:self.navigationBar]; | |
| 86 | + [self.view addSubview:self.listCollectionView]; | |
| 87 | + // Do any additional setup after loading the view. | |
| 88 | +} | |
| 89 | +- (void)viewDidLayoutSubviews | |
| 90 | +{ | |
| 91 | + [super viewDidLayoutSubviews]; | |
| 92 | + [self.listCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 93 | + make.top.equalTo(self.navigationBar.mas_bottom).offset(0); | |
| 94 | + make.left.right.equalTo(self.view); | |
| 95 | + make.bottom.equalTo(self.mas_bottomLayoutGuide); | |
| 96 | + }]; | |
| 97 | +} | |
| 98 | +- (void)viewWillAppear:(BOOL)animated{ | |
| 99 | + [super viewWillAppear:animated]; | |
| 100 | + self.navigationController.navigationBarHidden = YES; | |
| 101 | +} | |
| 102 | +- (void)viewWillDisappear:(BOOL)animated | |
| 103 | +{ | |
| 104 | + [super viewWillDisappear:animated]; | |
| 105 | + self.navigationController.navigationBarHidden = NO; | |
| 106 | +} | |
| 107 | +#pragma mark - UICollectionViewDelegate | |
| 108 | +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 109 | + CNLiveSearchHotsModel *model = self.dataSource[indexPath.section]; | |
| 110 | + CNLiveSearchModel *model1 = [CNLiveSearchModel mj_objectWithKeyValues:model.lists[indexPath.row]]; | |
| 111 | + [CNLiveServicePresent usedServiceWithServingId:model1.id]; | |
| 112 | + | |
| 113 | +} | |
| 114 | +#pragma mark - UICollectionViewDataSource | |
| 115 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ | |
| 116 | + CNLiveSearchHotsModel *model = self.dataSource[section]; | |
| 117 | + return model.lists.count; | |
| 118 | +} | |
| 119 | +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ | |
| 120 | + return self.dataSource.count; | |
| 121 | +} | |
| 122 | +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 123 | + CNLiveSearchHotsModel *model = self.dataSource[indexPath.section]; | |
| 124 | + if (_serviceId &&![_serviceId isEqualToString:@""]&&indexPath.section != 0){ | |
| 125 | + CNLIveCategoryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNCategoryCellID forIndexPath:indexPath]; | |
| 126 | + cell.model = [CNLiveSearchModel mj_objectWithKeyValues:model.lists[indexPath.row]]; | |
| 127 | + return cell; | |
| 128 | + }else{ | |
| 129 | + CNLiveSearchHotsCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:HotListCellID forIndexPath:indexPath]; | |
| 130 | + cell.model = [CNLiveSearchModel mj_objectWithKeyValues:model.lists[indexPath.row]]; | |
| 131 | + return cell; | |
| 132 | + } | |
| 133 | + | |
| 134 | +} | |
| 135 | +- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{ | |
| 136 | + | |
| 137 | + if ([kind isEqualToString:@"UICollectionElementKindSectionHeader"]) { | |
| 138 | + CNLiveSearchHotsModel *model = self.dataSource[indexPath.section]; | |
| 139 | + CNLiveSearchHeaderView *header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:HotHeaderID forIndexPath:indexPath]; | |
| 140 | + if (_serviceId &&![_serviceId isEqualToString:@""]&&indexPath.section == 0) { | |
| 141 | + header.type = CNServiceHeaderTypeCategoryId; | |
| 142 | + }else{ | |
| 143 | + header.type = CNServiceHeaderTypeService; | |
| 144 | + } | |
| 145 | + header.model = model; | |
| 146 | + return header; | |
| 147 | + }else | |
| 148 | + { | |
| 149 | + UICollectionReusableView *footer = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:HistoryFootID forIndexPath:indexPath]; | |
| 150 | + footer.backgroundColor = CNLiveColorWithHexString(@"#F5F5F5"); | |
| 151 | + return footer; | |
| 152 | + } | |
| 153 | + | |
| 154 | + | |
| 155 | +} | |
| 156 | +#pragma mark - UICollectionViewDelegateFlowLayout | |
| 157 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 158 | + CNLiveSearchHotsModel *model = self.dataSource[indexPath.section]; | |
| 159 | + return CGSizeMake(model.layout.width, model.layout.height); | |
| 160 | +} | |
| 161 | +- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ | |
| 162 | + return UIEdgeInsetsMake(5, 15, 10, 15); | |
| 163 | +} | |
| 164 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{ | |
| 165 | + return CGSizeMake(collectionView.width, 60); | |
| 166 | +} | |
| 167 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{ | |
| 168 | + return CGSizeMake(self.view.width, 5); | |
| 169 | +} | |
| 170 | +#pragma mark - Setting&&Getting | |
| 171 | +- (UICollectionView *)listCollectionView | |
| 172 | +{ | |
| 173 | + if (!_listCollectionView) { | |
| 174 | + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 175 | + layout.sectionFootersPinToVisibleBounds = YES; | |
| 176 | + layout.sectionHeadersPinToVisibleBounds = YES; | |
| 177 | + _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; | |
| 178 | + _listCollectionView.backgroundColor = kWhiteColor; | |
| 179 | + _listCollectionView.collectionViewLayout = layout; | |
| 180 | + _listCollectionView.delegate = self; | |
| 181 | + _listCollectionView.dataSource = self; | |
| 182 | + _listCollectionView.showsVerticalScrollIndicator = NO; | |
| 183 | + [_listCollectionView registerClass:[CNLiveSearchHotsCell class] forCellWithReuseIdentifier:HotListCellID]; | |
| 184 | + [_listCollectionView registerClass:[CNLiveSearchHeaderView class] forSupplementaryViewOfKind:@"UICollectionElementKindSectionHeader" withReuseIdentifier:HotHeaderID]; | |
| 185 | + [_listCollectionView registerClass:[CNLIveCategoryCell class] forCellWithReuseIdentifier:CNCategoryCellID]; | |
| 186 | + [_listCollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:@"UICollectionElementKindSectionFooter" withReuseIdentifier:HistoryFootID]; | |
| 187 | + weakself | |
| 188 | + MJRefreshAutoNormalFooter *loadFooter = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ | |
| 189 | + strongself | |
| 190 | + self.page ++; | |
| 191 | + [self requestService]; | |
| 192 | + }]; | |
| 193 | + _listCollectionView.mj_footer = loadFooter; | |
| 194 | + } | |
| 195 | + return _listCollectionView; | |
| 196 | +} | |
| 197 | +#pragma mark - Navigation | |
| 198 | + | |
| 199 | +- (CNLiveNavigationBar *)navigationBar { | |
| 200 | + if (!_navigationBar) { | |
| 201 | + _navigationBar = [CNLiveNavigationBar navigationBar]; | |
| 202 | + _navigationBar.title.text = self.title; | |
| 203 | + weakself | |
| 204 | + _navigationBar.onClickLeftButton = ^{ | |
| 205 | + strongself | |
| 206 | + [self.navigationController popViewControllerAnimated:YES]; | |
| 207 | + }; | |
| 208 | + if ([self.title isEqualToString:@"全部服务"]) { | |
| 209 | + [_navigationBar.right setTitleColor:CNLiveColorWithHexString(@"#F5A623") forState:UIControlStateNormal]; | |
| 210 | + _navigationBar.rightImage = [UIImage loadBundleImage:@"service_search"]; | |
| 211 | + _navigationBar.onClickRightButton = ^{ | |
| 212 | + [CNLiveServiceSearchVC serviceSearchVC:nil]; | |
| 213 | + }; | |
| 214 | + } | |
| 215 | + } | |
| 216 | + return _navigationBar; | |
| 217 | +} | |
| 218 | + | |
| 219 | + | |
| 220 | +@end | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveMyServicesVC.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveMyServicesVC.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/26. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <CNLiveBusinessBaseModule/CNLiveBusinessBaseModule.h> | |
| 9 | + | |
| 10 | +NS_ASSUME_NONNULL_BEGIN | |
| 11 | + | |
| 12 | +@interface CNLiveMyServicesVC : CNCommonViewController | |
| 13 | + | |
| 14 | ++ (instancetype)myServiceVC; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveMyServicesVC.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveMyServicesVC.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/26. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveMyServicesVC.h" | |
| 9 | +#import "CNLiveServicePresent.h" | |
| 10 | +#import "CNLiveSearchModel.h" | |
| 11 | +#import "CNLiveSearchHotsCell.h" | |
| 12 | + | |
| 13 | +@interface CNLiveMyServicesVC ()<UICollectionViewDelegate,UICollectionViewDataSource> | |
| 14 | +@property (nonatomic, strong) CNLiveNavigationBar *navigationBar; | |
| 15 | +@property (nonatomic ,strong) NSArray *dataSource; | |
| 16 | +@property (nonatomic, strong) UICollectionView *listCollectionView; | |
| 17 | +@property (nonatomic, assign) NSInteger page; | |
| 18 | +@end | |
| 19 | + | |
| 20 | +static NSString *HotListCellID = @"HotListCellID"; | |
| 21 | + | |
| 22 | +@implementation CNLiveMyServicesVC | |
| 23 | ++ (instancetype)myServiceVC | |
| 24 | +{ | |
| 25 | + CNLiveMyServicesVC *myService = [[CNLiveMyServicesVC alloc] init]; | |
| 26 | + [[BaseAppDelegate sharedAppDelegate] pushViewController:myService withBackTitle:@""]; | |
| 27 | + return myService; | |
| 28 | +} | |
| 29 | +- (void)myServiceData{ | |
| 30 | + if (![CNLiveNetworking isNetworking]) { | |
| 31 | + self.listCollectionView.mj_footer.hidden = YES; | |
| 32 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_noNet"] text:@"网络开小差了,刷新试试" detailText:nil buttonTitle:@" 刷新 " buttonAction:@selector(myServiceData)]; | |
| 33 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 34 | + [self setCNAPIErrorEmptyView]; | |
| 35 | + return; | |
| 36 | + } | |
| 37 | + weakself | |
| 38 | + [CNLiveServicePresent loadMyServicepage:[NSString stringWithFormat:@"%ld",_page] result:^(NSArray * _Nonnull dataArray) { | |
| 39 | + strongself | |
| 40 | + [self.listCollectionView.mj_footer endRefreshing]; | |
| 41 | + if (!dataArray||dataArray.count <= 0) { | |
| 42 | + self.listCollectionView.mj_footer.hidden = YES; | |
| 43 | + self.navigationBar.right.hidden = YES; | |
| 44 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_noMsg"] text:@"暂无内容" detailText:nil buttonTitle:NULL buttonAction:NULL]; | |
| 45 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 46 | + [self setCNAPIErrorEmptyView]; | |
| 47 | + }else{ | |
| 48 | + self.listCollectionView.mj_footer.hidden = NO; | |
| 49 | + [self removeEmptyView]; | |
| 50 | + if (dataArray.count < 10) { | |
| 51 | + [self.listCollectionView.mj_footer endRefreshingWithNoMoreData]; | |
| 52 | + | |
| 53 | + } | |
| 54 | + self.navigationBar.right.hidden = NO; | |
| 55 | + self.dataSource = dataArray; | |
| 56 | + [self.listCollectionView reloadData]; | |
| 57 | + } | |
| 58 | + } error:^{ | |
| 59 | + [self.listCollectionView.mj_footer endRefreshing]; | |
| 60 | + self.listCollectionView.mj_footer.hidden = YES; | |
| 61 | + strongself | |
| 62 | + self.navigationBar.right.hidden = YES; | |
| 63 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_failure"] text:@"加载失败,请点击重试" detailText:nil buttonTitle:@" 重试 " buttonAction:@selector(myServiceData)]; | |
| 64 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 65 | + [self setCNAPIErrorEmptyView]; | |
| 66 | + }]; | |
| 67 | +} | |
| 68 | +-(void)removeEmptyView | |
| 69 | +{ | |
| 70 | + [self.emptyView removeFromSuperview]; | |
| 71 | + self.emptyView = nil; | |
| 72 | +} | |
| 73 | +- (void)viewDidLoad { | |
| 74 | + [super viewDidLoad]; | |
| 75 | + self.view.backgroundColor = kWhiteColor; | |
| 76 | + [self.view addSubview:self.navigationBar]; | |
| 77 | + [self.view addSubview:self.listCollectionView]; | |
| 78 | + _page = 1; | |
| 79 | + [self myServiceData]; | |
| 80 | +} | |
| 81 | +- (void)viewDidLayoutSubviews | |
| 82 | +{ | |
| 83 | + [super viewDidLayoutSubviews]; | |
| 84 | + [self.listCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 85 | + make.top.equalTo(self.navigationBar.mas_bottom); | |
| 86 | + make.left.right.equalTo(self.view); | |
| 87 | + make.bottom.equalTo(self.mas_bottomLayoutGuide); | |
| 88 | + }]; | |
| 89 | +} | |
| 90 | +- (void)viewWillAppear:(BOOL)animated { | |
| 91 | + [super viewWillAppear:animated]; | |
| 92 | + self.navigationController.navigationBarHidden = YES; | |
| 93 | +} | |
| 94 | +- (void)viewWillDisappear:(BOOL)animated | |
| 95 | +{ | |
| 96 | + [super viewWillDisappear:animated]; | |
| 97 | + self.navigationController.navigationBarHidden = NO; | |
| 98 | +} | |
| 99 | +#pragma mark - UICollectionViewDelegate | |
| 100 | +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 101 | + | |
| 102 | + CNLiveSearchModel *model1 = self.dataSource[indexPath.row]; | |
| 103 | +#warning 跳转 | |
| 104 | + | |
| 105 | +} | |
| 106 | +#pragma mark - UICollectionViewDataSource | |
| 107 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ | |
| 108 | + | |
| 109 | + return self.dataSource.count; | |
| 110 | +} | |
| 111 | + | |
| 112 | +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 113 | + | |
| 114 | + CNLiveSearchHotsCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:HotListCellID forIndexPath:indexPath]; | |
| 115 | + cell.model = self.dataSource[indexPath.row]; | |
| 116 | + return cell; | |
| 117 | +} | |
| 118 | +#pragma mark - Getting | |
| 119 | +- (UICollectionView *)listCollectionView | |
| 120 | +{ | |
| 121 | + if (!_listCollectionView) { | |
| 122 | + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 123 | + layout.sectionFootersPinToVisibleBounds = YES; | |
| 124 | + layout.sectionHeadersPinToVisibleBounds = YES; | |
| 125 | + layout.itemSize = CGSizeMake((SCREEN_WIDTH-4*15-3*15)/4.0, 80); | |
| 126 | + layout.sectionInset = UIEdgeInsetsMake(15, 15, 15, 15); | |
| 127 | + _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; | |
| 128 | + _listCollectionView.backgroundColor = kWhiteColor; | |
| 129 | + _listCollectionView.collectionViewLayout = layout; | |
| 130 | + _listCollectionView.delegate = self; | |
| 131 | + _listCollectionView.dataSource = self; | |
| 132 | + _listCollectionView.showsVerticalScrollIndicator = NO; | |
| 133 | + [_listCollectionView registerClass:[CNLiveSearchHotsCell class] forCellWithReuseIdentifier:HotListCellID]; | |
| 134 | + weakself | |
| 135 | + MJRefreshAutoNormalFooter *loadFooter = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ | |
| 136 | + strongself | |
| 137 | + self.page ++; | |
| 138 | + [self myServiceData]; | |
| 139 | + }]; | |
| 140 | + _listCollectionView.mj_footer = loadFooter; | |
| 141 | + } | |
| 142 | + return _listCollectionView; | |
| 143 | +} | |
| 144 | + | |
| 145 | +#pragma mark - Navigation | |
| 146 | + | |
| 147 | +- (CNLiveNavigationBar *)navigationBar { | |
| 148 | + if (!_navigationBar) { | |
| 149 | + _navigationBar = [CNLiveNavigationBar navigationBar]; | |
| 150 | + _navigationBar.title.text = @"我的服务"; | |
| 151 | + weakself | |
| 152 | + _navigationBar.onClickLeftButton = ^{ | |
| 153 | + strongself | |
| 154 | + [self.navigationController popViewControllerAnimated:YES]; | |
| 155 | + }; | |
| 156 | +// [_navigationBar.right setTitleColor:CNLiveColorWithHexString(@"#F5A623") forState:UIControlStateNormal]; | |
| 157 | + _navigationBar.rightTitle = @"清空"; | |
| 158 | + _navigationBar.onClickRightButton = ^{ | |
| 159 | + | |
| 160 | + [CNLiveServicePresent removeMyServiceResult:^{ | |
| 161 | + strongself | |
| 162 | + [self myServiceData]; | |
| 163 | + }]; | |
| 164 | + }; | |
| 165 | + | |
| 166 | + } | |
| 167 | + return _navigationBar; | |
| 168 | +} | |
| 169 | + | |
| 170 | +@end | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveServiceSearchVC.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceSearchVC.h | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/24. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | + | |
| 10 | +NS_ASSUME_NONNULL_BEGIN | |
| 11 | + | |
| 12 | +@interface CNLiveServiceSearchVC : CNCommonViewController | |
| 13 | + | |
| 14 | +@property (nonatomic, strong) NSArray *hots; | |
| 15 | + | |
| 16 | ++ (instancetype)serviceSearchVC:(NSArray *_Nullable)array; | |
| 17 | +@end | |
| 18 | + | |
| 19 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveServiceSearchVC.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceSearchVC.m | |
| 3 | +// CNLiveCServiceModule | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/24. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveServiceSearchVC.h" | |
| 9 | +#import "CNLiveMainSearch.h" | |
| 10 | +#import "CNLiveSearchModel.h" | |
| 11 | +#import "CNLiveServicePresent.h" | |
| 12 | +#import "CNLiveSearchListCell.h" | |
| 13 | +#import "CNLiveServiceHistorySearch.h" | |
| 14 | +#import "CNLiveSearchHotsCell.h" | |
| 15 | +#import "CNLiveSearchHistoryCell.h" | |
| 16 | +#import "CNLiveSearchHotsFooterView.h" | |
| 17 | +#import "CNLiveSearchHeaderView.h" | |
| 18 | + | |
| 19 | +@interface CNLiveServiceSearchVC ()<UITableViewDelegate,UITableViewDataSource, UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> | |
| 20 | + | |
| 21 | +@property (nonatomic, strong) CNLiveMainSearch *searchView;//搜索框 | |
| 22 | +@property (nonatomic, strong) UIButton *cancelBtn; //取消按钮 | |
| 23 | +@property (nonatomic, assign) NSInteger page;//请求页数 | |
| 24 | +@property (nonatomic, strong) NSString *searchStr; | |
| 25 | +@property (nonatomic, strong) NSArray *histories; | |
| 26 | +@property (nonatomic, strong) UITableView *listTableView;//搜索结果列表 | |
| 27 | +@property (nonatomic, strong) NSArray <CNLiveSearchModel *>*dataListArr; | |
| 28 | + | |
| 29 | +@property (nonatomic, strong) UICollectionView *listCollectionView;//热搜/搜索历史列表 | |
| 30 | +@property (nonatomic, strong) NSArray *hDataSources;//包含搜索历史和热搜的数组 | |
| 31 | +@end | |
| 32 | + | |
| 33 | +static NSString *SearchListCellID = @"SearchListCellID"; | |
| 34 | +static NSString *HotListCellID = @"HotListCellID"; | |
| 35 | +static NSString *HistoryListCellID = @"HistoryListCellID"; | |
| 36 | +static NSString *HotHeaderID = @"HotHeaderID"; | |
| 37 | +static NSString *HistoryFootID = @"HistoryFootID"; | |
| 38 | + | |
| 39 | +@implementation CNLiveServiceSearchVC | |
| 40 | ++ (instancetype)serviceSearchVC:(NSArray *)array | |
| 41 | +{ | |
| 42 | + CNLiveServiceSearchVC *search = [[CNLiveServiceSearchVC alloc] init]; | |
| 43 | + search.hots = array; | |
| 44 | + [[BaseAppDelegate sharedAppDelegate] pushViewController:search]; | |
| 45 | + return search; | |
| 46 | +} | |
| 47 | +- (void)searchRequese{ | |
| 48 | + if (![CNLiveNetworking isNetworking]) { | |
| 49 | + self.listCollectionView.mj_footer.hidden = YES; | |
| 50 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_noNet"] text:@"网络开小差了,刷新试试" detailText:nil buttonTitle:@" 刷新 " buttonAction:@selector(searchRequese)]; | |
| 51 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 52 | + [self setCNAPIErrorEmptyView]; | |
| 53 | + return; | |
| 54 | + } | |
| 55 | + weakself | |
| 56 | + [CNLiveServicePresent searchServiceList:_searchStr page:[NSString stringWithFormat:@"%ld",_page] result:^(NSArray<CNLiveSearchModel *> * _Nonnull dataArray, BOOL isLastPage) { | |
| 57 | + weakSelf.listCollectionView.hidden = YES; | |
| 58 | + strongself | |
| 59 | + if (!dataArray||dataArray.count <= 0) { | |
| 60 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_noMsg"] text:@"暂无内容" detailText:nil buttonTitle:NULL buttonAction:@selector(searchRequese)]; | |
| 61 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 62 | + [self setCNAPIErrorEmptyView]; | |
| 63 | + }else{ | |
| 64 | + [self removeEmptyView]; | |
| 65 | + self.listTableView.mj_footer.hidden = NO; | |
| 66 | + if (isLastPage) { | |
| 67 | + [self.listTableView.mj_footer endRefreshingWithNoMoreData]; | |
| 68 | + }else{ | |
| 69 | + self.page ++; | |
| 70 | + } | |
| 71 | + self.listTableView.hidden = NO; | |
| 72 | + | |
| 73 | + self.dataListArr = dataArray; | |
| 74 | + [self.listTableView reloadData]; | |
| 75 | + } | |
| 76 | + } error:^{ | |
| 77 | + weakSelf.listCollectionView.hidden = YES; | |
| 78 | + strongself | |
| 79 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_failure"] text:@"加载失败,请点击重试" detailText:nil buttonTitle:@" 重试 " buttonAction:@selector(searchRequese)]; | |
| 80 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 81 | + [self setCNAPIErrorEmptyView]; | |
| 82 | + | |
| 83 | + }]; | |
| 84 | +} | |
| 85 | +-(void)removeEmptyView | |
| 86 | +{ | |
| 87 | + [self.emptyView removeFromSuperview]; | |
| 88 | + self.emptyView = nil; | |
| 89 | +} | |
| 90 | + | |
| 91 | +- (void)dealHotsAndHistories | |
| 92 | +{ | |
| 93 | + [CNLiveServicePresent dealHots:self.hots searchHistories:self.histories results:^(NSArray * _Nonnull dataArray) { | |
| 94 | + self.hDataSources = dataArray; | |
| 95 | + [self.listCollectionView reloadData]; | |
| 96 | + }]; | |
| 97 | +} | |
| 98 | +- (void)viewDidLoad { | |
| 99 | + [super viewDidLoad]; | |
| 100 | + NSMutableArray *historSearch = [CNLiveServiceHistorySearch readHistorySearch]; | |
| 101 | + self.histories = historSearch.copy; | |
| 102 | + [self dealHotsAndHistories]; | |
| 103 | + self.view.backgroundColor = kWhiteColor; | |
| 104 | + [self.view addSubview:self.searchView]; | |
| 105 | + [self.view addSubview:self.cancelBtn]; | |
| 106 | + [self.view addSubview:self.listTableView]; | |
| 107 | + [self.view addSubview:self.listCollectionView]; | |
| 108 | + // Do any additional setup after loading the view. | |
| 109 | +} | |
| 110 | +- (void)viewDidLayoutSubviews | |
| 111 | +{ | |
| 112 | + [super viewDidLayoutSubviews]; | |
| 113 | + [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 114 | + if (self.mas_topLayoutGuide > 0) { | |
| 115 | + make.top.equalTo(self.mas_topLayoutGuide); | |
| 116 | + }else{ | |
| 117 | + make.top.equalTo(self.view).offset(35.5); | |
| 118 | + } | |
| 119 | + make.height.offset(36); | |
| 120 | + make.right.equalTo(self.view).offset(-15); | |
| 121 | + }]; | |
| 122 | + [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 123 | + if (self.mas_topLayoutGuide > 0) { | |
| 124 | + make.top.equalTo(self.mas_topLayoutGuide); | |
| 125 | + }else{ | |
| 126 | + make.top.equalTo(self.view).offset(35.5); | |
| 127 | + } | |
| 128 | + make.left.equalTo(self.view).offset(15); | |
| 129 | + make.right.equalTo(self.cancelBtn.mas_left).offset(-15); | |
| 130 | + make.height.offset(36); | |
| 131 | + }]; | |
| 132 | + [self.listTableView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 133 | + make.top.equalTo(self.searchView.mas_bottom).offset(10); | |
| 134 | + make.left.right.equalTo(self.view); | |
| 135 | + make.bottom.equalTo(self.mas_bottomLayoutGuide); | |
| 136 | + }]; | |
| 137 | + [self.listCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 138 | + make.top.equalTo(self.searchView.mas_bottom).offset(7); | |
| 139 | + make.left.right.equalTo(self.view); | |
| 140 | + make.bottom.equalTo(self.mas_bottomLayoutGuide); | |
| 141 | + }]; | |
| 142 | +} | |
| 143 | +- (void)viewWillAppear:(BOOL)animated | |
| 144 | +{ | |
| 145 | + [super viewWillAppear:animated]; | |
| 146 | + self.navigationController.navigationBarHidden = YES; | |
| 147 | +} | |
| 148 | +- (void)viewWillDisappear:(BOOL)animated | |
| 149 | +{ | |
| 150 | + [super viewWillDisappear:animated]; | |
| 151 | + self.navigationController.navigationBarHidden = NO; | |
| 152 | + [CNLiveServiceHistorySearch saveHistorySearch:self.histories.mutableCopy]; | |
| 153 | +} | |
| 154 | +#pragma mark - Action | |
| 155 | +- (void)cancelBtnClick{ | |
| 156 | + [self.navigationController popViewControllerAnimated:YES]; | |
| 157 | +} | |
| 158 | +#pragma mark - UIScrollViewDelegate | |
| 159 | +- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ | |
| 160 | + [self.view endEditing:YES]; | |
| 161 | +} | |
| 162 | +#pragma mark - UITableViewDelegate | |
| 163 | +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ | |
| 164 | + return 75; | |
| 165 | +} | |
| 166 | +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | |
| 167 | +#warning 跳转 | |
| 168 | +} | |
| 169 | +#pragma mark - UITableViewDataSource | |
| 170 | +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | |
| 171 | +{ | |
| 172 | + return self.dataListArr.count; | |
| 173 | +} | |
| 174 | +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |
| 175 | + CNLiveSearchListCell *cell = [tableView dequeueReusableCellWithIdentifier:SearchListCellID]; | |
| 176 | + CNLiveSearchModel *model = self.dataListArr[indexPath.row]; | |
| 177 | + cell.model = model; | |
| 178 | + return cell; | |
| 179 | +} | |
| 180 | +#pragma mark - UICollectionViewDelegate | |
| 181 | +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 182 | + CNLiveSearchHotsModel *model = self.hDataSources[indexPath.section]; | |
| 183 | + if ([model.title isEqualToString:@"热度推荐"]) { | |
| 184 | + CNLiveSearchModel *model1 = model.lists[indexPath.row]; | |
| 185 | +#warning 跳转 | |
| 186 | + }else | |
| 187 | + { | |
| 188 | + CNLiveHistoryModel *model1 = model.lists[indexPath.row]; | |
| 189 | + self.searchStr = model1.title; | |
| 190 | + self.searchView.searchField.text = self.searchStr; | |
| 191 | + [self searchRequese]; | |
| 192 | + } | |
| 193 | +} | |
| 194 | +#pragma mark - UICollectionViewDataSource | |
| 195 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ | |
| 196 | + CNLiveSearchHotsModel *model = self.hDataSources[section]; | |
| 197 | + return model.lists.count; | |
| 198 | +} | |
| 199 | +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ | |
| 200 | + return self.hDataSources.count; | |
| 201 | +} | |
| 202 | +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 203 | + CNLiveSearchHotsModel *model = self.hDataSources[indexPath.section]; | |
| 204 | + if ([model.title isEqualToString:@"热度推荐"]) { | |
| 205 | + CNLiveSearchHotsCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:HotListCellID forIndexPath:indexPath]; | |
| 206 | + cell.model = model.lists[indexPath.row]; | |
| 207 | + return cell; | |
| 208 | + }else{ | |
| 209 | + CNLiveSearchHistoryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:HistoryListCellID forIndexPath:indexPath]; | |
| 210 | + cell.model = model.lists[indexPath.row]; | |
| 211 | + return cell; | |
| 212 | + } | |
| 213 | +} | |
| 214 | +- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{ | |
| 215 | + | |
| 216 | + if ([kind isEqualToString:@"UICollectionElementKindSectionHeader"]) { | |
| 217 | + CNLiveSearchHotsModel *model = self.hDataSources[indexPath.section]; | |
| 218 | + CNLiveSearchHeaderView *header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:HotHeaderID forIndexPath:indexPath]; | |
| 219 | + header.model = model; | |
| 220 | + return header; | |
| 221 | + }else | |
| 222 | + { | |
| 223 | + CNLiveSearchHotsFooterView *footer = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:HistoryFootID forIndexPath:indexPath]; | |
| 224 | + footer.clearBlock = ^{ | |
| 225 | + self.histories = @[]; | |
| 226 | + [self dealHotsAndHistories]; | |
| 227 | + }; | |
| 228 | + return footer; | |
| 229 | + } | |
| 230 | + | |
| 231 | + | |
| 232 | +} | |
| 233 | +#pragma mark - UICollectionViewDelegateFlowLayout | |
| 234 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 235 | + CNLiveSearchHotsModel *model = self.hDataSources[indexPath.section]; | |
| 236 | + return CGSizeMake(model.layout.width, model.layout.height); | |
| 237 | +} | |
| 238 | +- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ | |
| 239 | + return UIEdgeInsetsMake(10, 15, 10, 15); | |
| 240 | +} | |
| 241 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{ | |
| 242 | + return CGSizeMake(collectionView.width, 40); | |
| 243 | +} | |
| 244 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{ | |
| 245 | + if (section == 0) { | |
| 246 | + return CGSizeMake(0, 0); | |
| 247 | + } | |
| 248 | + return CGSizeMake(self.view.width, 40); | |
| 249 | +} | |
| 250 | +#pragma mark - Setting&&Getting | |
| 251 | + | |
| 252 | +- (CNLiveMainSearch *)searchView{ | |
| 253 | + if (!_searchView) { | |
| 254 | + _searchView = [[CNLiveMainSearch alloc] initWithType:CNSearchViewShowTypeSearch]; | |
| 255 | + weakself | |
| 256 | + _searchView.searchBlock = ^(NSString * _Nonnull searchStr) { | |
| 257 | + [weakSelf.view endEditing:YES]; | |
| 258 | + weakSelf.page = 1; | |
| 259 | + weakSelf.searchStr = searchStr; | |
| 260 | + [weakSelf searchRequese]; | |
| 261 | + if (![weakSelf isSearchEd:searchStr]) { | |
| 262 | + NSMutableArray *array = [NSMutableArray arrayWithArray:weakSelf.histories]; | |
| 263 | + NSDictionary *dic = @{ | |
| 264 | + @"title":searchStr, | |
| 265 | + }; | |
| 266 | + [array insertObject:dic atIndex:0]; | |
| 267 | + weakSelf.histories = array.copy; | |
| 268 | + [weakSelf dealHotsAndHistories]; | |
| 269 | + } | |
| 270 | + | |
| 271 | + }; | |
| 272 | + _searchView.clearBlock = ^{ | |
| 273 | + if (weakSelf.listCollectionView.isHidden) { | |
| 274 | + weakSelf.listCollectionView.hidden = NO; | |
| 275 | + } | |
| 276 | + if (!weakSelf.listTableView.isHidden) { | |
| 277 | + weakSelf.listTableView.hidden = YES; | |
| 278 | + } | |
| 279 | + if (weakSelf.emptyView) { | |
| 280 | + [weakSelf removeEmptyView]; | |
| 281 | + } | |
| 282 | + }; | |
| 283 | + } | |
| 284 | + return _searchView; | |
| 285 | +} | |
| 286 | +- (UIButton *)cancelBtn | |
| 287 | +{ | |
| 288 | + if (!_cancelBtn) { | |
| 289 | + _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 290 | + [_cancelBtn setTitle:@"取消" forState:UIControlStateNormal]; | |
| 291 | + [_cancelBtn setTitleColor:CNLiveColorWithHexString(@"#00CD1E") forState:UIControlStateNormal]; | |
| 292 | + _cancelBtn.titleLabel.font = UIFontMake(14); | |
| 293 | + _cancelBtn.backgroundColor = kClearColor; | |
| 294 | + [_cancelBtn sizeToFit]; | |
| 295 | + [ _cancelBtn addTarget:self action:@selector(cancelBtnClick) forControlEvents:UIControlEventTouchUpInside]; | |
| 296 | + } | |
| 297 | + return _cancelBtn; | |
| 298 | +} | |
| 299 | +- (UITableView *)listTableView | |
| 300 | +{ | |
| 301 | + if (!_listTableView) { | |
| 302 | + _listTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; | |
| 303 | + _listTableView.separatorStyle = UITableViewCellSeparatorStyleNone; | |
| 304 | + _listTableView.dataSource = self; | |
| 305 | + _listTableView.delegate = self; | |
| 306 | + [_listTableView registerClass:[CNLiveSearchListCell class] forCellReuseIdentifier:SearchListCellID]; | |
| 307 | + _listTableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(searchRequese)]; | |
| 308 | + _listTableView.hidden = YES; | |
| 309 | + } | |
| 310 | + return _listTableView; | |
| 311 | +} | |
| 312 | +- (UICollectionView *)listCollectionView | |
| 313 | +{ | |
| 314 | + if (!_listCollectionView) { | |
| 315 | + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 316 | + layout.sectionFootersPinToVisibleBounds = YES; | |
| 317 | + layout.sectionHeadersPinToVisibleBounds = YES; | |
| 318 | + _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; | |
| 319 | + _listCollectionView.backgroundColor = kWhiteColor; | |
| 320 | + _listCollectionView.collectionViewLayout = layout; | |
| 321 | + _listCollectionView.delegate = self; | |
| 322 | + _listCollectionView.dataSource = self; | |
| 323 | + _listCollectionView.showsVerticalScrollIndicator = NO; | |
| 324 | + [_listCollectionView registerClass:[CNLiveSearchHotsCell class] forCellWithReuseIdentifier:HotListCellID]; | |
| 325 | + [_listCollectionView registerClass:[CNLiveSearchHistoryCell class] forCellWithReuseIdentifier:HistoryListCellID]; | |
| 326 | + [_listCollectionView registerClass:[CNLiveSearchHeaderView class] forSupplementaryViewOfKind:@"UICollectionElementKindSectionHeader" withReuseIdentifier:HotHeaderID]; | |
| 327 | + [_listCollectionView registerClass:[CNLiveSearchHotsFooterView class] forSupplementaryViewOfKind:@"UICollectionElementKindSectionFooter" withReuseIdentifier:HistoryFootID]; | |
| 328 | + } | |
| 329 | + return _listCollectionView; | |
| 330 | +} | |
| 331 | + | |
| 332 | +- (BOOL)isSearchEd:(NSString *)string | |
| 333 | +{ | |
| 334 | + for (NSDictionary *dic in self.histories) { | |
| 335 | + if ([dic[@"title"] isEqualToString:string]) { | |
| 336 | + return YES; | |
| 337 | + } | |
| 338 | + } | |
| 339 | + return NO; | |
| 340 | +} | |
| 341 | +/* | |
| 342 | +#pragma mark - Navigation | |
| 343 | + | |
| 344 | +// In a storyboard-based application, you will often want to do a little preparation before navigation | |
| 345 | +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
| 346 | + // Get the new view controller using [segue destinationViewController]. | |
| 347 | + // Pass the selected object to the new view controller. | |
| 348 | +} | |
| 349 | +*/ | |
| 350 | + | |
| 351 | +@end | ... | ... |
CNLiveCServiceModule/Classes/ViewController/CNLiveServiceVC.h
0 → 100644
CNLiveCServiceModule/Classes/ViewController/CNLiveServiceVC.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveServiceVC.m | |
| 3 | +// CNLiveNewTripartiteManagement | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/11/22. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveServiceVC.h" | |
| 9 | +#import "CNLiveMainSearch.h" | |
| 10 | +#import "CNLiveServiceSearchVC.h" | |
| 11 | +#import "CNLiveServicePresent.h" | |
| 12 | +#import "CNLiveServiceModel.h" | |
| 13 | +#import "CNLiveMyServicesVC.h" | |
| 14 | +#import "CNLiveSearchHeaderView.h" | |
| 15 | +#import "CNLiveGoodsOrVideoHeaderView.h" | |
| 16 | +#import "CNLiveServiceChinasCell.h" | |
| 17 | +#import "CNLiveServiceEpiCell.h" | |
| 18 | +#import "CNLiveServiceLookCell.h" | |
| 19 | +#import "CNLiveRecommendCell.h" | |
| 20 | +#import "CNLiveVideoRecommendCell.h" | |
| 21 | +#import "CNLiveCycleActiveCell.h" | |
| 22 | + | |
| 23 | +static NSString *CNServiceChinaCellID = @"CNLiveServiceChinasCell"; | |
| 24 | +static NSString *CNServiceEpiCellID = @"CNLiveServiceEpiCell"; | |
| 25 | +static NSString *CNServiceLookCellID = @"CNLiveServiceLookCell"; | |
| 26 | +static NSString *CNCycleActiveCellID = @"CNLiveCycleActiveCell"; | |
| 27 | +static NSString *CNRecommendCellID = @"CNLiveRecommendCell"; | |
| 28 | +static NSString *CNServiceheaderID = @"CNLiveSearchHeaderView"; | |
| 29 | +static NSString *CNGoodsOrVideoheaderID = @"CNLiveGoodsOrVideoHeaderView"; | |
| 30 | + | |
| 31 | +@interface CNLiveServiceVC ()<UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> | |
| 32 | +@property (nonatomic, strong) UIImageView *topBackView;//头部背景色 | |
| 33 | +@property (nonatomic, strong) CNLiveMainSearch *searchView;//搜索栏目 | |
| 34 | +@property (nonatomic, strong) NSArray *dataSource;//服务号数据 | |
| 35 | +@property (nonatomic, strong) NSArray *pageListSource; | |
| 36 | +@property (nonatomic, strong) NSArray *hots; | |
| 37 | +@property (nonatomic, strong) UICollectionView *listCollectionView; | |
| 38 | + | |
| 39 | +@end | |
| 40 | + | |
| 41 | +@implementation CNLiveServiceVC | |
| 42 | +- (void)requestService{ | |
| 43 | + if (![CNLiveNetworking isNetworking]) { | |
| 44 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_noNet"] text:@"网络开小差了,刷新试试" detailText:nil buttonTitle:@" 刷新 " buttonAction:@selector(requestService)]; | |
| 45 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 46 | + [self setCNAPIErrorEmptyView]; | |
| 47 | + return; | |
| 48 | + } | |
| 49 | + dispatch_group_t requestGroup = dispatch_group_create(); | |
| 50 | + dispatch_group_enter(requestGroup); | |
| 51 | + weakself | |
| 52 | + [CNLiveServicePresent requestServiceListResult:^(NSArray * _Nonnull dataArray, NSArray * _Nonnull hots) { | |
| 53 | + strongself | |
| 54 | + [self removeEmptyView]; | |
| 55 | + self.dataSource = dataArray; | |
| 56 | + self.hots = hots; | |
| 57 | + dispatch_group_leave(requestGroup); | |
| 58 | + } error:^{ | |
| 59 | + strongself | |
| 60 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_failure"] text:@"加载失败,请点击重试" detailText:nil buttonTitle:@" 重试 " buttonAction:@selector(requestService)]; | |
| 61 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 62 | + [self setCNAPIErrorEmptyView]; | |
| 63 | + dispatch_group_leave(requestGroup); | |
| 64 | + }]; | |
| 65 | + dispatch_group_enter(requestGroup); | |
| 66 | + [CNLiveServicePresent requesrServiceGetPageResult:^(NSArray * _Nonnull dataArray) { | |
| 67 | + weakSelf.pageListSource = dataArray; | |
| 68 | + dispatch_group_leave(requestGroup); | |
| 69 | + } error:^{ | |
| 70 | + | |
| 71 | + strongself | |
| 72 | + [self showEmptyViewWithImage:[UIImage loadBundleImage:@"service_failure"] text:@"加载失败,请点击重试" detailText:nil buttonTitle:@" 重试 " buttonAction:@selector(requestService)]; | |
| 73 | + self.emptyView.frame = CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop); | |
| 74 | + [self setCNAPIErrorEmptyView]; | |
| 75 | + dispatch_group_leave(requestGroup); | |
| 76 | + }]; | |
| 77 | + dispatch_group_notify(requestGroup, dispatch_get_main_queue(), ^{ | |
| 78 | + strongself | |
| 79 | + if (self.dataSource.count>0&&self.pageListSource.count>0) { | |
| 80 | + [self.listCollectionView reloadData]; | |
| 81 | + } | |
| 82 | + | |
| 83 | + }); | |
| 84 | +} | |
| 85 | +-(void)removeEmptyView | |
| 86 | +{ | |
| 87 | + [self.emptyView removeFromSuperview]; | |
| 88 | + self.emptyView = nil; | |
| 89 | +} | |
| 90 | +- (void)viewDidLoad { | |
| 91 | + [super viewDidLoad]; | |
| 92 | + self.view.backgroundColor = [UIColor whiteColor]; | |
| 93 | + [self.view addSubview:self.topBackView]; | |
| 94 | + [self.view sendSubviewToBack:self.topBackView]; | |
| 95 | + [self.view addSubview:self.searchView]; | |
| 96 | + [self.view addSubview:self.listCollectionView]; | |
| 97 | +} | |
| 98 | + | |
| 99 | +- (void)viewWillAppear:(BOOL)animated | |
| 100 | +{ | |
| 101 | + [super viewWillAppear:animated]; | |
| 102 | + self.navigationController.navigationBarHidden = YES; | |
| 103 | + [self requestService]; | |
| 104 | +} | |
| 105 | + | |
| 106 | +- (void)viewWillDisappear:(BOOL)animated | |
| 107 | +{ | |
| 108 | + [super viewWillDisappear:animated]; | |
| 109 | + self.navigationController.navigationBarHidden = NO; | |
| 110 | +} | |
| 111 | +- (void)viewDidLayoutSubviews | |
| 112 | +{ | |
| 113 | + [super viewDidLayoutSubviews]; | |
| 114 | + [self.topBackView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 115 | + make.top.left.right.equalTo(self.view); | |
| 116 | + make.height.offset(159.5 *KScreenHeight / 667); | |
| 117 | + }]; | |
| 118 | + [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 119 | + if (self.mas_topLayoutGuide > 0) { | |
| 120 | + make.top.equalTo(self.mas_topLayoutGuide); | |
| 121 | + }else{ | |
| 122 | + make.top.equalTo(self.view).offset(35.5); | |
| 123 | + } | |
| 124 | + make.left.equalTo(self.view).offset(10); | |
| 125 | + make.right.equalTo(self.view).offset(-10); | |
| 126 | + make.height.offset(36); | |
| 127 | + }]; | |
| 128 | + [self.listCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 129 | + make.top.equalTo(self.searchView.mas_bottom).offset(10); | |
| 130 | + make.left.right.equalTo(self.view); | |
| 131 | + make.bottom.equalTo(self.mas_bottomLayoutGuide); | |
| 132 | + }]; | |
| 133 | +} | |
| 134 | +#pragma mark - Action | |
| 135 | +- (void)seachPushTap | |
| 136 | +{ | |
| 137 | + [CNLiveServiceSearchVC serviceSearchVC:self.hots]; | |
| 138 | +} | |
| 139 | +#pragma mark - UICollectionViewDataSource | |
| 140 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ | |
| 141 | + if (section < self.dataSource.count) { | |
| 142 | + CNLiveSearchHotsModel *model = self.dataSource[section]; | |
| 143 | + return model.lists.count; | |
| 144 | + }else { | |
| 145 | + return 1; | |
| 146 | + } | |
| 147 | + | |
| 148 | +} | |
| 149 | +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ | |
| 150 | + return self.dataSource.count + self.pageListSource.count; | |
| 151 | +} | |
| 152 | +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 153 | + if (indexPath.section < self.dataSource.count) { | |
| 154 | + CNLiveSearchHotsModel *model = self.dataSource[indexPath.section]; | |
| 155 | + CNLiveServiceChinasCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNServiceChinaCellID forIndexPath:indexPath]; | |
| 156 | + cell.model = model.lists[indexPath.row]; | |
| 157 | + return cell; | |
| 158 | + }else{ | |
| 159 | + CNliveServicePageModel *model = self.pageListSource[indexPath.section - self.dataSource.count]; | |
| 160 | + if ([model.blockName isEqualToString:@"疫情服务专区"]){ | |
| 161 | + CNLiveServiceEpiCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNServiceEpiCellID forIndexPath:indexPath]; | |
| 162 | + cell.model = model; | |
| 163 | + return cell; | |
| 164 | + }else if ([model.blockName isEqualToString:@"大家都在用"]){ | |
| 165 | + CNLiveServiceLookCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNServiceLookCellID forIndexPath:indexPath]; | |
| 166 | + cell.model = model; | |
| 167 | + return cell; | |
| 168 | + }else if ([model.blockName isEqualToString:@"轮播"]){ | |
| 169 | + CNLiveCycleActiveCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNCycleActiveCellID forIndexPath:indexPath]; | |
| 170 | + cell.model = model; | |
| 171 | + return cell; | |
| 172 | + } | |
| 173 | + else{ | |
| 174 | + CNLiveRecommendCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CNRecommendCellID forIndexPath:indexPath]; | |
| 175 | + cell.model = model; | |
| 176 | + return cell; | |
| 177 | + } | |
| 178 | + } | |
| 179 | +} | |
| 180 | +- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{ | |
| 181 | + | |
| 182 | + if (indexPath.section < self.dataSource.count) { | |
| 183 | + CNLiveSearchHeaderView *header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:CNServiceheaderID forIndexPath:indexPath]; | |
| 184 | + CNLiveSearchHotsModel *model = self.dataSource[indexPath.section]; | |
| 185 | + header.type = CNServiceHeaderTypeService; | |
| 186 | + header.model = model.lists[indexPath.row]; | |
| 187 | + return header; | |
| 188 | + }else{ | |
| 189 | + CNLiveGoodsOrVideoHeaderView *header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:CNGoodsOrVideoheaderID forIndexPath:indexPath]; | |
| 190 | + CNliveServicePageModel *model = self.pageListSource[indexPath.section - self.dataSource.count]; | |
| 191 | + header.pageModel = model; | |
| 192 | + return header; | |
| 193 | + } | |
| 194 | + | |
| 195 | +} | |
| 196 | +#pragma mark - UICollectionViewDelegateFlowLayout | |
| 197 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
| 198 | + if (indexPath.section < self.dataSource.count) { | |
| 199 | + CNLiveSearchHotsModel *model = self.dataSource[indexPath.section]; | |
| 200 | + return CGSizeMake(collectionView.width, model.cellHeight); | |
| 201 | + }else{ | |
| 202 | + CNliveServicePageModel *model = self.pageListSource[indexPath.section - self.dataSource.count]; | |
| 203 | + return CGSizeMake(collectionView.width, model.cellHeight); | |
| 204 | + } | |
| 205 | + | |
| 206 | +} | |
| 207 | +- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ | |
| 208 | + return UIEdgeInsetsMake(0, 0, 10, 0); | |
| 209 | +} | |
| 210 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{ | |
| 211 | + if (section < self.dataSource.count) { | |
| 212 | + CNLiveSearchHotsModel *model = self.dataSource[section]; | |
| 213 | + if ([model.title isEqualToString:@""]) { | |
| 214 | + return CGSizeMake(0, 0); | |
| 215 | + } | |
| 216 | + }else { | |
| 217 | + CNliveServicePageModel *model = self.pageListSource[section - self.dataSource.count]; | |
| 218 | + if ([model.blockName isEqualToString:@"轮播"] ||[model.blockName isEqualToString:@"疫情服务专区"]||[model.blockName isEqualToString:@"大家都在用"]) { | |
| 219 | + return CGSizeMake(0, 0); | |
| 220 | + } | |
| 221 | + } | |
| 222 | + | |
| 223 | + return CGSizeMake(collectionView.width, 40); | |
| 224 | +} | |
| 225 | +#pragma mark - Setting&&Getting | |
| 226 | + | |
| 227 | +- (UIImageView *)topBackView | |
| 228 | +{ | |
| 229 | + if (!_topBackView) { | |
| 230 | + _topBackView = [[UIImageView alloc] init]; | |
| 231 | + [_topBackView setImage:[UIImage loadBundleImage:@"service_top"]]; | |
| 232 | + | |
| 233 | + } | |
| 234 | + return _topBackView; | |
| 235 | +} | |
| 236 | +- (CNLiveMainSearch *)searchView | |
| 237 | +{ | |
| 238 | + if (!_searchView) { | |
| 239 | + _searchView = [[CNLiveMainSearch alloc] initWithType:CNSearchViewShowTypePush]; | |
| 240 | + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(seachPushTap)]; | |
| 241 | + [_searchView addGestureRecognizer:tap]; | |
| 242 | + } | |
| 243 | + return _searchView; | |
| 244 | +} | |
| 245 | +- (UICollectionView *)listCollectionView | |
| 246 | +{ | |
| 247 | + if (!_listCollectionView) { | |
| 248 | + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 249 | + layout.sectionFootersPinToVisibleBounds = YES; | |
| 250 | + layout.sectionHeadersPinToVisibleBounds = YES; | |
| 251 | + _listCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; | |
| 252 | + _listCollectionView.backgroundColor = kWhiteColor; | |
| 253 | + _listCollectionView.collectionViewLayout = layout; | |
| 254 | + _listCollectionView.delegate = self; | |
| 255 | + _listCollectionView.dataSource = self; | |
| 256 | + _listCollectionView.backgroundColor = kClearColor; | |
| 257 | + _listCollectionView.showsVerticalScrollIndicator = NO; | |
| 258 | + [_listCollectionView registerClass:[CNLiveServiceChinasCell class] forCellWithReuseIdentifier:CNServiceChinaCellID]; | |
| 259 | + [_listCollectionView registerClass:[CNLiveServiceEpiCell class] forCellWithReuseIdentifier:CNServiceEpiCellID]; | |
| 260 | + [_listCollectionView registerClass:[CNLiveServiceLookCell class] forCellWithReuseIdentifier:CNServiceLookCellID]; | |
| 261 | + [_listCollectionView registerClass:[CNLiveCycleActiveCell class] forCellWithReuseIdentifier:CNCycleActiveCellID]; | |
| 262 | + [_listCollectionView registerClass:[CNLiveRecommendCell class] forCellWithReuseIdentifier:CNRecommendCellID]; | |
| 263 | + [_listCollectionView registerClass:[CNLiveSearchHeaderView class] forSupplementaryViewOfKind:@"UICollectionElementKindSectionHeader" withReuseIdentifier:CNServiceheaderID]; | |
| 264 | + [_listCollectionView registerClass:[CNLiveGoodsOrVideoHeaderView class] forSupplementaryViewOfKind:@"UICollectionElementKindSectionHeader" withReuseIdentifier:CNGoodsOrVideoheaderID]; | |
| 265 | + } | |
| 266 | + return _listCollectionView; | |
| 267 | +} | |
| 268 | +/* | |
| 269 | +#pragma mark - Navigation | |
| 270 | + | |
| 271 | +// In a storyboard-based application, you will often want to do a little preparation before navigation | |
| 272 | +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
| 273 | + // Get the new view controller using [segue destinationViewController]. | |
| 274 | + // Pass the selected object to the new view controller. | |
| 275 | +} | |
| 276 | +*/ | |
| 277 | + | |
| 278 | +@end | ... | ... |
Example/CNLiveCServiceModule.xcodeproj/project.pbxproj
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | objects = { |
| 8 | 8 | |
| 9 | 9 | /* Begin PBXBuildFile section */ |
| 10 | + 08FF464C27586919001A767D /* CNLiveCServiceModuleImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FF464A27586918001A767D /* CNLiveCServiceModuleImpl.m */; }; | |
| 10 | 11 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; |
| 11 | 12 | 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; }; |
| 12 | 13 | 6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; |
| ... | ... | @@ -37,6 +38,8 @@ |
| 37 | 38 | /* End PBXContainerItemProxy section */ |
| 38 | 39 | |
| 39 | 40 | /* Begin PBXFileReference section */ |
| 41 | + 08FF464927586918001A767D /* Base */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Base; path = Base.lproj/CNLiveCServiceModuleImpl.h; sourceTree = "<group>"; }; | |
| 42 | + 08FF464B27586918001A767D /* Base */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Base; path = Base.lproj/CNLiveCServiceModuleImpl.m; sourceTree = "<group>"; }; | |
| 40 | 43 | 24FCDF117E18830B2795CC8A /* Pods_CNLiveCServiceModule_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CNLiveCServiceModule_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; |
| 41 | 44 | 2ABB53829768F83F1D995005 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; }; |
| 42 | 45 | 6003F58A195388D20070C39A /* CNLiveCServiceModule_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CNLiveCServiceModule_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; |
| ... | ... | @@ -95,6 +98,15 @@ |
| 95 | 98 | /* End PBXFrameworksBuildPhase section */ |
| 96 | 99 | |
| 97 | 100 | /* Begin PBXGroup section */ |
| 101 | + 08FF464727586356001A767D /* CNLIveCServiceModule */ = { | |
| 102 | + isa = PBXGroup; | |
| 103 | + children = ( | |
| 104 | + 08FF464827586918001A767D /* CNLiveCServiceModuleImpl.h */, | |
| 105 | + 08FF464A27586918001A767D /* CNLiveCServiceModuleImpl.m */, | |
| 106 | + ); | |
| 107 | + name = CNLIveCServiceModule; | |
| 108 | + sourceTree = "<group>"; | |
| 109 | + }; | |
| 98 | 110 | 5B5244BA99F3C5C09F2D42F0 /* Pods */ = { |
| 99 | 111 | isa = PBXGroup; |
| 100 | 112 | children = ( |
| ... | ... | @@ -143,6 +155,7 @@ |
| 143 | 155 | 6003F593195388D20070C39A /* Example for CNLiveCServiceModule */ = { |
| 144 | 156 | isa = PBXGroup; |
| 145 | 157 | children = ( |
| 158 | + 08FF464727586356001A767D /* CNLIveCServiceModule */, | |
| 146 | 159 | 6003F59C195388D20070C39A /* CNLIVEAppDelegate.h */, |
| 147 | 160 | 6003F59D195388D20070C39A /* CNLIVEAppDelegate.m */, |
| 148 | 161 | 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */, |
| ... | ... | @@ -328,11 +341,45 @@ |
| 328 | 341 | ); |
| 329 | 342 | inputPaths = ( |
| 330 | 343 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveCServiceModule_Example/Pods-CNLiveCServiceModule_Example-frameworks.sh", |
| 344 | + "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", | |
| 345 | + "${BUILT_PRODUCTS_DIR}/CNLiveBaseKit/CNLiveBaseKit.framework", | |
| 346 | + "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework", | |
| 347 | + "${BUILT_PRODUCTS_DIR}/CNLiveBusinessBaseModule/CNLiveBusinessBaseModule.framework", | |
| 331 | 348 | "${BUILT_PRODUCTS_DIR}/CNLiveCServiceModule/CNLiveCServiceModule.framework", |
| 349 | + "${BUILT_PRODUCTS_DIR}/CNLiveCategory/CNLiveCategory.framework", | |
| 350 | + "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework", | |
| 351 | + "${BUILT_PRODUCTS_DIR}/CNLiveCustomControl/CNLiveCustomControl.framework", | |
| 352 | + "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", | |
| 353 | + "${BUILT_PRODUCTS_DIR}/CNLiveNewTripartiteManagement/CNLiveNewTripartiteManagement.framework", | |
| 354 | + "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", | |
| 355 | + "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework", | |
| 356 | + "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework", | |
| 357 | + "${BUILT_PRODUCTS_DIR}/MJRefresh/MJRefresh.framework", | |
| 358 | + "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", | |
| 359 | + "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", | |
| 360 | + "${BUILT_PRODUCTS_DIR}/SDCycleScrollView/SDCycleScrollView.framework", | |
| 361 | + "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", | |
| 332 | 362 | ); |
| 333 | 363 | name = "[CP] Embed Pods Frameworks"; |
| 334 | 364 | outputPaths = ( |
| 365 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", | |
| 366 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseKit.framework", | |
| 367 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework", | |
| 368 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBusinessBaseModule.framework", | |
| 335 | 369 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCServiceModule.framework", |
| 370 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCategory.framework", | |
| 371 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework", | |
| 372 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCustomControl.framework", | |
| 373 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", | |
| 374 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveNewTripartiteManagement.framework", | |
| 375 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", | |
| 376 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework", | |
| 377 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework", | |
| 378 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJRefresh.framework", | |
| 379 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", | |
| 380 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", | |
| 381 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDCycleScrollView.framework", | |
| 382 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", | |
| 336 | 383 | ); |
| 337 | 384 | runOnlyForDeploymentPostprocessing = 0; |
| 338 | 385 | shellPath = /bin/sh; |
| ... | ... | @@ -370,6 +417,7 @@ |
| 370 | 417 | files = ( |
| 371 | 418 | 6003F59E195388D20070C39A /* CNLIVEAppDelegate.m in Sources */, |
| 372 | 419 | 6003F5A7195388D20070C39A /* CNLIVEViewController.m in Sources */, |
| 420 | + 08FF464C27586919001A767D /* CNLiveCServiceModuleImpl.m in Sources */, | |
| 373 | 421 | 6003F59A195388D20070C39A /* main.m in Sources */, |
| 374 | 422 | ); |
| 375 | 423 | runOnlyForDeploymentPostprocessing = 0; |
| ... | ... | @@ -393,6 +441,22 @@ |
| 393 | 441 | /* End PBXTargetDependency section */ |
| 394 | 442 | |
| 395 | 443 | /* Begin PBXVariantGroup section */ |
| 444 | + 08FF464827586918001A767D /* CNLiveCServiceModuleImpl.h */ = { | |
| 445 | + isa = PBXVariantGroup; | |
| 446 | + children = ( | |
| 447 | + 08FF464927586918001A767D /* Base */, | |
| 448 | + ); | |
| 449 | + name = CNLiveCServiceModuleImpl.h; | |
| 450 | + sourceTree = "<group>"; | |
| 451 | + }; | |
| 452 | + 08FF464A27586918001A767D /* CNLiveCServiceModuleImpl.m */ = { | |
| 453 | + isa = PBXVariantGroup; | |
| 454 | + children = ( | |
| 455 | + 08FF464B27586918001A767D /* Base */, | |
| 456 | + ); | |
| 457 | + name = CNLiveCServiceModuleImpl.m; | |
| 458 | + sourceTree = "<group>"; | |
| 459 | + }; | |
| 396 | 460 | 6003F596195388D20070C39A /* InfoPlist.strings */ = { |
| 397 | 461 | isa = PBXVariantGroup; |
| 398 | 462 | children = ( | ... | ... |
Example/CNLiveCServiceModule/Base.lproj/CNLiveCServiceModuleImpl.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveCServiceModuleImpl.h | |
| 3 | +// CNLiveCServiceModule_Example | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/12/2. | |
| 6 | +// Copyright © 2021 杨苓玉. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <Foundation/Foundation.h> | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveCServiceModuleImpl : NSObject | |
| 14 | + | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
Example/CNLiveCServiceModule/Base.lproj/CNLiveCServiceModuleImpl.m
0 → 100644
Example/CNLiveCServiceModule/CNLIVEAppDelegate.h
| ... | ... | @@ -7,9 +7,8 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | @import UIKit; |
| 10 | +#import <CNLiveBusinessBaseModule/CNLiveBusinessBaseModule.h> | |
| 10 | 11 | |
| 11 | -@interface CNLIVEAppDelegate : UIResponder <UIApplicationDelegate> | |
| 12 | - | |
| 13 | -@property (strong, nonatomic) UIWindow *window; | |
| 12 | +@interface CNLIVEAppDelegate : BaseAppDelegate <UIApplicationDelegate> | |
| 14 | 13 | |
| 15 | 14 | @end | ... | ... |
Example/CNLiveCServiceModule/CNLIVEAppDelegate.m
| ... | ... | @@ -7,12 +7,19 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import "CNLIVEAppDelegate.h" |
| 10 | +#import <CNLiveCServiceModule/CNLiveServiceVC.h> | |
| 11 | +#import <CNLiveUserManagement/CNUserInfoManager.h> | |
| 12 | + | |
| 10 | 13 | |
| 11 | 14 | @implementation CNLIVEAppDelegate |
| 12 | 15 | |
| 13 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions |
| 14 | 17 | { |
| 15 | - // Override point for customization after application launch. | |
| 18 | + CNLiveServiceVC *vc = [[CNLiveServiceVC alloc] init]; | |
| 19 | + CNUserShareModel.uid = @"1000057899"; | |
| 20 | + UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; | |
| 21 | + self.window.rootViewController = nav; | |
| 22 | + [self.window makeKeyAndVisible]; | |
| 16 | 23 | return YES; |
| 17 | 24 | } |
| 18 | 25 | ... | ... |
Example/CNLiveCServiceModule/CNLiveCServiceModule-Info.plist
| ... | ... | @@ -2,6 +2,11 @@ |
| 2 | 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 3 | 3 | <plist version="1.0"> |
| 4 | 4 | <dict> |
| 5 | + <key>NSAppTransportSecurity</key> | |
| 6 | + <dict> | |
| 7 | + <key>NSAllowsArbitraryLoads</key> | |
| 8 | + <true/> | |
| 9 | + </dict> | |
| 5 | 10 | <key>CFBundleDevelopmentRegion</key> |
| 6 | 11 | <string>en</string> |
| 7 | 12 | <key>CFBundleDisplayName</key> | ... | ... |
Example/CNLiveCServiceModule/main.m
| ... | ... | @@ -8,10 +8,12 @@ |
| 8 | 8 | |
| 9 | 9 | @import UIKit; |
| 10 | 10 | #import "CNLIVEAppDelegate.h" |
| 11 | +#import <CNLiveEnvironment/CNLiveEnvironmentManager.h> | |
| 11 | 12 | |
| 12 | 13 | int main(int argc, char * argv[]) |
| 13 | 14 | { |
| 14 | 15 | @autoreleasepool { |
| 16 | + [CNLiveEnvironmentManager setEnvironment:CNLiveDebugAppStore]; | |
| 15 | 17 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([CNLIVEAppDelegate class])); |
| 16 | 18 | } |
| 17 | 19 | } | ... | ... |
Example/Podfile
| 1 | 1 | use_frameworks! |
| 2 | 2 | |
| 3 | -platform :ios, '9.0' | |
| 4 | - | |
| 3 | +platform :ios, '10.0' | |
| 4 | +source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git' | |
| 5 | +source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git' | |
| 6 | +source 'http://bj.gitlab.cnlive.com/DSIOSTeam/DSSpecRepos.git' | |
| 5 | 7 | target 'CNLiveCServiceModule_Example' do |
| 6 | 8 | pod 'CNLiveCServiceModule', :path => '../' |
| 7 | 9 | ... | ... |