| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- //
- // FamilyDesViewController.m
- // BuguLive
- //
- // Created by 王珂 on 16/9/26.
- // Copyright © 2016年 xfg. All rights reserved.
- //
- #import "FamilyDesViewController.h"
- #import "GetHeadImgViewController.h"
- #import "EditFamilyViewController.h"
- #import "FamilyDesModel.h"
- #import "FamilyMemberViewController.h"
- #import "FamilyListModel.h"
- @interface FamilyDesViewController ()<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 * familyLabel;
- @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) FamilyDesModel * model; //公会信息Model;
- @property (nonatomic, strong) UILabel * familyHeaderName; //公会族长名
- @property (nonatomic, strong) UILabel * numberLable; //公会人数
- @property (nonatomic, assign) int canEditAll;
- @end
- @implementation FamilyDesViewController
- - (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.text =ASLocalizedString(@"道道道非常道");
- _nameTextView.font = [UIFont systemFontOfSize:15];
- _nameTextView.editable = NO;
- [_view2 addSubview:_nameTextView];
- _familyHeaderName = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*95/1200)];
- _familyHeaderName.backgroundColor = [UIColor whiteColor];
- _familyHeaderName.font = [UIFont systemFontOfSize:15];
- _familyHeaderName.textAlignment = NSTextAlignmentCenter;
- // _familyHeaderName.text = ASLocalizedString(@"公会族长");
- [_view3 addSubview:_familyHeaderName];
-
- _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 (_isFamilyHeder==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];
- _familyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_headBtn.frame)+10, kScreenW, 17)];
- _familyLabel.text = ASLocalizedString(@"编辑公会头像");
- _familyLabel.textAlignment = NSTextAlignmentCenter;
- _familyLabel.font = [UIFont systemFontOfSize:17];
- _familyLabel.textColor = kAppGrayColor2;
- [_view1 addSubview:_familyLabel];
-
- _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 (_isFamilyHeder==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 (_isFamilyHeder ==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.family_logo] forState:UIControlStateNormal placeholderImage:kDefaultPreloadHeadImg];
- _nameTextView.text = _listModel.family_name;
- // _desTextView.text =_model.family_manifesto;
- _familyHeaderName.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
- {
- EditFamilyViewController * editFamilyVC = [[EditFamilyViewController alloc] init];
- editFamilyVC.type = 1;
- editFamilyVC.model = self.model;
- editFamilyVC.user_id = self.user_id;
- editFamilyVC.canEditAll = self.canEditAll;
- [self.navigationController pushViewController:editFamilyVC animated:YES];
- }
- //点击成员管理按钮
- - (void)clickManagerBtn
- {
- FamilyMemberViewController * familyMemberVC = [[FamilyMemberViewController alloc] init];
- familyMemberVC.isFamilyHeder = 1;
- familyMemberVC.jid = self.model.family_id;
- [self.navigationController pushViewController:familyMemberVC animated:YES];
- }
- //点击公会成员按钮
- - (void)clickMemberBtn
- {
- FamilyMemberViewController * familyMemberVC = [[FamilyMemberViewController alloc] init];
- familyMemberVC.isFamilyHeder = 0;
- familyMemberVC.jid = self.model.family_id;
- [self.navigationController pushViewController:familyMemberVC animated:YES];
- }
- //点击编辑公会头像
- - (void)clickHeadImage
- {
- EditFamilyViewController * editFamilyVC = [[EditFamilyViewController alloc] init];
- editFamilyVC.type = 1;
- editFamilyVC.model = self.model;
- editFamilyVC.user_id = self.user_id;
- [self.navigationController pushViewController:editFamilyVC animated:YES];
- }
- //点击退出公会
- - (void)clickLeaveBtn
- {
- FWWeakify(self)
- [FanweMessage alert:nil message:ASLocalizedString(@"是否退出该公会")destructiveAction:^{
-
- FWStrongify(self)
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"family_user" forKey:@"ctl"];
- [parmDict setObject:@"logout" forKey:@"act"];
- [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
-
- if ([responseJson toInt:@"status"]==1)
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
-
- } FailureBlock:^(NSError *error) {
-
- }];
-
- } cancelAction:^{
-
- }];
- }
- //申请加入公会
- - (void)clickApplyBtn
- {
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"family_user" forKey:@"ctl"];
- [parmDict setObject:@"user_join" forKey:@"act"];
- [parmDict setObject:_jid forKey:@"family_id"];
-
- FWWeakify(self)
- [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
-
- FWStrongify(self)
- if ([responseJson toInt:@"status"]==1)
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"申请已提交")];
- self.applyBtn.backgroundColor = kAppGrayColor3;
- [self.applyBtn setTitle:ASLocalizedString(@"申请中")forState:UIControlStateNormal];
- self.applyBtn.enabled = NO;
- }
-
- } FailureBlock:^(NSError *error) {
-
- }];
- }
- //点击返回按钮
- - (void)comeBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)loadData
- {
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"family" forKey:@"ctl"];
- [parmDict setObject:@"index" forKey:@"act"];
- [parmDict setObject:_jid forKey:@"family_id"];
-
- __weak typeof(self) ws = self;
- [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
-
- NSDictionary * dic = [responseJson objectForKey:@"family_info"];
- if (dic && [dic isKindOfClass:[NSDictionary class]])
- {
- _model = [FamilyDesModel mj_objectWithKeyValues:dic];
- [_headBtn sd_setImageWithURL:[NSURL URLWithString:_model.family_logo] forState:UIControlStateNormal placeholderImage:kDefaultPreloadHeadImg];
- _nameTextView.text = _model.family_name;
- _desTextView.text =_model.family_manifesto;
- _familyHeaderName.text = [NSString stringWithFormat:ASLocalizedString(@"公会族长 : %@"),_model.nick_name];
- _numberLable.text = [NSString stringWithFormat:ASLocalizedString(@"公会人数 : %@人"),_model.user_count];
- }
- if ([responseJson toInt:@"status"]==1)
- {
- if (_isFamilyHeder==1)
- {
- _headBtn.userInteractionEnabled = YES;
- _editBtn.userInteractionEnabled = YES;
- _editBtn.backgroundColor = kAppMainColor;
- _managerBtn.userInteractionEnabled = YES;
- _managerBtn.backgroundColor = kAppFamilyBtnColor;
- _canEditAll = 0;
- }
- if (_isFamilyHeder==0)
- {
- _memberBtn.userInteractionEnabled = YES;
- _memberBtn.backgroundColor = kAppMainColor;
- }
- }
- else if ([responseJson toInt:@"status"] ==0 ) // 申请正在审核
- {
- if (_isFamilyHeder==1) {
- _headBtn.userInteractionEnabled = NO;
- _editBtn.userInteractionEnabled = NO;
- _editBtn.backgroundColor = kAppGrayColor3;
- _managerBtn.userInteractionEnabled = NO;
- _managerBtn.backgroundColor = kAppGrayColor3;
- }
- else if (_isFamilyHeder==0)
- {
- _memberBtn.userInteractionEnabled = NO;
- _memberBtn.backgroundColor = kAppGrayColor3;
- }
- }
- else if ([responseJson toInt:@"status"]==2) // 审核未通过
- {
- if (_isFamilyHeder==1)
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"您的公会未通过审核")];
- _headBtn.userInteractionEnabled = YES;
- _editBtn.userInteractionEnabled = YES;
- _editBtn.backgroundColor = kAppMainColor;
- _managerBtn.userInteractionEnabled = NO;
- _managerBtn.backgroundColor = kAppGrayColor3;
- _canEditAll = 1;
- }
- if (_isFamilyHeder==0)
- {
- _memberBtn.userInteractionEnabled = NO;
- _memberBtn.backgroundColor = kAppGrayColor3;
- }
- }
-
- else if ([responseJson toInt:@"status"] == 3) // 公会已解散
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"您的公会已解散")];
- [ws.navigationController popViewControllerAnimated:YES];
- }
-
- } 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;
- }
- @end
|