| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- //
- // SocietyDesViewController.m
- // BuguLive
- //
- // Created by 王珂 on 17/1/22.
- // Copyright © 2017年 xfg. All rights reserved.
- //
- #import "SocietyDesViewController.h"
- #import "GetHeadImgViewController.h"
- #import "EditSocietyViewController.h"
- #import "SocietyDesModel.h"
- #import "SocietyMemberViewController.h"
- #import "SocietyListModel.h"
- @interface SocietyDesViewController ()<UITextViewDelegate>
- @property (nonatomic, strong) UIView * view1;
- @property (nonatomic, strong) UIView * view2;
- @property (nonatomic, strong) UIView * view3;
- @property (nonatomic, strong) UIView * view4;
- @property (nonatomic, strong) UIView * view5;
- @property (nonatomic, strong) UIButton * headBtn;
- @property (nonatomic, strong) UILabel * societyLabel;
- @property (nonatomic, strong) UITextView * nameTextView;//公会名称
- @property (nonatomic, strong) UITextView * desTextView;//公会宣言
- @property (nonatomic, strong) UIButton * editBtn; //编辑按钮
- @property (nonatomic, strong) UIButton * managerBtn; //成员管理
- @property (nonatomic, strong) UIButton * memberBtn; //公会成员
- @property (nonatomic, strong) UIButton * leaveBtn; //退出公会
- @property (nonatomic, strong) UIButton * applyBtn; //申请加入公会
- @property (nonatomic, strong) SocietyDesModel * model; //公会信息Model;
- @property (nonatomic, strong) UILabel * societyHeaderName; //公会会长名
- @property (nonatomic, strong) UILabel * numberLable; //公会人数
- @property (nonatomic, assign) int canEditAll;
- @end
- @implementation SocietyDesViewController
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- [self createView];
- [self loadData];
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self loadData];
- }
- - (void)createView
- {
- self.navigationItem.title = ASLocalizedString(@"公会详情");
- self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(comeBack) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
- self.view.backgroundColor = kFamilyBackGroundColor;
- _view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*375/1200)];
- [self.view addSubview:_view1];
- _view2 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_view1.frame), kScreenW, (kScreenH-64)*115/1200)];
- [self.view addSubview:_view2];
- _view3 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_view2.frame), kScreenW, (kScreenH-64)*115/1200)];
- [self.view addSubview:_view3];
- _view4 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_view3.frame), kScreenW, (kScreenH-64)*115/1200)];
- [self.view addSubview:_view4];
- _view5 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_view4.frame), kScreenW, (kScreenH-64)*490/1200)];
- [self.view addSubview:_view5];
- _nameTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*95/1200)];
- _nameTextView.backgroundColor = [UIColor whiteColor];
- _nameTextView.textAlignment = NSTextAlignmentCenter;
- _nameTextView.font = [UIFont systemFontOfSize:15];
- _nameTextView.editable = NO;
- [_view2 addSubview:_nameTextView];
- _societyHeaderName = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*95/1200)];
- _societyHeaderName.backgroundColor = [UIColor whiteColor];
- _societyHeaderName.font = [UIFont systemFontOfSize:15];
- _societyHeaderName.textAlignment = NSTextAlignmentCenter;
- [_view3 addSubview:_societyHeaderName];
-
- _numberLable= [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*95/1200)];
- _numberLable.backgroundColor = [UIColor whiteColor];
- _numberLable.font = [UIFont systemFontOfSize:15];
- _numberLable.textAlignment = NSTextAlignmentCenter;
- // _numberLable.text = ASLocalizedString(@"公会人数");
- [_view4 addSubview:_numberLable];
-
- _desTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*310/1200)];
- _desTextView.backgroundColor = [UIColor whiteColor];
- // _desTextView.text = ASLocalizedString(@"公会详情描述");
- _desTextView.editable = NO;
- _desTextView.font = [UIFont systemFontOfSize:15];
- [_view5 addSubview:_desTextView];
- [self createBtn];
- }
- - (void)createBtn
- {
- //如果是公会会长
- if (_isSocietyHeder==1) {
-
- _headBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _headBtn.frame = CGRectMake((kScreenW-90)/2, (CGRectGetHeight(_view1.frame)-117)/2, 90, 90);
- _headBtn.backgroundColor = [UIColor whiteColor];
- _headBtn.layer.cornerRadius = 45;
- _headBtn.layer.masksToBounds = YES;
- [_headBtn addTarget:self action:@selector(clickHeadImage) forControlEvents:UIControlEventTouchUpInside];
- [_view1 addSubview:_headBtn];
- _societyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_headBtn.frame)+10, kScreenW, 17)];
- _societyLabel.text = ASLocalizedString(@"编辑公会头像");
- _societyLabel.textAlignment = NSTextAlignmentCenter;
- _societyLabel.font = [UIFont systemFontOfSize:17];
- _societyLabel.textColor = kAppGrayColor2;
- [_view1 addSubview:_societyLabel];
-
- _editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _editBtn.frame = CGRectMake(25, 25+CGRectGetMaxY(_desTextView.frame), (kScreenW-75)/2, 40 );
- _editBtn.backgroundColor = kAppMainColor;
- _editBtn.layer.cornerRadius = 20;
- _editBtn.layer.masksToBounds = YES;
- [_editBtn setTitle:ASLocalizedString(@"编辑资料")forState:UIControlStateNormal];
- [_editBtn addTarget:self action:@selector(clickEditBtn) forControlEvents:UIControlEventTouchUpInside];
- [_view5 addSubview:_editBtn];
- _managerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _managerBtn.frame = CGRectMake(50+(kScreenW-75)/2, 25+CGRectGetMaxY(_desTextView.frame), (kScreenW-75)/2, 40);
- _managerBtn.backgroundColor = kAppFamilyBtnColor;
- _managerBtn.layer.cornerRadius = 20;
- _managerBtn.layer.masksToBounds = YES;
- [_managerBtn setTitle:ASLocalizedString(@"成员管理")forState:UIControlStateNormal];
- [_managerBtn addTarget:self action:@selector(clickManagerBtn) forControlEvents:UIControlEventTouchUpInside];
- [_view5 addSubview:_managerBtn];
- }
- else
- {
- _headBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _headBtn.frame = CGRectMake((kScreenW-90)/2, (CGRectGetHeight(_view1.frame)-90)/2, 90, 90);
- _headBtn.backgroundColor = [UIColor whiteColor];
- _headBtn.layer.cornerRadius = 45;
- _headBtn.layer.masksToBounds = YES;
- _headBtn.userInteractionEnabled = NO;
- [_view1 addSubview:_headBtn];
- if (_isSocietyHeder==0) {
- _memberBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _memberBtn.frame = CGRectMake(25, 25+CGRectGetMaxY(_desTextView.frame), (kScreenW-75)/2, 40);
- _memberBtn.backgroundColor = kAppMainColor;
- _memberBtn.layer.cornerRadius = 20;
- _memberBtn.layer.masksToBounds = YES;
- [_memberBtn setTitle:ASLocalizedString(@"公会成员")forState:UIControlStateNormal];
- [_memberBtn addTarget:self action:@selector(clickMemberBtn) forControlEvents:UIControlEventTouchUpInside];
- [_view5 addSubview:_memberBtn];
- _leaveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _leaveBtn.frame = CGRectMake(50+(kScreenW-75)/2, 25+CGRectGetMaxY(_desTextView.frame), (kScreenW-75)/2, 40);
- _leaveBtn.backgroundColor = kAppFamilyBtnColor;
- _leaveBtn.layer.cornerRadius = 20;
- _leaveBtn.layer.masksToBounds = YES;
- [_leaveBtn setTitle:ASLocalizedString(@"退出公会")forState:UIControlStateNormal];
- [_leaveBtn addTarget:self action:@selector(clickLeaveBtn) forControlEvents:UIControlEventTouchUpInside];
- [_view5 addSubview:_leaveBtn];
- }
- else if (_isSocietyHeder ==2)
- {
- _applyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _applyBtn.frame = CGRectMake(25, 25+CGRectGetMaxY(_desTextView.frame), kScreenW-50, 40);
- _applyBtn.layer.cornerRadius = 20;
- _applyBtn.layer.masksToBounds = YES;
- [_headBtn sd_setImageWithURL:[NSURL URLWithString:_listModel.logo] forState:UIControlStateNormal placeholderImage:kDefaultPreloadHeadImg];
- _nameTextView.text = _listModel.name;
- // _desTextView.text =_model.family_manifesto;
- _societyHeaderName.text = [NSString stringWithFormat:ASLocalizedString(@"公会会长 : %@"),_listModel.nick_name];
- _numberLable.text = [NSString stringWithFormat:ASLocalizedString(@"公会人数 : %@人"),_listModel.user_count];
- if([_is_apply isEqualToString:@"0"])
- {
- _applyBtn.backgroundColor = kAppMainColor;
- [_applyBtn setTitle:ASLocalizedString(@"加入公会")forState:UIControlStateNormal];
- [_applyBtn addTarget:self action:@selector(clickApplyBtn) forControlEvents:UIControlEventTouchUpInside];
- }
- else if ([_is_apply isEqualToString:@"1"])
- {
- _applyBtn.backgroundColor = kAppGrayColor3;
- [_applyBtn setTitle:ASLocalizedString(@"申请中")forState:UIControlStateNormal];
- _applyBtn.enabled = NO;
- }
- else if ([_is_apply isEqualToString:@"2"])
- {
- _applyBtn.backgroundColor = kAppGrayColor3;
- [_applyBtn setTitle:ASLocalizedString(@"已加入")forState:UIControlStateNormal];
- _applyBtn.enabled = NO;
- }
- [_view5 addSubview:_applyBtn];
- }
- }
- }
- //点击编辑资料按钮
- - (void)clickEditBtn
- {
- EditSocietyViewController * editSocietyVC = [[EditSocietyViewController alloc] init];
- editSocietyVC.type = 1;
- editSocietyVC.model = self.model;
- editSocietyVC.user_id = self.user_id;
- editSocietyVC.canEditAll = self.canEditAll;
- [self.navigationController pushViewController:editSocietyVC animated:YES];
- }
- //点击成员管理按钮
- - (void)clickManagerBtn
- {
- SocietyMemberViewController * societyMemberVC = [[SocietyMemberViewController alloc] init];
- societyMemberVC.isSocietyHeder = 1;
- societyMemberVC.society_id = self.model.society_id;
- [self.navigationController pushViewController:societyMemberVC animated:YES];
- }
- //点击公会成员按钮
- - (void)clickMemberBtn
- {
- SocietyMemberViewController * societyMemberVC = [[SocietyMemberViewController alloc] init];
- societyMemberVC.isSocietyHeder = 0;
- societyMemberVC.society_id = self.model.society_id;
- [self.navigationController pushViewController:societyMemberVC animated:YES];
- }
- //点击编辑公会头像
- - (void)clickHeadImage
- {
- EditSocietyViewController * editSocietyVC = [[EditSocietyViewController alloc] init];
- editSocietyVC.type = 1;
- editSocietyVC.model = self.model;
- editSocietyVC.user_id = self.user_id;
- [self.navigationController pushViewController:editSocietyVC animated:YES];
- }
- //点击退出公会
- - (void)clickLeaveBtn
- {
- FWWeakify(self)
- [FanweMessage alert:ASLocalizedString(@"提示")message:ASLocalizedString(@"是否退出该公会")destructiveAction:^{
-
- FWStrongify(self)
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"society_user" forKey:@"ctl"];
- [parmDict setObject:@"logout" forKey:@"act"];
- [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
-
- } FailureBlock:^(NSError *error) {
-
- }];
-
- } cancelAction:^{
-
- }];
- }
- //申请加入公会
- - (void)clickApplyBtn
- {
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"society_user" forKey:@"ctl"];
- [parmDict setObject:@"join" forKey:@"act"];
- [parmDict setObject:_society_id forKey:@"society_id"];
- [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
-
- if ([responseJson toInt:@"status"]==1)
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"申请已提交")];
- _applyBtn.backgroundColor = kAppGrayColor3;
- [_applyBtn setTitle:ASLocalizedString(@"申请中")forState:UIControlStateNormal];
- _applyBtn.enabled = NO;
- }
-
- } FailureBlock:^(NSError *error) {
- NSLog(@"%@",error);
- }];
- }
- //点击返回按钮
- - (void)comeBack
- {
- [self.navigationController popViewControllerAnimated:NO];
- }
- - (void)loadData
- {
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"society" forKey:@"ctl"];
- [parmDict setObject:@"index" forKey:@"act"];
- [parmDict setObject:_society_id forKey:@"society_id"];
- [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
-
- NSDictionary * dic = [responseJson objectForKey:@"society_info"];
- if (dic && [dic isKindOfClass:[NSDictionary class]])
- {
- _model = [SocietyDesModel mj_objectWithKeyValues:dic];
- [_headBtn sd_setImageWithURL:[NSURL URLWithString:_model.logo] forState:UIControlStateNormal placeholderImage:kDefaultPreloadHeadImg];
- _nameTextView.text = _model.name;
- _desTextView.text =_model.manifesto;
- _societyHeaderName.text = [NSString stringWithFormat:ASLocalizedString(@"公会会长 : %@"),_model.nick_name];
- _numberLable.text = [NSString stringWithFormat:ASLocalizedString(@"公会人数 : %@人"),_model.user_count];
- }
- if ([dic toInt:@"status"]==1)
- {
- if (_isSocietyHeder==1)
- {
- _headBtn.userInteractionEnabled = YES;
- _editBtn.userInteractionEnabled = YES;
- _editBtn.backgroundColor = kAppMainColor;
- _managerBtn.userInteractionEnabled = YES;
- _managerBtn.backgroundColor = kAppFamilyBtnColor;
- _canEditAll = 0;
- }
- if (_isSocietyHeder==0)
- {
- _memberBtn.userInteractionEnabled = YES;
- _memberBtn.backgroundColor = kAppMainColor;
- }
- }
- else if ([dic toInt:@"status"]==0) // 申请正在审核
- {
- if (_isSocietyHeder==1)
- {
- _headBtn.userInteractionEnabled = NO;
- _editBtn.userInteractionEnabled = NO;
- _editBtn.backgroundColor = kAppGrayColor3;
- _managerBtn.userInteractionEnabled = NO;
- _managerBtn.backgroundColor = kAppGrayColor3;
- }
- else if (_isSocietyHeder==0)
- {
- _memberBtn.userInteractionEnabled = NO;
- _memberBtn.backgroundColor = kAppGrayColor3;
- }
- }
-
- else if ([dic toInt:@"status"]==2) // 审核未通过
- {
- if (_isSocietyHeder==1)
- {
- _headBtn.userInteractionEnabled = YES;
- _editBtn.userInteractionEnabled = YES;
- _editBtn.backgroundColor = kAppMainColor;
- _managerBtn.userInteractionEnabled = NO;
- _managerBtn.backgroundColor = kAppGrayColor3;
- _canEditAll = 1;
- }
- if (_isSocietyHeder==0)
- {
- _memberBtn.userInteractionEnabled = NO;
- _memberBtn.backgroundColor = kAppGrayColor3;
- }
- }
-
- } FailureBlock:^(NSError *error) {
-
- }];
- }
- - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
- {
- [UIMenuController sharedMenuController].menuVisible = NO; //donot display the menu
- [_desTextView resignFirstResponder]; //do not allow the user to selected anything
- [_nameTextView resignFirstResponder];
- return NO;
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- }
- @end
|