294 lines
12 KiB
Objective-C
294 lines
12 KiB
Objective-C
//
|
|
// LMCPSpaceViewController.m
|
|
// SweetParty
|
|
//
|
|
// Created by Xmac on 2024/8/13.
|
|
//
|
|
|
|
#import "LMCPSpaceViewController.h"
|
|
#import "LMCPSpaceCollectionViewCell.h"
|
|
#import "LMCPSpaceInfoModel.h"
|
|
#import "QGVAPWrapView.h"
|
|
#import "UIView+VAP.h"
|
|
#import "QGVAPWrapView+download.h"
|
|
|
|
@interface LMCPSpaceViewController ()<JXCategoryViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,HWDMP4PlayDelegate,VAPWrapViewDelegate>
|
|
|
|
@property (weak, nonatomic) IBOutlet UIView *cateCoverView;
|
|
@property (weak, nonatomic) IBOutlet UILabel *topLevelLabel;
|
|
|
|
@property (weak, nonatomic) IBOutlet UIImageView *leftHeaderPic;
|
|
@property (weak, nonatomic) IBOutlet UIImageView *rightHeaderPic;
|
|
@property (weak, nonatomic) IBOutlet UILabel *valueLabel;
|
|
@property (weak, nonatomic) IBOutlet UILabel *leftNameLabel;
|
|
@property (weak, nonatomic) IBOutlet UILabel *rightNameLabel;
|
|
|
|
@property (nonatomic, strong) JXCategoryTitleView *categoryView;
|
|
@property (weak, nonatomic) IBOutlet UICollectionView *dressItemView;
|
|
|
|
@property (nonatomic, strong) LMCPSpaceInfoModel *infoModel;
|
|
@property (nonatomic, assign) NSInteger type;
|
|
@property (nonatomic, strong) NSMutableArray *dataArr;
|
|
|
|
@property (nonatomic, strong) QGVAPWrapView *leftHeaderVapView;
|
|
@property (nonatomic, strong) QGVAPWrapView *rightHeaderVapView;
|
|
@property (nonatomic, strong) QGVAPWrapView *texiaoVapView;
|
|
|
|
@property (weak, nonatomic) IBOutlet UIView *rightVapCover;
|
|
@property (weak, nonatomic) IBOutlet UIView *leftVapCover;
|
|
|
|
@end
|
|
|
|
@implementation LMCPSpaceViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
self.navTitle = @"情侣空间";
|
|
[self.customNavBar styleClear];
|
|
self.type = 1;
|
|
|
|
[self setupUI];
|
|
[self requestLoadMyCPInfo];
|
|
[self requestLoadCPDressList];
|
|
}
|
|
|
|
- (void)setupUI
|
|
{
|
|
[self.cateCoverView addSubview:self.categoryView];
|
|
[self.categoryView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.cateCoverView);
|
|
}];
|
|
|
|
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
|
|
flowLayout.itemSize = CGSizeMake((APPW-15*6)/3, 126);
|
|
flowLayout.minimumLineSpacing = 15;
|
|
flowLayout.minimumInteritemSpacing = 15;
|
|
flowLayout.sectionInset = UIEdgeInsetsMake(0, 15, 15, 15);
|
|
|
|
self.dressItemView.collectionViewLayout = flowLayout;
|
|
self.dressItemView.delegate = self;
|
|
self.dressItemView.dataSource = self;
|
|
[self.dressItemView registerNib:[UINib nibWithNibName:@"LMCPSpaceCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:LMCPSpaceCollectionViewCellID];
|
|
|
|
[self.leftVapCover addSubview:self.leftHeaderVapView];
|
|
[self.leftHeaderVapView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.leftVapCover);
|
|
}];
|
|
|
|
[self.rightVapCover addSubview:self.rightHeaderVapView];
|
|
[self.rightHeaderVapView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.rightVapCover);
|
|
}];
|
|
|
|
[self.view addSubview:self.texiaoVapView];
|
|
[self.texiaoVapView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.view);
|
|
}];
|
|
}
|
|
|
|
|
|
- (void)setupInfoWithModel
|
|
{
|
|
[self.leftHeaderPic sd_setImageWithURL:[NSURL URLWithString:self.infoModel.u_head_pic] placeholderImage:kDefaultUserIcon];
|
|
[self.rightHeaderPic sd_setImageWithURL:[NSURL URLWithString:self.infoModel.receive_head_pic] placeholderImage:kDefaultUserIcon];
|
|
self.leftNameLabel.text = self.infoModel.u_nick_name;
|
|
self.rightNameLabel.text = self.infoModel.receive_nick_name;
|
|
self.topLevelLabel.text = [NSString stringWithFormat:@"LV.%@",self.infoModel.cp_level];
|
|
self.valueLabel.text = [NSString stringWithFormat:@"%.0f/%.0f",self.infoModel.cp_value,self.infoModel.next_cp_value];
|
|
WEAK_SELF;
|
|
if (self.infoModel.u_avatar_play_image.length>0){
|
|
[self.leftHeaderVapView playMemoryWithStr:C_string(self.infoModel.u_avatar_play_image) Success:^(NSURL * _Nonnull filePath) {
|
|
NSString *fileStr = [filePath absoluteString];
|
|
if ([fileStr containsString:@"file://"]) {
|
|
fileStr = [fileStr substringFromIndex:7];
|
|
}
|
|
[self.leftHeaderVapView playHWDMP4:fileStr repeatCount:-1 delegate:self];
|
|
} Failure:^(NSError * _Nonnull error) {
|
|
[weakSelf.leftHeaderVapView removeFromSuperview];
|
|
}];
|
|
}
|
|
if (self.infoModel.receive_avatar_play_image.length>0){
|
|
[self.rightHeaderVapView playMemoryWithStr:C_string(self.infoModel.receive_avatar_play_image) Success:^(NSURL * _Nonnull filePath) {
|
|
NSString *fileStr = [filePath absoluteString];
|
|
if ([fileStr containsString:@"file://"]) {
|
|
fileStr = [fileStr substringFromIndex:7];
|
|
}
|
|
[self.rightHeaderVapView playHWDMP4:fileStr repeatCount:-1 delegate:self];
|
|
} Failure:^(NSError * _Nonnull error) {
|
|
[weakSelf.rightHeaderVapView removeFromSuperview];
|
|
}];
|
|
}
|
|
}
|
|
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
|
|
{
|
|
return self.dataArr.count;
|
|
}
|
|
|
|
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
LMCPSpaceCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:LMCPSpaceCollectionViewCellID forIndexPath:indexPath];
|
|
LMCPSpaceDressListModel *model = self.dataArr[indexPath.item];
|
|
if (self.type == 1){
|
|
[cell setHeaderDecInfoWithModel:model];
|
|
}else{
|
|
[cell setCPTexiaoInfoWithModel:model];
|
|
}
|
|
|
|
return cell;
|
|
}
|
|
|
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
LMCPSpaceDressListModel *model = self.dataArr[indexPath.item];
|
|
if ([model.js_suo isEqualToString:@"1"]){
|
|
NSDictionary *params = @{@"udid":model.udid};
|
|
NSString *urlStr = @"/api/decorate/user_use_decorate";
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:urlStr Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
|
|
[self requestLoadCPDressList];
|
|
if (self.type == 1){
|
|
if ([self.infoModel.uid isEqualToString:[BJUserManager userInfo].uid]){
|
|
[self.leftHeaderVapView playMemoryWithStr:C_string(model.head_decorate_play_img) Success:^(NSURL * _Nonnull filePath) {
|
|
NSString *fileStr = [filePath absoluteString];
|
|
if ([fileStr containsString:@"file://"]) {
|
|
fileStr = [fileStr substringFromIndex:7];
|
|
}
|
|
[self.leftHeaderVapView playHWDMP4:fileStr repeatCount:-1 delegate:self];
|
|
} Failure:^(NSError * _Nonnull error) {
|
|
[self.leftHeaderVapView removeFromSuperview];
|
|
}];
|
|
}else{
|
|
[self.rightHeaderVapView playMemoryWithStr:C_string(model.head_decorate_play_img) Success:^(NSURL * _Nonnull filePath) {
|
|
NSString *fileStr = [filePath absoluteString];
|
|
if ([fileStr containsString:@"file://"]) {
|
|
fileStr = [fileStr substringFromIndex:7];
|
|
}
|
|
[self.rightHeaderVapView playHWDMP4:fileStr repeatCount:-1 delegate:self];
|
|
} Failure:^(NSError * _Nonnull error) {
|
|
[self.rightHeaderVapView removeFromSuperview];
|
|
}];
|
|
}
|
|
}else{
|
|
self.texiaoVapView.hidden = NO;
|
|
[self.texiaoVapView playMemoryWithStr:C_string(model.cp_tx_play_img) Success:^(NSURL * _Nonnull filePath) {
|
|
NSString *fileStr = [filePath absoluteString];
|
|
if ([fileStr containsString:@"file://"]) {
|
|
fileStr = [fileStr substringFromIndex:7];
|
|
}
|
|
[self.texiaoVapView playHWDMP4:fileStr repeatCount:0 delegate:self];
|
|
} Failure:^(NSError * _Nonnull error) {
|
|
[self.texiaoVapView removeFromSuperview];
|
|
}];
|
|
}
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}else{
|
|
[HelpPageDefine showMessage:@"未解锁"];
|
|
}
|
|
|
|
}
|
|
|
|
- (void)requestLoadMyCPInfo
|
|
{
|
|
[BJHttpTool BJ_GetMy_cpWithParameters:@{} success:^(id response) {
|
|
self.infoModel = [LMCPSpaceInfoModel mj_objectWithKeyValues:response[@"data"]];
|
|
[self setupInfoWithModel];
|
|
} failure:^(NSError *error) {
|
|
[self.leftHeaderPic sd_setImageWithURL:[NSURL URLWithString:[BJUserManager userInfo].head_pic] placeholderImage:kDefaultUserIcon];
|
|
self.leftNameLabel.text = [BJUserManager userInfo].nick_name;
|
|
}];
|
|
|
|
}
|
|
|
|
- (void)requestLoadCPDressList
|
|
{
|
|
[BJHttpTool BJ_GetMy_cp_txkWithParameters:@{@"type":[NSString stringWithFormat:@"%ld",self.type]} success:^(id response) {
|
|
self.dataArr = [LMCPSpaceDressListModel mj_objectArrayWithKeyValuesArray:response[@"data"]];
|
|
[self.dressItemView reloadData];
|
|
} failure:^(NSError *error) {
|
|
|
|
}];
|
|
}
|
|
|
|
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index
|
|
{
|
|
if (index == 0){
|
|
self.type = 1;
|
|
}else{
|
|
self.type = 9;
|
|
}
|
|
[self requestLoadCPDressList];
|
|
}
|
|
|
|
// 分页菜单视图
|
|
- (JXCategoryTitleView *)categoryView {
|
|
if (!_categoryView) {
|
|
_categoryView = [[JXCategoryTitleView alloc] init];
|
|
_categoryView.titleFont = YBBoldFont(14);
|
|
_categoryView.titleSelectedFont = YBBoldFont(16);
|
|
_categoryView.titleColor = HEXCOLORA(0x999999, 1);
|
|
_categoryView.titleSelectedColor = HEXCOLOR(0x333333);
|
|
_categoryView.delegate = self;
|
|
_categoryView.contentEdgeInsetLeft = 60;
|
|
_categoryView.contentEdgeInsetRight = 60;
|
|
_categoryView.titles = @[@"头像框",@"入场特效"];
|
|
|
|
// JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
|
|
// backgroundView.indicatorWidth = 69;
|
|
// backgroundView.indicatorHeight = 27;
|
|
// backgroundView.indicatorCornerRadius = 13.5;
|
|
// backgroundView.indicatorColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(79, 27) direction:(FXGradientChangeDirectionHorizontal) startColor:mainLightColor endColor:mainDeepColor];
|
|
// _categoryView.indicators = @[backgroundView];
|
|
}
|
|
return _categoryView;
|
|
}
|
|
|
|
- (NSMutableArray *)dataArr
|
|
{
|
|
if (!_dataArr){
|
|
_dataArr = [NSMutableArray array];
|
|
}
|
|
return _dataArr;
|
|
}
|
|
|
|
- (QGVAPWrapView *)leftHeaderVapView {
|
|
if (!_leftHeaderVapView) {
|
|
_leftHeaderVapView = [[QGVAPWrapView alloc] initWithFrame:CGRectZero];
|
|
// _leftHeaderVapView.hwd_Delegate = self;
|
|
_leftHeaderVapView.contentMode = QGVAPWrapViewContentModeScaleToFill;
|
|
_leftHeaderVapView.userInteractionEnabled = NO;
|
|
}
|
|
return _leftHeaderVapView;
|
|
}
|
|
|
|
- (QGVAPWrapView *)rightHeaderVapView {
|
|
if (!_rightHeaderVapView) {
|
|
_rightHeaderVapView = [[QGVAPWrapView alloc] initWithFrame:CGRectZero];
|
|
// _rightHeaderVapView.hwd_Delegate = self;
|
|
_rightHeaderVapView.contentMode = QGVAPWrapViewContentModeScaleToFill;
|
|
_rightHeaderVapView.userInteractionEnabled = NO;
|
|
}
|
|
return _rightHeaderVapView;
|
|
}
|
|
|
|
|
|
- (QGVAPWrapView *)texiaoVapView {
|
|
if (!_texiaoVapView) {
|
|
_texiaoVapView = [[QGVAPWrapView alloc] initWithFrame:CGRectZero];
|
|
_texiaoVapView.hwd_Delegate = self;
|
|
_texiaoVapView.contentMode = QGVAPWrapViewContentModeScaleToFill;
|
|
_texiaoVapView.userInteractionEnabled = NO;
|
|
_texiaoVapView.hidden = YES;
|
|
}
|
|
return _texiaoVapView;
|
|
}
|
|
|
|
- (void)vapWrap_viewDidStopPlayMP4:(NSInteger)lastFrameIndex view:(VAPView *)container
|
|
{
|
|
if (container == self.texiaoVapView){
|
|
self.texiaoVapView.hidden = YES;
|
|
}
|
|
}
|
|
|
|
@end
|