214 lines
7.9 KiB
Objective-C
Executable File
214 lines
7.9 KiB
Objective-C
Executable File
//
|
|
// SPGonghuiDetailVC.m
|
|
// SweetParty
|
|
//
|
|
// Created by bj_szd on 2022/6/29.
|
|
//
|
|
|
|
#import "SPGonghuiDetailVC.h"
|
|
#import "SPGonghuiDetailListVC.h"
|
|
#import "SPGonghuiApplyListVC.h"
|
|
#import "SPGonghuiJoinAlert.h"
|
|
|
|
@interface SPGonghuiDetailVC ()<JXCategoryListContainerViewDelegate>
|
|
|
|
@property (nonatomic, strong) NSArray *titles;
|
|
@property (nonatomic, strong) JXCategoryTitleView *categoryView;
|
|
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
|
|
|
|
@property (nonatomic, strong) UIButton *applyListBtn;
|
|
|
|
@property (nonatomic, strong) UIButton *joinBtn;
|
|
|
|
@property (nonatomic, strong) NSString *quit_money;//退出需要的金额
|
|
|
|
@property (nonatomic, strong) UILabel *redLab;
|
|
|
|
@end
|
|
|
|
@implementation SPGonghuiDetailVC
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
[super viewWillAppear:animated];
|
|
|
|
[self onRequestJoinNum];
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
|
|
[self showNaviBarWithTitle:@""];
|
|
|
|
self.titles = @[@"公会成员", @"房间列表"];
|
|
|
|
[self createUI];
|
|
|
|
[self onJudgeHuizhang];
|
|
}
|
|
|
|
- (void)createUI {
|
|
UIImageView *bgImgV = [[UIImageView alloc] initWithImage:ImageNamed(@"gonghui_bg")];
|
|
[self.view insertSubview:bgImgV atIndex:0];
|
|
[bgImgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.left.right.equalTo(self.view);
|
|
make.height.mas_equalTo(ScreenWidth/375*812);
|
|
}];
|
|
|
|
[self.view addSubview:self.categoryView];
|
|
[self.view addSubview:self.listContainerView];
|
|
|
|
[self.categoryView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.view).offset(yb_NavigationBar_H+4);
|
|
make.left.equalTo(self.view).offset(15);
|
|
make.right.equalTo(self.view).offset(-15);
|
|
make.height.mas_equalTo(40);
|
|
}];
|
|
[self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.categoryView.mas_bottom).offset(12);
|
|
make.left.right.bottom.equalTo(self.view);
|
|
}];
|
|
|
|
self.applyListBtn = [ControlCreator createButton:self.view rect:CGRectMake(ScreenWidth-60-12, yb_StatusBar_H+7, 60, 30) text:@"申请列表" font:YBMediumFont(12) color:HEXCOLOR(0x333333) backguoundColor:nil imageName:nil target:self action:@selector(onApplyList)];
|
|
self.applyListBtn.hidden = YES;
|
|
|
|
self.redLab = [ControlCreator createLabel:self.view rect:CGRectMake(ScreenWidth-20-2, yb_StatusBar_H+3, 18, 18) text:@"0" font:YBBoldFont(10) color:kWhiteColor backguoundColor:kRedColor align:NSTextAlignmentCenter lines:1];
|
|
self.redLab.layer.cornerRadius = 9;
|
|
self.redLab.layer.masksToBounds = YES;
|
|
self.redLab.hidden = YES;
|
|
|
|
self.joinBtn = [ControlCreator createButton:self.view rect:CGRectMake(27, ScreenHeight-50-49, ScreenWidth-27*2, 49) text:@"申请加入" font:YBBoldFont(15) color:HEXCOLOR(0x333333) backguoundColor:nil imageName:nil target:self action:@selector(onJoinOrQuitGonghui)];
|
|
[self.joinBtn setTitle:@"退出公会" forState:UIControlStateSelected];
|
|
self.joinBtn.layer.cornerRadius = 24.5;
|
|
self.joinBtn.layer.masksToBounds = YES;
|
|
[self.joinBtn styleGradiBlueColor];
|
|
self.joinBtn.hidden = YES;
|
|
}
|
|
|
|
- (void)onApplyList {
|
|
SPGonghuiApplyListVC *vc = [[SPGonghuiApplyListVC alloc] init];
|
|
vc.guild_id = self.guild_id;
|
|
[vc pushSelf];
|
|
}
|
|
|
|
- (void)onRequestJoinNum {
|
|
NSDictionary *params = @{@"guild_id":C_string(self.guild_id), @"page":@(1), @"page_limit":@"1000"};
|
|
[AFNetworkRequset.shared postRequestWithParams:params Path:@"api/guild/get_apply_guild_list" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
|
|
NSArray *arr = [responseDic[@"data"] safeArrayForKey:@"list"];
|
|
self.redLab.text = [NSString stringWithFormat:@"%ld", arr.count];
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}
|
|
|
|
- (void)onJudgeHuizhang {
|
|
NSDictionary *params = @{@"guild_id":C_string(self.guild_id)};
|
|
[AFNetworkRequset.shared postRequestWithParams:params Path:@"api/guild/user_is_deacon" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
|
|
self.naviView.titleLab.text = responseDic[@"data"][@"guild_name"];
|
|
self.quit_money = [responseDic[@"data"] safeStringForKey:@"quit_money"];
|
|
NSInteger is_deacon = [responseDic[@"data"] safeIntForKey:@"is_deacon"];
|
|
if (is_deacon == 1) {
|
|
self.applyListBtn.hidden = self.redLab.hidden = NO;
|
|
self.joinBtn.hidden = YES;
|
|
}else {
|
|
self.applyListBtn.hidden = self.redLab.hidden = YES;
|
|
self.joinBtn.hidden = NO;
|
|
self.joinBtn.selected = [BJUserManager.userInfo.guild_id integerValue] == [self.guild_id integerValue];
|
|
}
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}
|
|
|
|
- (void)onJoinOrQuitGonghui {
|
|
WEAK_SELF
|
|
SPGonghuiJoinAlert *alert = [[NSBundle mainBundle] loadNibNamed:@"SPGonghuiJoinAlert" owner:self options:nil].firstObject;
|
|
alert.frame = [UIScreen mainScreen].bounds;
|
|
[KEYWINDOW addSubview:alert];
|
|
|
|
if ([BJUserManager.userInfo.guild_id integerValue] == [self.guild_id integerValue]) {
|
|
//退出
|
|
alert.onConfirmBlock = ^{
|
|
[self onQuitRequest];
|
|
};
|
|
alert.contentLab.text = [NSString stringWithFormat:@"退出公会需要支付%@金币,您确定要退出吗?", self.quit_money];
|
|
[alert.confirmBtn setTitle:@"申请退出" forState:UIControlStateNormal];
|
|
}else {
|
|
//加入
|
|
alert.onConfirmBlock = ^{
|
|
[weakSelf onJoinRequest];
|
|
};
|
|
}
|
|
}
|
|
|
|
- (void)onJoinRequest {
|
|
NSDictionary *params = @{@"guild_id":C_string(self.guild_id)};
|
|
[AFNetworkRequset.shared postRequestWithParams:params Path:@"api/guild/join_guild" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
|
|
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}
|
|
|
|
- (void)onQuitRequest {
|
|
NSDictionary *params = @{@"guild_id":C_string(self.guild_id)};
|
|
[AFNetworkRequset.shared postRequestWithParams:params Path:@"api/guild/quit_guild" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
|
|
[self.navigationController popToRootViewControllerAnimated:YES];
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}
|
|
|
|
// 分页菜单视图
|
|
- (JXCategoryTitleView *)categoryView {
|
|
if (!_categoryView) {
|
|
_categoryView = [[JXCategoryTitleView alloc] init];
|
|
_categoryView.titleFont = YBMediumFont(15);
|
|
_categoryView.titleSelectedFont = [UIFont systemFontOfSize:17 weight:UIFontWeightHeavy];
|
|
_categoryView.titleColor = HEXCOLOR(0x666666);
|
|
_categoryView.titleSelectedColor = HEXCOLOR(0x111111);
|
|
|
|
_categoryView.listContainer = self.listContainerView;
|
|
_categoryView.titles = self.titles;
|
|
|
|
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
|
|
lineView.indicatorImageViewSize = CGSizeMake(15, 15);
|
|
lineView.indicatorImageView.image = ImageNamed(@"common_zhishi");
|
|
lineView.verticalMargin = 20;
|
|
lineView.horizontalMargin = 34;
|
|
_categoryView.indicators = @[lineView];
|
|
}
|
|
return _categoryView;
|
|
}
|
|
|
|
// 列表容器视图
|
|
- (JXCategoryListContainerView *)listContainerView {
|
|
if (!_listContainerView) {
|
|
_listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
|
}
|
|
return _listContainerView;
|
|
}
|
|
|
|
#pragma mark - JXCategoryListContainerViewDelegate
|
|
|
|
// 返回列表的数量
|
|
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
|
|
return self.titles.count;
|
|
}
|
|
|
|
// 返回各个列表菜单下的实例,该实例需要遵守并实现 <JXCategoryListContentViewDelegate> 协议
|
|
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
|
SPGonghuiDetailListVC *list = [[SPGonghuiDetailListVC alloc] init];
|
|
list.type = index+1;
|
|
list.guild_id = self.guild_id;
|
|
|
|
return list;
|
|
}
|
|
|
|
#pragma mark - JXCategoryListContentViewDelegate
|
|
|
|
- (UIView *)listView {
|
|
return self.view;
|
|
}
|
|
|
|
@end
|