userInfoVC.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. //
  2. // userInfoVC.m
  3. // sjvodios
  4. //
  5. // Created by on 12-5-29.
  6. // Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "userInfoVC.h"
  9. #import "JXImageView.h"
  10. #import "JXLabel.h"
  11. #import "AppDelegate.h"
  12. #import "JXServer.h"
  13. #import "JXConnection.h"
  14. #import "UIFactory.h"
  15. #import "JXTableView.h"
  16. #import "JXFriendViewController.h"
  17. #import "ImageResize.h"
  18. #import "userWeiboVC.h"
  19. #import "LXActionSheet.h"
  20. #import "webpageVC.h"
  21. @implementation userInfoVC
  22. @synthesize user,userId;
  23. - (id)init
  24. {
  25. self = [super init];
  26. if (self) {
  27. self.title = Localized(@"UserInfoVC_UserInfo");
  28. self.heightHeader = JX_SCREEN_TOP;
  29. self.heightFooter = 0;
  30. //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  31. self.isGotoBack = YES;
  32. [self createHeadAndFoot];
  33. self.tableBody.backgroundColor = HEXCOLOR(0xf0eff4);
  34. if(self.user)
  35. [self show];
  36. else
  37. [g_server getUser:userId toView:self];
  38. }
  39. return self;
  40. }
  41. -(void)dealloc{
  42. // NSLog(@"userInfoVC.dealloc");
  43. // [_image release];
  44. self.user = nil;
  45. self.userId = nil;
  46. // [super dealloc];
  47. }
  48. - (void)didReceiveMemoryWarning
  49. {
  50. // Releases the view if it doesn't have a superview.
  51. [super didReceiveMemoryWarning];
  52. // Release any cached data, images, etc that aren't in use.
  53. }
  54. - (void)viewWillAppear:(BOOL)animated
  55. {
  56. [super viewWillAppear:animated];
  57. }
  58. - (void)viewDidAppear:(BOOL)animated
  59. {
  60. [super viewDidAppear:animated];
  61. }
  62. - (void)viewDidUnload
  63. {
  64. [super viewDidUnload];
  65. // Release any retained subviews of the main view.
  66. // e.g. self.myOutlet = nil;
  67. }
  68. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  69. {
  70. // Return YES for supported orientations
  71. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  72. }
  73. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  74. [_wait hide];
  75. if( [aDownload.action isEqualToString:act_UploadHeadImage] ){
  76. _head.image = _image;
  77. // [_image release];
  78. _image = nil;
  79. }
  80. if( [aDownload.action isEqualToString:act_UserGet] ){
  81. user = [[JXUserObject alloc]init];
  82. [user getDataFromDict:dict];
  83. [self show];
  84. }
  85. }
  86. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  87. [_wait hide];
  88. return show_error;
  89. }
  90. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  91. [_wait hide];
  92. return show_error;
  93. }
  94. -(void) didServerConnectStart:(JXConnection*)aDownload{
  95. [_wait start];
  96. }
  97. -(void)showOneLine:(NSString*)title value:(NSString*)value y:(int)y height:(int)height{
  98. UIView* v = [[UIView alloc]init];
  99. v.frame = CGRectMake(0, y, JX_SCREEN_WIDTH, height);
  100. v.backgroundColor = [UIColor whiteColor];
  101. [self.tableBody addSubview:v];
  102. // [v release];
  103. UILabel* name = [[UILabel alloc]initWithFrame:CGRectMake(12, 0, 78, height)];
  104. name.font = g_factory.font13b;
  105. name.text = title;
  106. name.textColor = HEXCOLOR(0xa7a7a7);
  107. name.backgroundColor = [UIColor clearColor];
  108. [v addSubview:name];
  109. // [name release];
  110. UILabel* p = [[UILabel alloc]initWithFrame:CGRectMake(90, 0, 200, height)];
  111. p.font = g_factory.font13;
  112. p.text = value;
  113. p.textColor = [UIColor blackColor];
  114. p.backgroundColor = [UIColor clearColor];
  115. p.numberOfLines = 0;
  116. [v addSubview:p];
  117. // [p release];
  118. UIView* line = [[UIView alloc]initWithFrame:CGRectMake(0,height-0.5,JX_SCREEN_WIDTH,0.5)];
  119. line.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
  120. [v addSubview:line];
  121. // [line release];
  122. }
  123. #pragma mark -----------------对用户进行操作------------------
  124. -(void)onMore{
  125. if(g_myself.userId == self.userId){
  126. LXActionSheet* _menu = [[LXActionSheet alloc]
  127. initWithTitle:nil
  128. delegate:self
  129. cancelButtonTitle:Localized(@"JX_Cencal")
  130. destructiveButtonTitle:Localized(@"JXUserInfoVC_SetName")
  131. otherButtonTitles:@[Localized(@"UserInfoVC_SendToFirend"),Localized(@"UserInfoVC_Complaint")]];
  132. [g_window addSubview:_menu];
  133. // [_menu release];
  134. }else{
  135. LXActionSheet* _menu = [[LXActionSheet alloc]
  136. initWithTitle:nil
  137. delegate:self
  138. cancelButtonTitle:Localized(@"JX_Cencal")
  139. destructiveButtonTitle:Localized(@"JXUserInfoVC_SetName")
  140. otherButtonTitles:@[Localized(@"UserInfoVC_SendToFirend"),Localized(@"UserInfoVC_Complaint")]];
  141. [g_window addSubview:_menu];
  142. // [_menu release];
  143. }
  144. }
  145. - (void)didClickOnButtonIndex:(LXActionSheet*)sender buttonIndex:(int)buttonIndex{
  146. if(buttonIndex<0)
  147. return;
  148. switch (buttonIndex) {
  149. case 0:
  150. break;
  151. case 1:
  152. break;
  153. case 2:
  154. break;
  155. case 3:
  156. break;
  157. default:
  158. break;
  159. }
  160. }
  161. -(void)onHeadImage{
  162. userWeiboVC* vc = [userWeiboVC alloc];
  163. vc.user = user;
  164. [vc init];
  165. [g_window addSubview:vc.view];
  166. }
  167. -(void)show{
  168. UIButton* btn;
  169. int h=0;int h1=35;
  170. // int w=JX_SCREEN_WIDTH-9*2;
  171. btn = [UIFactory createButtonWithImage:@"title_more@2x" highlight:nil target:self selector:@selector(onMore)];
  172. btn.frame = CGRectMake(JX_SCREEN_WIDTH-24-8, 20+10, 24, 24);
  173. [self.tableHeader addSubview:btn];
  174. UIView* v = [[UIView alloc]init];
  175. v.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, 90);
  176. [self.tableBody addSubview:v];
  177. // [v release];
  178. h+=v.frame.size.height;
  179. _head = [[JXImageView alloc]initWithFrame:CGRectMake(9, 10, 70, 70)];
  180. _head.layer.cornerRadius = 6;
  181. _head.layer.masksToBounds = YES;
  182. _head.didTouch = @selector(onHeadImage);
  183. _head.delegate = self;
  184. [v addSubview:_head];
  185. // [_head release];
  186. [g_server getHeadImageSmall:user.userId imageView:_head];
  187. UILabel* p = [[UILabel alloc]initWithFrame:CGRectMake(_head.frame.size.width+20, 10, 200, 20)];
  188. p.font = g_factory.font16;
  189. p.text = user.userNickname;
  190. p.backgroundColor = [UIColor clearColor];
  191. [v addSubview:p];
  192. // [p release];
  193. JXImageView* iv = [[JXImageView alloc]initWithFrame:CGRectMake(75+15,60,20,20)];
  194. iv.image = [UIImage imageNamed:@"icon_fans@2x.png"];
  195. iv.userInteractionEnabled = YES;
  196. [v addSubview:iv];
  197. // [iv release];
  198. p = [[JXLabel alloc]initWithFrame:CGRectMake(95+15, 60, 180-97, 20)];
  199. p.textColor = HEXCOLOR(0x36d55c);
  200. p.backgroundColor = [UIColor clearColor];
  201. p.font = g_factory.font12;
  202. p.text = [NSString stringWithFormat:@"%d%@",[user.fansCount intValue],Localized(@"UserInfoVC_Fans")];
  203. [v addSubview:p];
  204. // [p release];
  205. iv = [[JXImageView alloc]initWithFrame:CGRectMake(75+15,35,20,20)];
  206. iv.userInteractionEnabled = YES;
  207. iv.image = [UIImage imageNamed:@"avatar_icon_boy@2x.png"];
  208. [v addSubview:iv];
  209. // [iv release];
  210. p = [[JXLabel alloc]initWithFrame:CGRectMake(95+15, 35, 160, 20)];
  211. p.textColor = HEXCOLOR(0xa7a7a7);
  212. p.backgroundColor = [UIColor clearColor];
  213. p.font = g_factory.font12;
  214. p.text = [NSString stringWithFormat:@"%d%@",[user.level intValue],Localized(@"UserInfoVC_Lever")];
  215. [v addSubview:p];
  216. // [p release];
  217. [self showOneLine:Localized(@"UserInfoVC_BirthDay") value:[TimeUtil formatDate:user.birthday format:@"yyyy-MM"] y:h height:h1];
  218. h+=h1;
  219. [self showOneLine:Localized(@"UserInfoVC_Loation") value:user.location y:h height:h1];
  220. h+=h1;
  221. [self showOneLine:Localized(@"UserInfoVC_CompanyName") value:user.companyName y:h height:h1];
  222. h+=h1;
  223. [self showOneLine:Localized(@"UserInfoVC_Job") value:@"" y:h height:h1];
  224. h+=h1;
  225. [self showOneLine:Localized(@"UserInfoVC_PerSign") value:user.userDescription y:h height:60];
  226. h+=60;
  227. UIButton* _btn;
  228. _btn = [UIFactory createCommonButton:Localized(@"JX_Attion") target:self action:@selector(onSearch)];
  229. _btn.frame = CGRectMake(10, h, 300, 44);
  230. [self.tableBody addSubview:_btn];
  231. self.tableBody.contentSize = CGSizeMake(self_width, h);
  232. if(h>JX_SCREEN_HEIGHT-JX_SCREEN_TOP)
  233. self.tableBody.scrollEnabled = YES;
  234. }
  235. @end