654 lines
26 KiB
Objective-C
654 lines
26 KiB
Objective-C
//
|
||
// ShouYeNewView.m
|
||
// KuaiCunShiPin
|
||
//
|
||
// Created by 工作 on 2025/4/29.
|
||
//
|
||
|
||
#import "ShouYeNewView.h"
|
||
|
||
#import "TongZhiTSView.h"
|
||
#import "ShouYeNewCollectionViewCell.h"
|
||
#import "WYCamaImageTools.h"
|
||
|
||
#import "HuiYuanZXViewController.h"
|
||
#import "TZImagePickerController.h"
|
||
#import "XZM3SaveManager.h"
|
||
#import "ShiPingEditJGViewController.h"
|
||
#import "ShiPingEditHomeViewController.h"
|
||
|
||
|
||
@interface ShouYeNewView ()<UICollectionViewDelegate,UICollectionViewDataSource,SDCycleScrollViewDelegate,WYCamaImageToolsDelegate>
|
||
///
|
||
@property (nonatomic , strong) TongZhiTSView *viewtz;
|
||
///
|
||
@property (nonatomic , strong) UIView *viewfunctq;
|
||
///
|
||
@property (nonatomic , strong) UICollectionView *collect;
|
||
///
|
||
@property (nonatomic , strong) NSArray *arrdata;
|
||
//轮播
|
||
@property (nonatomic, strong) SDCycleScrollView *cleScrollView;
|
||
|
||
@property (nonatomic, strong) WYCamaImageTools *tools;
|
||
|
||
@property (nonatomic , assign) int typefunction;
|
||
@end
|
||
|
||
@implementation ShouYeNewView
|
||
|
||
-(id)initWithFrame:(CGRect)frame
|
||
{
|
||
if(self = [super initWithFrame:frame])
|
||
{
|
||
[self setBackgroundColor:RGBCOLOR(20, 20, 20)];
|
||
|
||
UIScrollView *scvback = [[UIScrollView alloc] init];
|
||
[self addSubview:scvback];
|
||
[scvback mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.top.offset(0);
|
||
make.width.height.equalTo(self);
|
||
}];
|
||
if (@available(iOS 11.0, *)) {
|
||
scvback.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||
}else{
|
||
self.viewController.automaticallyAdjustsScrollViewInsets =NO;
|
||
}
|
||
TongZhiTSView *viewtz = [[TongZhiTSView alloc] initWithFrame:CGRectMake(12, 0, UISCREEN_WIDTH-24, 36)];
|
||
[scvback addSubview:viewtz];
|
||
[viewtz mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.offset(12);
|
||
make.width.offset(UISCREEN_WIDTH-24);
|
||
make.top.offset(KMagrinTop+5);
|
||
make.height.offset(36);
|
||
}];
|
||
_viewtz = viewtz;
|
||
[viewtz setHidden:YES];
|
||
// viewtz.arrdata = @[@" 阿斯蒂芬阿斯蒂芬",@" 撒旦法萨芬",@"水岸东方阿萨德发送"];
|
||
|
||
UIView *viewfunctq = [[UIView alloc] init];
|
||
[scvback addSubview:viewfunctq];
|
||
[viewfunctq mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.offset(12);
|
||
make.right.equalTo(viewtz).offset(-12);
|
||
make.top.equalTo(viewtz.mas_bottom).offset(15);
|
||
make.height.offset(130);
|
||
}];
|
||
[self drawFuncTQView:viewfunctq];
|
||
_viewfunctq = viewfunctq;
|
||
|
||
UIView *viewvideo = [[UIView alloc] init];
|
||
[viewvideo setBackgroundColor:RGBCOLOR(27, 29, 33)];
|
||
[scvback addSubview:viewvideo];
|
||
[viewvideo mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.right.equalTo(viewfunctq);
|
||
make.top.equalTo(viewfunctq.mas_bottom).offset(20);
|
||
make.height.offset(188);
|
||
}];
|
||
[viewvideo.layer setMasksToBounds:YES];
|
||
[viewvideo.layer setCornerRadius:10];
|
||
|
||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||
layout.minimumLineSpacing = 0;
|
||
layout.minimumInteritemSpacing = 0;
|
||
UICollectionView *collect = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||
[collect setScrollEnabled:NO];
|
||
[collect setDelegate:self];
|
||
[collect setDataSource:self];
|
||
[collect setBackgroundColor:[UIColor clearColor]];
|
||
[viewvideo addSubview:collect];
|
||
[collect mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.edges.equalTo(viewvideo);
|
||
}];
|
||
[collect registerClass:[ShouYeNewCollectionViewCell class] forCellWithReuseIdentifier:@"ShouYeNewCollectionViewCell"];
|
||
_collect = collect;
|
||
self.arrdata = @[@"加水印",@"MD5去重",@"视频倒放",@"视频裁剪",@"去音乐",@"加音乐",@"视频转音频",@"视频拼接",@"时长剪切"];
|
||
|
||
SDCycleScrollView *cleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero imageNamesGroup:@[]];
|
||
cleScrollView.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||
cleScrollView.delegate = self;
|
||
cleScrollView.backgroundColor = [UIColor clearColor];
|
||
cleScrollView.titleLabelBackgroundColor = [UIColor clearColor];
|
||
cleScrollView.titleLabelTextColor = [UIColor darkGrayColor];
|
||
cleScrollView.titleLabelTextFont = [UIFont systemFontOfSize:[Tools sizeFont:14]];
|
||
cleScrollView.autoScrollTimeInterval = 3.0;
|
||
cleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
|
||
[cleScrollView setShowPageControl:NO];
|
||
[scvback addSubview:cleScrollView];
|
||
[cleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.width.equalTo(collect);
|
||
make.top.equalTo(viewvideo.mas_bottom).offset(20);
|
||
make.height.offset(100*(UISCREEN_WIDTH-24)/351.0);
|
||
}];
|
||
[cleScrollView.layer setMasksToBounds:YES];
|
||
[cleScrollView.layer setCornerRadius:10];
|
||
_cleScrollView = cleScrollView;
|
||
[scvback mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.bottom.equalTo(cleScrollView).offset(20);
|
||
}];
|
||
[self refShowBanner];
|
||
|
||
}
|
||
return self;
|
||
}
|
||
|
||
-(void)drawFuncTQView:(UIView *)view
|
||
{
|
||
for(UIView *viewitem in view.subviews)
|
||
{
|
||
[viewitem removeFromSuperview];
|
||
}
|
||
if([UserDetailModel zhiFuState])
|
||
{
|
||
UIView *viewlj = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH-147, 106)];
|
||
[view addSubview:viewlj];
|
||
[viewlj mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.top.offset(0);
|
||
make.height.offset(106);
|
||
make.width.offset(UISCREEN_WIDTH-147);
|
||
}];
|
||
[self drawItemView:viewlj title:@"链接提取" info:@"涵盖绝大大多数平台" img:@"newhome_ljtq"];
|
||
|
||
UIView *viewznsp = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 114, 106)];
|
||
[view addSubview:viewznsp];
|
||
[viewznsp mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.height.equalTo(viewlj);
|
||
make.left.equalTo(viewlj.mas_right).offset(9);
|
||
make.right.equalTo(view);
|
||
}];
|
||
[self drawItemView:viewznsp title:@"智能视频" info:@" " img:@"newhome_znsp"];
|
||
|
||
UIView *viewsph = [[UIView alloc] initWithFrame:CGRectMake(0, 0, (UISCREEN_WIDTH-33)/2.0, 106)];
|
||
[view addSubview:viewsph];
|
||
[viewsph mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.equalTo(viewlj.mas_bottom).offset(9);
|
||
make.left.height.equalTo(viewlj);
|
||
make.width.offset((UISCREEN_WIDTH-33)/2.0);
|
||
}];
|
||
[self drawItemView:viewsph title:@"视频号" info:@"支持微信视频号" img:@"newhome_sph"];
|
||
|
||
UIView *viewzbhf = [[UIView alloc] initWithFrame:CGRectMake(0, 0, (UISCREEN_WIDTH-33)/2.0, 106)];
|
||
[view addSubview:viewzbhf];
|
||
[viewzbhf mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.height.equalTo(viewsph);
|
||
make.left.equalTo(viewsph.mas_right).offset(9);
|
||
make.right.equalTo(view);
|
||
}];
|
||
[self drawItemView:viewzbhf title:@"直播回放" info:@"支持微信直播回放" img:@"newhome_zbhf"];
|
||
[view mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
make.height.offset(221);
|
||
}];
|
||
}
|
||
else
|
||
{
|
||
UIView *viewlj = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH-24, 130)];
|
||
[view addSubview:viewlj];
|
||
[viewlj mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.top.offset(0);
|
||
make.height.offset(130);
|
||
make.width.offset(UISCREEN_WIDTH-24);
|
||
}];
|
||
[self drawItemZNSPView:viewlj];
|
||
}
|
||
}
|
||
-(void)drawItemZNSPView:(UIView *)view
|
||
{
|
||
[view.layer setMasksToBounds:YES];
|
||
[view.layer setCornerRadius:10];
|
||
|
||
UILabel *lbname = [[UILabel alloc] init];
|
||
[lbname setText:@"智能视频"];
|
||
[lbname setTextColor:[UIColor whiteColor]];
|
||
[lbname setTextAlignment:NSTextAlignmentLeft];
|
||
[lbname setFont:[UIFont fontWithName:@"AlimamaShuHeiTi-Bold" size:24]];
|
||
[view addSubview:lbname];
|
||
[lbname mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.offset(18);
|
||
make.top.offset(14);
|
||
}];
|
||
|
||
UILabel *lbinfo = [[UILabel alloc] init];
|
||
[lbinfo setText:@"视频素材智能生成"];
|
||
[lbinfo setTextColor:[UIColor whiteColor]];
|
||
[lbinfo setTextAlignment:NSTextAlignmentLeft];
|
||
[lbinfo setFont:[UIFont fontWithName:@"PingFangSC-Regular" size:14]];
|
||
[view addSubview:lbinfo];
|
||
[lbinfo mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(lbname);
|
||
make.top.equalTo(lbname.mas_bottom).offset(2);
|
||
}];
|
||
|
||
UIButton *btstart = [[UIButton alloc] init];
|
||
[btstart setTitle:@"开始生成 >" forState:UIControlStateNormal];
|
||
[btstart setTitleColor:RGBCOLOR(70, 120, 253) forState:UIControlStateNormal];
|
||
[btstart.titleLabel setFont:[UIFont systemFontOfSize:14]];
|
||
[btstart.layer setMasksToBounds:YES];
|
||
[btstart.layer setCornerRadius:16];
|
||
[btstart setBackgroundColor:[UIColor whiteColor]];
|
||
[view addSubview:btstart];
|
||
[btstart mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.size.sizeOffset(CGSizeMake(94, 32));
|
||
make.left.equalTo(lbname);
|
||
make.bottom.equalTo(view).offset(-14);
|
||
}];
|
||
|
||
UIImageView *imgvback = [[UIImageView alloc] init];
|
||
[imgvback setImage:[UIImage imageNamed:@"newhome_znsp1"]];
|
||
[imgvback setContentMode:UIViewContentModeScaleAspectFit];
|
||
[view addSubview:imgvback];
|
||
[view sendSubviewToBack:imgvback];
|
||
|
||
UIButton *btitem = [[UIButton alloc] init];
|
||
[view addSubview:btitem];
|
||
[btitem mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.edges.equalTo(view);
|
||
}];
|
||
[btitem addTarget:self action:@selector(tqAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
[btitem setTag:1];
|
||
[imgvback mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.equalTo(view).offset(-16);
|
||
make.bottom.equalTo(view).offset(-3);
|
||
make.size.sizeOffset(CGSizeMake(122, 114));
|
||
}];
|
||
[Tools changedView:view colors:@[(id)RGBCOLOR(73, 170, 255).CGColor,(id)RGBCOLOR(69, 113, 252).CGColor] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
|
||
|
||
}
|
||
-(void)drawItemView:(UIView *)view title:(NSString *)title info:(NSString *)info img:(NSString *)img
|
||
{
|
||
[view.layer setMasksToBounds:YES];
|
||
[view.layer setCornerRadius:10];
|
||
|
||
UILabel *lbname = [[UILabel alloc] init];
|
||
[lbname setText:title];
|
||
[lbname setTextColor:[UIColor whiteColor]];
|
||
[lbname setTextAlignment:NSTextAlignmentLeft];
|
||
[lbname setFont:[UIFont fontWithName:@"AlimamaShuHeiTi-Bold" size:18]];
|
||
[view addSubview:lbname];
|
||
[lbname mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.top.offset(12);
|
||
}];
|
||
|
||
UILabel *lbinfo = [[UILabel alloc] init];
|
||
[lbinfo setText:info];
|
||
[lbinfo setTextColor:[UIColor whiteColor]];
|
||
[lbinfo setTextAlignment:NSTextAlignmentLeft];
|
||
[lbinfo setFont:[UIFont systemFontOfSize:14]];
|
||
[view addSubview:lbinfo];
|
||
[lbinfo mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(lbname);
|
||
make.top.equalTo(lbname.mas_bottom);
|
||
}];
|
||
|
||
UIImageView *imgvnext = [[UIImageView alloc] init];
|
||
[imgvnext setImage:[UIImage imageNamed:@"newhome_next"]];
|
||
[view addSubview:imgvnext];
|
||
[imgvnext mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.width.height.offset(20);
|
||
make.left.equalTo(lbname);
|
||
make.bottom.equalTo(view).offset(-12);
|
||
}];
|
||
|
||
UIImageView *imgvback = [[UIImageView alloc] init];
|
||
[imgvback setImage:[UIImage imageNamed:img]];
|
||
[imgvback setContentMode:UIViewContentModeScaleAspectFit];
|
||
[view addSubview:imgvback];
|
||
[view sendSubviewToBack:imgvback];
|
||
|
||
UIButton *btitem = [[UIButton alloc] init];
|
||
[view addSubview:btitem];
|
||
[btitem mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.edges.equalTo(view);
|
||
}];
|
||
[btitem addTarget:self action:@selector(tqAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
if([title isEqualToString:@"链接提取"])
|
||
{
|
||
[btitem setTag:0];
|
||
[imgvback mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.equalTo(view).offset(-6);
|
||
make.bottom.equalTo(view).offset(-4);
|
||
make.size.sizeOffset(CGSizeMake(74, 88));
|
||
}];
|
||
[Tools changedView:view colors:@[(id)RGBCOLOR(143, 148, 255).CGColor,(id)RGBCOLOR(181, 114, 251).CGColor] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
|
||
}
|
||
else if([title isEqualToString:@"智能视频"])
|
||
{
|
||
[btitem setTag:1];
|
||
[imgvback mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.equalTo(view).offset(-5);
|
||
make.bottom.equalTo(view).offset(0);
|
||
make.size.sizeOffset(CGSizeMake(60, 68));
|
||
}];
|
||
[Tools changedView:view colors:@[(id)RGBCOLOR(73, 170, 255).CGColor,(id)RGBCOLOR(69, 113, 252).CGColor] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
|
||
}
|
||
else if([title isEqualToString:@"视频号"])
|
||
{
|
||
[btitem setTag:2];
|
||
[imgvback mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.equalTo(view).offset(-6);
|
||
make.bottom.equalTo(view).offset(-5);
|
||
make.size.sizeOffset(CGSizeMake(64, 77));
|
||
}];
|
||
[Tools changedView:view colors:@[(id)RGBCOLOR(162, 227, 88).CGColor,(id)RGBCOLOR(45, 199, 106).CGColor] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
|
||
}
|
||
else if([title isEqualToString:@"直播回放"])
|
||
{
|
||
[btitem setTag:3];
|
||
[imgvback mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.equalTo(view).offset(-5);
|
||
make.bottom.equalTo(view).offset(0);
|
||
make.size.sizeOffset(CGSizeMake(68, 70));
|
||
}];
|
||
[Tools changedView:view colors:@[(id)RGBCOLOR(255, 149, 255).CGColor,(id)RGBCOLOR(176, 77, 252).CGColor] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
|
||
}
|
||
}
|
||
|
||
-(void)tqAction:(UIButton *)sender
|
||
{
|
||
switch (sender.tag) {
|
||
case 0:
|
||
{//
|
||
UIViewController *vc = [NSClassFromString(@"UrlXiaZaiViewController") new];
|
||
[self.viewController.navigationController pushViewController:vc animated:YES];
|
||
}
|
||
break;
|
||
case 1:
|
||
{
|
||
UIViewController *vc = [NSClassFromString(@"ZhiNengShiPingViewController") new];
|
||
[self.viewController.navigationController pushViewController:vc animated:YES];
|
||
}
|
||
break;
|
||
case 2:
|
||
{//
|
||
UIViewController *vc = [NSClassFromString(@"ShiPingHaoViewController") new];
|
||
[self.viewController.navigationController pushViewController:vc animated:YES];
|
||
}
|
||
break;
|
||
case 3:
|
||
{//
|
||
UIViewController *vc = [NSClassFromString(@"ZhiBoHuiFangViewController") new];
|
||
[self.viewController.navigationController pushViewController:vc animated:YES];
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
-(void)refShowBanner
|
||
{
|
||
NSArray *arrbanner = [[UserDetailModel shareModel].config objectForKey:@"client.banner.urls"];
|
||
|
||
NSMutableArray *arrurl = [NSMutableArray new];
|
||
if([arrbanner isKindOfClass:[NSArray class]])
|
||
{
|
||
for(NSDictionary *dic in arrbanner)
|
||
{
|
||
if([[dic objectForKey:@"page"] isEqualToString:@"Cash_Task"])
|
||
{
|
||
if([UserDetailModel zhiFuState]==YES && [[[[UserDetailModel shareModel] config] objectForKey:@"client.cashtask.enable"] intValue] == 1)
|
||
{
|
||
[arrurl addObject:[Tools isStringnil:[dic objectForKey:@"image"]]];
|
||
}
|
||
}
|
||
else if([[dic objectForKey:@"page"] containsString:@"recharge"])
|
||
{
|
||
NSString *str = [[UserDetailModel shareModel].config objectForKey:@"client.pay.enable"];
|
||
if([str intValue] != 0 && [UserDetailModel shareModel].vip.intValue != 3)
|
||
{
|
||
[arrurl addObject:[Tools isStringnil:[dic objectForKey:@"image"]]];
|
||
}
|
||
}
|
||
else if([[dic objectForKey:@"page"] isEqualToString:@"check_Task"])
|
||
{
|
||
// [arrurl addObject:[Tools isStringnil:[dic objectForKey:@"image"]]];
|
||
}
|
||
else
|
||
{
|
||
[arrurl addObject:[Tools isStringnil:[dic objectForKey:@"image"]]];
|
||
}
|
||
}
|
||
}
|
||
self.cleScrollView.imageURLStringsGroup = arrurl;
|
||
|
||
}
|
||
-(void)refShowData
|
||
{
|
||
[self drawFuncTQView:self.viewfunctq];
|
||
}
|
||
-(void)showTSData:(NSArray *)arr
|
||
{
|
||
[self.viewtz setHidden:YES];
|
||
if([arr isKindOfClass:[NSArray class]])
|
||
{
|
||
if(arr.count>0)
|
||
{
|
||
[self.viewtz setHidden:NO];
|
||
self.viewtz.arrdata = arr;
|
||
}
|
||
}
|
||
}
|
||
#pragma mark - SDCycleScrollViewDelegate
|
||
/** 图片滚动回调 */
|
||
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index
|
||
{
|
||
|
||
}
|
||
/** 点击图片回调 */
|
||
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
|
||
{
|
||
NSArray *arrbanner = [[UserDetailModel shareModel].config objectForKey:@"client.banner.urls"];
|
||
NSDictionary *dic = arrbanner[index];
|
||
if([[dic objectForKey:@"page"] containsString:@"recharge"])
|
||
{
|
||
NSString *str = [[UserDetailModel shareModel].config objectForKey:@"client.pay.enable"];
|
||
if([str intValue] == 0 || [UserDetailModel shareModel].vip.intValue == 3)
|
||
{
|
||
return;
|
||
}
|
||
if([UserDetailModel pushDengLuVC:self.viewController ispush:YES]==NO)return;;
|
||
HuiYuanZXViewController *vc = [[HuiYuanZXViewController alloc] init];
|
||
vc.source = @"banner";
|
||
[self.viewController.navigationController pushViewController:vc animated:YES];
|
||
[UserDetailModel pushActionInfo:0 key:@"client.jump.to.member.recharge" value:@"banner" extra:@""];
|
||
}
|
||
}
|
||
#pragma mark - UICollectionView
|
||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
|
||
{
|
||
return self.arrdata.count;
|
||
}
|
||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||
{
|
||
ShouYeNewCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ShouYeNewCollectionViewCell" forIndexPath:indexPath];
|
||
cell.lbname.text = self.arrdata[indexPath.row];
|
||
cell.imgvback.image = [UIImage imageNamed:[NSString stringWithFormat:@"newhome_%@",self.arrdata[indexPath.row]]];
|
||
|
||
return cell;
|
||
}
|
||
//定义每个section的间距
|
||
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
|
||
|
||
return UIEdgeInsetsMake(10, 0, 10, 0);
|
||
}
|
||
//纵向cell间距
|
||
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
|
||
return 0;
|
||
}
|
||
//cell 间距
|
||
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout ForSectionAtIndex:(NSInteger)section{
|
||
return 0;
|
||
}
|
||
// 定义每个UICollectionViewCell 的大小
|
||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
|
||
{
|
||
return CGSizeMake((UISCREEN_WIDTH-54)/5.0, 84);
|
||
}
|
||
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
|
||
{
|
||
///[@"加水印",@"MD5去重",@"视频倒放",@"视频裁剪",@"去音乐",@"加音乐",@"视频转音频",@"视频拼接",@"时长剪切"];
|
||
NSString *strtitle = self.arrdata[indexPath.row];
|
||
[UserDetailModel pushActionInfo:0 key:@"click.go.to.vc" value:strtitle extra:@""];
|
||
if([strtitle isEqualToString:@"视频转音频"])
|
||
{
|
||
UIViewController *vc = [NSClassFromString(@"ShiPingTiQuYinPingViewController") new];
|
||
[self.viewController.navigationController pushViewController:vc animated:YES];
|
||
}
|
||
else if([strtitle isEqualToString:@"视频拼接"])
|
||
{
|
||
[self pinJieVideoSelect];
|
||
}
|
||
else
|
||
{
|
||
self.typefunction = [self getFunctionTag:strtitle];
|
||
self.tools.isvideo = YES;
|
||
[self.tools choosePicWithViewController:self.viewController chooseType:ChooseTypeAlbum];
|
||
}
|
||
}
|
||
-(void)pinJieVideoSelect
|
||
{
|
||
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:4 columnNumber:4 delegate:nil pushPhotoPickerVc:YES];
|
||
imagePickerVc.isSelectOriginalPhoto = NO;
|
||
imagePickerVc.allowTakePicture = YES; // 在内部显示拍照按钮
|
||
imagePickerVc.navigationBar.barTintColor = [UIColor blackColor];
|
||
imagePickerVc.minImagesCount = 2;
|
||
imagePickerVc.maxImagesCount = 4;
|
||
imagePickerVc.oKButtonTitleColorDisabled = [UIColor lightGrayColor];
|
||
imagePickerVc.oKButtonTitleColorNormal = [UIColor greenColor];
|
||
imagePickerVc.navigationBar.translucent = NO;
|
||
// 3. 设置是否可以选择视频/图片/原图
|
||
imagePickerVc.allowPickingVideo = YES;
|
||
imagePickerVc.presetName=AVAssetExportPresetHighestQuality;
|
||
imagePickerVc.allowPickingImage = NO;
|
||
|
||
imagePickerVc.allowPickingMultipleVideo = YES;
|
||
imagePickerVc.maxCropVideoDuration = 600;
|
||
|
||
imagePickerVc.allowPickingOriginalPhoto = NO;
|
||
// 4. 照片排列按修改时间升序
|
||
imagePickerVc.sortAscendingByModificationDate = NO;
|
||
// 你可以通过block或者代理,来得到用户选择的照片.
|
||
[imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
|
||
if(assets.count>1)
|
||
{
|
||
[KCSPHUDAlterView showView];
|
||
NSMutableArray *arrtemp = [NSMutableArray new];
|
||
__block int icc = 0;
|
||
for(PHAsset *aset in assets)
|
||
{
|
||
|
||
[self getVideoUrl:aset back:^(NSURL *url) {
|
||
icc+=1;
|
||
if(url)
|
||
{
|
||
[arrtemp addObject:url];
|
||
}
|
||
if(icc == assets.count)
|
||
{
|
||
if(arrtemp.count!=icc)
|
||
{
|
||
[KCSPHUDAlterView dismis];
|
||
[HXHud showMessage:@"视频合并失败,请重新选择视频" afterDelayType:0];
|
||
return;
|
||
}
|
||
NSString *outputPath = [Tools audioRecordingPath:[NSString stringWithFormat:@"%@.mp4",[Tools getCurrentTime:@"yyyyMMddHHmmss"]]];
|
||
[[XZM3SaveManager shareManager] MergeToValue:arrtemp outUrl:[NSURL fileURLWithPath:outputPath] back:^(NSURL * _Nonnull backurl) {
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[KCSPHUDAlterView dismis];
|
||
if(backurl)
|
||
{
|
||
ShiPingEditJGViewController *vc = [[ShiPingEditJGViewController alloc] init];
|
||
vc.urlvideo = backurl;
|
||
[self.viewController.navigationController pushViewController:vc animated:NO];
|
||
}
|
||
else
|
||
{
|
||
[HXHud showMessage:@"视频合并失败,请重新选择视频" afterDelayType:0];
|
||
}
|
||
});
|
||
} progess:^(float progress) {
|
||
|
||
}];
|
||
}
|
||
}];
|
||
}
|
||
}
|
||
|
||
}];
|
||
[self.viewController presentViewController:imagePickerVc animated:YES completion:^{
|
||
|
||
}];
|
||
}
|
||
///获取相册视频地址
|
||
-(void)getVideoUrl:(PHAsset *)phAsset back:(void(^)(NSURL *url))backValue
|
||
{
|
||
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
|
||
options.version = PHVideoRequestOptionsVersionCurrent;
|
||
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
|
||
options.networkAccessAllowed = true;
|
||
|
||
PHImageManager *manager = [PHImageManager defaultManager];
|
||
[manager requestAVAssetForVideo:phAsset options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
|
||
AVURLAsset *urlAsset = (AVURLAsset *)asset;
|
||
NSURL *url = urlAsset.URL;
|
||
backValue(url);
|
||
}];
|
||
|
||
}
|
||
|
||
-(int)getFunctionTag:(NSString *)name
|
||
{
|
||
///1水印 2MD5 3裁剪 5去背景
|
||
int back = 1;
|
||
if([name isEqualToString:@"加水印"])
|
||
{
|
||
back = 1;
|
||
}
|
||
else if([name isEqualToString:@"MD5去重"])
|
||
{
|
||
back = 2;
|
||
}
|
||
else if([name isEqualToString:@"视频裁剪"])
|
||
{
|
||
back = 3;
|
||
}
|
||
else if([name isEqualToString:@"去音乐"])
|
||
{
|
||
back = 5;
|
||
}
|
||
else if([name isEqualToString:@"时长剪切"])
|
||
{
|
||
back = 6;
|
||
}
|
||
else if([name isEqualToString:@"加音乐"])
|
||
{
|
||
back = 7;
|
||
}
|
||
else if([name isEqualToString:@"视频倒放"])
|
||
{
|
||
back = 8;
|
||
}
|
||
else if([name isEqualToString:@"视频拼接"])
|
||
{
|
||
back = 9;
|
||
}
|
||
return back;
|
||
}
|
||
|
||
- (void)didEndChooseVideo:(NSURL *)videourl
|
||
{
|
||
ShiPingEditHomeViewController *vc = [ShiPingEditHomeViewController new];
|
||
vc.urlvideo = videourl;
|
||
vc.type = self.typefunction;
|
||
[self.viewController.navigationController pushViewController:vc animated:YES];
|
||
}
|
||
|
||
- (WYCamaImageTools *)tools {
|
||
if (!_tools) {
|
||
_tools = [[WYCamaImageTools alloc] init];
|
||
_tools.delegate = self;
|
||
}return _tools;
|
||
}
|
||
|
||
@end
|