JXUserInfoVC.m 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519
  1. //
  2. // JXUserInfoVC.m
  3. // shiku_im
  4. //
  5. // Created by flyeagleTang on 14-6-10.
  6. // Copyright (c) 2014年 Reese. All rights reserved.
  7. //
  8. #import "JXUserInfoVC.h"
  9. //#import "selectTreeVC.h"
  10. #import "selectValueVC.h"
  11. #import "selectProvinceVC.h"
  12. #import "ImageResize.h"
  13. #import "JXChatViewController.h"
  14. #import "JXLocationVC.h"
  15. #import "JXMapData.h"
  16. #import "JXInputValueVC.h"
  17. #import "FMDatabase.h"
  18. #import "userWeiboVC.h"
  19. #import "JXReportUserVC.h"
  20. #import "JXQRCodeViewController.h"
  21. #import "JXImageScrollVC.h"
  22. #import "DMScaleTransition.h"
  23. #import "JXSetLabelVC.h"
  24. #import "JXLabelObject.h"
  25. #import "JXSetNoteAndLabelVC.h"
  26. #import "JXCirclePermissionsVC.h"
  27. #import "CYSpecialCareViewController.h"
  28. #import "JLBubbleModel.h"
  29. #import "JXChatViewC.h"
  30. #define HEIGHT 56
  31. #define LINE_INSET 8
  32. //#define IMGSIZE 150
  33. #define TopHeight 7
  34. #define CellHeight 45
  35. @interface JXUserInfoVC ()<JXReportUserDelegate,UITextFieldDelegate,JXSelectMenuViewDelegate,UIAlertViewDelegate>
  36. {
  37. JXImageView *iv;
  38. JXImageView *iv2;
  39. }
  40. @property (nonatomic, assign) CGFloat topHeight; // 记录一个生活圈的开始高度
  41. @property (nonatomic, strong) UILabel *tintLab;
  42. @property (nonatomic, strong) UIView *baseView;
  43. @property (nonatomic, strong) UILabel *serverName;
  44. @property (nonatomic, strong) UIButton *notFocusBtn;
  45. @end
  46. @implementation JXUserInfoVC
  47. @synthesize user;
  48. -(void)viewWillAppear:(BOOL)animated{
  49. [super viewWillAppear:true];
  50. BOOL isFlag = YES;
  51. NSString *name = @"已开启";
  52. if ([self.user.veryCare intValue] == 0) {
  53. isFlag = NO;
  54. name = @"已关闭";
  55. }
  56. _veryCare.text = name;
  57. }
  58. - (id)init
  59. {
  60. self = [super init];
  61. if (self) {
  62. _titleArr = [[NSMutableArray alloc]init];
  63. _friendStatus = [user.status intValue];
  64. _latitude = [user.latitude doubleValue];
  65. _longitude = [user.longitude doubleValue];
  66. self.isGotoBack = YES;
  67. self.title = Localized(@"JX_BaseInfo");
  68. self.heightFooter = 0;
  69. self.heightHeader = JX_SCREEN_TOP;
  70. //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  71. [self createHeadAndFoot];
  72. self.tableBody.backgroundColor = HEXCOLOR(0xF2F2F2);
  73. self.tableBody.scrollEnabled = YES;
  74. if([self.userId isKindOfClass:[NSNumber class]])
  75. self.userId = [(NSNumber*)self.userId stringValue];
  76. [g_server getUser:self.userId toView:self];
  77. //memberData *data2 =[user getMember:g_myself.userId];
  78. [g_notify addObserver:self selector:@selector(newReceipt:) name:kXMPPReceiptNotifaction object:nil];
  79. [g_notify addObserver:self selector:@selector(onSendTimeout:) name:kXMPPSendTimeOutNotifaction object:nil];
  80. [g_notify addObserver:self selector:@selector(friendPassNotif:) name:kFriendPassNotif object:nil];
  81. [g_notify addObserver:self selector:@selector(newRequest:) name:kXMPPNewRequestNotifaction object:nil];
  82. }
  83. return self;
  84. }
  85. //群主
  86. - (void)setupServers {
  87. //如果是自己,则不现实按钮
  88. // 自己/公众号/厂家不删除
  89. if (![self.userId isEqualToString:MY_USER_ID] && ![self.userId isEqualToString:@"18938880001"]) {
  90. UIButton *btn = [UIFactory createButtonWithImage:THESIMPLESTYLE ? @"title_more_black" : @"title_more" highlight:nil target:self selector:@selector(onMore)];
  91. btn.frame = CGRectMake(JX_SCREEN_WIDTH-24-8, JX_SCREEN_TOP - 34, 24, 24);
  92. [self.tableHeader addSubview:btn];
  93. }
  94. _baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 0)];
  95. //_baseView.backgroundColor = [UIColor yellowColor];
  96. [self.tableBody addSubview:_baseView];
  97. // 更新头像缓存
  98. // [g_server delHeadImage:self.userId];
  99. _head = [[JXImageView alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2-70/2, 40, 70, 70)];
  100. _head.layer.cornerRadius = _head.frame.size.width/2;
  101. _head.layer.masksToBounds = YES;
  102. _head.didTouch = @selector(onHeadImage);
  103. _head.delegate = self;
  104. _head.image = [UIImage imageNamed:@"avatar_normal"];
  105. [_baseView addSubview:_head];
  106. [g_server getHeadImageSmall:self.userId userName:self.user.userNickname imageView:_head];
  107. _serverName = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_head.frame)+15, JX_SCREEN_WIDTH, 16)];
  108. _serverName.text = self.user.userNickname;
  109. _serverName.font = SYSFONT(16);
  110. _serverName.textAlignment = NSTextAlignmentCenter;
  111. [_baseView addSubview:_serverName];
  112. _tintLab = [[UILabel alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(_serverName.frame)+20, JX_SCREEN_WIDTH-60, 40)];
  113. _tintLab.text = @"说点什么~~";
  114. _tintLab.font = SYSFONT(15);
  115. _tintLab.textColor = HEXCOLOR(0x999999);
  116. _tintLab.numberOfLines = 0;
  117. _tintLab.textAlignment = NSTextAlignmentCenter;
  118. [_baseView addSubview:_tintLab];
  119. _btn = [[UIButton alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2-50, CGRectGetMaxY(_tintLab.frame)+40, 100, 16)];
  120. [_btn.titleLabel setFont:SYSFONT(16)];
  121. [_btn setTitleColor:THEMECOLOR forState:UIControlStateNormal];
  122. [_btn addTarget:self action:@selector(actionAddFriend:) forControlEvents:UIControlEventTouchUpInside];
  123. [_baseView addSubview:_btn];
  124. // 不再关注
  125. _notFocusBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, CGRectGetMinY(_btn.frame), 100, 16)];
  126. [_notFocusBtn.titleLabel setFont:SYSFONT(16)];
  127. [_notFocusBtn setTitleColor:THEMECOLOR forState:UIControlStateNormal];
  128. [_notFocusBtn addTarget:self action:@selector(onDeleteFriend) forControlEvents:UIControlEventTouchUpInside];
  129. _notFocusBtn.hidden = YES;
  130. [_baseView addSubview:_notFocusBtn];
  131. _baseView.frame = CGRectMake(_baseView.frame.origin.x, _baseView.frame.origin.y, _baseView.frame.size.width, CGRectGetMaxY(_btn.frame)+40);
  132. }
  133. - (void)setServerDetail {
  134. _serverName.text = self.user.userNickname;
  135. if (self.user.userDescription.length > 0) {
  136. _tintLab.text = self.user.userDescription;
  137. }
  138. CGSize size = [_tintLab.text boundingRectWithSize:CGSizeMake(JX_SCREEN_WIDTH-60, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:SYSFONT(15)} context:nil].size;
  139. _tintLab.frame = CGRectMake(_tintLab.frame.origin.x, _tintLab.frame.origin.y, _tintLab.frame.size.width, size.height);
  140. _btn.frame = CGRectMake(_btn.frame.origin.x, CGRectGetMaxY(_tintLab.frame)+40, _btn.frame.size.width, _btn.frame.size.height);
  141. _notFocusBtn.frame = CGRectMake(_notFocusBtn.frame.origin.x, CGRectGetMaxY(_tintLab.frame)+40, _notFocusBtn.frame.size.width, _notFocusBtn.frame.size.height);
  142. _baseView.frame = CGRectMake(_baseView.frame.origin.x, _baseView.frame.origin.y, _baseView.frame.size.width, CGRectGetMaxY(_btn.frame)+40);
  143. [self showAddFriend];
  144. }
  145. - (void)createViews {
  146. [self.tableBody.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  147. int h = 0;
  148. NSString* s;
  149. if (![self.userId isEqualToString:MY_USER_ID] && ![self.userId isEqualToString:@"18938880001"]) {
  150. UIButton *btn = [UIFactory createButtonWithImage:THESIMPLESTYLE ? @"title_more_black" : @"title_more" highlight:nil target:self selector:@selector(onMore)];
  151. btn.frame = CGRectMake(JX_SCREEN_WIDTH-24-8, JX_SCREEN_TOP - 34, 24, 24);
  152. [self.tableHeader addSubview:btn];
  153. }
  154. // 更新头像缓存
  155. [g_server delHeadImage:self.userId];
  156. int Head_height = 132;
  157. UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, Head_height)];
  158. headView.backgroundColor = [UIColor whiteColor];
  159. [self.tableBody addSubview:headView];
  160. _head = [[JXImageView alloc]initWithFrame:CGRectMake(15, (Head_height-83)/2, 83, 83)];
  161. _head.layer.cornerRadius = _head.frame.size.width/2;
  162. _head.layer.masksToBounds = YES;
  163. _head.didTouch = @selector(onHeadImage);
  164. _head.delegate = self;
  165. _head.image = [UIImage imageNamed:@"avatar_normal"];
  166. [headView addSubview:_head];
  167. [g_server getHeadImageLarge:self.userId userName:self.user.userNickname imageView:_head];
  168. // 名字
  169. _remarkName = [[UILabel alloc] init];
  170. _remarkName.font = [UIFont boldSystemFontOfSize:17];
  171. _remarkName.textColor = [UIColor blackColor];
  172. _remarkName.frame = CGRectMake(CGRectGetMaxX(_head.frame)+15, CGRectGetMinY(_head.frame), 120, 19);
  173. _remarkName.text = @"网络有问题";
  174. [headView addSubview:_remarkName];
  175. _sex = [[UIImageView alloc] init];
  176. _sex.frame = CGRectMake(CGRectGetMaxX(_remarkName.frame)+5, CGRectGetMinY(_remarkName.frame)+1.5, 14, 14);
  177. _sex.image = [UIImage imageNamed:@"basic_famale"];
  178. [headView addSubview:_sex];
  179. #pragma mark ---------- 呢称
  180. // 昵称
  181. _name = [[UILabel alloc] init];
  182. _name.font = SYSFONT(15);
  183. _name.textColor = [UIColor grayColor];
  184. _name.text = [NSString stringWithFormat:@"%@ : %@",Localized(@"JX_NickName"),@"--"];
  185. [headView addSubview:_name];
  186. //通讯号
  187. _account = [[UILabel alloc] init];
  188. _account.font = SYSFONT(15);
  189. _account.textColor = [UIColor grayColor];
  190. //_account.text = [NSString stringWithFormat:@"%@ : %@",Localized(@"JX_Communication"),@"--"];
  191. _account.text = [NSString stringWithFormat:@"%@ : %@",@"地址",@"--"];
  192. [headView addSubview:_account];
  193. NSLog(@"0932309%@",g_myself.gradeIndex);
  194. // 地区
  195. _city = [[UILabel alloc] init];
  196. _city.font = SYSFONT(15);
  197. _city.textColor = [UIColor grayColor];
  198. NSString *gradeIndexcc= [[NSUserDefaults standardUserDefaults] objectForKey:@"gradeIndexcc"];
  199. _city.text = [NSString stringWithFormat:@"会员等级VIP: %@",gradeIndexcc];
  200. [headView addSubview:_city];
  201. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, Head_height-LINE_WH, JX_SCREEN_WIDTH, LINE_WH)];
  202. line.backgroundColor = THE_LINE_COLOR;
  203. [headView addSubview:line];
  204. h = Head_height;
  205. if ([self.userId intValue] != [MY_USER_ID intValue]) {
  206. //标签
  207. //Localized(@"JX_SetNotesAndLabels")
  208. iv = [self createButton:@"备注和标签" drawTop:NO drawBottom:NO must:NO click:@selector(onRemark) superView:self.tableBody];
  209. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  210. _label = [self createLabel:iv default:user.userNickname];
  211. _label.frame = CGRectMake(_label.frame.origin.x, _label.frame.origin.y, _label.frame.size.width-7-9, _label.frame.size.height);
  212. h+=iv.frame.size.height;
  213. // 描述
  214. // iv2 = [self createButton:Localized(@"JX_UserInfoDescribe") drawTop:YES drawBottom:NO must:NO click:nil superView:self.tableBody];
  215. // iv2.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  216. // //如果是朋友且设置备注,这修改为备注,暂时不知道有没有此接口
  217. // _describe = [self createLabel:iv2 default:user.describe];
  218. // h+=iv2.frame.size.height;
  219. // _describeImgV = iv2;
  220. //
  221. //
  222. // // 设置生活圈权限
  223. // iv2 = [self createButton:@"设置社交圈权限" drawTop:YES drawBottom:NO must:NO click:@selector(onCirclePermissions) superView:self.tableBody];
  224. // iv2.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  225. // //如果是朋友且设置备注,这修改为备注,暂时不知道有没有此接口
  226. //// h+=iv.frame.size.height;
  227. // _circleImgV = iv2;
  228. h+=LINE_INSET;
  229. }
  230. // self.topHeight = h;
  231. // _baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 20, JX_SCREEN_WIDTH, 0)];
  232. // [self.tableBody addSubview:_baseView];
  233. h = 0;
  234. //h+=30;
  235. _btn = [[UIButton alloc]init];// [UIFactory createCommonButton:Localized(@"JX_AddFriend") target:self action:@selector(actionAddFriend:)];
  236. _btn.backgroundColor=[UIColor whiteColor];
  237. _btn.frame = CGRectMake(15, 210, JX_SCREEN_WIDTH-30, 40);
  238. _btn.layer.masksToBounds = YES;
  239. _btn.layer.cornerRadius = 7.f;
  240. [_btn setTitleColor:kRGBColor51 forState:UIControlStateNormal];
  241. _btn.custom_acceptEventInterval = 1.0;
  242. [self.tableBody addSubview:_btn];
  243. [_btn addTarget:self action:@selector(actionAddFriend:) forControlEvents:UIControlEventTouchUpInside];
  244. [self showAddFriend];
  245. h+=_btn.frame.size.height;
  246. h+=INSETS;
  247. _btnTemp = [[UIButton alloc]init];
  248. _btnTemp.backgroundColor=[UIColor whiteColor];
  249. [_btnTemp setTitleColor:kRGBColor51 forState:UIControlStateNormal];
  250. [_btnTemp setTitle:@"临时会话" forState:UIControlStateNormal];
  251. [_btnTemp addTarget:self action:@selector(actionTempFriend:) forControlEvents:UIControlEventTouchUpInside];
  252. _btnTemp.layer.masksToBounds = YES;
  253. _btnTemp.layer.cornerRadius = 7.f;
  254. [_btnTemp setBackgroundImage:[UIImage imageNamed:@"navBarBackground"] forState:UIControlStateNormal];
  255. _btnTemp.frame = CGRectMake(15, 270, JX_SCREEN_WIDTH-30, 40);
  256. _btnTemp.custom_acceptEventInterval = 1.0;
  257. [self.tableBody addSubview:_btnTemp];
  258. h+=_btnTemp.frame.size.height;
  259. h+=INSETS;
  260. if ([_data.role intValue]==1 || [_data.role intValue]==2||[_data22.role intValue]==1 || [_data22.role intValue]==2) {
  261. _btnTemp.hidden=NO;
  262. }else{
  263. _btnTemp.hidden=YES;
  264. }
  265. // CGRect frame = _baseView.frame;
  266. // frame.size.height = h;
  267. // _baseView.frame = frame;
  268. // if (self.tableBody.frame.size.height < CGRectGetMaxY(_baseView.frame)+30) {
  269. // self.tableBody.contentSize = CGSizeMake(JX_SCREEN_WIDTH, CGRectGetMaxY(_baseView.frame)+30);
  270. // }
  271. // JXUserObject *user = [[JXUserObject sharedInstance] getUserById:_userId];
  272. // [self setUserInfo:user];
  273. }
  274. //临时会话
  275. - (void)actionTempFriend:(UIButton *)btn{
  276. JXChatViewC *chatVC=[JXChatViewC alloc];
  277. chatVC.title = user.userNickname;
  278. chatVC.chatPerson = self.user;
  279. chatVC = [chatVC init];
  280. chatVC.useInfoTempChat=11;
  281. // [g_App.window addSubview:chatVC.view];
  282. [g_navigation pushViewController:chatVC animated:YES];
  283. //
  284. }
  285. - (void)onCirclePermissions {
  286. JXCirclePermissionsVC *vc = [[JXCirclePermissionsVC alloc] init];
  287. vc.user = self.user;
  288. [g_navigation pushViewController:vc animated:YES];
  289. }
  290. - (void)newRequest:(NSNotification *)notif {
  291. [g_server getUser:self.userId toView:self];
  292. }
  293. - (void) setUserInfo:(JXUserObject *)user {
  294. if (self.user.content) {
  295. user.content = self.user.content;
  296. }
  297. self.user = user;
  298. // 更新用户信息
  299. [user updateUserNickname];
  300. _friendStatus = [user.status intValue];
  301. _latitude = [user.latitude doubleValue];
  302. _longitude = [user.longitude doubleValue];
  303. // 设置用户名字、备注、通讯号、地区等...
  304. [self setLabelAndDescribe];
  305. if ([user.showLastLoginTime intValue] > 0 && [user.userType intValue] != 2) {
  306. _lastTime.text = [self dateTimeDifferenceWithStartTime:user.showLastLoginTime];
  307. _lastTImgV.hidden = NO;
  308. }else {
  309. _lastTImgV.hidden = YES;
  310. }
  311. if (user.telephone.length > 0 && [user.userType intValue] != 2) {
  312. _showNum.text = user.phone;
  313. _showNImgV.hidden = NO;
  314. }else {
  315. _showNImgV.hidden = YES;
  316. }
  317. if (user.userDescription.length > 0) {
  318. _desLab.text = user.userDescription;
  319. _desImgV.hidden = NO;
  320. }else {
  321. _desImgV.hidden = YES;
  322. }
  323. if (self.tableBody.frame.size.height < CGRectGetMaxY(_baseView.frame)+30) {
  324. self.tableBody.contentSize = CGSizeMake(JX_SCREEN_WIDTH, CGRectGetMaxY(_baseView.frame)+30);
  325. }
  326. _date.text = [TimeUtil formatDate:user.birthday format:@"yyyy-MM-dd"];
  327. NSString *name = @"已开启";
  328. if ([user.veryCare intValue] == 0) {
  329. name = @"已关闭";
  330. }
  331. _veryCare.text = name;
  332. if ([user.offlineNoPushMsg intValue] == 1) {
  333. [_messageFreeSwitch setOn:YES];
  334. }else {
  335. [_messageFreeSwitch setOn:NO];
  336. }
  337. if (_tel) {
  338. NSString *subString = [user.telephone substringToIndex:2];
  339. if ([subString isEqualToString:@"86"]) {
  340. NSDate *date = [g_myself.phoneDic objectForKey:[user.telephone substringFromIndex:2]];
  341. if (date) {
  342. long long n = (long long)[date timeIntervalSince1970];
  343. NSString *time = [TimeUtil getTimeStrStyle1:n];
  344. NSString *str = [NSString stringWithFormat:@"%@,%@:%@",[user.telephone substringFromIndex:2],Localized(@"JX_HaveToDial"),time];
  345. _tel.text = str;
  346. }else {
  347. _tel.text = [user.telephone substringFromIndex:2];
  348. }
  349. }else {
  350. _tel.text = user.telephone;
  351. }
  352. }
  353. [self showAddFriend];
  354. }
  355. - (void)setLabelAndDescribe {
  356. NSString* city = [g_constant getAddressForNumber:user.provinceId cityId:user.cityId areaId:user.areaId];
  357. _remarkName.text = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  358. CGSize sizeN = [_remarkName.text sizeWithAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17]}];
  359. _remarkName.frame = CGRectMake(_remarkName.frame.origin.x, _remarkName.frame.origin.y, sizeN.width, _remarkName.frame.size.height);
  360. _sex.frame = CGRectMake(CGRectGetMaxX(_remarkName.frame)+5, _sex.frame.origin.y, 14, 14);
  361. if ([user.sex intValue] == 0) {// 女
  362. _sex.image = [UIImage imageNamed:@"basic_famale"];
  363. }else {// 男
  364. _sex.image = [UIImage imageNamed:@"basic_male"];
  365. }
  366. if (user.remarkName.length > 0) {
  367. _name.hidden = NO;
  368. _name.frame = CGRectMake(CGRectGetMinX(_remarkName.frame), CGRectGetMaxY(_remarkName.frame)+10, 200, 15);
  369. _account.frame = CGRectMake(CGRectGetMinX(_remarkName.frame), CGRectGetMaxY(_name.frame)+10, 200, 15);
  370. _name.text = [NSString stringWithFormat:@"%@ : %@",Localized(@"JX_NickName"),user.userNickname];
  371. }else {
  372. _name.hidden = YES;
  373. _account.frame = CGRectMake(CGRectGetMinX(_remarkName.frame), CGRectGetMaxY(_remarkName.frame)+10, 200, 15);
  374. }
  375. if (user.account.length > 0) {
  376. _account.hidden = NO;
  377. _city.frame = CGRectMake(CGRectGetMinX(_remarkName.frame), CGRectGetMaxY(_account.frame)+10, 200, 15);
  378. _account.text = [NSString stringWithFormat:@"%@ : %@",@"地址",city.length > 0 ? city : @"--"];
  379. }else {
  380. _account.hidden = YES;
  381. _city.frame = CGRectMake(CGRectGetMinX(_remarkName.frame), user.remarkName.length > 0 ? CGRectGetMaxY(_name.frame)+3 :CGRectGetMaxY(_remarkName.frame)+10, 200, 15);
  382. }
  383. NSString *gradeIndexcc= [[NSUserDefaults standardUserDefaults] objectForKey:@"gradeIndexcc"];
  384. _city.text = [NSString stringWithFormat:@"会员等级VIP: %@",gradeIndexcc];
  385. _describe.text = self.user.describe;
  386. // 标签
  387. NSMutableArray *array = [[JXLabelObject sharedInstance] fetchLabelsWithUserId:self.user.userId];
  388. NSMutableString *labelsName = [NSMutableString string];
  389. for (NSInteger i = 0; i < array.count; i ++) {
  390. JXLabelObject *labelObj = array[i];
  391. if (i == 0) {
  392. [labelsName appendString:labelObj.groupName];
  393. }else {
  394. [labelsName appendFormat:@",%@",labelObj.groupName];
  395. }
  396. }
  397. if (labelsName.length > 0 && self.user.describe.length <= 0) {
  398. _labelLab.text = Localized(@"JX_Label");
  399. _label.text = labelsName;
  400. [self updateSubviewFrameIsHide:YES];
  401. _describeImgV.hidden = YES;
  402. }
  403. else if (labelsName.length > 0 && self.user.describe.length > 0) {
  404. _labelLab.text = Localized(@"JX_Label");
  405. _label.text = labelsName;
  406. [self updateSubviewFrameIsHide:NO];
  407. _describeImgV.hidden = NO;
  408. }
  409. else if (self.user.describe.length > 0 && labelsName.length <= 0) {
  410. _labelLab.text = Localized(@"JX_UserInfoDescribe");
  411. _label.text = self.user.describe;
  412. [self updateSubviewFrameIsHide:YES];
  413. _describeImgV.hidden = YES;
  414. }
  415. else {
  416. _labelLab.text = @"备注和标签";//Localized(@"JX_SetNotesAndLabels");
  417. _label.text = @"";
  418. [self updateSubviewFrameIsHide:YES];
  419. _describeImgV.hidden = YES;
  420. }
  421. }
  422. - (void)updateSubviewFrameIsHide:(BOOL)isHide {
  423. int y = 0;
  424. if ([self.userId intValue] == [MY_USER_ID intValue]) {
  425. y = self.topHeight;
  426. }else {
  427. if(isHide) {
  428. y = self.topHeight-HEIGHT;
  429. }else {
  430. y = self.topHeight;
  431. }
  432. }
  433. _circleImgV.frame = CGRectMake(0, y-HEIGHT-8+60, JX_SCREEN_WIDTH, HEIGHT);
  434. // y += HEIGHT;
  435. _specialCareImgV.frame = CGRectMake(0, y, JX_SCREEN_WIDTH, HEIGHT);
  436. y += HEIGHT;
  437. // _lifeImgV.frame = CGRectMake(0, y, JX_SCREEN_WIDTH, HEIGHT);
  438. if ((_lifeImgV && [self.user.status intValue] != friend_status_none) || [self.userId isEqualToString:g_myself.userId]) {
  439. _lifeImgV.hidden = NO;
  440. _lifeImgV.frame = CGRectMake(0, y, JX_SCREEN_WIDTH, HEIGHT);
  441. y += HEIGHT;
  442. }else {
  443. _lifeImgV.hidden = YES;
  444. }
  445. _birthdayImgV.frame = CGRectMake(0, y, JX_SCREEN_WIDTH, HEIGHT);
  446. if ([user.showLastLoginTime intValue] > 0 && [user.userType intValue] != 2){
  447. y += HEIGHT;
  448. _lastTImgV.frame = CGRectMake(0, y, JX_SCREEN_WIDTH, HEIGHT);
  449. }
  450. if (user.telephone.length > 0 && [user.userType intValue] != 2 && [g_config.regeditPhoneOrName intValue] == 0) {
  451. y += HEIGHT;
  452. _showNImgV.frame = CGRectMake(0, y, JX_SCREEN_WIDTH, HEIGHT);
  453. }
  454. if (user.userDescription.length > 0) {
  455. y += HEIGHT;
  456. CGSize size = [user.userDescription boundingRectWithSize:CGSizeMake(JX_SCREEN_WIDTH/2-15, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:SYSFONT(15)} context:nil].size;
  457. int h = HEIGHT;
  458. if (size.height > 20) {
  459. // 大于一行,就改变高度
  460. h = (HEIGHT-15) + size.height;
  461. _desLab.frame = CGRectMake(_desLab.frame.origin.x, _desLab.frame.origin.y, _desLab.frame.size.width, size.height);
  462. UILabel *label = [_desImgV viewWithTag:100];
  463. label.frame = CGRectMake(label.frame.origin.x, 0, label.frame.size.width, h);
  464. }
  465. _desImgV.frame = CGRectMake(0, y, JX_SCREEN_WIDTH, h);
  466. y += h;
  467. }else {
  468. y += HEIGHT;
  469. }
  470. _baseView.frame = CGRectMake(0, y+INSETS, JX_SCREEN_WIDTH, _baseView.frame.size.height);
  471. }
  472. - (void)friendPassNotif:(NSNotification *)notif {
  473. JXFriendObject *user = notif.object;
  474. if ([user.userId isEqualToString:self.userId]) {
  475. _friendStatus = friend_status_friend;
  476. [self showAddFriend];
  477. }
  478. }
  479. - (void)callNumber {
  480. NSMutableString* str;
  481. NSString *subString = [user.telephone substringToIndex:2];
  482. if ([subString isEqualToString:@"86"]) {
  483. str = [[NSMutableString alloc]initWithFormat:@"telprompt://%@",[user.telephone substringFromIndex:2]];
  484. [g_myself insertPhone:[user.telephone substringFromIndex:2] time:[NSDate date]];
  485. [g_myself.phoneDic setObject:[NSDate date] forKey:[user.telephone substringFromIndex:2]];
  486. NSDate *date = [g_myself.phoneDic objectForKey:[user.telephone substringFromIndex:2]];
  487. if (date) {
  488. long long n = (long long)[date timeIntervalSince1970];
  489. NSString *time = [TimeUtil getTimeStrStyle1:n];
  490. NSString *str = [NSString stringWithFormat:@"%@,%@:%@",[user.telephone substringFromIndex:2],Localized(@"JX_HaveToDial"),time];
  491. _tel.text = str;
  492. }else {
  493. _tel.text = [user.telephone substringFromIndex:2];
  494. }
  495. }else {
  496. str = [[NSMutableString alloc]initWithFormat:@"telprompt://%@",user.telephone];
  497. [g_myself insertPhone:user.telephone time:[NSDate date]];
  498. [g_myself.phoneDic setObject:[NSDate date] forKey:user.telephone];
  499. _tel.text = user.telephone;
  500. }
  501. [g_notify postNotificationName:kNearRefreshCallPhone object:nil];
  502. [[UIApplication sharedApplication]openURL:[NSURL URLWithString:str]];
  503. }
  504. - (void) longTapAction:(UILongPressGestureRecognizer *)longTap {
  505. if(longTap.state == UIGestureRecognizerStateBegan)
  506. {
  507. NSString *subString = [user.telephone substringToIndex:2];
  508. if ([subString isEqualToString:@"86"]) {
  509. [g_myself deletePhone:[user.telephone substringFromIndex:2]];
  510. [g_myself.phoneDic removeObjectForKey:[user.telephone substringFromIndex:2]];
  511. _tel.text = [user.telephone substringFromIndex:2];
  512. }else {
  513. [g_myself deletePhone:user.telephone];
  514. [g_myself.phoneDic removeObjectForKey:user.telephone];
  515. _tel.text = user.telephone;
  516. }
  517. [g_notify postNotificationName:kNearRefreshCallPhone object:nil];
  518. }
  519. }
  520. -(void)switchAction:(UISwitch *) sender{
  521. if (_friendStatus == friend_status_friend && ![user.isBeenBlack boolValue]) {
  522. int offlineNoPushMsg = sender.isOn;
  523. [g_server friendsUpdateOfflineNoPushMsgUserId:g_myself.userId toUserId:user.userId offlineNoPushMsg:offlineNoPushMsg type:0 toView:self];
  524. }else {
  525. [sender setOn:!sender.isOn];
  526. [g_server showMsg:Localized(@"JX_PleaseAddAsFriendFirst")];
  527. }
  528. }
  529. -(void)onHeadImage{
  530. [g_server delHeadImage:self.user.userId];
  531. JXImageScrollVC * imageVC = [[JXImageScrollVC alloc]init];
  532. imageVC.imageSize = CGSizeMake(JX_SCREEN_WIDTH, JX_SCREEN_WIDTH);
  533. imageVC.iv = [[JXImageView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_WIDTH)];
  534. imageVC.iv.center = imageVC.view.center;
  535. [g_server getHeadImageLarge:self.user.userId userName:self.user.userNickname imageView:imageVC.iv];
  536. [self addTransition:imageVC];
  537. [self presentViewController:imageVC animated:YES completion:^{
  538. }];
  539. }
  540. //添加VC转场动画
  541. - (void) addTransition:(JXImageScrollVC *) siv
  542. {
  543. _scaleTransition = [[DMScaleTransition alloc]init];
  544. [siv setTransitioningDelegate:_scaleTransition];
  545. }
  546. -(void)dealloc{
  547. NSLog(@"JXUserInfoVC.dealloc");
  548. [g_notify removeObserver:self name:kXMPPSendTimeOutNotifaction object:nil];
  549. [g_notify removeObserver:self name:kXMPPReceiptNotifaction object:nil];
  550. [g_notify removeObserver:self];
  551. self.user = nil;
  552. // [super dealloc];
  553. }
  554. - (void)viewDidLoad
  555. {
  556. [super viewDidLoad];
  557. // Do any additional setup after loading the view.
  558. }
  559. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  560. if([aDownload.action isEqualToString:act_AttentionAdd]){//加好友
  561. int n = [[dict objectForKey:@"type"] intValue];
  562. if( n==2 || n==4)
  563. _friendStatus = friend_status_friend;//成为好友,一般是无需验证
  564. // else
  565. // _friendStatus = friend_status_see;//单向关注
  566. if ([user.userType intValue] == 2) {
  567. user.status = [NSNumber numberWithInt:2];
  568. if([user haveTheUser])
  569. [user insert];
  570. else
  571. [user update];
  572. [self actionQuit];
  573. [g_notify postNotificationName:kActionRelayQuitVC object:nil];
  574. [self.user doSendMsg:XMPP_TYPE_FRIEND content:nil];
  575. [self showAddFriend];
  576. //JXChatViewC
  577. JXChatViewC *chatVC=[JXChatViewC alloc];
  578. chatVC.title = user.userNickname;
  579. chatVC.chatPerson = self.user;
  580. chatVC = [chatVC init];
  581. [g_navigation pushViewController:chatVC animated:YES];
  582. }else {
  583. if(_friendStatus == friend_status_friend){
  584. [_wait stop];
  585. [self doMakeFriend];
  586. }
  587. else{
  588. [self doSayHello];
  589. }
  590. }
  591. }
  592. if ([aDownload.action isEqualToString:act_FriendDel]) {//删除好友
  593. [self.user doSendMsg:XMPP_TYPE_DELALL content:nil];
  594. }
  595. if([aDownload.action isEqualToString:act_BlacklistAdd]){//拉黑
  596. [self.user doSendMsg:XMPP_TYPE_BLACK content:nil];
  597. }
  598. if([aDownload.action isEqualToString:act_FriendRemark]){
  599. [_wait stop];
  600. JXUserObject* user1 = [[JXUserObject sharedInstance] getUserById:user.userId];
  601. // user1.userNickname = user.remarkName;
  602. user1.remarkName = user.remarkName;
  603. user1.describe = user.describe;
  604. // 修改备注后实时刷新
  605. [user updateRemarkName];
  606. [g_notify postNotificationName:kFriendRemark object:user1];
  607. [g_server showMsg:Localized(@"JXAlert_SetOK")];
  608. }
  609. if([aDownload.action isEqualToString:act_BlacklistDel]){
  610. [self.user doSendMsg:XMPP_TYPE_NOBLACK content:nil];
  611. }
  612. if([aDownload.action isEqualToString:act_AttentionDel]){
  613. [user doSendMsg:XMPP_TYPE_DELSEE content:nil];
  614. }
  615. if([aDownload.action isEqualToString:act_Report]){
  616. [_wait stop];
  617. [g_server showMsg:Localized(@"JXUserInfoVC_ReportSuccess")];
  618. }
  619. if([aDownload.action isEqualToString:act_friendsUpdateOfflineNoPushMsg]){
  620. [_wait stop];
  621. [g_server showMsg:Localized(@"JXAlert_SetOK")];
  622. }
  623. if([aDownload.action isEqualToString:act_filterUserCircle]){
  624. [_wait stop];
  625. }
  626. if( [aDownload.action isEqualToString:act_UserGet] ){
  627. [_wait stop];
  628. JXUserObject* user = [[JXUserObject alloc]init];
  629. [user getDataFromDict:dict];
  630. [user insertFriend];
  631. [user updateUserNickname];
  632. [user updateRemarkName];
  633. [user updateTelephone];
  634. // 更新等级气泡
  635. [g_server getbubbleFontByUserId:user.userId ToView:self];
  636. if ([user.userType intValue] != 2) {
  637. [self createViews];
  638. }
  639. if (self.user && ![self.user.userNickname isEqualToString:user.userNickname]) {
  640. [g_notify postNotificationName:kFriendListRefresh object:nil];
  641. }
  642. [self setUserInfo:user];
  643. if ([user.userType intValue] == 2) {
  644. [self setupServers];
  645. [self setServerDetail];
  646. }
  647. if (self.chatVC) {
  648. [self.chatVC.tableView reloadData];
  649. }
  650. }
  651. if([aDownload.action isEqualToString:act_getbubbleFontByUserId]){
  652. // 保存到数据库
  653. JLBubbleManager *manager = [JLBubbleManager sharedManager];
  654. FMDatabase* db = [manager openResouceDb];
  655. BOOL result = [manager checkBubbleFontTableCreatedInDb:db];
  656. if (result) {
  657. // self.id, self.iosLeftUrl, self.iosRightUrl, self.name, self.code, self.color
  658. for (NSDictionary *tempDict in array1) {
  659. JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:tempDict];
  660. manager.id = model.id;
  661. manager.iosLeftUrl = model.bubble.iosLeftUrl;
  662. manager.iosRightUrl = model.bubble.iosRightUrl;
  663. manager.name = model.bubble.name;
  664. manager.code = [NSString stringWithFormat:@"%d", model.font.code];
  665. manager.color = model.font.color;
  666. [manager insertBubbleFontTable];
  667. }
  668. }
  669. }
  670. [_wait stop];
  671. }
  672. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  673. [_wait stop];
  674. return show_error;
  675. }
  676. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  677. [_wait stop];
  678. return show_error;
  679. }
  680. -(void) didServerConnectStart:(JXConnection*)aDownload{
  681. if( [aDownload.action isEqualToString:act_UserGet] ){
  682. [_wait stop];
  683. return;
  684. }
  685. [_wait start];
  686. }
  687. -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom must:(BOOL)must click:(SEL)click superView:(UIView *)superView{
  688. JXImageView* btn = [[JXImageView alloc] init];
  689. btn.backgroundColor = [UIColor whiteColor];
  690. btn.userInteractionEnabled = YES;
  691. btn.didTouch = click;
  692. btn.delegate = self;
  693. [superView addSubview:btn];
  694. if(must){
  695. UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(INSETS, 5, 20, HEIGHT-5)];
  696. p.text = @"*";
  697. p.font = g_factory.font18;
  698. p.backgroundColor = [UIColor clearColor];
  699. p.textColor = [UIColor redColor];
  700. p.textAlignment = NSTextAlignmentCenter;
  701. [btn addSubview:p];
  702. }
  703. JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(15, 0, 200, HEIGHT)];
  704. p.text = title;
  705. p.font = g_factory.font16;
  706. p.backgroundColor = [UIColor clearColor];
  707. p.tag = 100;
  708. p.textColor = [UIColor blackColor];
  709. [btn addSubview:p];
  710. if (@selector(onRemark) == click) {
  711. _labelLab = p;
  712. }
  713. if(drawTop){
  714. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(15,0,JX_SCREEN_WIDTH-15,LINE_WH)];
  715. line.backgroundColor = THE_LINE_COLOR;
  716. [btn addSubview:line];
  717. }
  718. if(drawBottom){
  719. UIView* line = [[UIView alloc]initWithFrame:CGRectMake(15,HEIGHT-LINE_WH,JX_SCREEN_WIDTH-15,LINE_WH)];
  720. line.backgroundColor = THE_LINE_COLOR;
  721. [btn addSubview:line];
  722. }
  723. //这个选择器仅用于判断,之后会修改为不可点击
  724. SEL check = @selector(switchAction:);
  725. //创建switch
  726. if(click == check){
  727. UISwitch * switchView = [[UISwitch alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-INSETS-51, 6, 20, 20)];
  728. if ([title isEqualToString:Localized(@"JX_MessageFree")]) {
  729. _messageFreeSwitch = switchView;
  730. if ([user.offlineNoPushMsg intValue] == 1) {
  731. [_messageFreeSwitch setOn:YES];
  732. }else {
  733. [_messageFreeSwitch setOn:NO];
  734. }
  735. }
  736. switchView.onTintColor = THEMECOLOR;
  737. [switchView addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
  738. [btn addSubview:switchView];
  739. //取消调用switchAction
  740. btn.didTouch = @selector(hideKeyboard);
  741. }else if(click){
  742. btn.frame = CGRectMake(btn.frame.origin.x -20, btn.frame.origin.y, btn.frame.size.width, btn.frame.size.height);
  743. UIImageView* iv;
  744. iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, (HEIGHT-13)/2, 7, 13)];
  745. iv.image = [UIImage imageNamed:@"new_icon_>"];
  746. [btn addSubview:iv];
  747. }
  748. return btn;
  749. }
  750. -(UITextField*)createTextField:(UIView*)parent default:(NSString*)s hint:(NSString*)hint{
  751. UITextField* p = [[UITextField alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2,INSETS,JX_SCREEN_WIDTH/2,HEIGHT-INSETS*2)];
  752. p.delegate = self;
  753. p.autocorrectionType = UITextAutocorrectionTypeNo;
  754. p.autocapitalizationType = UITextAutocapitalizationTypeNone;
  755. p.enablesReturnKeyAutomatically = YES;
  756. p.borderStyle = UITextBorderStyleNone;
  757. p.returnKeyType = UIReturnKeyDone;
  758. p.clearButtonMode = UITextFieldViewModeAlways;
  759. p.textAlignment = NSTextAlignmentRight;
  760. p.userInteractionEnabled = YES;
  761. p.text = s;
  762. p.placeholder = hint;
  763. p.font = g_factory.font14;
  764. [parent addSubview:p];
  765. // [p release];
  766. return p;
  767. }
  768. -(UILabel*)createLabel:(UIView*)parent default:(NSString*)s{
  769. // UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2,(HEIGHT-15)/2,JX_SCREEN_WIDTH/2 - 15,15)];
  770. UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2,INSETS,JX_SCREEN_WIDTH/2 - INSETS - 20 - 5,HEIGHT-INSETS*2)];
  771. p.userInteractionEnabled = NO;
  772. p.text = s;
  773. p.font = g_factory.font15;
  774. p.textAlignment = NSTextAlignmentRight;
  775. p.textColor = HEXCOLOR(0x999999);
  776. [parent addSubview:p];
  777. return p;
  778. }
  779. - (BOOL)textFieldShouldReturn:(UITextField *)textField
  780. {
  781. [self.view endEditing:YES];
  782. return YES;
  783. }
  784. -(void)actionAddFriend:(UIView*)sender{
  785. // 验证XMPP是否在线
  786. if(g_xmpp.isLogined != 1){
  787. [g_xmpp showXmppOfflineAlert];
  788. return;
  789. }
  790. if([user.isBeenBlack boolValue]){
  791. [g_server showMsg:Localized(@"TO_BLACKLIST")];
  792. return;
  793. }
  794. switch (_friendStatus) {
  795. case friend_status_black:{
  796. // [g_server addAttention:user.userId toView:self];
  797. [self onDelBlack];
  798. // [self viewDisMissAction];
  799. }
  800. break;
  801. case friend_status_none:
  802. case friend_status_see:
  803. [g_server addAttention:user.userId fromAddType:self.fromAddType toView:self];
  804. break;
  805. // case friend_status_see:
  806. // [self doSayHello];
  807. // break;
  808. case friend_status_friend:{//发消息
  809. if([user haveTheUser])
  810. [user insert];
  811. else
  812. [user update];
  813. // [self actionQuit];
  814. [g_notify postNotificationName:kActionRelayQuitVC object:nil];
  815. //
  816. // JXChatViewController *chatVC=[JXChatViewController alloc];
  817. JXChatViewC *chatVC=[JXChatViewC alloc];
  818. chatVC.title = user.userNickname;
  819. chatVC.chatPerson = self.user;
  820. chatVC = [chatVC init];
  821. // [g_App.window addSubview:chatVC.view];
  822. [g_navigation pushViewController:chatVC animated:YES];
  823. }
  824. break;
  825. }
  826. }
  827. -(void)doSayHello{//打招呼
  828. _xmppMsgId = [self.user doSendMsg:XMPP_TYPE_SAYHELLO content:Localized(@"JXUserInfoVC_Hello")];
  829. }
  830. -(void)onSendTimeout:(NSNotification *)notifacation//超时未收到回执
  831. {
  832. // NSLog(@"onSendTimeout");
  833. [_wait stop];
  834. // [g_App showAlert:Localized(@"JXAlert_SendFilad")];
  835. [JXMyTools showTipView:Localized(@"JXAlert_SendFilad")];
  836. }
  837. -(void)newReceipt:(NSNotification *)notifacation{//新回执
  838. // NSLog(@"newReceipt");
  839. JXMessageObject *msg = (JXMessageObject *)notifacation.object;
  840. if(msg == nil)
  841. return;
  842. if(![msg isAddFriendMsg])
  843. return;
  844. if(![msg.toUserId isEqualToString:self.user.userId])
  845. return;
  846. [_wait stop];
  847. if([msg.type intValue] == XMPP_TYPE_SAYHELLO){//打招呼
  848. [g_server showMsg:Localized(@"JXAlert_SayHiOK")];
  849. }
  850. if([msg.type intValue] == XMPP_TYPE_BLACK){//拉黑
  851. user.status = [NSNumber numberWithInt:friend_status_black];
  852. _friendStatus = [user.status intValue];
  853. [[JXXMPP sharedInstance].blackList addObject:user.userId];
  854. [user update];
  855. [self showAddFriend];
  856. [g_server showMsg:Localized(@"JXAlert_AddBlackList")];
  857. [g_notify postNotificationName:kXMPPNewFriendNotifaction object:nil];
  858. // [JXMessageObject msgWithFriendStatus:user.userId status:_friendStatus];
  859. // [user notifyDelFriend];
  860. }
  861. if([msg.type intValue] == XMPP_TYPE_DELSEE){//删除关注,弃用
  862. _friendStatus = friend_status_none;
  863. [self showAddFriend];
  864. [JXMessageObject msgWithFriendStatus:user.userId status:_friendStatus];
  865. [g_server showMsg:Localized(@"JXAlert_CencalFollow")];
  866. }
  867. if([msg.type intValue] == XMPP_TYPE_DELALL){//删除好友
  868. _friendStatus = friend_status_none;
  869. [self showAddFriend];
  870. [g_notify postNotificationName:kXMPPNewFriendNotifaction object:nil];
  871. if ([self.user.userType intValue] == 2) {
  872. [g_server showMsg:@"已取消关注"];
  873. user.status = [NSNumber numberWithInt:1];
  874. [user update];
  875. }else {
  876. [g_server showMsg:Localized(@"JXAlert_DeleteFirend")];
  877. }
  878. }
  879. if([msg.type intValue] == XMPP_TYPE_NOBLACK){//取消拉黑
  880. user.status = [NSNumber numberWithInt:friend_status_friend];
  881. [user updateStatus];
  882. _friendStatus = friend_status_friend;
  883. [self showAddFriend];
  884. if ([[JXXMPP sharedInstance].blackList containsObject:user.userId]) {
  885. [[JXXMPP sharedInstance].blackList removeObject:user.userId];
  886. [JXMessageObject msgWithFriendStatus:user.userId status:friend_status_friend];
  887. }
  888. [g_server showMsg:Localized(@"JXAlert_MoveBlackList")];
  889. [g_notify postNotificationName:kXMPPNewFriendNotifaction object:nil];
  890. }
  891. if([msg.type intValue] == XMPP_TYPE_FRIEND){//无验证加好友
  892. if ([g_myself.telephone rangeOfString:@"18938880001"].location == NSNotFound) {
  893. [g_server showMsg:Localized(@"JX_AddSuccess")];
  894. }
  895. user.status = [NSNumber numberWithInt:2];
  896. [g_notify postNotificationName:kXMPPNewFriendNotifaction object:nil];
  897. }
  898. }
  899. //显示添加朋友状态
  900. -(void)showAddFriend{
  901. CGFloat inset = (JX_SCREEN_WIDTH-200)/3;
  902. _notFocusBtn.hidden = YES;
  903. iv.hidden=YES;
  904. iv2.hidden=YES;
  905. switch (_friendStatus) {
  906. case friend_status_hisBlack:
  907. break;
  908. case friend_status_black://黑名单则不显示
  909. [_btn setTitle:Localized(@"JXUserInfoVC_CancelBlackList") forState:UIControlStateNormal];
  910. break;
  911. case friend_status_none:
  912. case friend_status_see:
  913. if([user.isBeenBlack boolValue])
  914. [_btn setTitle:Localized(@"TO_BLACKLIST") forState:UIControlStateNormal];
  915. else {
  916. if ([self.user.userType intValue] == 2) {
  917. _btn.hidden = NO;
  918. [_btn setTitle:@"关注公众号" forState:UIControlStateNormal];
  919. _btn.frame = CGRectMake(JX_SCREEN_WIDTH/2-50, _btn.frame.origin.y, _btn.frame.size.width, _btn.frame.size.height);
  920. }else {
  921. if ([_data.role intValue]==1||[_data.role intValue]==2) {
  922. [_btn setTitle:Localized(@"JX_AddFriend") forState:UIControlStateNormal];
  923. _btn.hidden=NO;
  924. }else{
  925. if (_msgUser==nil && _data==nil && _friendStatus==2) {
  926. [_btn setTitle:Localized(@"JX_AddFriend") forState:UIControlStateNormal];
  927. _btn.hidden=NO;
  928. }else{
  929. if ([_isSearchPush isEqualToString:@"10000"]) {
  930. [_btn setTitle:Localized(@"JX_AddFriend") forState:UIControlStateNormal];
  931. }else{
  932. _btn.hidden=YES;
  933. }
  934. }
  935. }
  936. }
  937. }
  938. break;
  939. case friend_status_friend:
  940. iv.hidden=NO;
  941. iv2.hidden=NO;
  942. if([user.isBeenBlack boolValue])
  943. [_btn setTitle:Localized(@"TO_BLACKLIST") forState:UIControlStateNormal];
  944. else {
  945. if ([_data.role intValue]==1||[_data.role intValue]==2 ) {
  946. [_btn setTitle:Localized(@"JXUserInfoVC_SendMseeage") forState:UIControlStateNormal];
  947. _btn.hidden=NO;
  948. }else{
  949. if (_msgUser==nil && _data==nil) {
  950. if (_friendStatus ==2) {
  951. [_btn setTitle:Localized(@"JXUserInfoVC_SendMseeage") forState:UIControlStateNormal];
  952. _btn.hidden=NO;
  953. }else{
  954. [_btn setTitle:Localized(@"JX_AddFriend") forState:UIControlStateNormal];
  955. _btn.hidden=NO;
  956. }
  957. }else{
  958. if ([_isSearchPush isEqualToString:@"1000"]) {
  959. [_btn setTitle:Localized(@"JXUserInfoVC_SendMseeage") forState:UIControlStateNormal];
  960. }else{
  961. _btn.hidden=YES;
  962. }
  963. }
  964. }
  965. }
  966. break;
  967. }
  968. }
  969. -(void)specialCareClick{
  970. CYSpecialCareViewController *vc = [[CYSpecialCareViewController alloc] init];
  971. vc.user = self.user;
  972. vc.userId = self.userId;
  973. [g_navigation pushViewController:vc animated:YES];
  974. }
  975. -(void)onMyBlog{
  976. userWeiboVC* vc = [userWeiboVC alloc];
  977. vc.user = user;
  978. vc.isGotoBack = YES;
  979. vc = [vc init];
  980. // [g_window addSubview:vc.view];
  981. [g_navigation pushViewController:vc animated:YES];
  982. }
  983. -(void)actionMap{
  984. if (_longitude <=0 && _latitude <= 0) {
  985. [g_server showMsg:Localized(@"JX_NotShareLocation")];
  986. return;
  987. }
  988. JXMapData * mapData = [[JXMapData alloc] init];
  989. mapData.latitude = [NSString stringWithFormat:@"%f",_latitude];
  990. mapData.longitude = [NSString stringWithFormat:@"%f",_longitude];
  991. NSArray * locations = @[mapData];
  992. if (g_config.isChina) {
  993. JXLocationVC * vc = [JXLocationVC alloc];
  994. vc.locations = [NSMutableArray arrayWithArray:locations];
  995. vc.locationType = JXLocationTypeShowStaticLocation;
  996. vc = [vc init];
  997. [g_navigation pushViewController:vc animated:YES];
  998. }else {
  999. _gooMap = [JXGoogleMapVC alloc];
  1000. _gooMap.locations = [NSMutableArray arrayWithArray:locations];
  1001. _gooMap.locationType = JXGooLocationTypeShowStaticLocation;
  1002. _gooMap = [_gooMap init];
  1003. [g_navigation pushViewController:_gooMap animated:YES];
  1004. }
  1005. // JXLocationVC* vc = [JXLocationVC alloc];
  1006. // vc.isSend = NO;
  1007. // vc.locationType = JXLocationTypeShowStaticLocation;
  1008. // NSMutableArray * locationsArray = [[NSMutableArray alloc]init];
  1009. //
  1010. // JXMapData* p = [[JXMapData alloc]init];
  1011. // p.latitude = [NSString stringWithFormat:@"%f",_latitude];
  1012. // p.longitude = [NSString stringWithFormat:@"%f",_longitude];
  1013. // p.title = _name.text;
  1014. // p.subtitle = _city.text;
  1015. // [locationsArray addObject:p];
  1016. // vc.locations = locationsArray;
  1017. //
  1018. // vc = [vc init];
  1019. //// [g_window addSubview:vc.view];
  1020. // [g_navigation pushViewController:vc animated:YES];
  1021. }
  1022. -(void)reportUserView{
  1023. JXReportUserVC * reportVC = [[JXReportUserVC alloc] init];
  1024. reportVC.user = user;
  1025. reportVC.delegate = self;
  1026. // [g_window addSubview:reportVC.view];
  1027. [g_navigation pushViewController:reportVC animated:YES];
  1028. }
  1029. - (void)report:(JXUserObject *)reportUser reasonId:(NSNumber *)reasonId {
  1030. [g_server reportUser:reportUser.userId roomId:nil webUrl:nil reasonId:reasonId toView:self];
  1031. }
  1032. - (void)onMore{
  1033. int n = _friendStatus;
  1034. //标题数组
  1035. [_titleArr removeAllObjects];
  1036. [_titleArr addObject:Localized(@"JXUserInfoVC_Report")];
  1037. if ([self.user.userType intValue] != 2) {
  1038. //[_titleArr addObject:Localized(@"JX_SetNotesAndDescriptions")];
  1039. [_titleArr addObject:@"设置备注和名称"];//Localized(@"JX_SetNotesAndDescriptions")];
  1040. if(n == friend_status_friend){
  1041. // if(n == friend_status_black)
  1042. // [_titleArr addObject:Localized(@"JXUserInfoVC_CancelBlackList")];
  1043. // else if(![user.isBeenBlack boolValue]) {
  1044. // [_titleArr addObject:Localized(@"JXUserInfoVC_AddBlackList")];
  1045. // }
  1046. if(![user.isBeenBlack boolValue]){
  1047. if(n == friend_status_friend)
  1048. [_titleArr addObject:Localized(@"JXUserInfoVC_DeleteFirend")];
  1049. else
  1050. [_titleArr addObject:Localized(@"JX_AddFriend")];
  1051. }
  1052. }
  1053. }
  1054. // //模糊背景
  1055. // _bgBlackAlpha = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT)];
  1056. // _bgBlackAlpha.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
  1057. // [self.view addSubview:_bgBlackAlpha];
  1058. //// [_bgBlackAlpha release];
  1059. //自定义View
  1060. _selectView = [[JX_SelectMenuView alloc] initWithTitle:_titleArr image:@[] cellHeight:CellHeight];
  1061. _selectView.alpha = 0.0;
  1062. _selectView.delegate = self;
  1063. [self.view addSubview:_selectView];
  1064. // [_selectView release];
  1065. //动画
  1066. [UIView animateWithDuration:0.3 animations:^{
  1067. _selectView.alpha = 1;
  1068. }];
  1069. }
  1070. - (void)didMenuView:(JX_SelectMenuView *)MenuView WithIndex:(NSInteger)index {
  1071. long n = _friendStatus;//好友状态
  1072. // if(n>[_titleArr count]-1)
  1073. // return;
  1074. switch (index) {
  1075. case 0:
  1076. [self reportUserView];
  1077. [self viewDisMissAction];
  1078. break;
  1079. case 1:
  1080. [self onRemark];
  1081. [self viewDisMissAction];
  1082. break;
  1083. // case 2:
  1084. // if(n == friend_status_black){
  1085. // [self onDelBlack];
  1086. // [self viewDisMissAction];
  1087. // }else{
  1088. // [self onAddBlack];
  1089. // [self viewDisMissAction];
  1090. // }
  1091. // break;
  1092. case 2:
  1093. if(n == friend_status_see || n == friend_status_friend){
  1094. // [self onCancelSee];
  1095. // [self viewDisMissAction];
  1096. UIAlertView *alertShwo = [[UIAlertView alloc]initWithTitle:@"删除好友" message:@"确认删除好友" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
  1097. [alertShwo show];
  1098. }else{
  1099. [self actionAddFriend:nil];
  1100. [self viewDisMissAction];
  1101. }
  1102. break;
  1103. default:
  1104. [self viewDisMissAction];
  1105. break;
  1106. }
  1107. }
  1108. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
  1109. if (buttonIndex==0) {
  1110. return;
  1111. }
  1112. [self onDeleteFriend];
  1113. [self viewDisMissAction];
  1114. }
  1115. - (void)viewDisMissAction{
  1116. [UIView animateWithDuration:0.4 animations:^{
  1117. _bgBlackAlpha.alpha = 0.0;
  1118. } completion:^(BOOL finished) {
  1119. [_selectView removeFromSuperview];
  1120. _selectView = nil;
  1121. [_bgBlackAlpha removeFromSuperview];
  1122. }];
  1123. }
  1124. #pragma mark ---------------创建设置好友备注页面----------------
  1125. -(void)onRemark{
  1126. // JXInputValueVC* vc = [JXInputValueVC alloc];
  1127. // vc.value = user.remarkName;
  1128. // vc.title = Localized(@"JXUserInfoVC_SetName");
  1129. // vc.delegate = self;
  1130. // vc.isLimit = YES;
  1131. // vc.didSelect = @selector(onSaveNickName:);
  1132. // vc = [vc init];
  1133. //// [g_window addSubview:vc.view];
  1134. // [g_navigation pushViewController:vc animated:YES];
  1135. JXSetNoteAndLabelVC *vc = [[JXSetNoteAndLabelVC alloc] init];
  1136. vc.title = @"设置备注和标签";// Localized(@"JX_SetNotesAndLabels");
  1137. vc.delegate = self;
  1138. vc.didSelect = @selector(refreshLabel:);
  1139. vc.user = self.user;
  1140. [g_navigation pushViewController:vc animated:YES];
  1141. }
  1142. - (void)refreshLabel:(JXUserObject *)user {
  1143. self.user.remarkName = user.remarkName;
  1144. self.user.describe = user.describe;
  1145. // CGSize sizeN = [user.remarkName sizeWithAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16]}];
  1146. // _remarkName.frame = CGRectMake(_remarkName.frame.origin.x, _remarkName.frame.origin.y, sizeN.width, _remarkName.frame.size.height);
  1147. // _sex.frame = CGRectMake(CGRectGetMaxX(_remarkName.frame)+3, _sex.frame.origin.y, _sex.frame.size.width, _sex.frame.size.height);
  1148. //
  1149. // _remarkName.text = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  1150. [self setLabelAndDescribe];
  1151. [g_server setFriendName:self.user.userId noteName:user.remarkName describe:user.describe toView:self];
  1152. }
  1153. -(void)onSaveNickName:(JXInputValueVC*)vc{
  1154. _remarkName.text = vc.value;
  1155. user.remarkName = vc.value;
  1156. [g_server setFriendName:user.userId noteName:vc.value describe:nil toView:self];
  1157. }
  1158. -(void)onAddBlack{
  1159. [g_server addBlacklist:user.userId toView:self];
  1160. }
  1161. -(void)onDelBlack{
  1162. [g_server delBlacklist:user.userId toView:self];
  1163. }
  1164. -(void)onCancelSee{
  1165. [g_server delAttention:user.userId toView:self];
  1166. }
  1167. -(void)onDeleteFriend{
  1168. // [g_server delAttention:user.userId toView:self];
  1169. [g_server delFriend:user.userId toView:self];
  1170. }
  1171. -(void)doMakeFriend{
  1172. _friendStatus = friend_status_friend;
  1173. // user.status = [NSNumber numberWithInt:_friendStatus];
  1174. // if([user haveTheUser])
  1175. // [user update];
  1176. // else
  1177. // [user insert];
  1178. [self.user doSendMsg:XMPP_TYPE_FRIEND content:nil];
  1179. [JXMessageObject msgWithFriendStatus:user.userId status:_friendStatus];
  1180. [self showAddFriend];
  1181. }
  1182. -(void)showUserQRCode{
  1183. JXQRCodeViewController * qrVC = [[JXQRCodeViewController alloc] init];
  1184. qrVC.type = QRUserType;
  1185. qrVC.userId = user.userId;
  1186. qrVC.account = user.account;
  1187. qrVC.nickName = user.userNickname;
  1188. qrVC.sex = user.sex;
  1189. // [g_window addSubview:qrVC.view];
  1190. [g_navigation pushViewController:qrVC animated:YES];
  1191. }
  1192. - (NSString *)dateTimeDifferenceWithStartTime:(NSNumber *)compareDate {
  1193. NSInteger timeInterval = [[NSDate date] timeIntervalSince1970] - [compareDate integerValue];
  1194. long temp = 0;
  1195. NSString *result;
  1196. if (timeInterval < 60) {
  1197. result = [NSString stringWithFormat:@"%d%@",(int)timeInterval,Localized(@"SECONDS_AGO")];
  1198. }
  1199. else if((temp = timeInterval/60) <60){
  1200. result = [NSString stringWithFormat:@"%ld%@",temp,Localized(@"MINUTES_AGO")];
  1201. }
  1202. else if((temp = temp/60) <24){
  1203. result = [NSString stringWithFormat:@"%ld%@",temp,Localized(@"JX_HoursAgo")];
  1204. }
  1205. else if((temp = temp/24) <30){
  1206. result = [NSString stringWithFormat:@"%ld%@",temp,Localized(@"JX_DaysAgo")];
  1207. }
  1208. else if((temp = temp/30) <12){
  1209. result = [NSString stringWithFormat:@"%ld%@",temp,Localized(@"JX_MonthAgo")];
  1210. }
  1211. else{
  1212. temp = temp/12;
  1213. result = [NSString stringWithFormat:@"%ld%@",temp,Localized(@"JX_YearsAgo")];
  1214. }
  1215. return result;
  1216. }
  1217. @end