Files
yinmeng-ios-store/yinmeng-ios/DingDangApp/CodeClass/MyInfo/DDMyInfoViewController.m
2023-12-07 10:50:21 +08:00

526 lines
21 KiB
Objective-C

//
// DDMyInfoViewController.m
// DingDangApp
//
// Created by apple on 2023/5/29.
//
#import "DDMyInfoViewController.h"
#import "DDHoriCollectionView.h"
#import "DDMyInfoClassView.h"
#import "DDCellModel.h"
#import "DDMyInfoCommonListViewController.h"
#import "DDMyInfoFootRoomListViewController.h"
#import "DDMyInfoSettingViewController.h"
#import "DDMyRoomHomeViewController.h"
#import "DDStorePageVC.h"
#import "DDMyWalletVC.h"
#import "DDYoungModeViewController.h"
#import "DDNobleHomeViewController.h"
#import "DDMyLevelViewController.h"
#import "DDMyAuthorStatusViewController.h"
#import "DDMyAuthorViewController.h"
#import "DDRealNameModel.h"
@interface DDMyInfoViewController ()
@property (nonatomic, strong) UIImageView *bgImgV;
@property (nonatomic, strong) UIView *shadowV;
@property (nonatomic, strong) UIButton * setBtn;
@property (nonatomic, strong) NSMutableArray *collectionListArr;
@property (nonatomic, strong) UIImageView * topBgImageView;
@property (nonatomic, strong) UIView *myFansV;
@property (nonatomic, strong) UIImageView *myFansImgV;
@property (nonatomic, strong) UILabel *myFansLabel;
@property (nonatomic, strong) UIView *myFollowV;
@property (nonatomic, strong) UIImageView *myFollowImgV;
@property (nonatomic, strong) UILabel *myFollowLabel;
@property (nonatomic, strong) DDAnimateImageView * headImage;
@property (nonatomic, strong) UIButton * lookBtn;
@property (nonatomic, strong) UILabel * nameLabel;
@property (nonatomic, strong) UIImageView * rightImg;
@property (nonatomic, strong) UIView *collectionBGView;
@property (nonatomic, strong) DDHoriCollectionView *collectionView;
@property (nonatomic, strong) DDMyInfoClassView *loginOutClassView;
@property (nonatomic, strong) AppUserModel * userModel;
@end
@implementation DDMyInfoViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self ddBaseUI];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self getUserInfo];
}
-(void)getUserInfo
{
WeakSelf(weakSelf)
NSMutableDictionary *requestDict = [NSMutableDictionary dictionary];
[NetworkRequest requestPOST:@"/user/info" parameters:requestDict block:^(BaseResponse * _Nonnull response) {
if (response.code == 200){
if ([ToolsObject IsNullWithObject:response.data]) {
return;
}
AppUserModel *model = [AppUserModel yy_modelWithJSON:response.data];
AppUserModel * myModel = [ToolsObject getUserModel];
NSString * token = myModel.token;
myModel = model;
myModel.token = token;
[ToolsObject saveUserModel:myModel];
weakSelf.userModel = model;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.topBgImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:DDPlaceholderHeadImage()];
});
}
}];
}
- (void)ddBaseUI{
self.view.backgroundColor = [UIColor jk_colorWithHexString:@"#f6f6f6"];
[self.view addSubview:self.bgImgV];
[self.bgImgV mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.left.right.top.equalTo(self.view);
}];
[self.view addSubview:self.topBgImageView];
[self.topBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self.view);
make.height.mas_equalTo(DDNavigationBarHeight() + 120);
}];
[self.view addSubview:self.shadowV];
[self.shadowV mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.topBgImageView).insets(UIEdgeInsetsMake(0, 0, 0, 0));
}];
[self.view addSubview:self.setBtn];
[self.setBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.view).inset(15);
make.top.equalTo(self.view).offset(DDStatusTopHeight());
make.width.height.mas_equalTo(24);
}];
[self.view addSubview:self.headImage];
[self.headImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view).inset(30);
make.width.height.mas_equalTo(90);
make.top.equalTo(self.setBtn.mas_bottom).mas_offset(10);
}];
[self.headImage layoutIfNeeded];
[self.headImage roundCorners:UIRectCornerAllCorners radius:45];
[self.view addSubview:self.lookBtn];
[self.lookBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view);
make.top.bottom.equalTo(self.view);
}];
[self.view addSubview:self.nameLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.headImage.mas_right).offset(10);
make.height.mas_equalTo(18);
make.centerY.equalTo(self.headImage);
}];
[self.view addSubview:self.rightImg];
[self.rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.view).offset(-20);
make.centerY.equalTo(self.nameLabel);
make.width.mas_equalTo(12);
make.height.mas_equalTo(12);
}];
[self.view addSubview:self.myFansV];
[self.myFansV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view).offset(15);
make.top.equalTo(self.headImage.mas_bottom).offset(10);
make.height.mas_equalTo(70);
}];
[self.myFansV addSubview:self.myFansImgV];
[self.myFansImgV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.myFansV).offset(20);
make.centerY.equalTo(self.myFansV);
make.width.height.mas_equalTo(42);
}];
[self.myFansV addSubview:self.myFansLabel];
[self.myFansLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.myFansImgV.mas_right).offset(10);
make.right.equalTo(self.myFansV).inset(20);
make.top.bottom.equalTo(self.myFansV);
}];
[self.view addSubview:self.myFollowV];
[self.myFollowV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.myFansV.mas_right).offset(20);
make.right.equalTo(self.view).inset(15);
make.width.equalTo(self.myFansV).multipliedBy(1);
make.top.bottom.equalTo(self.myFansV);
}];
[self.myFollowV addSubview:self.myFollowImgV];
[self.myFollowImgV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.myFollowV).offset(20);
make.centerY.equalTo(self.myFollowV);
make.width.height.mas_equalTo(42);
}];
[self.myFollowV addSubview:self.myFollowLabel];
[self.myFollowLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.myFollowImgV.mas_right).offset(10);
make.right.equalTo(self.myFollowV).inset(20);
make.top.bottom.equalTo(self.myFollowV);
}];
[self.view addSubview:self.collectionBGView];
[self.collectionBGView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(280);
make.left.equalTo(self.view).offset(15);
make.right.equalTo(self.view).inset(15);
make.top.equalTo(self.topBgImageView.mas_bottom).offset(50);
}];
[self.collectionBGView addSubview:self.collectionView];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.collectionBGView).insets(UIEdgeInsetsMake(10, 10, 10, 10));
}];
[self.view addSubview:self.loginOutClassView];
[self.loginOutClassView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view).offset(15);
make.right.equalTo(self.view).inset(15);
make.height.mas_equalTo(50);
make.top.equalTo(self.collectionBGView.mas_bottom).offset(10);
}];
[self.loginOutClassView layoutIfNeeded];
[self.loginOutClassView roundCorners:UIRectCornerAllCorners radius:10];
[self.view bringSubviewToFront:self.setBtn];
self.collectionView.itemArr = self.collectionListArr;
}
-(void)setUserModel:(AppUserModel *)userModel
{
_userModel = userModel;
[self.headImage ddSetAnimatedImageView:[NSURL URLWithString:userModel.avatar] placeholderImage:DDPlaceholderHeadImage()];
self.nameLabel.text = userModel.nickname;
NSString * fans = [ToolsObject turnMoreThanTenThousandCount:userModel.fans_num type:0];
self.myFansLabel.attributedText = [self getAttributeString:@"我的粉丝" bottom:fans];
NSString * follows = [ToolsObject turnMoreThanTenThousandCount:userModel.attention_num type:0];
self.myFollowLabel.attributedText = [self getAttributeString:@"我的关注" bottom:follows];
}
- (void)pushCommonList:(DDMyInfoCommonListStyle)listStyle{
DDMyInfoCommonListViewController * listVC = [[DDMyInfoCommonListViewController alloc] init];
listVC.listStyle =listStyle;
[self.navigationController pushViewController:listVC animated:YES];
}
-(DDHoriCollectionView *)collectionView
{
if (!_collectionView) {
_collectionView = [[DDHoriCollectionView alloc]initWithFrame:CGRectZero];
WeakSelf(weakSelf)
_collectionView.didSelectedItemBlock = ^(id _Nonnull model) {
DDCellModel * clickModel = (DDCellModel *)model;
[weakSelf clickCellBtn:clickModel.setType];
};
}
return _collectionView;
}
-(DDMyInfoClassView *)loginOutClassView
{
if (!_loginOutClassView) {
_loginOutClassView = [[DDMyInfoClassView alloc]init];
_loginOutClassView.cellModel =[DDCellModel addDataWithName:@"退出登录" icon:@"myinfo_2" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_LoginOut) content:@""];
_loginOutClassView.backgroundColor = UIColor.whiteColor;
_loginOutClassView.backTapBlock = ^(DDCellModel * _Nonnull model) {
DDCustomAlertView * alertView = [[DDCustomAlertView alloc] init:@[@"取消",@"退出"] title:@"确定要退出账号吗?" content:@"" alertType:0];
alertView.alertViewClickBlock = ^(NSInteger index, NSString * _Nonnull title) {
if ([title isEqualToString:@"退出"]) {
[ToolsObject loginOutJump];
}
};
[alertView showAlertView];
};
}
return _loginOutClassView;
}
-(DDAnimateImageView *)headImage
{
if (!_headImage) {
_headImage = [DDAnimateImageView new];
_headImage.contentMode = UIViewContentModeScaleAspectFill;
_headImage.clipsToBounds = YES;
_headImage.userInteractionEnabled = YES;
[_headImage jk_addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
AppUserModel * myModel = [ToolsObject getUserModel];
[ToolsObject pushMyInformationViewController:myModel.user_id];
}];
}
return _headImage;
}
- (UIButton *)lookBtn{
if (!_lookBtn) {
_lookBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_lookBtn jk_addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
AppUserModel * myModel = [ToolsObject getUserModel];
[ToolsObject pushMyInformationViewController:myModel.user_id];
}];
}
return _lookBtn;
}
-(UILabel *)nameLabel
{
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.textColor = UIColor.whiteColor;
_nameLabel.font = [UIFont systemFontOfSize:18];
_nameLabel.text = @"";
_nameLabel.textAlignment = NSTextAlignmentLeft;
}
return _nameLabel;
}
-(UIImageView *)rightImg
{
if (!_rightImg) {
_rightImg = [UIImageView new];
_rightImg.image = [UIImage imageNamed:@"myinfo_5"];
}
return _rightImg;
}
-(void)clickCellBtn:(DDMyInfoModelType)type
{
switch (type) {
case DDMyInfoModelType_Wallet:
{
DDMyWalletVC *VC = [[DDMyWalletVC alloc] init];
[self.navigationController pushViewController:VC animated:YES];
}
break;
case DDMyInfoModelType_MineFanSi:
{
[self pushCommonList:DDMyInfoCommonListStyleFans];
}
break;
case DDMyInfoModelType_MineFollow:
{
[self pushCommonList:DDMyInfoCommonListStyleFollow];
}
break;
case DDMyInfoModelType_MineFootPrint:
{
DDMyInfoFootRoomListViewController *footVC = [[DDMyInfoFootRoomListViewController alloc]init];
[self.navigationController pushViewController:footVC animated:YES];
}
break;
case DDMyInfoModelType_MineVisitor:
{
[self pushCommonList:DDMyInfoCommonListStyleVisitor];
}
break;
case DDMyInfoModelType_customerservice:
{
//[BBPublicJumpTools jumpToContactCustomerService];
}
break;
case DDMyInfoModelType_DressUp:
{
DDStorePageVC *VC = [[DDStorePageVC alloc] init];
[self.navigationController pushViewController:VC animated:YES];
}
break;
case DDMyInfoModelType_YoungMode:
{
DDYoungModeViewController *VC = [[DDYoungModeViewController alloc] init];
[self.navigationController pushViewController:VC animated:YES];
}
break;
case DDMyInfoModelType_GuiZu:
{
DDNobleHomeViewController *vc = [[DDNobleHomeViewController alloc]init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case DDMyInfoModelType_MyRoom:
{
DDMyRoomHomeViewController *vc = [[DDMyRoomHomeViewController alloc]init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case DDMyInfoModelType_MyLevel:
{
DDMyLevelViewController *vc = [[DDMyLevelViewController alloc]init];
[self.navigationController pushViewController:vc animated:YES];
}
break;
case DDMyInfoModelType_Auther:
{
[self authorClick];
}
break;
// case DDMyInfoModelType_Social:
// {
//
// }
// break;
// case DDMyInfoModelType_Package:
// {
//
// }
// break;
default:
break;
}
}
- (void)authorClick{
WeakSelf(weakSelf)
[NetworkRequest requestPOST:@"/user/check/realname" parameters:@{}.mutableCopy block:^(BaseResponse * _Nonnull response) {
if ([ToolsObject IsNullWithObject:response.data]) {
return;
}
if (response.code == 200) {
DDRealNameModel *model = [DDRealNameModel yy_modelWithJSON:response.data];
if (model.status == 4) {
DDMyAuthorViewController *vc = [[DDMyAuthorViewController alloc]init];
[weakSelf.navigationController pushViewController:vc animated:YES];
}else{
DDMyAuthorStatusViewController * statusVC = [[DDMyAuthorStatusViewController alloc] init];
statusVC.realNameModel = model;
statusVC.authenType = model.status;
[weakSelf.navigationController pushViewController:statusVC animated:YES];
}
}
}];
}
- (void)setManagerClick{
DDMyInfoSettingViewController * settingVC = [[DDMyInfoSettingViewController alloc] init];
[self.navigationController pushViewController:settingVC animated:YES];
}
- (NSMutableAttributedString *)getAttributeString:(NSString *)top bottom:(NSString *)bottom{
NSString * contentString = [NSString stringWithFormat:@"%@\n%@",top,bottom];
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:contentString];
[attributedString addAttributes:@{NSForegroundColorAttributeName:[UIColor jk_colorWithHexString:@"#333333"], NSFontAttributeName:[UIFont boldSystemFontOfSize:16]}
range:NSMakeRange(0, top.length)];
return attributedString;
}
-(UIButton *)setBtn
{
if (!_setBtn) {
_setBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
[_setBtn setImage:[UIImage imageNamed:@"myinfo_8"] forState:(UIControlStateNormal)];
[_setBtn addTarget:self action:@selector(setManagerClick) forControlEvents:UIControlEventTouchUpInside];
}
return _setBtn;
}
-(NSMutableArray *)collectionListArr
{
if (!_collectionListArr) {
_collectionListArr = @[
[DDCellModel addDataWithName:@"实名认证" icon:@"myinfo_64" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_Auther) content:@""],
[DDCellModel addDataWithName:@"我的足迹" icon:@"myinfo_3" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_MineFootPrint) content:@""],
[DDCellModel addDataWithName:@"我的访客" icon:@"myinfo_7" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_MineVisitor) content:@""],
[DDCellModel addDataWithName:@"我的房间" icon:@"myinfo_50" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_MyRoom) content:@""],
[DDCellModel addDataWithName:@"我的钱包" icon:@"myinfo_9" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_Wallet) content:@""],
// [DDCellModel addDataWithName:@"我的背包" icon:@"myinfo_47" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_Package) content:@""],
[DDCellModel addDataWithName:@"装饰商城" icon:@"myinfo_10" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_DressUp) content:@""],
[DDCellModel addDataWithName:@"我的等级" icon:@"myinfo_49" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_MyLevel) content:@""],
// [DDCellModel addDataWithName:@"公会" icon:@"myinfo_51" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_Social) content:@""],
[DDCellModel addDataWithName:@"贵族特权" icon:@"myinfo_48" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_GuiZu) content:@""],
[DDCellModel addDataWithName:@"青少年模式" icon:@"myinfo_52" cellType:DDCellModelType_Icon setType:(DDMyInfoModelType_YoungMode) content:@""]
].mutableCopy;
}
return _collectionListArr;
}
- (UIImageView *)topBgImageView{
if (!_topBgImageView) {
_topBgImageView = [[UIImageView alloc] init];
_topBgImageView.contentMode = UIViewContentModeScaleAspectFill;
_topBgImageView.clipsToBounds = YES;
}
return _topBgImageView;
}
- (UIImageView *)bgImgV {
if (!_bgImgV) {
_bgImgV = [UIImageView new];
_bgImgV.image = [UIImage imageNamed:@"homepayty_1"];
_bgImgV.contentMode = UIViewContentModeScaleAspectFill;
} return _bgImgV;
}
- (UIView *)shadowV {
if (!_shadowV) {
_shadowV = [UIView new];
_shadowV.backgroundColor = [[UIColor jk_colorWithHexString:@"#111111"] colorWithAlphaComponent:0.4];
} return _shadowV;
}
- (UIView *)myFansV {
if (!_myFansV) {
_myFansV = [UIView new];
_myFansV.backgroundColor = [[UIColor jk_colorWithHexString:@"#ffffff"] colorWithAlphaComponent:1];
_myFansV.layer.cornerRadius = 10;
_myFansV.layer.masksToBounds = YES;
_myFansV.userInteractionEnabled = YES;
WeakSelf(weakSelf)
[_myFansV jk_addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
[weakSelf clickCellBtn:DDMyInfoModelType_MineFanSi];
}];
} return _myFansV;
}
- (UIView *)collectionBGView {
if (!_collectionBGView) {
_collectionBGView = [UIView new];
_collectionBGView.backgroundColor = [[UIColor jk_colorWithHexString:@"#ffffff"] colorWithAlphaComponent:1];
_collectionBGView.layer.cornerRadius = 10;
_collectionBGView.layer.masksToBounds = YES;
} return _collectionBGView;
}
- (UIView *)myFollowV {
if (!_myFollowV) {
_myFollowV = [UIView new];
_myFollowV.backgroundColor = [[UIColor jk_colorWithHexString:@"#ffffff"] colorWithAlphaComponent:1];
_myFollowV.layer.cornerRadius = 10;
_myFollowV.layer.masksToBounds = YES;
_myFollowV.userInteractionEnabled = YES;
WeakSelf(weakSelf)
[_myFollowV jk_addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
[weakSelf clickCellBtn:DDMyInfoModelType_MineFollow];
}];
} return _myFollowV;
}
- (UIImageView *)myFansImgV {
if (!_myFansImgV) {
_myFansImgV = [UIImageView new];
_myFansImgV.image = [UIImage imageNamed:@"myinfo_16"];
_myFansImgV.contentMode = UIViewContentModeScaleAspectFill;
} return _myFansImgV;
}
- (UIImageView *)myFollowImgV {
if (!_myFollowImgV) {
_myFollowImgV = [UIImageView new];
_myFollowImgV.image = [UIImage imageNamed:@"myinfo_15"];
_myFollowImgV.contentMode = UIViewContentModeScaleAspectFill;
} return _myFollowImgV;
}
- (UILabel *)myFansLabel {
if (!_myFansLabel) {
_myFansLabel = [UILabel new];
_myFansLabel.text = @"";
_myFansLabel.textColor = [UIColor jk_colorWithHexString:@"#999999"];
_myFansLabel.font = [UIFont systemFontOfSize:16];
_myFansLabel.numberOfLines = 2;
_myFansLabel.attributedText = [self getAttributeString:@"我的粉丝" bottom:@"0"];
} return _myFansLabel;
}
- (UILabel *)myFollowLabel {
if (!_myFollowLabel) {
_myFollowLabel = [UILabel new];
_myFollowLabel.text = @"";
_myFollowLabel.textColor = [UIColor jk_colorWithHexString:@"#999999"];
_myFollowLabel.font = [UIFont systemFontOfSize:16];
_myFollowLabel.numberOfLines = 2;
_myFollowLabel.attributedText = [self getAttributeString:@"我的关注" bottom:@"0"];
} return _myFollowLabel;
}
@end