234 lines
9.0 KiB
Objective-C
234 lines
9.0 KiB
Objective-C
//
|
|
// LMGonghuiDetailsViewController.m
|
|
// SweetParty
|
|
//
|
|
// Created by Xmac on 2024/8/8.
|
|
//
|
|
|
|
#import "LMGonghuiDetailsViewController.h"
|
|
#import "LMGonghuiDetailModel.h"
|
|
#import "SPGonghuiJoinAlert.h"
|
|
#import "SPGonghuiApplyListVC.h"
|
|
#import "SPGonghuiDetailListVC.h"
|
|
#import "LMGonghuiButieViewController.h"
|
|
#import "NSString+category.h"
|
|
|
|
@interface LMGonghuiDetailsViewController ()
|
|
|
|
@property (weak, nonatomic) IBOutlet UIImageView *gonghuiCover;
|
|
@property (weak, nonatomic) IBOutlet UILabel *gonghuiNameLabel;
|
|
@property (weak, nonatomic) IBOutlet UILabel *gonghuiIDLabel;
|
|
@property (weak, nonatomic) IBOutlet UILabel *gonghuiPersonNumLabel;
|
|
@property (weak, nonatomic) IBOutlet UILabel *totalValueLabel;
|
|
|
|
@property (weak, nonatomic) IBOutlet UIView *gonghuiRoomView;
|
|
@property (weak, nonatomic) IBOutlet UIView *gonghuiPersonView;
|
|
@property (weak, nonatomic) IBOutlet UIView *gonghuiButieView;
|
|
|
|
@property (weak, nonatomic) IBOutlet UIImageView *huizhangHeaderPic;
|
|
@property (weak, nonatomic) IBOutlet UILabel *huizhangNameLabel;
|
|
@property (weak, nonatomic) IBOutlet UIImageView *huizhangGXPic;
|
|
@property (weak, nonatomic) IBOutlet UIImageView *huizhangMLpic;
|
|
@property (weak, nonatomic) IBOutlet UIImageView *huizhangJueweiPic;
|
|
|
|
@property (weak, nonatomic) IBOutlet UIView *huizhangInfoCoverView;
|
|
@property (weak, nonatomic) IBOutlet UIButton *joinButton;
|
|
@property (weak, nonatomic) IBOutlet UILabel *createTimeLab;
|
|
|
|
@property (weak, nonatomic) IBOutlet UILabel *gonghuiIntroLabel;
|
|
@property (nonatomic, strong) LMGonghuiDetailModel *infoModel;
|
|
@property (nonatomic, strong) UIButton *applyListBtn;
|
|
@property (nonatomic, assign) NSInteger is_deacon;
|
|
|
|
@property (nonatomic, strong) NSString *quit_money;//退出需要的金额
|
|
|
|
|
|
@end
|
|
|
|
@implementation LMGonghuiDetailsViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view from its nib.
|
|
self.navTitle = @"公会";
|
|
[self.customNavBar styleClear];
|
|
|
|
self.joinButton.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(APPW-15*2, 48) direction:(FXGradientChangeDirectionHorizontal) startColor:mainLightColor endColor:mainDeepColor];
|
|
|
|
[self requestGonghuiDetails];
|
|
[self onJudgeHuizhang];
|
|
|
|
WEAK_SELF;
|
|
[self.gonghuiRoomView dg_Tapped:^{
|
|
SPGonghuiDetailListVC *list = [[SPGonghuiDetailListVC alloc] init];
|
|
list.type = 2;
|
|
list.guild_id = weakSelf.guild_id;
|
|
[list pushSelf];
|
|
}];
|
|
|
|
[self.gonghuiPersonView dg_Tapped:^{
|
|
SPGonghuiDetailListVC *list = [[SPGonghuiDetailListVC alloc] init];
|
|
list.type = 1;
|
|
list.guild_id = weakSelf.guild_id;
|
|
[list pushSelf];
|
|
}];
|
|
|
|
[self.gonghuiButieView dg_Tapped:^{
|
|
LMGonghuiButieViewController *vc = [[LMGonghuiButieViewController alloc] init];
|
|
vc.last_week_income = weakSelf.infoModel.last_week_income;
|
|
vc.this_week_income = weakSelf.infoModel.this_week_income;
|
|
vc.last_week_income_money = weakSelf.infoModel.last_week_income_money;
|
|
[vc pushSelf];
|
|
}];
|
|
|
|
// 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;
|
|
}
|
|
|
|
- (void)setupGonghuiInfo
|
|
{
|
|
[self.gonghuiCover sd_setImageWithURL:[NSURL URLWithString:self.infoModel.cover] placeholderImage:kDefaultUserIcon];
|
|
self.createTimeLab.text = [NSString stringWithFormat:@"创建时间:%@",self.infoModel.add_time.formateDateYMD];
|
|
if ([self.infoModel.guild_special_id isEqualToString:@"0"]){
|
|
self.gonghuiIDLabel.text = [NSString stringWithFormat:@"%@",self.infoModel.guild_id];
|
|
}else{
|
|
self.gonghuiIDLabel.text = [NSString stringWithFormat:@"%@",self.infoModel.guild_special_id];
|
|
}
|
|
self.gonghuiNameLabel.text = self.infoModel.guild_name;
|
|
self.gonghuiPersonNumLabel.text = self.infoModel.num;
|
|
self.totalValueLabel.text = self.infoModel.contribution_value;
|
|
[self.huizhangHeaderPic sd_setImageWithURL:[NSURL URLWithString:self.infoModel.ghz.head_pic] placeholderImage:kDefaultUserIcon];
|
|
self.huizhangNameLabel.text = self.infoModel.ghz.nick_name;
|
|
[self.huizhangGXPic sd_setImageWithURL:[NSURL URLWithString:self.infoModel.ghz.contribution_level_image]];
|
|
[self.huizhangMLpic sd_setImageWithURL:[NSURL URLWithString:self.infoModel.ghz.charm_level_image]];
|
|
[self.huizhangJueweiPic sd_setImageWithURL:[NSURL URLWithString:self.infoModel.ghz.noblity_image]];
|
|
|
|
[self.huizhangInfoCoverView dg_Tapped:^{
|
|
[UIViewController goUserMainpageWith:self.infoModel.ghz.uid withRid:@""];
|
|
}];
|
|
self.quit_money = self.infoModel.money;
|
|
if (self.infoModel.intro.length > 0){
|
|
self.gonghuiIntroLabel.text = self.infoModel.intro;
|
|
}else{
|
|
self.gonghuiIntroLabel.text = @"暂无简介";
|
|
}
|
|
}
|
|
|
|
- (void)onApplyList {
|
|
SPGonghuiApplyListVC *vc = [[SPGonghuiApplyListVC alloc] init];
|
|
vc.guild_id = self.guild_id;
|
|
[vc pushSelf];
|
|
}
|
|
|
|
- (void)requestGonghuiDetails
|
|
{
|
|
[BJHttpTool BJ_Get_the_guild_infoWithParameters:@{@"guild_id":self.guild_id} success:^(id response) {
|
|
self.infoModel = [LMGonghuiDetailModel mj_objectWithKeyValues:response[@"data"]];
|
|
[self setupGonghuiInfo];
|
|
} failure:^(NSError *error) {
|
|
|
|
}];
|
|
}
|
|
|
|
- (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) {
|
|
NSInteger is_deacon = [responseDic[@"data"] safeIntForKey:@"is_deacon"];
|
|
self.is_deacon = is_deacon;
|
|
if (is_deacon == 1) {
|
|
if ([BJUserManager.userInfo.guild_id integerValue] == [self.guild_id integerValue]){
|
|
[self.joinButton setTitle:@"解散公会" forState:(UIControlStateNormal)];
|
|
self.gonghuiButieView.hidden = NO;
|
|
}
|
|
}else {
|
|
if ([BJUserManager.userInfo.guild_id integerValue] == [self.guild_id integerValue]){
|
|
[self.joinButton setTitle:@"退出公会" forState:(UIControlStateNormal)];
|
|
}
|
|
self.gonghuiButieView.hidden = YES;
|
|
}
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}
|
|
|
|
|
|
- (IBAction)gonghuiIDCopyButtonClick:(UIButton *)sender {
|
|
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
|
|
pasteboard.string = self.gonghuiIDLabel.text;
|
|
|
|
[HelpPageDefine showMessage:@"复制成功"];
|
|
}
|
|
|
|
- (IBAction)joinButtonClick:(UIButton *)sender {
|
|
if (_is_deacon == 1) {
|
|
//解散公会、
|
|
[self onJiesanGonghui];
|
|
}else{
|
|
[self onJoinOrQuitGonghui];
|
|
}
|
|
}
|
|
|
|
- (void)onJoinOrQuitGonghui {
|
|
WEAK_SELF
|
|
SPGonghuiJoinAlert *alert = [[NSBundle mainBundle] loadNibNamed:@"SPGonghuiJoinAlert" owner:self options:nil].firstObject;
|
|
alert.frame = [UIScreen mainScreen].bounds;
|
|
[MainWindow() 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) {
|
|
|
|
}];
|
|
}
|
|
|
|
- (void)ondissGuildRequest {
|
|
NSDictionary *params = @{@"guild_id":C_string(self.guild_id)};
|
|
[AFNetworkRequset.shared postRequestWithParams:params Path:@"api/guild/diss_guild" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
|
|
[self.navigationController popToRootViewControllerAnimated:YES];
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}
|
|
|
|
- (void)onJiesanGonghui {
|
|
WEAK_SELF
|
|
SPGonghuiJoinAlert *alert = [[NSBundle mainBundle] loadNibNamed:@"SPGonghuiJoinAlert" owner:self options:nil].firstObject;
|
|
alert.frame = [UIScreen mainScreen].bounds;
|
|
[MainWindow() addSubview:alert];
|
|
|
|
alert.onConfirmBlock = ^{
|
|
[weakSelf ondissGuildRequest];
|
|
};
|
|
alert.contentLab.text = @"确定要解散该公会吗?";
|
|
[alert.confirmBtn setTitle:@"解散公会" forState:UIControlStateNormal];
|
|
}
|
|
|
|
|
|
@end
|