YOUPAILZLiveVC.m 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. //
  2. // YOUPAILZLiveVC.m
  3. // TIANYAN
  4. //
  5. // Created by CY on 2021/5/19.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZLiveVC.h"
  9. #import "YOUPAILZLiveListVC.h"
  10. #import "LZAlertWindow.h"
  11. #import "UIViewController+TFPresent.h"
  12. #import "YOUPAILZLiveAnchorVC.h"
  13. #import "YOUPAILZLiveVerifyResultVC.h"
  14. #import "YOUPAILZVerifyPhoneWindow.h"
  15. //#import <RPSDK/RPSDK.h>
  16. #import "YOUPAILZLiveCategoryModel.h"
  17. #import "JXCategoryView.h"
  18. #import "JXCategoryListContainerView.h"
  19. #import "YOUPAILCBoardVC.h"
  20. #import "TYCyclePagerView.h"
  21. #import "TYPageControl.h"
  22. #import "YOUPAILZHomeBannerCell.h"
  23. #import "JXPagerListRefreshView.h"
  24. #import "YOUPAILCBannerModel.h"
  25. #define LZCategoryViewHeight 54.0f
  26. #define LZCategoryViewItemWidth 64.0f
  27. #define LZHeaderViewHeigth ScaleSize(98.0f)
  28. @interface YOUPAILZLiveVC ()<JXCategoryViewDelegate,TYCyclePagerViewDataSource, TYCyclePagerViewDelegate,JXPagerMainTableViewGestureDelegate,JXPagerViewDelegate>
  29. //<LZScrollViewDisScrollDelegate,UIScrollViewDelegate,ZCNavMenuViewDelegate>
  30. //@property(nonatomic,strong)UIView* youpaipnavBaseView;
  31. //@property(nonatomic,strong)ZCNavMenuView* youpaipnavView;
  32. //
  33. //@property(nonatomic,strong)UIScrollView* scrollView;
  34. //
  35. //@property (nonatomic,assign) CGFloat youpaiplastContentOffset;
  36. //
  37. //@property (nonatomic,strong) NSArray <YOUPAILZLiveListVC *>*youpaipliveListControllers;
  38. //
  39. //@property (nonatomic,assign) NSInteger currentControllerIndex;
  40. @property (nonatomic, strong) NSArray <YOUPAILZLiveCategoryModel *> *youpaipcategorys;
  41. @property (nonatomic, strong) JXPagerListRefreshView *youpaippagerView;
  42. @property (nonatomic, strong) JXCategoryTitleView *youpaipcategoryView;
  43. @property (nonatomic, strong) UIView *youpaipcategoryBgV;
  44. /* youpaipstartLiveBtn */
  45. @property (strong, nonatomic) UIButton *youpaipstartLiveBtn;
  46. @property (nonatomic, strong) TYCyclePagerView* youpaipbannerView;
  47. /* pageControl */
  48. @property (strong, nonatomic) TYPageControl *youpaippageControl;
  49. @property (nonatomic, strong) NSArray <YOUPAILCBannerModel *> *youpaipbannerArray;
  50. /* imageURLStringsGroup */
  51. @property (strong, nonatomic) NSMutableArray *youpaipimageURLStringsGroup;
  52. @end
  53. @implementation YOUPAILZLiveVC
  54. //- (NSArray<YOUPAILZLiveListVC *> *)youpaipliveListControllers{
  55. // if (!_youpaipliveListControllers) {
  56. //
  57. // NSArray *dataSource = @[
  58. // @{@"title":@"推荐",@"type":@(1)},
  59. // @{@"title":@"热门",@"type":@(2)},
  60. // @{@"title":@"摘星站",@"type":@(3)},
  61. // @{@"title":@"新秀",@"type":@(4)},
  62. // ];
  63. //
  64. // NSMutableArray <YOUPAILZLiveListVC *>*vcs = [NSMutableArray array];
  65. // for (NSDictionary *dict in dataSource) {
  66. // YOUPAILZLiveListVC *vc = [[YOUPAILZLiveListVC alloc]init];
  67. // vc.title = [dict valueForKey:@"title"];
  68. // vc.scrollDelegate = self;
  69. // vc.type = [[dict valueForKey:@"type"] integerValue];
  70. // [self addChildViewController:vc];
  71. // [vcs addObject:vc];
  72. // }
  73. // _youpaipliveListControllers = vcs.copy;
  74. // }
  75. // return _youpaipliveListControllers;
  76. //}
  77. //
  78. //- (UIScrollView *)scrollView{
  79. // if (!_scrollView) {
  80. // _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,NavBarHeight, KScreenWidth, KScreenHeight-TabbarHeight-NavBarHeight)];
  81. // _scrollView.scrollEnabled = YES;
  82. // _scrollView.pagingEnabled = YES;
  83. // _scrollView.bounces = NO;
  84. // _scrollView.delegate = self;
  85. // _scrollView.showsVerticalScrollIndicator = NO;
  86. // _scrollView.showsHorizontalScrollIndicator = NO;
  87. // }
  88. // return _scrollView;
  89. //}
  90. //- (void)viewWillAppear:(BOOL)animated{
  91. // [super viewWillAppear:animated];
  92. // [self show];
  93. //}
  94. //- (void)viewWillDisappear:(BOOL)animated{
  95. // [super viewWillDisappear:animated];
  96. // [self show];
  97. //}
  98. - (void)viewWillAppear:(BOOL)animated{
  99. [super viewWillAppear:animated];
  100. [self.navigationController setNavigationBarHidden:YES animated:animated];
  101. }
  102. - (void)viewWillDisappear:(BOOL)animated{
  103. [super viewWillDisappear:animated];
  104. [self.navigationController setNavigationBarHidden:NO animated:animated];
  105. }
  106. - (void)viewDidLoad {
  107. [super viewDidLoad];
  108. // self.currentControllerIndex = 0;
  109. // if ([LCSaveModel getUserModel].userinfo.is_anchor == 1) {
  110. // self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(startLiveClick) image:[UIImage imageNamed:@"vqu_images_L_live"]];
  111. // }
  112. //
  113. // [self setupScrollView];
  114. // [self setupNavigationView];
  115. // /// 线上版本状态改变,接收通知
  116. //// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onlineVersionNotification) name:@"OnlineVersion" object:nil];
  117. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaiftoTopAction) name:@"videoToTop" object:nil];//置顶
  118. // [self youpaifinitUI];
  119. dispatch_group_t group = dispatch_group_create();
  120. dispatch_group_enter(group);
  121. dispatch_group_async(group, dispatch_get_main_queue(), ^{
  122. NSLog(@"%@---获取 余额",[NSThread currentThread]);
  123. // 获取余额
  124. [self youpaifrequestBannerData:^{
  125. dispatch_group_leave(group);
  126. }];
  127. });
  128. dispatch_group_notify(group, dispatch_get_main_queue(), ^{
  129. NSLog(@"%@---全部结束。。。",[NSThread currentThread]);
  130. [self youpaifrequestCategoryListData];
  131. });
  132. [self youpaifinitConfig];
  133. }
  134. - (void)youpaifinitUI{
  135. TYCyclePagerView *youpaipbannerView = [[TYCyclePagerView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth,LZHeaderViewHeigth)];
  136. youpaipbannerView.isInfiniteLoop = YES;
  137. youpaipbannerView.autoScrollInterval = 6.0;
  138. youpaipbannerView.dataSource = self;
  139. youpaipbannerView.delegate = self;
  140. [youpaipbannerView registerClass:[YOUPAILZHomeBannerCell class] forCellWithReuseIdentifier:@"cellId"];
  141. self.youpaipbannerView = youpaipbannerView;
  142. youpaipbannerView.backgroundColor = LCBkgColor;
  143. NSMutableArray *imgUrlArray = [NSMutableArray array];
  144. for (YOUPAILCBannerModel* model in self.youpaipbannerArray) {
  145. [imgUrlArray addObject:[LCTools getImageUrlWithAddress:model.youpaipimage]];
  146. }
  147. self.youpaipimageURLStringsGroup = imgUrlArray;
  148. self.youpaippageControl.numberOfPages = imgUrlArray.count;
  149. TYPageControl *pageControl = [[TYPageControl alloc]initWithFrame:CGRectMake(0, CGRectGetHeight(_youpaipbannerView.frame) - 26, CGRectGetWidth(_youpaipbannerView.frame), 26)];
  150. //pageControl.numberOfPages = _datas.count;
  151. pageControl.currentPageIndicatorSize = CGSizeMake(6, 6);
  152. pageControl.pageIndicatorSize = CGSizeMake(6, 6);
  153. // pageControl.currentPageIndicatorTintColor = [UIColor redColor];
  154. // pageControl.pageIndicatorTintColor = [UIColor grayColor];
  155. pageControl.pageIndicatorImage = [UIImage imageNamed:@"vqu_images_H_home_page_n"];
  156. pageControl.currentPageIndicatorImage = [UIImage imageNamed:@"vqu_images_H_home_page_s"];
  157. pageControl.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
  158. pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  159. pageControl.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
  160. pageControl.pageIndicatorSpaing = 1;
  161. [youpaipbannerView addSubview:pageControl];
  162. self.youpaippageControl = pageControl;
  163. UIView *youpaipcategoryBgV = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, KScreenWidth, LZCategoryViewHeight)];
  164. youpaipcategoryBgV.backgroundColor = LCBkgColor;
  165. self.youpaipcategoryBgV = youpaipcategoryBgV;
  166. CGFloat categoryViewWidth = KScreenWidth - 16.0f;
  167. if ([LCSaveModel getUserModel].youpaipuserinfo.youpaipis_anchor == 1 && [LCSaveData getIsLive] != 2) {
  168. UIButton *youpaipstartLiveBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth - 16 - 24,(LZCategoryViewHeight - 24) / 2.0f,24,24)];
  169. self.youpaipstartLiveBtn = youpaipstartLiveBtn;
  170. [youpaipstartLiveBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_play"] forState:(UIControlStateNormal)];
  171. [youpaipstartLiveBtn addTarget:self action:@selector(youpaifstartLiveClick) forControlEvents:(UIControlEventTouchUpInside)];
  172. [youpaipcategoryBgV addSubview:youpaipstartLiveBtn];
  173. categoryViewWidth-=24;
  174. }
  175. // UIButton *rankBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  176. // [rankBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_rank_play"] forState:UIControlStateNormal];
  177. // rankBtn.frame = CGRectMake(categoryViewWidth - 24.0f - 10.0f, (LZCategoryViewHeight - 24) / 2.0f, 24.0f, 24.0f);
  178. // [rankBtn addTarget:self action:@selector(youpaifrankBtnClick) forControlEvents:UIControlEventTouchUpInside];
  179. // [youpaipcategoryBgV addSubview:rankBtn];
  180. // categoryViewWidth = rankBtn.mj_x - 16.0f;
  181. //
  182. // [rankBtn addTarget:self action:@selector(youpaifrankBtnClick) forControlEvents:UIControlEventTouchUpInside];
  183. //
  184. JXCategoryTitleView *youpaipcategoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, categoryViewWidth, LZCategoryViewHeight)];
  185. NSMutableArray <NSString *>*titles = [NSMutableArray array];
  186. for (YOUPAILZLiveCategoryModel *model in self.youpaipcategorys) {
  187. [titles addObject:model.youpaiptitle];
  188. }
  189. youpaipcategoryView.backgroundColor = LCBkgColor;
  190. youpaipcategoryView.titles = titles.copy;
  191. youpaipcategoryView.delegate = self;
  192. youpaipcategoryView.titleSelectedColor = HexColorFromRGB(0xF4003F);
  193. youpaipcategoryView.titleColor = HexColorFromRGB(0x6C6B70);
  194. youpaipcategoryView.titleColorGradientEnabled = YES;
  195. youpaipcategoryView.titleFont = LCFont(18.0f);
  196. youpaipcategoryView.titleSelectedFont = LCBoldFont(18.0f);
  197. youpaipcategoryView.cellWidth = LZCategoryViewItemWidth;
  198. youpaipcategoryView.cellSpacing = 0.0f;
  199. youpaipcategoryView.averageCellSpacingEnabled = NO;
  200. [youpaipcategoryBgV addSubview:youpaipcategoryView];
  201. self.youpaipcategoryView = youpaipcategoryView;
  202. JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
  203. lineView.verticalMargin = 6.0f;
  204. lineView.indicatorHeight = 2.5f;
  205. lineView.indicatorWidth = 8;
  206. lineView.layer.cornerRadius = 1.25;
  207. lineView.layer.masksToBounds = YES;
  208. [lineView.layer addSublayer:[LCTools getGradientLayerWithSize:CGSizeMake(lineView.indicatorWidth, lineView.indicatorHeight) twoColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] gradientType:GradientLeftToRight]];
  209. youpaipcategoryView.indicators = @[lineView];
  210. JXPagerListRefreshView *pagerView = [[JXPagerListRefreshView alloc] initWithDelegate:self listContainerType:JXPagerListContainerType_CollectionView];
  211. pagerView.mainTableView.gestureDelegate = self;
  212. [self.view addSubview:pagerView];
  213. self.youpaippagerView = pagerView;
  214. self.youpaippagerView.frame = CGRectMake(0, StatusBarHeight, KScreenWidth, KScreenHeight-(TabbarHeight + StatusBarHeight));
  215. youpaipcategoryView.listContainer = (id<JXCategoryViewListContainer>)self.youpaippagerView.listContainerView;
  216. // UIButton *rankBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  217. // [rankBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_H_home_rank"] forState:UIControlStateNormal];
  218. // rankBtn.frame = CGRectMake(KScreenWidth - 10.0f - 62.0f, KScreenHeight - 21.0f - 26.0f - TabbarHeight, 62.0f, 26.0f);
  219. // [rankBtn addTarget:self action:@selector(youpaifrankBtnClick) forControlEvents:UIControlEventTouchUpInside];
  220. // [self.view addSubview:rankBtn];
  221. //
  222. // UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifhandlePan:)];
  223. // [rankBtn addGestureRecognizer:panGestureRecognizer];
  224. }
  225. /// 获取banner数据
  226. - (void)youpaifrequestBannerData:(void(^)(void))complete{
  227. WeakSelf;
  228. [LCHttpHelper requestWithURLString:HomeBanner parameters:@{@"cate_id":@"2"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  229. NSDictionary* dict = (NSDictionary*)responseObject;
  230. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  231. if (code==0) {//成功
  232. weakSelf.youpaipbannerArray = [YOUPAILCBannerModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"banner"]];
  233. if (complete) {
  234. complete();
  235. }
  236. }
  237. } failure:^(NSError *error) {
  238. }];
  239. }
  240. - (void)youpaifstartLiveClick{
  241. WeakSelf;
  242. [LCHttpHelper requestWithURLString:BindInit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  243. NSDictionary* dict = (NSDictionary*)responseObject;
  244. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  245. if (code==0) {//成功
  246. NSString *mobile = [[dict objectForKey:@"data"]objectForKey:@"mobile"];
  247. if (mobile.length != 0) {
  248. [weakSelf youpaifverifyOfCertificationAnchor];
  249. }else{
  250. YOUPAILZVerifyPhoneWindow *vc= [[YOUPAILZVerifyPhoneWindow alloc]init];
  251. vc.isTouchDismiss = YES;
  252. [vc setBlock:^(NSString * _Nonnull phone) {
  253. [weakSelf youpaifverifyOfCertificationAnchor];
  254. }];
  255. [weakSelf TFPresentVC:vc completion:^{}];
  256. }
  257. }else{
  258. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  259. }
  260. } failure:^(NSError *error) {
  261. [ZCHUDHelper showTitle:error.localizedDescription];
  262. }];
  263. }
  264. - (void)youpaifverifyOfCertificationAnchor{
  265. WeakSelf;
  266. [LCHttpHelper requestWithURLString:StatusLive parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  267. NSDictionary* dict = (NSDictionary*)responseObject;
  268. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  269. if (code == 0) {
  270. NSInteger live_status = [[[dict objectForKey:@"data"] objectForKey:@"live_status"] integerValue]; // 认证状态 1未认证 2已认证
  271. if (live_status == 1) {
  272. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
  273. }];
  274. cancelAction.cornerRadius = 24.0f;
  275. cancelAction.bgColor = HexColorFromRGB(0x9F9DA5);
  276. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"去认证" handler:^(LZAlertAction *action) {
  277. [weakSelf youpaifrealNameAuthentication];
  278. }];
  279. confimAction.cornerRadius = 24.0f;
  280. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]];
  281. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"您还未实名认证,需认证后才能开启直播!" action:@[cancelAction,confimAction]];
  282. [weakSelf TFPresentVC:alert completion:^{}];
  283. }else if(live_status == 3){
  284. YOUPAILZLiveVerifyResultVC *vc = [[YOUPAILZLiveVerifyResultVC alloc] init];
  285. vc.youpaipstate = LZLiveVerifyStateWithInReview;
  286. vc.youpaipcontent_str = [dict objectForKey:@"message"];
  287. [weakSelf.navigationController pushViewController:vc animated:YES];
  288. }else if(live_status == 2){
  289. [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
  290. YOUPAILZLiveAnchorVC *anchorVC = [[YOUPAILZLiveAnchorVC alloc] init];
  291. anchorVC.youpaipshareModel = [YOUPAILZLiveShareModel mj_objectWithKeyValues:[[dict objectForKey:@"data"] objectForKey:@"share"]];
  292. anchorVC.youpaipcover = [[dict objectForKey:@"data"] objectForKey:@"cover"];
  293. [weakSelf.navigationController pushViewController:anchorVC animated:YES];
  294. }
  295. }else{
  296. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  297. }
  298. } failure:^(NSError *error) {
  299. [ZCHUDHelper showTitle:error.localizedDescription];
  300. }];
  301. }
  302. /// 阿里实名认证
  303. - (void)youpaifrealNameAuthentication{
  304. [UCAuthorityManager cameraAuthority:^{
  305. YMCustomCameraViewModel *customCameraVM = [[YMCustomCameraViewModel alloc]initWithParams:@{}];
  306. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_CUSTOM_CAMERA) withUserInfo:@{
  307. RouterViewModel:customCameraVM
  308. } completion:nil];
  309. } denied:^{
  310. YMTipsPopupView *customView = [[YMTipsPopupView alloc]init];
  311. [customView configutationWithTips:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" TipsAlignment:NSTextAlignmentCenter IsHideTitle:NO IsHideSingleButton:NO];
  312. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:[YMGlobalUtils getCurrentVC].view popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
  313. popupView.priority = 999;
  314. popupView.cornerRadius = adapt(10);
  315. popupView.rectCorners = UIRectCornerAllCorners;
  316. popupView.positionStyle = YMPositionStyleCenter;
  317. popupView.isHideBg = NO;
  318. popupView.bgAlpha = 0.3;
  319. @weakify(popupView)
  320. customView.buttonBlock = ^(BOOL isConfirm) {
  321. @strongify(popupView)
  322. if (isConfirm) {
  323. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
  324. }
  325. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  326. };
  327. [popupView pop];
  328. }];
  329. // WeakSelf;
  330. // [LCHttpHelper requestWithURLString:GetLiveVerifyToken parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  331. // NSDictionary* dict = (NSDictionary*)responseObject;
  332. // NSInteger code = [[dict objectForKey:@"code"] integerValue];
  333. // if (code == 0) {
  334. // NSString *token = dict[@"data"][@"VerifyToken"];
  335. // NSString *BizId = dict[@"data"][@"BizId"];
  336. // [weakSelf youpaifpushToAliSdk:token BizId:BizId];
  337. //
  338. // }else{
  339. //
  340. // [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  341. // }
  342. //
  343. //
  344. //
  345. // } failure:^(NSError *error) {
  346. // [ZCHUDHelper showTitle:error.localizedDescription];
  347. //
  348. // }];
  349. //
  350. }
  351. -(void)youpaifpushToAliSdk:(NSString*)token BizId:(NSString*)bizIdStr{
  352. // RPConfiguration *configuration = [RPConfiguration configuration];
  353. // NSString *filePath1 = [[NSBundle mainBundle] pathForResource:@"RPCustomUI" ofType:@"bundle"];
  354. // configuration.customUIPath = filePath1;
  355. // [RPSDK startWithVerifyToken:token viewController:self configuration:configuration completion:^(RPResult * _Nonnull result) {
  356. //
  357. // NSLog(@"实人认证结果:%@==%@", result,result.message);
  358. // switch (result.state) {
  359. // case RPStatePass:
  360. // // 认证通过。
  361. // [self youpaifpostBizId:bizIdStr];
  362. // break;
  363. // case RPStateFail:
  364. // // 认证不通过。
  365. // break;
  366. // case RPStateNotVerify:
  367. // // 未认证。
  368. // // 通常是用户主动退出或者姓名身份证号实名校验不匹配等原因导致。
  369. // // 具体原因可通过result.errorCode来区分(详见文末错误码说明表格)。
  370. // break;
  371. // }
  372. // }];
  373. }
  374. -(void)youpaifpostBizId:(NSString*)ID{
  375. NSMutableDictionary *dict = [NSMutableDictionary new];
  376. [dict setObject:ID forKey:@"BizId"];
  377. WeakSelf;
  378. [LCHttpHelper requestWithURLString:LiveVerifyTokenSuccess parameters:dict needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  379. NSDictionary* dict = (NSDictionary*)responseObject;
  380. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  381. if (code == 0) {
  382. YOUPAILZLiveVerifyResultVC *vc = [[YOUPAILZLiveVerifyResultVC alloc] init];
  383. vc.youpaipstate = LZLiveVerifyStateWithInReview;
  384. vc.youpaipcontent_str = [dict objectForKey:@"message"];
  385. [weakSelf.navigationController pushViewController:vc animated:YES];
  386. }else{
  387. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  388. }
  389. } failure:^(NSError *error) {
  390. [ZCHUDHelper showTitle:error.localizedDescription];
  391. }];
  392. }
  393. - (void)youpaifrequestCategoryListData{
  394. WeakSelf;
  395. [LCHttpHelper requestWithURLString:GetLiveCateList parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  396. NSDictionary* dict = (NSDictionary*)responseObject;
  397. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  398. if (code == 0) {
  399. weakSelf.youpaipcategorys = [YOUPAILZLiveCategoryModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]];
  400. [weakSelf youpaifinitUI];
  401. [self.youpaipbannerView reloadData];
  402. }else{
  403. [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
  404. }
  405. } failure:^(NSError *error) {
  406. [ZCHUDHelper showTitle:error.localizedDescription];
  407. }];
  408. }
  409. #pragma mark - JXPagerViewDelegate
  410. - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
  411. return self.youpaipbannerView;
  412. }
  413. - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
  414. return LZHeaderViewHeigth;
  415. }
  416. - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  417. return LZCategoryViewHeight;
  418. }
  419. - (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  420. return self.youpaipcategoryBgV;
  421. }
  422. - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
  423. return self.youpaipcategorys.count;
  424. }
  425. - (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index{
  426. YOUPAILZLiveListVC *vc = [[YOUPAILZLiveListVC alloc] init];
  427. if (self.youpaipcategorys.count > index) {
  428. vc.youpaiptype = [self.youpaipcategorys[index].youpaipid integerValue];
  429. }
  430. return vc;
  431. }
  432. #pragma mark - TYCyclePagerViewDataSource
  433. - (NSInteger)numberOfItemsInPagerView:(TYCyclePagerView *)youpaippageView {
  434. return self.youpaipimageURLStringsGroup.count;
  435. }
  436. - (UICollectionViewCell *)pagerView:(TYCyclePagerView *)pagerView cellForItemAtIndex:(NSInteger)index {
  437. YOUPAILZHomeBannerCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"cellId" forIndex:index];
  438. NSString *url;
  439. if (self.youpaipimageURLStringsGroup) {
  440. url = [self.youpaipimageURLStringsGroup[index] absoluteString];
  441. [cell.youpaipbgImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"banner_default"]];
  442. }
  443. cell.layer.cornerRadius = 5;
  444. cell.layer.masksToBounds = YES;
  445. cell.backgroundColor = LCBkgColor;
  446. // cell.backgroundColor = _datas[index];
  447. // cell.label.text = [NSString stringWithFormat:@"index->%ld",index];
  448. return cell;
  449. }
  450. - (TYCyclePagerViewLayout *)layoutForPagerView:(TYCyclePagerView *)youpaippageView {
  451. TYCyclePagerViewLayout *layout = [[TYCyclePagerViewLayout alloc]init];
  452. layout.itemSize = CGSizeMake(CGRectGetWidth(youpaippageView.frame)*0.9, CGRectGetHeight(youpaippageView.frame)*0.9);
  453. layout.itemSpacing = 10;
  454. layout.layoutType = TYCyclePagerTransformLayoutLinear;
  455. //layout.minimumAlpha = 0.3;
  456. return layout;
  457. }
  458. - (void)pagerView:(TYCyclePagerView *)youpaippageView didSelectedItemCell:(__kindof UICollectionViewCell *)cell atIndex:(NSInteger)index{
  459. YOUPAILCBannerModel* model = self.youpaipbannerArray[index];
  460. if (model.youpaiplink_type==1) {
  461. ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  462. baseWeb.contentUrl = model.youpaiplink_url;
  463. [self.navigationController pushViewController:baseWeb animated:YES];
  464. }else if (model.youpaiplink_type==2||model.youpaiplink_type==3){
  465. [self youpaifpageToStr:model.youpaiplink_url];
  466. }
  467. }
  468. - (void)pagerView:(TYCyclePagerView *)youpaippageView didScrollFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex {
  469. _youpaippageControl.currentPage = toIndex;
  470. //[_pageControl setCurrentPage:newIndex animate:YES];
  471. // NSLog(@"%ld -> %ld",fromIndex,toIndex);
  472. }
  473. #pragma mark-点击排行榜
  474. - (void)youpaifrankBtnClick{
  475. if ([LCSaveData getRankH5Url].length != 0) {
  476. ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  477. baseWeb.contentUrl = [LCSaveData getRankH5Url];
  478. [self.navigationController pushViewController:baseWeb animated:YES];
  479. }else{
  480. YOUPAILCBoardVC *board = [[YOUPAILCBoardVC alloc]init];
  481. board.youpaiptype = 0;
  482. board.youpaiphiddenBack = YES;
  483. [self.navigationController pushViewController:board animated:YES];
  484. }
  485. }
  486. - (void)youpaifhandlePan:(UIPanGestureRecognizer*) recognizer{
  487. CGPoint translation = [recognizer translationInView:self.view];
  488. CGFloat centerX=recognizer.view.center.x+ translation.x;
  489. CGFloat thecenter=0;
  490. recognizer.view.center = CGPointMake(centerX,recognizer.view.center.y+ translation.y);
  491. [recognizer setTranslation:CGPointZero inView:self.view];
  492. if(recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled) {
  493. if(centerX > KScreenWidth/2) {
  494. thecenter = KScreenWidth-62.0f/2 - 10.0f;
  495. }else{
  496. thecenter = 62.0f / 2 + 10.0f;
  497. }
  498. [UIView animateWithDuration:0.3 animations:^{
  499. CGFloat y = recognizer.view.center.y;
  500. if (recognizer.view.center.y < NavBarHeight) {
  501. y = NavBarHeight + 21.0f + 62.0f / 2.0f;
  502. }else if (recognizer.view.center.y > KScreenHeight - TabbarHeight - 21.0f - 62.0f / 2.0f){
  503. y = KScreenHeight - TabbarHeight - 21.0f - 62.0f / 2.0f;
  504. }
  505. recognizer.view.center=CGPointMake(thecenter, y + translation.y);
  506. }];
  507. }
  508. }
  509. //// 置顶
  510. //-(void)youpaiftoTopAction{
  511. // YOUPAILZLiveListVC *vc = self.youpaipliveListControllers[self.currentControllerIndex];
  512. // if (vc.dataSource.count > 0) {
  513. // NSIndexPath* indexPat = [NSIndexPath indexPathForItem:0 inSection:0];
  514. // [vc.collectionView scrollToItemAtIndexPath:indexPat atScrollPosition:UICollectionViewScrollPositionBottom animated:YES];
  515. // }
  516. //}
  517. //- (void)setupScrollView{
  518. // [self.view addSubview:self.scrollView];
  519. // self.scrollView.contentSize = CGSizeMake(self.youpaipliveListControllers.count*CGRectGetWidth(_scrollView.frame), CGRectGetHeight(_scrollView.frame));
  520. // for (NSInteger i = 0; i < self.youpaipliveListControllers.count; i ++) {
  521. // YOUPAILZLiveListVC *vc = self.youpaipliveListControllers[i];
  522. // vc.view.frame = CGRectMake(i * KScreenWidth, 0, KScreenWidth, CGRectGetHeight(self.scrollView.frame));
  523. // [self.scrollView addSubview:vc.view];
  524. // }
  525. //}
  526. //
  527. //- (void)setupNavigationView{
  528. // self.youpaipnavBaseView = [[UIView alloc] initWithFrame:CGRectMake(0,0, KScreenWidth, 44)];
  529. // self.navigationItem.titleView = self.youpaipnavBaseView;
  530. //
  531. // NSMutableArray *titles = [NSMutableArray array];
  532. // for (YOUPAILZLiveListVC *vc in self.youpaipliveListControllers) {
  533. // [titles addObject:vc.title];
  534. // }
  535. //
  536. // ZCNavMenuView* navMenu = [[ZCNavMenuView alloc]initWithFrame:CGRectMake(0, 0,65.0f * titles.count,44) TitleArr:titles normalFont:LCBoldFont(16) normalColor:HexColorFromRGB(0x222222) selectFont:LCBoldFont(21) selectColor:HexColorFromRGB(0x222222) selectLineColor:HexColorFromRGB(0xCB44FF) currentIndex:0 isBackground:NO];
  537. // navMenu.delegate = self;
  538. // self.youpaipnavView = navMenu;
  539. // [self.youpaipnavBaseView addSubview:self.youpaipnavView];
  540. //}
  541. //- (void)onlineVersionNotification{
  542. // [self setupNavigationView];
  543. //}
  544. //- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  545. // if ([scrollView isEqual:self.scrollView]) {
  546. // [self show];
  547. // }else{
  548. // if ([scrollView.mj_footer isRefreshing] || [scrollView.mj_header isRefreshing] || scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.mj_h - 1) {
  549. // return;
  550. // }
  551. // if (scrollView.contentOffset.y < self.youpaiplastContentOffset || scrollView.contentOffset.y <= 0){
  552. // //向上
  553. // [self show];
  554. // } else if (scrollView.contentOffset.y > self.youpaiplastContentOffset ){
  555. // //向下
  556. // [self hide];
  557. // }
  558. // self.youpaiplastContentOffset = scrollView.contentOffset.y;
  559. // }
  560. //}
  561. //- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
  562. // if ([scrollView isEqual:self.scrollView]) {
  563. // CGPoint offset = scrollView.contentOffset;
  564. // NSInteger index = offset.x/KScreenWidth;
  565. // [self.youpaipnavView changeCurrentSelectButton:index];
  566. // self.currentControllerIndex = index;
  567. // }
  568. //}
  569. //
  570. //- (void)youpaifnavBtnClick:(NSInteger)index{
  571. // self.scrollView.contentOffset = CGPointMake(index * KScreenWidth, 0.0f);
  572. // self.currentControllerIndex = index;
  573. //}
  574. //
  575. //- (void)show{
  576. // [UIView animateWithDuration:0.25f animations:^{
  577. // self.tabBarController.tabBar.frame = CGRectMake(0, KScreenHeight-TabbarHeight, KScreenWidth, TabbarHeight);
  578. // self.scrollView.frame = CGRectMake(0,NavBarHeight, KScreenWidth, KScreenHeight-TabbarHeight-NavBarHeight);
  579. // for (YOUPAILZLiveListVC *vc in self.youpaipliveListControllers) {
  580. // CGRect rect = vc.view.frame;
  581. // rect.origin.y = 0.0f;
  582. // rect.size.height = CGRectGetHeight(self.scrollView.frame);
  583. // vc.view.frame = rect;
  584. // }
  585. // }];
  586. // [self.navigationController setNavigationBarHidden:NO animated:YES];
  587. //}
  588. //- (void)hide{
  589. // [UIView animateWithDuration:0.25f animations:^{
  590. // self.tabBarController.tabBar.frame = CGRectMake(0, KScreenHeight+20, KScreenWidth, TabbarHeight);
  591. // self.scrollView.frame = CGRectMake(0,0.0f, KScreenWidth, KScreenHeight);
  592. // for (YOUPAILZLiveListVC *vc in self.youpaipliveListControllers) {
  593. // CGRect rect = vc.view.frame;
  594. // rect.origin.y = 0;
  595. // rect.size.height = CGRectGetHeight(self.scrollView.frame);
  596. // vc.view.frame = rect;
  597. // }
  598. // }];
  599. // [self.navigationController setNavigationBarHidden:YES animated:YES];
  600. //}
  601. //
  602. //-(void)setCurrentControllerIndex:(NSInteger)currentControllerIndex{
  603. // _currentControllerIndex = currentControllerIndex;
  604. // if (currentControllerIndex == 0) {
  605. // if (self.youpaipliveListControllers.count != 0) {
  606. // [self.youpaipliveListControllers[0] youpaifjoin];
  607. // }
  608. // }else{
  609. // if (self.youpaipliveListControllers.count != 0) {
  610. // [self.youpaipliveListControllers[0] leave];
  611. // }
  612. // }
  613. //}
  614. - (void)youpaifinitConfig{ //系统配置信息
  615. [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[LCTools getImageUrlWithAddress:@"/v1.3/dress/bubble/lALPD3zUOqg7eJA7bg_110_59.png"] options:SDWebImageDownloaderUseNSURLCache progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {} completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
  616. if(data != nil){
  617. [LCSaveData saveBubbleWithKey:[LCTools getImageUrlWithAddress:@"/v1.3/dress/bubble/lALPD3zUOqg7eJA7bg_110_59.png"].absoluteString Data:data];
  618. }
  619. }];
  620. [LCHttpHelper requestWithURLString:AppConfig parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  621. NSDictionary* dict = (NSDictionary*)responseObject;
  622. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  623. if (code==0) {//成功
  624. NSArray *bubbles = [[[dict objectForKey:@"data"]objectForKey:@"dress"] objectForKey:@"bubble"];
  625. for (NSDictionary *bubbleDist in bubbles) {
  626. [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[LCTools getImageUrlWithAddress:[bubbleDist objectForKey:@"bubble"]] options:SDWebImageDownloaderUseNSURLCache progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {} completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
  627. if(data != nil){
  628. [LCSaveData saveBubbleWithKey:[LCTools getImageUrlWithAddress:[bubbleDist objectForKey:@"bubble"]].absoluteString Data:data];
  629. }
  630. }];
  631. }
  632. }
  633. } failure:^(NSError *error) {
  634. }];
  635. }
  636. @end