JXUserDetialVc.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. //
  2. // JXUserDetialVc.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/5/7.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #define HEIGHT 56
  9. #define LINE_INSET 8
  10. #define TopHeight 7
  11. #define CellHeight 45
  12. #import "JXUserDetialVc.h"
  13. @interface JXUserDetialVc ()<UITextFieldDelegate,JXSelectMenuViewDelegate,JXReportUserDelegate>
  14. /**去掉了*/
  15. @property (weak, nonatomic) IBOutlet UILabel *nickNameL;
  16. @property (weak, nonatomic) IBOutlet UIImageView *headIMG;
  17. @property (weak, nonatomic) IBOutlet UIImageView *setIMG;
  18. @property (weak, nonatomic) IBOutlet UILabel *nameL;
  19. @property (weak, nonatomic) IBOutlet UILabel *levelL;
  20. @property (weak, nonatomic) IBOutlet UILabel *jixinNoL;
  21. @property (weak, nonatomic) IBOutlet UILabel *bridthyL;
  22. @end
  23. @implementation JXUserDetialVc
  24. - (void)onCirclePermissions {
  25. JXCirclePermissionsVC *vc = [[JXCirclePermissionsVC alloc] init];
  26. vc.user = self.user;
  27. [g_navigation pushViewController:vc animated:YES];
  28. }
  29. /**
  30. * 备注标签 与朋友圈
  31. */
  32. - (IBAction)tagBtn:(UIButton *)sender {
  33. if (sender.tag==0) {//备注标签
  34. JXSetNoteAndLabelVC *vc = [[JXSetNoteAndLabelVC alloc] init];
  35. vc.title =@"设置备注和标签";// Localized(@"JX_SetNotesAndLabels");
  36. vc.delegate = self;
  37. vc.didSelect = @selector(refreshLabel:);
  38. vc.user = self.user;
  39. [g_navigation pushViewController:vc animated:YES];
  40. }else{//朋友权限
  41. [self onCirclePermissions];
  42. }
  43. }
  44. - (id)init
  45. {
  46. self = [super init];
  47. if (self) {
  48. _titleArr = [[NSMutableArray alloc]init];
  49. _friendStatus = [_user.status intValue];
  50. _latitude = [_user.latitude doubleValue];
  51. _longitude = [_user.longitude doubleValue];
  52. if([self.userId isKindOfClass:[NSNumber class]])
  53. self.userId = [(NSNumber*)self.userId stringValue];
  54. [g_server getUser:self.userId toView:self];
  55. [g_notify addObserver:self selector:@selector(newReceipt:) name:kXMPPReceiptNotifaction object:nil];
  56. [g_notify addObserver:self selector:@selector(onSendTimeout:) name:kXMPPSendTimeOutNotifaction object:nil];
  57. [g_notify addObserver:self selector:@selector(friendPassNotif:) name:kFriendPassNotif object:nil];
  58. [g_notify addObserver:self selector:@selector(newRequest:) name:kXMPPNewRequestNotifaction object:nil];
  59. }
  60. return self;
  61. }
  62. - (void)viewDidLoad {
  63. [super viewDidLoad];
  64. self.title = Localized(@"JX_BaseInfo");
  65. UIButton *btn = [UIFactory createButtonWithImage:THESIMPLESTYLE ? @"title_more_black" : @"title_more" highlight:nil target:self selector:@selector(onMore)];
  66. btn.frame = CGRectMake(JX_SCREEN_WIDTH-24-8, JX_SCREEN_TOP - 34, 24, 24);
  67. [self.view addSubview:btn];
  68. [self setupServers];
  69. }
  70. - (void)setupServers {
  71. //如果是自己,则不现实按钮
  72. // 自己/公众号/厂家不删除
  73. // 更新头像缓存
  74. // [g_server delHeadImage:self.userId];
  75. self.headIMG.image = [UIImage imageNamed:@"face_cry "];
  76. [self.headIMG addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onHeadImage)]];
  77. [g_server getHeadImageSmall:self.userId userName:self.user.userNickname imageView:_headIMG];
  78. // 更新头像缓存
  79. [g_server delHeadImage:self.userId];
  80. #pragma mark ---------- 呢称
  81. // 昵称
  82. _levelL.text = [NSString stringWithFormat:@"%@",@"帝王"];
  83. _nameL.text = [NSString stringWithFormat:@"%@ : %@",Localized(@"JX_NickName"),@"--"];
  84. _nickNameL.text = [NSString stringWithFormat:@"%@ : %@",Localized(@"JX_NickName"),@"--"];
  85. //即信号
  86. _jixinNoL.text = [NSString stringWithFormat:@"%@ : %@",Localized(@"JX_Communication"),@"--"];
  87. /*
  88. if ([self.userId intValue]>10100 || [self.userId intValue]<10000) {
  89. iv = [self createButton:Localized(@"JX_MemoName") drawTop:NO drawBottom:YES must:NO click:nil superView:self.tableBody];
  90. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  91. //如果是朋友且设置备注,这修改为备注,暂时不知道有没有此接口
  92. _remarkName = [self createLabel:iv default:user.remarkName];
  93. h+=iv.frame.size.height;
  94. iv = [self createButton:Localized(@"JX_UserInfoDescribe") drawTop:NO drawBottom:YES must:NO click:nil superView:self.tableBody];
  95. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  96. //如果是朋友且设置备注,这修改为备注,暂时不知道有没有此接口
  97. _describe = [self createLabel:iv default:user.describe];
  98. h+=iv.frame.size.height;
  99. }
  100. */
  101. JXUserObject *friend = [[JXUserObject sharedInstance] getUserById:self.userId];
  102. if ((friend && [friend.status intValue] != friend_status_none) || [self.userId isEqualToString:g_myself.userId]) {}
  103. if ([g_config.isOpenPositionService intValue] == 0) {
  104. if (!self.isJustShow) {
  105. // iv = [self createButton:Localized(@"JXUserInfoVC_Loation") drawTop:NO drawBottom:YES must:NO click:@selector(actionMap) superView:_baseView];
  106. // iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  107. // h+=iv.frame.size.height;
  108. }
  109. }
  110. }
  111. - (void)newRequest:(NSNotification *)notif {
  112. [g_server getUser:self.userId toView:self];
  113. }
  114. - (void) setUserInfo:(JXUserObject *)user {
  115. if (self.user.content) {
  116. user.content = self.user.content;
  117. }
  118. self.user = user;
  119. // 更新用户信息
  120. [user updateUserNickname];
  121. _friendStatus = [user.status intValue];
  122. _latitude = [user.latitude doubleValue];
  123. _longitude = [user.longitude doubleValue];
  124. // 设置用户名字、备注、通讯号、地区等.
  125. if ([user.showLastLoginTime intValue] > 0 && [user.userType intValue] != 2) {
  126. //_lastTime.text = [self dateTimeDifferenceWithStartTime:user.showLastLoginTime];
  127. // _lastTImgV.hidden = NO;
  128. }else {
  129. // _lastTImgV.hidden = YES;
  130. }
  131. if (user.telephone.length > 0 && [user.userType intValue] != 2) {
  132. // _showNum.text = user.phone;
  133. // _showNImgV.hidden = NO;
  134. }else {
  135. // _showNImgV.hidden = YES;
  136. }
  137. if (user.userDescription.length > 0) {
  138. // _desLab.text = user.userDescription;
  139. // _desImgV.hidden = NO;
  140. }else {
  141. // _desImgV.hidden = YES;
  142. }
  143. //NSString* city = [g_constant getAddressForNumber:user.provinceId cityId:user.cityId areaId:user.areaId];
  144. if ([user.sex intValue] == 0) {// 女
  145. // _sex.image = [UIImage imageNamed:@"basic_famale"];
  146. }else {// 男
  147. // _sex.image = [UIImage imageNamed:@"basic_male"];
  148. }
  149. // 标签
  150. NSMutableArray *array = [[JXLabelObject sharedInstance] fetchLabelsWithUserId:self.user.userId];
  151. NSMutableString *labelsName = [NSMutableString string];
  152. for (NSInteger i = 0; i < array.count; i ++) {
  153. JXLabelObject *labelObj = array[i];
  154. if (i == 0) {
  155. [labelsName appendString:labelObj.groupName];
  156. }else {
  157. [labelsName appendFormat:@",%@",labelObj.groupName];
  158. }
  159. }
  160. if (labelsName.length > 0 && self.user.describe.length <= 0) {
  161. // _labelLab.text = Localized(@"JX_Label");
  162. }
  163. else if (labelsName.length > 0 && self.user.describe.length > 0) {
  164. // _labelLab.text = Localized(@"JX_Label");
  165. }
  166. else {
  167. //_labelLab.text = Localized(@"JX_SetNotesAndLabels");
  168. // _label.text = @"";
  169. //_describeImgV.hidden = YES;
  170. }
  171. }
  172. - (void)friendPassNotif:(NSNotification *)notif {
  173. JXFriendObject *user = notif.object;
  174. if ([user.userId isEqualToString:self.userId]) {
  175. _friendStatus = friend_status_friend;
  176. [self showAddFriend];
  177. }
  178. }
  179. -(void)switchAction:(UISwitch *) sender{
  180. if (_friendStatus == friend_status_friend && ![_user.isBeenBlack boolValue]) {
  181. int offlineNoPushMsg = sender.isOn;
  182. [g_server friendsUpdateOfflineNoPushMsgUserId:g_myself.userId toUserId:_user.userId offlineNoPushMsg:offlineNoPushMsg type:0 toView:self];
  183. }else {
  184. [sender setOn:!sender.isOn];
  185. [g_server showMsg:Localized(@"JX_PleaseAddAsFriendFirst")];
  186. }
  187. }
  188. /**
  189. *头像的缩放
  190. */
  191. -(void)onHeadImage{
  192. [g_server delHeadImage:self.user.userId];
  193. JXImageScrollVC * imageVC = [[JXImageScrollVC alloc]init];
  194. imageVC.imageSize = CGSizeMake(JX_SCREEN_WIDTH, JX_SCREEN_WIDTH);
  195. imageVC.iv = [[JXImageView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_WIDTH)];
  196. imageVC.iv.center = imageVC.view.center;
  197. [g_server getHeadImageLarge:self.user.userId userName:self.user.userNickname imageView:imageVC.iv];
  198. [self addTransition:imageVC];
  199. [self presentViewController:imageVC animated:YES completion:^{
  200. }];
  201. }
  202. //添加VC转场动画
  203. - (void) addTransition:(JXImageScrollVC *) siv
  204. {
  205. _scaleTransition = [[DMScaleTransition alloc]init];
  206. [siv setTransitioningDelegate:_scaleTransition];
  207. }
  208. -(void)dealloc{
  209. NSLog(@"JXUserInfoVC.dealloc");
  210. [g_notify removeObserver:self name:kXMPPSendTimeOutNotifaction object:nil];
  211. [g_notify removeObserver:self name:kXMPPReceiptNotifaction object:nil];
  212. [g_notify removeObserver:self];
  213. self.user = nil;
  214. // [super dealloc];
  215. }
  216. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  217. if([aDownload.action isEqualToString:act_AttentionAdd]){//加好友
  218. int n = [[dict objectForKey:@"type"] intValue];
  219. if( n==2 || n==4)
  220. _friendStatus = friend_status_friend;//成为好友,一般是无需验证
  221. // else
  222. // _friendStatus = friend_status_see;//单向关注
  223. if ([self.user.userType intValue] == 2) {
  224. _user.status = [NSNumber numberWithInt:2];
  225. if([_user haveTheUser])
  226. [_user insert];
  227. else
  228. [_user update];
  229. //[self actionQuit];
  230. [g_notify postNotificationName:kActionRelayQuitVC object:nil];
  231. [self.user doSendMsg:XMPP_TYPE_FRIEND content:nil];
  232. [self showAddFriend];
  233. JXChatViewController *chatVC=[JXChatViewController alloc];
  234. chatVC.title = _user.userNickname;
  235. chatVC.chatPerson = self.user;
  236. chatVC = [chatVC init];
  237. [g_navigation pushViewController:chatVC animated:YES];
  238. }else {
  239. if(_friendStatus == friend_status_friend){
  240. // [_wait stop];
  241. [self doMakeFriend];
  242. }
  243. else
  244. [self doSayHello];
  245. }
  246. }
  247. if ([aDownload.action isEqualToString:act_FriendDel]) {//删除好友
  248. [self.user doSendMsg:XMPP_TYPE_DELALL content:nil];
  249. }
  250. if([aDownload.action isEqualToString:act_BlacklistAdd]){//拉黑
  251. [self.user doSendMsg:XMPP_TYPE_BLACK content:nil];
  252. }
  253. if([aDownload.action isEqualToString:act_FriendRemark]){
  254. //[_wait stop];
  255. JXUserObject* user1 = [[JXUserObject sharedInstance] getUserById:_user.userId];
  256. // user1.userNickname = user.remarkName;
  257. //user1.remarkName = user.remarkName;
  258. //user1.describe = user.describe;
  259. // 修改备注后实时刷新
  260. [g_notify postNotificationName:kFriendRemark object:user1];
  261. [g_server showMsg:Localized(@"JXAlert_SetOK")];
  262. }
  263. if([aDownload.action isEqualToString:act_BlacklistDel]){
  264. [self.user doSendMsg:XMPP_TYPE_NOBLACK content:nil];
  265. }
  266. if([aDownload.action isEqualToString:act_AttentionDel]){
  267. [_user doSendMsg:XMPP_TYPE_DELSEE content:nil];
  268. }
  269. if([aDownload.action isEqualToString:act_Report]){
  270. [g_server showMsg:Localized(@"JXUserInfoVC_ReportSuccess")];
  271. }
  272. if([aDownload.action isEqualToString:act_friendsUpdateOfflineNoPushMsg]){
  273. [g_server showMsg:Localized(@"JXAlert_SetOK")];
  274. }
  275. if([aDownload.action isEqualToString:act_filterUserCircle]){
  276. }
  277. if( [aDownload.action isEqualToString:act_UserGet] ){
  278. JXUserObject* user = [[JXUserObject alloc]init];
  279. [user getDataFromDict:dict];
  280. [user insertFriend];
  281. [user updateUserNickname];
  282. [user updateRemarkName];
  283. [user updateTelephone];
  284. // 更新等级气泡
  285. [g_server getbubbleFontByUserId:user.userId ToView:self];
  286. if ([user.userType intValue] != 2) {
  287. // [self createViews];
  288. }
  289. if (self.user && ![self.user.userNickname isEqualToString:user.userNickname]) {
  290. [g_notify postNotificationName:kFriendListRefresh object:nil];
  291. }
  292. [self setUserInfo:user];
  293. if ([user.userType intValue] == 2) {
  294. [self setupServers];
  295. // [self setServerDetail];
  296. }
  297. if (self.chatVC) {
  298. [self.chatVC.tableView reloadData];
  299. }
  300. }
  301. if([aDownload.action isEqualToString:act_getbubbleFontByUserId]){
  302. // 保存到数据库
  303. JLBubbleManager *manager = [JLBubbleManager sharedManager];
  304. FMDatabase* db = [manager openResouceDb];
  305. BOOL result = [manager checkBubbleFontTableCreatedInDb:db];
  306. if (result) {
  307. // self.id, self.iosLeftUrl, self.iosRightUrl, self.name, self.code, self.color
  308. for (NSDictionary *tempDict in array1) {
  309. JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:tempDict];
  310. manager.id = model.id;
  311. manager.iosLeftUrl = model.bubble.iosLeftUrl;
  312. manager.iosRightUrl = model.bubble.iosRightUrl;
  313. manager.name = model.bubble.name;
  314. manager.code = [NSString stringWithFormat:@"%d", model.font.code];
  315. manager.color = model.font.color;
  316. [manager insertBubbleFontTable];
  317. }
  318. }
  319. }
  320. }
  321. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  322. return show_error;
  323. }
  324. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  325. return show_error;
  326. }
  327. -(void) didServerConnectStart:(JXConnection*)aDownload{
  328. if( [aDownload.action isEqualToString:act_UserGet] ){
  329. return;
  330. }
  331. }
  332. - (BOOL)textFieldShouldReturn:(UITextField *)textField
  333. {
  334. [self.view endEditing:YES];
  335. return YES;
  336. }
  337. -(void)actionAddFriend:(UIView*)sender{
  338. // 验证XMPP是否在线
  339. if(g_xmpp.isLogined != 1){
  340. [g_xmpp showXmppOfflineAlert];
  341. return;
  342. }
  343. if([_user.isBeenBlack boolValue]){
  344. [g_server showMsg:Localized(@"TO_BLACKLIST")];
  345. return;
  346. }
  347. switch (_friendStatus) {
  348. case friend_status_black:{
  349. // [g_server addAttention:user.userId toView:self];
  350. [self onDelBlack];
  351. // [self viewDisMissAction];
  352. }
  353. break;
  354. case friend_status_none:
  355. case friend_status_see:
  356. [g_server addAttention:_user.userId fromAddType:self.fromAddType toView:self];
  357. break;
  358. // case friend_status_see:
  359. // [self doSayHello];
  360. // break;
  361. case friend_status_friend:{//发消息
  362. if([_user haveTheUser])
  363. [_user insert];
  364. else
  365. [_user update];
  366. // [self actionQuit];
  367. [g_notify postNotificationName:kActionRelayQuitVC object:nil];
  368. JXChatViewController *chatVC=[JXChatViewController alloc];
  369. chatVC.title = _user.userNickname;
  370. chatVC.chatPerson = self.user;
  371. chatVC = [chatVC init];
  372. // [g_App.window addSubview:chatVC.view];
  373. [g_navigation pushViewController:chatVC animated:YES];
  374. }
  375. break;
  376. }
  377. }
  378. -(void)doSayHello{//打招呼
  379. //_xmppMsgId = [self.user doSendMsg:XMPP_TYPE_SAYHELLO content:Localized(@"JXUserInfoVC_Hello")];
  380. }
  381. -(void)onSendTimeout:(NSNotification *)notifacation//超时未收到回执
  382. {
  383. // NSLog(@"onSendTimeout");
  384. // [g_App showAlert:Localized(@"JXAlert_SendFilad")];
  385. [JXMyTools showTipView:Localized(@"JXAlert_SendFilad")];
  386. }
  387. -(void)newReceipt:(NSNotification *)notifacation{//新回执
  388. // NSLog(@"newReceipt");
  389. JXMessageObject *msg = (JXMessageObject *)notifacation.object;
  390. if(msg == nil)
  391. return;
  392. if(![msg isAddFriendMsg])
  393. return;
  394. if(![msg.toUserId isEqualToString:self.user.userId])
  395. return;
  396. if([msg.type intValue] == XMPP_TYPE_SAYHELLO){//打招呼
  397. [g_server showMsg:Localized(@"JXAlert_SayHiOK")];
  398. }
  399. if([msg.type intValue] == XMPP_TYPE_BLACK){//拉黑
  400. _user.status = [NSNumber numberWithInt:friend_status_black];
  401. _friendStatus = [_user.status intValue];
  402. [[JXXMPP sharedInstance].blackList addObject:_user.userId];
  403. [_user update];
  404. [self showAddFriend];
  405. [g_server showMsg:Localized(@"JXAlert_AddBlackList")];
  406. [g_notify postNotificationName:kXMPPNewFriendNotifaction object:nil];
  407. // [JXMessageObject msgWithFriendStatus:user.userId status:_friendStatus];
  408. // [user notifyDelFriend];
  409. }
  410. if([msg.type intValue] == XMPP_TYPE_DELSEE){//删除关注,弃用
  411. _friendStatus = friend_status_none;
  412. [self showAddFriend];
  413. [JXMessageObject msgWithFriendStatus:_user.userId status:_friendStatus];
  414. [g_server showMsg:Localized(@"JXAlert_CencalFollow")];
  415. }
  416. if([msg.type intValue] == XMPP_TYPE_DELALL){//删除好友
  417. _friendStatus = friend_status_none;
  418. [self showAddFriend];
  419. [g_notify postNotificationName:kXMPPNewFriendNotifaction object:nil];
  420. if ([self.user.userType intValue] == 2) {
  421. [g_server showMsg:@"已取消关注"];
  422. _user.status = [NSNumber numberWithInt:1];
  423. [_user update];
  424. }else {
  425. [g_server showMsg:Localized(@"JXAlert_DeleteFirend")];
  426. }
  427. }
  428. if([msg.type intValue] == XMPP_TYPE_NOBLACK){//取消拉黑
  429. _user.status = [NSNumber numberWithInt:friend_status_friend];
  430. [_user updateStatus];
  431. _friendStatus = friend_status_friend;
  432. [self showAddFriend];
  433. if ([[JXXMPP sharedInstance].blackList containsObject:_user.userId]) {
  434. [[JXXMPP sharedInstance].blackList removeObject:_user.userId];
  435. [JXMessageObject msgWithFriendStatus:_user.userId status:friend_status_friend];
  436. }
  437. [g_server showMsg:Localized(@"JXAlert_MoveBlackList")];
  438. [g_notify postNotificationName:kXMPPNewFriendNotifaction object:nil];
  439. }
  440. if([msg.type intValue] == XMPP_TYPE_FRIEND){//无验证加好友
  441. if ([g_myself.telephone rangeOfString:@"18938880001"].location == NSNotFound) {
  442. [g_server showMsg:Localized(@"JX_AddSuccess")];
  443. }
  444. _user.status = [NSNumber numberWithInt:2];
  445. [g_notify postNotificationName:kXMPPNewFriendNotifaction object:nil];
  446. }
  447. }
  448. -(void)showAddFriend{
  449. }
  450. -(void)specialCareClick{
  451. CYSpecialCareViewController *vc = [[CYSpecialCareViewController alloc] init];
  452. vc.user = self.user;
  453. vc.userId = self.userId;
  454. [g_navigation pushViewController:vc animated:YES];
  455. }
  456. -(void)onMyBlog{
  457. userWeiboVC* vc = [userWeiboVC alloc];
  458. vc.user = _user;
  459. vc.isGotoBack = YES;
  460. vc = [vc init];
  461. // [g_window addSubview:vc.view];
  462. [g_navigation pushViewController:vc animated:YES];
  463. }
  464. /**
  465. * 地图
  466. */
  467. -(void)actionMap{
  468. if (_longitude <=0 && _latitude <= 0) {
  469. [g_server showMsg:Localized(@"JX_NotShareLocation")];
  470. return;
  471. }
  472. JXMapData * mapData = [[JXMapData alloc] init];
  473. mapData.latitude = [NSString stringWithFormat:@"%f",_latitude];
  474. mapData.longitude = [NSString stringWithFormat:@"%f",_longitude];
  475. NSArray * locations = @[mapData];
  476. if (g_config.isChina) {
  477. JXLocationVC * vc = [JXLocationVC alloc];
  478. vc.locations = [NSMutableArray arrayWithArray:locations];
  479. vc.locationType = JXLocationTypeShowStaticLocation;
  480. vc = [vc init];
  481. [g_navigation pushViewController:vc animated:YES];
  482. }else {
  483. _gooMap = [JXGoogleMapVC alloc];
  484. _gooMap.locations = [NSMutableArray arrayWithArray:locations];
  485. _gooMap.locationType = JXGooLocationTypeShowStaticLocation;
  486. _gooMap = [_gooMap init];
  487. [g_navigation pushViewController:_gooMap animated:YES];
  488. }
  489. // JXLocationVC* vc = [JXLocationVC alloc];
  490. // vc.isSend = NO;
  491. // vc.locationType = JXLocationTypeShowStaticLocation;
  492. // NSMutableArray * locationsArray = [[NSMutableArray alloc]init];
  493. //
  494. // JXMapData* p = [[JXMapData alloc]init];
  495. // p.latitude = [NSString stringWithFormat:@"%f",_latitude];
  496. // p.longitude = [NSString stringWithFormat:@"%f",_longitude];
  497. // p.title = _name.text;
  498. // p.subtitle = _city.text;
  499. // [locationsArray addObject:p];
  500. // vc.locations = locationsArray;
  501. //
  502. // vc = [vc init];
  503. //// [g_window addSubview:vc.view];
  504. // [g_navigation pushViewController:vc animated:YES];
  505. }
  506. -(void)reportUserView{
  507. JXReportUserVC * reportVC = [[JXReportUserVC alloc] init];
  508. reportVC.user = _user;
  509. reportVC.delegate = self;
  510. // [g_window addSubview:reportVC.view];
  511. [g_navigation pushViewController:reportVC animated:YES];
  512. }
  513. - (void)report:(JXUserObject *)reportUser reasonId:(NSNumber *)reasonId {
  514. [g_server reportUser:reportUser.userId roomId:nil webUrl:nil reasonId:reasonId toView:self];
  515. }
  516. - (void)onMore{
  517. int n = _friendStatus;
  518. //标题数组
  519. [_titleArr removeAllObjects];
  520. [_titleArr addObject:Localized(@"JXUserInfoVC_Report")];
  521. if ([self.user.userType intValue] != 2) {
  522. //[_titleArr addObject:Localized(@"JX_SetNotesAndDescriptions")];
  523. [_titleArr addObject:@"设置备注和名称"];//Localized(@"JX_SetNotesAndDescriptions")];
  524. if(n == friend_status_friend){
  525. if(n == friend_status_black)
  526. [_titleArr addObject:Localized(@"JXUserInfoVC_CancelBlackList")];
  527. else if(![_user.isBeenBlack boolValue]) {
  528. [_titleArr addObject:Localized(@"JXUserInfoVC_AddBlackList")];
  529. }
  530. if(![_user.isBeenBlack boolValue]){
  531. if(n == friend_status_friend)
  532. [_titleArr addObject:Localized(@"JXUserInfoVC_DeleteFirend")];
  533. else
  534. [_titleArr addObject:Localized(@"JX_AddFriend")];
  535. }
  536. }
  537. }
  538. //自定义View
  539. _selectView = [[JX_SelectMenuView alloc] initWithTitle:_titleArr image:@[] cellHeight:CellHeight];
  540. _selectView.alpha = 0.0;
  541. _selectView.delegate = self;
  542. [self.view addSubview:_selectView];
  543. // [_selectView release];
  544. //动画
  545. [UIView animateWithDuration:0.3 animations:^{
  546. _selectView.alpha = 1;
  547. }];
  548. }
  549. - (void)didMenuView:(JX_SelectMenuView *)MenuView WithIndex:(NSInteger)index {
  550. long n = _friendStatus;//好友状态
  551. // if(n>[_titleArr count]-1)
  552. // return;
  553. switch (index) {
  554. case 0:
  555. [self reportUserView];
  556. [self viewDisMissAction];
  557. break;
  558. case 1:
  559. [self onRemark];
  560. [self viewDisMissAction];
  561. break;
  562. case 2:
  563. if(n == friend_status_black){
  564. [self onDelBlack];
  565. [self viewDisMissAction];
  566. }else{
  567. [self onAddBlack];
  568. [self viewDisMissAction];
  569. }
  570. break;
  571. case 3:
  572. if(n == friend_status_see || n == friend_status_friend){
  573. // [self onCancelSee];
  574. // [self viewDisMissAction];
  575. [self onDeleteFriend];
  576. [self viewDisMissAction];
  577. }else{
  578. [self actionAddFriend:nil];
  579. [self viewDisMissAction];
  580. }
  581. break;
  582. default:
  583. [self viewDisMissAction];
  584. break;
  585. }
  586. }
  587. - (void)viewDisMissAction{
  588. [UIView animateWithDuration:0.4 animations:^{
  589. _bgBlackAlpha.alpha = 0.0;
  590. } completion:^(BOOL finished) {
  591. [_selectView removeFromSuperview];
  592. _selectView = nil;
  593. [_bgBlackAlpha removeFromSuperview];
  594. }];
  595. }
  596. #pragma mark ---------------创建设置好友备注页面----------------
  597. -(void)onRemark{
  598. // JXInputValueVC* vc = [JXInputValueVC alloc];
  599. // vc.value = user.remarkName;
  600. // vc.title = Localized(@"JXUserInfoVC_SetName");
  601. // vc.delegate = self;
  602. // vc.isLimit = YES;
  603. // vc.didSelect = @selector(onSaveNickName:);
  604. // vc = [vc init];
  605. //// [g_window addSubview:vc.view];
  606. // [g_navigation pushViewController:vc animated:YES];
  607. JXSetNoteAndLabelVC *vc = [[JXSetNoteAndLabelVC alloc] init];
  608. vc.title = @"设置备注和名称";// Localized(@"JX_SetNotesAndLabels");
  609. vc.delegate = self;
  610. vc.didSelect = @selector(refreshLabel:);
  611. vc.user = self.user;
  612. [g_navigation pushViewController:vc animated:YES];
  613. }
  614. - (void)refreshLabel:(JXUserObject *)user {
  615. self.user.remarkName = user.remarkName;
  616. self.user.describe = user.describe;
  617. // CGSize sizeN = [user.remarkName sizeWithAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16]}];
  618. // _remarkName.frame = CGRectMake(_remarkName.frame.origin.x, _remarkName.frame.origin.y, sizeN.width, _remarkName.frame.size.height);
  619. // _sex.frame = CGRectMake(CGRectGetMaxX(_remarkName.frame)+3, _sex.frame.origin.y, _sex.frame.size.width, _sex.frame.size.height);
  620. //
  621. // _remarkName.text = user.remarkName.length > 0 ? user.remarkName : user.userNickname;
  622. [g_server setFriendName:self.user.userId noteName:user.remarkName describe:user.describe toView:self];
  623. }
  624. -(void)onSaveNickName:(JXInputValueVC*)vc{
  625. _user.remarkName = vc.value;
  626. [g_server setFriendName:_user.userId noteName:vc.value describe:nil toView:self];
  627. }
  628. -(void)onAddBlack{
  629. [g_server addBlacklist:_user.userId toView:self];
  630. }
  631. -(void)onDelBlack{
  632. [g_server delBlacklist:_user.userId toView:self];
  633. }
  634. -(void)onCancelSee{
  635. [g_server delAttention:_user.userId toView:self];
  636. }
  637. -(void)onDeleteFriend{
  638. // [g_server delAttention:user.userId toView:self];
  639. [g_server delFriend:_user.userId toView:self];
  640. }
  641. -(void)doMakeFriend{
  642. _friendStatus = friend_status_friend;
  643. // user.status = [NSNumber numberWithInt:_friendStatus];
  644. // if([user haveTheUser])
  645. // [user update];
  646. // else
  647. // [user insert];
  648. [self.user doSendMsg:XMPP_TYPE_FRIEND content:nil];
  649. [JXMessageObject msgWithFriendStatus:_user.userId status:_friendStatus];
  650. [self showAddFriend];
  651. }
  652. -(void)showUserQRCode{
  653. JXQRCodeViewController * qrVC = [[JXQRCodeViewController alloc] init];
  654. qrVC.type = QRUserType;
  655. qrVC.userId = _user.userId;
  656. qrVC.account = _user.account;
  657. qrVC.nickName=_user.userNickname;
  658. qrVC.sex = _user.sex;
  659. // [g_window addSubview:qrVC.view];
  660. [g_navigation pushViewController:qrVC animated:YES];
  661. }
  662. - (NSString *)dateTimeDifferenceWithStartTime:(NSNumber *)compareDate {
  663. NSInteger timeInterval = [[NSDate date] timeIntervalSince1970] - [compareDate integerValue];
  664. long temp = 0;
  665. NSString *result;
  666. if (timeInterval < 60) {
  667. result = [NSString stringWithFormat:@"%d%@",(int)timeInterval,Localized(@"SECONDS_AGO")];
  668. }
  669. else if((temp = timeInterval/60) <60){
  670. result = [NSString stringWithFormat:@"%ld%@",temp,Localized(@"MINUTES_AGO")];
  671. }
  672. else if((temp = temp/60) <24){
  673. result = [NSString stringWithFormat:@"%ld%@",temp,Localized(@"JX_HoursAgo")];
  674. }
  675. else if((temp = temp/24) <30){
  676. result = [NSString stringWithFormat:@"%ld%@",temp,Localized(@"JX_DaysAgo")];
  677. }
  678. else if((temp = temp/30) <12){
  679. result = [NSString stringWithFormat:@"%ld%@",temp,Localized(@"JX_MonthAgo")];
  680. }
  681. else{
  682. temp = temp/12;
  683. result = [NSString stringWithFormat:@"%ld%@",temp,Localized(@"JX_YearsAgo")];
  684. }
  685. return result;
  686. }
  687. @end