SocietyDesViewController.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. //
  2. // SocietyDesViewController.m
  3. // BuguLive
  4. //
  5. // Created by 王珂 on 17/1/22.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "SocietyDesViewController.h"
  9. #import "GetHeadImgViewController.h"
  10. #import "EditSocietyViewController.h"
  11. #import "SocietyDesModel.h"
  12. #import "SocietyMemberViewController.h"
  13. #import "SocietyListModel.h"
  14. @interface SocietyDesViewController ()<UITextViewDelegate>
  15. @property (nonatomic, strong) UIView * view1;
  16. @property (nonatomic, strong) UIView * view2;
  17. @property (nonatomic, strong) UIView * view3;
  18. @property (nonatomic, strong) UIView * view4;
  19. @property (nonatomic, strong) UIView * view5;
  20. @property (nonatomic, strong) UIButton * headBtn;
  21. @property (nonatomic, strong) UILabel * societyLabel;
  22. @property (nonatomic, strong) UITextView * nameTextView;//公会名称
  23. @property (nonatomic, strong) UITextView * desTextView;//公会宣言
  24. @property (nonatomic, strong) UIButton * editBtn; //编辑按钮
  25. @property (nonatomic, strong) UIButton * managerBtn; //成员管理
  26. @property (nonatomic, strong) UIButton * memberBtn; //公会成员
  27. @property (nonatomic, strong) UIButton * leaveBtn; //退出公会
  28. @property (nonatomic, strong) UIButton * applyBtn; //申请加入公会
  29. @property (nonatomic, strong) SocietyDesModel * model; //公会信息Model;
  30. @property (nonatomic, strong) UILabel * societyHeaderName; //公会会长名
  31. @property (nonatomic, strong) UILabel * numberLable; //公会人数
  32. @property (nonatomic, assign) int canEditAll;
  33. @end
  34. @implementation SocietyDesViewController
  35. - (void)viewDidLoad
  36. {
  37. [super viewDidLoad];
  38. [self createView];
  39. [self loadData];
  40. }
  41. - (void)viewWillAppear:(BOOL)animated
  42. {
  43. [super viewWillAppear:animated];
  44. [self loadData];
  45. }
  46. - (void)createView
  47. {
  48. self.navigationItem.title = ASLocalizedString(@"公会详情");
  49. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(comeBack) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  50. self.view.backgroundColor = kFamilyBackGroundColor;
  51. _view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*375/1200)];
  52. [self.view addSubview:_view1];
  53. _view2 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_view1.frame), kScreenW, (kScreenH-64)*115/1200)];
  54. [self.view addSubview:_view2];
  55. _view3 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_view2.frame), kScreenW, (kScreenH-64)*115/1200)];
  56. [self.view addSubview:_view3];
  57. _view4 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_view3.frame), kScreenW, (kScreenH-64)*115/1200)];
  58. [self.view addSubview:_view4];
  59. _view5 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_view4.frame), kScreenW, (kScreenH-64)*490/1200)];
  60. [self.view addSubview:_view5];
  61. _nameTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*95/1200)];
  62. _nameTextView.backgroundColor = [UIColor whiteColor];
  63. _nameTextView.textAlignment = NSTextAlignmentCenter;
  64. _nameTextView.font = [UIFont systemFontOfSize:15];
  65. _nameTextView.editable = NO;
  66. [_view2 addSubview:_nameTextView];
  67. _societyHeaderName = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*95/1200)];
  68. _societyHeaderName.backgroundColor = [UIColor whiteColor];
  69. _societyHeaderName.font = [UIFont systemFontOfSize:15];
  70. _societyHeaderName.textAlignment = NSTextAlignmentCenter;
  71. [_view3 addSubview:_societyHeaderName];
  72. _numberLable= [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*95/1200)];
  73. _numberLable.backgroundColor = [UIColor whiteColor];
  74. _numberLable.font = [UIFont systemFontOfSize:15];
  75. _numberLable.textAlignment = NSTextAlignmentCenter;
  76. // _numberLable.text = ASLocalizedString(@"公会人数");
  77. [_view4 addSubview:_numberLable];
  78. _desTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, (kScreenH-64)*310/1200)];
  79. _desTextView.backgroundColor = [UIColor whiteColor];
  80. // _desTextView.text = ASLocalizedString(@"公会详情描述");
  81. _desTextView.editable = NO;
  82. _desTextView.font = [UIFont systemFontOfSize:15];
  83. [_view5 addSubview:_desTextView];
  84. [self createBtn];
  85. }
  86. - (void)createBtn
  87. {
  88. //如果是公会会长
  89. if (_isSocietyHeder==1) {
  90. _headBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  91. _headBtn.frame = CGRectMake((kScreenW-90)/2, (CGRectGetHeight(_view1.frame)-117)/2, 90, 90);
  92. _headBtn.backgroundColor = [UIColor whiteColor];
  93. _headBtn.layer.cornerRadius = 45;
  94. _headBtn.layer.masksToBounds = YES;
  95. [_headBtn addTarget:self action:@selector(clickHeadImage) forControlEvents:UIControlEventTouchUpInside];
  96. [_view1 addSubview:_headBtn];
  97. _societyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_headBtn.frame)+10, kScreenW, 17)];
  98. _societyLabel.text = ASLocalizedString(@"编辑公会头像");
  99. _societyLabel.textAlignment = NSTextAlignmentCenter;
  100. _societyLabel.font = [UIFont systemFontOfSize:17];
  101. _societyLabel.textColor = kAppGrayColor2;
  102. [_view1 addSubview:_societyLabel];
  103. _editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  104. _editBtn.frame = CGRectMake(25, 25+CGRectGetMaxY(_desTextView.frame), (kScreenW-75)/2, 40 );
  105. _editBtn.backgroundColor = kAppMainColor;
  106. _editBtn.layer.cornerRadius = 20;
  107. _editBtn.layer.masksToBounds = YES;
  108. [_editBtn setTitle:ASLocalizedString(@"编辑资料")forState:UIControlStateNormal];
  109. [_editBtn addTarget:self action:@selector(clickEditBtn) forControlEvents:UIControlEventTouchUpInside];
  110. [_view5 addSubview:_editBtn];
  111. _managerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  112. _managerBtn.frame = CGRectMake(50+(kScreenW-75)/2, 25+CGRectGetMaxY(_desTextView.frame), (kScreenW-75)/2, 40);
  113. _managerBtn.backgroundColor = kAppFamilyBtnColor;
  114. _managerBtn.layer.cornerRadius = 20;
  115. _managerBtn.layer.masksToBounds = YES;
  116. [_managerBtn setTitle:ASLocalizedString(@"成员管理")forState:UIControlStateNormal];
  117. [_managerBtn addTarget:self action:@selector(clickManagerBtn) forControlEvents:UIControlEventTouchUpInside];
  118. [_view5 addSubview:_managerBtn];
  119. }
  120. else
  121. {
  122. _headBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  123. _headBtn.frame = CGRectMake((kScreenW-90)/2, (CGRectGetHeight(_view1.frame)-90)/2, 90, 90);
  124. _headBtn.backgroundColor = [UIColor whiteColor];
  125. _headBtn.layer.cornerRadius = 45;
  126. _headBtn.layer.masksToBounds = YES;
  127. _headBtn.userInteractionEnabled = NO;
  128. [_view1 addSubview:_headBtn];
  129. if (_isSocietyHeder==0) {
  130. _memberBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  131. _memberBtn.frame = CGRectMake(25, 25+CGRectGetMaxY(_desTextView.frame), (kScreenW-75)/2, 40);
  132. _memberBtn.backgroundColor = kAppMainColor;
  133. _memberBtn.layer.cornerRadius = 20;
  134. _memberBtn.layer.masksToBounds = YES;
  135. [_memberBtn setTitle:ASLocalizedString(@"公会成员")forState:UIControlStateNormal];
  136. [_memberBtn addTarget:self action:@selector(clickMemberBtn) forControlEvents:UIControlEventTouchUpInside];
  137. [_view5 addSubview:_memberBtn];
  138. _leaveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  139. _leaveBtn.frame = CGRectMake(50+(kScreenW-75)/2, 25+CGRectGetMaxY(_desTextView.frame), (kScreenW-75)/2, 40);
  140. _leaveBtn.backgroundColor = kAppFamilyBtnColor;
  141. _leaveBtn.layer.cornerRadius = 20;
  142. _leaveBtn.layer.masksToBounds = YES;
  143. [_leaveBtn setTitle:ASLocalizedString(@"退出公会")forState:UIControlStateNormal];
  144. [_leaveBtn addTarget:self action:@selector(clickLeaveBtn) forControlEvents:UIControlEventTouchUpInside];
  145. [_view5 addSubview:_leaveBtn];
  146. }
  147. else if (_isSocietyHeder ==2)
  148. {
  149. _applyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  150. _applyBtn.frame = CGRectMake(25, 25+CGRectGetMaxY(_desTextView.frame), kScreenW-50, 40);
  151. _applyBtn.layer.cornerRadius = 20;
  152. _applyBtn.layer.masksToBounds = YES;
  153. [_headBtn sd_setImageWithURL:[NSURL URLWithString:_listModel.logo] forState:UIControlStateNormal placeholderImage:kDefaultPreloadHeadImg];
  154. _nameTextView.text = _listModel.name;
  155. // _desTextView.text =_model.family_manifesto;
  156. _societyHeaderName.text = [NSString stringWithFormat:ASLocalizedString(@"公会会长 : %@"),_listModel.nick_name];
  157. _numberLable.text = [NSString stringWithFormat:ASLocalizedString(@"公会人数 : %@人"),_listModel.user_count];
  158. if([_is_apply isEqualToString:@"0"])
  159. {
  160. _applyBtn.backgroundColor = kAppMainColor;
  161. [_applyBtn setTitle:ASLocalizedString(@"加入公会")forState:UIControlStateNormal];
  162. [_applyBtn addTarget:self action:@selector(clickApplyBtn) forControlEvents:UIControlEventTouchUpInside];
  163. }
  164. else if ([_is_apply isEqualToString:@"1"])
  165. {
  166. _applyBtn.backgroundColor = kAppGrayColor3;
  167. [_applyBtn setTitle:ASLocalizedString(@"申请中")forState:UIControlStateNormal];
  168. _applyBtn.enabled = NO;
  169. }
  170. else if ([_is_apply isEqualToString:@"2"])
  171. {
  172. _applyBtn.backgroundColor = kAppGrayColor3;
  173. [_applyBtn setTitle:ASLocalizedString(@"已加入")forState:UIControlStateNormal];
  174. _applyBtn.enabled = NO;
  175. }
  176. [_view5 addSubview:_applyBtn];
  177. }
  178. }
  179. }
  180. //点击编辑资料按钮
  181. - (void)clickEditBtn
  182. {
  183. EditSocietyViewController * editSocietyVC = [[EditSocietyViewController alloc] init];
  184. editSocietyVC.type = 1;
  185. editSocietyVC.model = self.model;
  186. editSocietyVC.user_id = self.user_id;
  187. editSocietyVC.canEditAll = self.canEditAll;
  188. [self.navigationController pushViewController:editSocietyVC animated:YES];
  189. }
  190. //点击成员管理按钮
  191. - (void)clickManagerBtn
  192. {
  193. SocietyMemberViewController * societyMemberVC = [[SocietyMemberViewController alloc] init];
  194. societyMemberVC.isSocietyHeder = 1;
  195. societyMemberVC.society_id = self.model.society_id;
  196. [self.navigationController pushViewController:societyMemberVC animated:YES];
  197. }
  198. //点击公会成员按钮
  199. - (void)clickMemberBtn
  200. {
  201. SocietyMemberViewController * societyMemberVC = [[SocietyMemberViewController alloc] init];
  202. societyMemberVC.isSocietyHeder = 0;
  203. societyMemberVC.society_id = self.model.society_id;
  204. [self.navigationController pushViewController:societyMemberVC animated:YES];
  205. }
  206. //点击编辑公会头像
  207. - (void)clickHeadImage
  208. {
  209. EditSocietyViewController * editSocietyVC = [[EditSocietyViewController alloc] init];
  210. editSocietyVC.type = 1;
  211. editSocietyVC.model = self.model;
  212. editSocietyVC.user_id = self.user_id;
  213. [self.navigationController pushViewController:editSocietyVC animated:YES];
  214. }
  215. //点击退出公会
  216. - (void)clickLeaveBtn
  217. {
  218. FWWeakify(self)
  219. [FanweMessage alert:ASLocalizedString(@"提示")message:ASLocalizedString(@"是否退出该公会")destructiveAction:^{
  220. FWStrongify(self)
  221. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  222. [parmDict setObject:@"society_user" forKey:@"ctl"];
  223. [parmDict setObject:@"logout" forKey:@"act"];
  224. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  225. } FailureBlock:^(NSError *error) {
  226. }];
  227. } cancelAction:^{
  228. }];
  229. }
  230. //申请加入公会
  231. - (void)clickApplyBtn
  232. {
  233. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  234. [parmDict setObject:@"society_user" forKey:@"ctl"];
  235. [parmDict setObject:@"join" forKey:@"act"];
  236. [parmDict setObject:_society_id forKey:@"society_id"];
  237. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  238. if ([responseJson toInt:@"status"]==1)
  239. {
  240. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"申请已提交")];
  241. _applyBtn.backgroundColor = kAppGrayColor3;
  242. [_applyBtn setTitle:ASLocalizedString(@"申请中")forState:UIControlStateNormal];
  243. _applyBtn.enabled = NO;
  244. }
  245. } FailureBlock:^(NSError *error) {
  246. NSLog(@"%@",error);
  247. }];
  248. }
  249. //点击返回按钮
  250. - (void)comeBack
  251. {
  252. [self.navigationController popViewControllerAnimated:NO];
  253. }
  254. - (void)loadData
  255. {
  256. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  257. [parmDict setObject:@"society" forKey:@"ctl"];
  258. [parmDict setObject:@"index" forKey:@"act"];
  259. [parmDict setObject:_society_id forKey:@"society_id"];
  260. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  261. NSDictionary * dic = [responseJson objectForKey:@"society_info"];
  262. if (dic && [dic isKindOfClass:[NSDictionary class]])
  263. {
  264. _model = [SocietyDesModel mj_objectWithKeyValues:dic];
  265. [_headBtn sd_setImageWithURL:[NSURL URLWithString:_model.logo] forState:UIControlStateNormal placeholderImage:kDefaultPreloadHeadImg];
  266. _nameTextView.text = _model.name;
  267. _desTextView.text =_model.manifesto;
  268. _societyHeaderName.text = [NSString stringWithFormat:ASLocalizedString(@"公会会长 : %@"),_model.nick_name];
  269. _numberLable.text = [NSString stringWithFormat:ASLocalizedString(@"公会人数 : %@人"),_model.user_count];
  270. }
  271. if ([dic toInt:@"status"]==1)
  272. {
  273. if (_isSocietyHeder==1)
  274. {
  275. _headBtn.userInteractionEnabled = YES;
  276. _editBtn.userInteractionEnabled = YES;
  277. _editBtn.backgroundColor = kAppMainColor;
  278. _managerBtn.userInteractionEnabled = YES;
  279. _managerBtn.backgroundColor = kAppFamilyBtnColor;
  280. _canEditAll = 0;
  281. }
  282. if (_isSocietyHeder==0)
  283. {
  284. _memberBtn.userInteractionEnabled = YES;
  285. _memberBtn.backgroundColor = kAppMainColor;
  286. }
  287. }
  288. else if ([dic toInt:@"status"]==0) // 申请正在审核
  289. {
  290. if (_isSocietyHeder==1)
  291. {
  292. _headBtn.userInteractionEnabled = NO;
  293. _editBtn.userInteractionEnabled = NO;
  294. _editBtn.backgroundColor = kAppGrayColor3;
  295. _managerBtn.userInteractionEnabled = NO;
  296. _managerBtn.backgroundColor = kAppGrayColor3;
  297. }
  298. else if (_isSocietyHeder==0)
  299. {
  300. _memberBtn.userInteractionEnabled = NO;
  301. _memberBtn.backgroundColor = kAppGrayColor3;
  302. }
  303. }
  304. else if ([dic toInt:@"status"]==2) // 审核未通过
  305. {
  306. if (_isSocietyHeder==1)
  307. {
  308. _headBtn.userInteractionEnabled = YES;
  309. _editBtn.userInteractionEnabled = YES;
  310. _editBtn.backgroundColor = kAppMainColor;
  311. _managerBtn.userInteractionEnabled = NO;
  312. _managerBtn.backgroundColor = kAppGrayColor3;
  313. _canEditAll = 1;
  314. }
  315. if (_isSocietyHeder==0)
  316. {
  317. _memberBtn.userInteractionEnabled = NO;
  318. _memberBtn.backgroundColor = kAppGrayColor3;
  319. }
  320. }
  321. } FailureBlock:^(NSError *error) {
  322. }];
  323. }
  324. - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
  325. {
  326. [UIMenuController sharedMenuController].menuVisible = NO; //donot display the menu
  327. [_desTextView resignFirstResponder]; //do not allow the user to selected anything
  328. [_nameTextView resignFirstResponder];
  329. return NO;
  330. }
  331. - (void)didReceiveMemoryWarning
  332. {
  333. [super didReceiveMemoryWarning];
  334. }
  335. @end