JXSelfUserInfoVC.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. //
  2. // JXSelfUserInfoVC.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/6/1.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXSelfUserInfoVC.h"
  9. #import "selectValueVC.h"
  10. #import "selectProvinceVC.h"
  11. #import "ImageResize.h"
  12. #import "JXChatViewController.h"
  13. #import "JXLocationVC.h"
  14. #import "JXMapData.h"
  15. #import "JXInputValueVC.h"
  16. #import "FMDatabase.h"
  17. #import "userWeiboVC.h"
  18. #import "JXReportUserVC.h"
  19. #import "JXQRCodeViewController.h"
  20. #import "JXImageScrollVC.h"
  21. #import "DMScaleTransition.h"
  22. #import "JXSetLabelVC.h"
  23. #import "JXLabelObject.h"
  24. #import "JXSetNoteAndLabelVC.h"
  25. #import "JXCirclePermissionsVC.h"
  26. #import "CYSpecialCareViewController.h"
  27. #import "JLBubbleModel.h"
  28. #import "JXChatViewC.h"
  29. #define HEIGHT 56
  30. #define LINE_INSET 8
  31. //#define IMGSIZE 150
  32. #define TopHeight 7
  33. #define CellHeight 45
  34. @interface JXSelfUserInfoVC ()<JXSelectMenuViewDelegate>
  35. @property (nonatomic,strong) NSMutableArray *titleArr;
  36. @end
  37. @implementation JXSelfUserInfoVC
  38. - (id)init
  39. {
  40. self = [super init];
  41. if (self) {
  42. [g_navigation dismissViewController:self animated:YES];
  43. [g_navigation dismissViewController:self animated:YES];
  44. self.isGotoBack = YES;
  45. self.title = Localized(@"JX_BaseInfo");
  46. self.heightFooter = 0;
  47. self.heightHeader = JX_SCREEN_TOP;
  48. //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  49. [self createHeadAndFoot];
  50. self.tableBody.backgroundColor = HEXCOLOR(0xF2F2F2);
  51. self.tableBody.scrollEnabled = YES;
  52. // UIButton *rightBtn=[[UIButton alloc]init];
  53. // [rightBtn setImage:[UIImage imageNamed:@"title_more_black"] forState:UIControlStateNormal];
  54. // [self.view addSubview:rightBtn];
  55. // [self.tableHeader addSubview:rightBtn];
  56. // rightBtn.frame = CGRectMake(JX_SCREEN_WIDTH-24-8, JX_SCREEN_TOP - 34, 24, 24);
  57. // [rightBtn addTarget:self action:@selector(onMore) forControlEvents:UIControlEventTouchUpInside];
  58. // [g_navigation dismissViewController:self animated:NO];
  59. // [g_navigation dismissViewController:self animated:NO];
  60. }
  61. return self;
  62. }
  63. - (void)viewDidLoad {
  64. [super viewDidLoad];
  65. _titleArr = [[NSMutableArray alloc]init];
  66. self.view.backgroundColor=kRGBColor246;
  67. UIView *toView=[[UIView alloc]init];
  68. toView.backgroundColor=[UIColor whiteColor];
  69. [self.view addSubview:toView];
  70. [toView mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.left.mas_equalTo(0);
  72. make.height.mas_equalTo(200);
  73. make.right.mas_equalTo(0);
  74. make.top.mas_equalTo(JX_SCREEN_TOP);
  75. }];
  76. // 头像
  77. UIImageView *imageHead=[[UIImageView alloc]init];
  78. imageHead.backgroundColor=[UIColor lightGrayColor];
  79. imageHead.layer.cornerRadius=50;
  80. imageHead.layer.masksToBounds=YES;
  81. [toView addSubview:imageHead];
  82. [imageHead mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.top.mas_equalTo(30);
  84. make.left.mas_equalTo(15);
  85. make.height.mas_equalTo(100);
  86. make.width.mas_equalTo(100);
  87. }];
  88. [g_server delHeadImage:g_server.myself.userId];
  89. [g_server getHeadImageSmall:g_server.myself.userId userName:g_server.myself.userNickname imageView:imageHead];
  90. //
  91. // UILabel *nameL=[[UILabel alloc]init];
  92. // nameL.textColor=kRGBColor51;
  93. // nameL.font=[UIFont systemFontOfSize:20 weight:UIFontWeightMedium];
  94. // nameL.text=memberAcc;
  95. // [toView addSubview:nameL];
  96. // [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
  97. // make.left.mas_equalTo(imageHead.mas_right).mas_offset(15);
  98. // make.top.mas_equalTo(35);
  99. //
  100. // }];
  101. UILabel *nickNam=[[UILabel alloc]init];
  102. nickNam.text= [NSString stringWithFormat:@"昵称:%@",g_server.myself.userNickname];
  103. nickNam.textColor=kRGBColor51;
  104. [toView addSubview:nickNam];
  105. [nickNam mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.mas_equalTo(imageHead.mas_right).mas_offset(15);
  107. // make.top.mas_equalTo(nameL.mas_bottom).mas_offset(10);
  108. make.top.mas_equalTo(35);
  109. }];
  110. UIImageView *sex = [[UIImageView alloc] init];
  111. if ([g_server.myself.sex intValue]==0) {
  112. sex.image = [UIImage imageNamed:@"basic_famale"];
  113. }else {// 男
  114. sex.image = [UIImage imageNamed:@"basic_male"];
  115. }
  116. [toView addSubview:sex];
  117. [sex mas_makeConstraints:^(MASConstraintMaker *make) {
  118. make.left.mas_equalTo(nickNam.mas_right).mas_offset(5);
  119. make.centerY.mas_equalTo(nickNam.mas_centerY).mas_offset(0);
  120. }];
  121. NSString *gradeIndexcc= [[NSUserDefaults standardUserDefaults] objectForKey:@"gradeIndexcc"];
  122. UILabel *vipL=[[UILabel alloc]init];
  123. vipL.text= [NSString stringWithFormat:@"会员等级:VIP%@",gradeIndexcc];
  124. vipL.textColor=kRGBColor51;
  125. [toView addSubview:vipL];
  126. [vipL mas_makeConstraints:^(MASConstraintMaker *make) {
  127. make.top.mas_equalTo(nickNam.mas_bottom).mas_offset(10);
  128. make.left.mas_equalTo(imageHead.mas_right).mas_offset(15);
  129. }];
  130. NSString* city = [g_constant getAddressForNumber:g_server.myself.provinceId cityId:g_server.myself.cityId areaId:g_server.myself.areaId];
  131. UILabel *cityL=[[UILabel alloc]init];
  132. cityL.text= [NSString stringWithFormat:@"%@",city];
  133. cityL.textColor=kRGBColor51;
  134. [toView addSubview:cityL];
  135. [cityL mas_makeConstraints:^(MASConstraintMaker *make) {
  136. make.top.mas_equalTo(vipL.mas_bottom).mas_offset(10);
  137. make.left.mas_equalTo(imageHead.mas_right).mas_offset(15);
  138. }];
  139. }
  140. - (void)onMore{
  141. int n = _friendStatus;
  142. [_titleArr removeAllObjects];
  143. [_titleArr addObject:Localized(@"JXUserInfoVC_Report")];
  144. if ([self.user.userType intValue] != 2) {
  145. [_titleArr addObject:@"设置备注和名称"];//Localized(@"JX_SetNotesAndDescriptions")];
  146. if(n == friend_status_friend){
  147. if(n == friend_status_black)
  148. [_titleArr addObject:Localized(@"JXUserInfoVC_CancelBlackList")];
  149. else if(![_user.isBeenBlack boolValue]) {
  150. [_titleArr addObject:Localized(@"JXUserInfoVC_AddBlackList")];
  151. }
  152. if(![_user.isBeenBlack boolValue]){
  153. if(n == friend_status_friend)
  154. [_titleArr addObject:Localized(@"JXUserInfoVC_DeleteFirend")];
  155. else
  156. [_titleArr addObject:Localized(@"JX_AddFriend")];
  157. }
  158. }
  159. }
  160. _selectView = [[JX_SelectMenuView alloc] initWithTitle:_titleArr image:@[] cellHeight:CellHeight];
  161. _selectView.alpha = 0.0;
  162. _selectView.delegate = self;
  163. [self.view addSubview:_selectView];
  164. // [_selectView release];
  165. //动画
  166. [UIView animateWithDuration:0.3 animations:^{
  167. _selectView.alpha = 1;
  168. }];
  169. }
  170. /*
  171. #pragma mark - Navigation
  172. // In a storyboard-based application, you will often want to do a little preparation before navigation
  173. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  174. // Get the new view controller using [segue destinationViewController].
  175. // Pass the selected object to the new view controller.
  176. }
  177. */
  178. - (void)didMenuView:(JX_SelectMenuView *)MenuView WithIndex:(NSInteger)index {
  179. long n = _friendStatus;//好友状态
  180. // if(n>[_titleArr count]-1)
  181. // return;
  182. switch (index) {
  183. case 0:
  184. [self viewDisMissAction];
  185. break;
  186. case 1:
  187. [self viewDisMissAction];
  188. break;
  189. case 2:
  190. if(n == friend_status_black){
  191. [self onDelBlack];
  192. [self viewDisMissAction];
  193. }else{
  194. [self onAddBlack];
  195. [self viewDisMissAction];
  196. }
  197. break;
  198. case 3:
  199. if(n == friend_status_see || n == friend_status_friend){
  200. // [self onCancelSee];
  201. // [self viewDisMissAction];
  202. [self onDeleteFriend];
  203. [self viewDisMissAction];
  204. }else{
  205. [self actionAddFriend:nil];
  206. [self viewDisMissAction];
  207. }
  208. break;
  209. default:
  210. [self viewDisMissAction];
  211. break;
  212. }
  213. }
  214. - (void)viewDisMissAction{
  215. [UIView animateWithDuration:0.4 animations:^{
  216. _bgBlackAlpha.alpha = 0.0;
  217. } completion:^(BOOL finished) {
  218. [_selectView removeFromSuperview];
  219. _selectView = nil;
  220. [_bgBlackAlpha removeFromSuperview];
  221. }];
  222. }
  223. -(void)onAddBlack{
  224. [g_server addBlacklist:_user.userId toView:self];
  225. }
  226. -(void)onDelBlack{
  227. [g_server delBlacklist:_user.userId toView:self];
  228. }
  229. -(void)onCancelSee{
  230. [g_server delAttention:_user.userId toView:self];
  231. }
  232. -(void)onDeleteFriend{
  233. // [g_server delAttention:user.userId toView:self];
  234. [g_server delFriend:_user.userId toView:self];
  235. }
  236. -(void)doMakeFriend{
  237. _friendStatus = friend_status_friend;
  238. // user.status = [NSNumber numberWithInt:_friendStatus];
  239. // if([user haveTheUser])
  240. // [user update];
  241. // else
  242. // [user insert];
  243. [self.user doSendMsg:XMPP_TYPE_FRIEND content:nil];
  244. [JXMessageObject msgWithFriendStatus:_user.userId status:_friendStatus];
  245. }
  246. -(void)actionAddFriend:(UIView*)sender{
  247. // 验证XMPP是否在线
  248. if(g_xmpp.isLogined != 1){
  249. [g_xmpp showXmppOfflineAlert];
  250. return;
  251. }
  252. if([_user.isBeenBlack boolValue]){
  253. [g_server showMsg:Localized(@"TO_BLACKLIST")];
  254. return;
  255. }
  256. switch (_friendStatus) {
  257. case friend_status_black:{
  258. // [g_server addAttention:user.userId toView:self];
  259. [self onDelBlack];
  260. // [self viewDisMissAction];
  261. }
  262. break;
  263. case friend_status_none:
  264. case friend_status_see:
  265. [g_server addAttention:_user.userId fromAddType:self.fromAddType toView:self];
  266. break;
  267. // case friend_status_see:
  268. // [self doSayHello];
  269. // break;
  270. case friend_status_friend:{//发消息
  271. if([_user haveTheUser])
  272. [_user insert];
  273. else
  274. [_user update];
  275. [self actionQuit];
  276. [g_notify postNotificationName:kActionRelayQuitVC object:nil];
  277. //
  278. // JXChatViewController *chatVC=[JXChatViewController alloc];
  279. JXChatViewC *chatVC=[JXChatViewC alloc];
  280. chatVC.title =_user.userNickname;
  281. chatVC.chatPerson = self.user;
  282. chatVC = [chatVC init];
  283. // [g_App.window addSubview:chatVC.view];
  284. [g_navigation pushViewController:chatVC animated:YES];
  285. }
  286. break;
  287. }
  288. }
  289. @end