PSMyViewController.m 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  1. //
  2. // myViewController.m
  3. // sjvodios
  4. //
  5. // Created by on 12-5-29.
  6. // Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "PSMyViewController.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 "myMediaVC.h"
  20. #import "webpageVC.h"
  21. #import "loginVC.h"
  22. #import "JXNewFriendViewController.h"
  23. #import "PSRegisterBaseVC.h"
  24. #import "photosViewController.h"
  25. #import "JXSettingVC.h"
  26. #import "PSUpdateUserVC.h"
  27. #import "OrganizTreeViewController.h"
  28. #import "JXCourseListVC.h"
  29. #import "JXMyMoneyViewController.h"
  30. #import "JXNearVC.h"
  31. #import "JXSelFriendVC.h"
  32. #import "JXSelectFriendsVC.h"
  33. #ifdef Meeting_Version
  34. #import "JXAVCallViewController.h"
  35. #endif
  36. #ifdef Live_Version
  37. #import "JXLiveViewController.h"
  38. #endif
  39. #import "JXFriendViewController.h"
  40. #import "JXGroupViewController.h"
  41. #import "UIImage+Color.h"
  42. #import "JXScanQRViewController.h"
  43. #import "JLApplyForWithdrawalViewController.h"
  44. #import "JLMyBonusViewController.h"
  45. #import "UILabel+Size.h"
  46. #import "JLBubbleViewController.h"
  47. #import "JXChatViewController.h"
  48. #import "UIView+LK.h"
  49. #define HEIGHT 55
  50. #define MY_INSET 0 // 每行左右间隙
  51. #define SEVICE_INSET 10 // 服务左右间隙
  52. #define TOP_ADD_HEIGHT 400 // 顶部添加的高度,防止下拉顶部空白
  53. @interface PSMyViewController()
  54. @property (nonatomic,weak) UIView *titlesView;
  55. @property (nonatomic,weak) UIView *indicatorView;
  56. @property (nonatomic,weak) UIButton *button_n;
  57. @property (nonatomic,weak) UIButton *selectedButton;
  58. @property (nonatomic,weak) UILabel *countTipL;
  59. @end
  60. @implementation PSMyViewController
  61. - (void)bubbleFontClick {
  62. JLBubbleViewController *vc = [[JLBubbleViewController alloc] init];
  63. [g_navigation pushViewController:vc animated:YES];
  64. }
  65. - (void)myBossClick {
  66. [g_App showAlert:@"暂未开放!"];
  67. }
  68. - (void)callServiceClick {
  69. JXChatViewController *vc = [[JXChatViewController alloc] init];
  70. JXUserObject *user = [[JXUserObject sharedInstance] getUserById:@"10000"];
  71. vc.chatPerson = user;
  72. [g_navigation pushViewController:vc animated:YES];
  73. }
  74. - (void)myGiftClick {
  75. JLMyBonusViewController *myBonusVC = [[JLMyBonusViewController alloc] init];
  76. [g_navigation pushViewController:myBonusVC animated:YES];
  77. }
  78. - (void)suggestionsClick {
  79. JLApplyForWithdrawalViewController *vc = [[JLApplyForWithdrawalViewController alloc] init];
  80. [g_App.navigation pushViewController:vc animated:YES];
  81. return;
  82. [g_App showAlert:@"暂未开放!"];
  83. }
  84. - (id)init
  85. {
  86. self = [super init];
  87. if (self) {
  88. self.isRefresh = YES;
  89. self.title = Localized(@"JX_My");
  90. self.heightHeader = 0;
  91. self.heightFooter = JX_SCREEN_BOTTOM;
  92. [self createHeadAndFoot];
  93. // self.tableBody.backgroundColor = HEXCOLOR(0xf0eff4);
  94. [g_server getUser:MY_USER_ID toView:self];
  95. int h=-20;
  96. int w=JX_SCREEN_WIDTH;
  97. float marginHei = 10;
  98. int H = 86;
  99. JXImageView* iv;
  100. iv = [self createHeadButtonclick:@selector(onResume)];
  101. _topImageVeiw = iv;
  102. // CGFloat height = THE_DEVICE_HAVE_HEAD ? 55 : 75;
  103. // if (THESIMPLESTYLE) {
  104. // iv.frame = CGRectMake(0, h-TOP_ADD_HEIGHT, w, 266+TOP_ADD_HEIGHT-H+55);
  105. // h+=iv.frame.size.height-TOP_ADD_HEIGHT;
  106. // }else {
  107. // iv.frame = CGRectMake(0, h-TOP_ADD_HEIGHT, w, 266+TOP_ADD_HEIGHT-H);
  108. // h+=iv.frame.size.height-TOP_ADD_HEIGHT+ height;
  109. // }
  110. iv.frame = CGRectMake(0, THE_DEVICE_HAVE_HEAD ? -TOP_ADD_HEIGHT- 44 : -TOP_ADD_HEIGHT-20, w, 173+TOP_ADD_HEIGHT);
  111. h = CGRectGetMaxY(iv.frame);
  112. // 好友
  113. // NSArray *friends = [[JXUserObject sharedInstance] fetchAllUserFromLocal];
  114. // UIButton *button;
  115. // button = [self createViewWithFrame:CGRectMake(0, h, JX_SCREEN_WIDTH/2, H) title:[NSString stringWithFormat:@"%ld",friends.count] icon:@"my_topFriends" index:0 showLine:YES];
  116. //
  117. // // 群组
  118. // NSArray *groups = [[JXUserObject sharedInstance] fetchAllRoomsFromLocal];
  119. // button = [self createViewWithFrame:CGRectMake(CGRectGetMaxX(button.frame), h, JX_SCREEN_WIDTH/2, H) title:[NSString stringWithFormat:@"%ld",groups.count] icon:@"my_groups" index:1 showLine:NO];
  120. // h+=button.frame.size.height+marginHei;
  121. // iv = [self createButton:@"我的名片盒" drawTop:YES drawBottom:YES icon:@"set_card" click:@selector(onFriend)];
  122. // iv.frame = CGRectMake(0,h, w, HEIGHT);
  123. // h+=iv.frame.size.height;
  124. // NSArray * titleArray = [NSArray arrayWithObjects:@"我的资料",@"我的朋友",@"我的空间",@"搜索好友",@"我的附件",nil];
  125. // NSArray * iconArray = [NSArray arrayWithObjects:@"my_friend",@"my_space",@"search_friends",@"my_attachment",@"balance_recharge",@"set_up",nil];
  126. // iv = [self createButton:@"我的资料" drawTop:YES drawBottom:YES icon:@"资料" click:@selector(onResume)];
  127. // iv.frame = CGRectMake(0,h, w, HEIGHT);
  128. // h+=iv.frame.size.height+marginHei;
  129. // iv = [self createButton:Localized(@"PSMyViewController_MyFirend") drawTop:NO drawBottom:YES icon:@"my_friend" click:@selector(onFriend)];
  130. // iv.frame = CGRectMake(0,h, w, HEIGHT);
  131. // h+=iv.frame.size.height;
  132. // iv = [self createButton:@"搜索好友" drawTop:NO drawBottom:YES icon:@"search_friends" click:@selector(onSearch)];
  133. // iv.frame = CGRectMake(0,h, w, HEIGHT);
  134. // h+=iv.frame.size.height;
  135. _setBaseView = [[UIView alloc] initWithFrame:CGRectMake(0, h-20, JX_SCREEN_WIDTH,JX_SCREEN_HEIGHT - h - JX_SCREEN_BOTTOM)];
  136. _setBaseView.backgroundColor = [UIColor whiteColor];
  137. // [self.tableBody addSubview:_setBaseView];
  138. [self setPartRoundWithView:_setBaseView corners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadius:20];
  139. //------------------------------------------------------------------------
  140. _setBaseView2 = [[UIView alloc] initWithFrame:CGRectMake(0, h, JX_SCREEN_WIDTH,JX_SCREEN_HEIGHT - h - JX_SCREEN_BOTTOM+(THE_DEVICE_HAVE_HEAD?68:250))];
  141. self.tableBody.contentSize =_setBaseView2.frame.size;
  142. _setBaseView2.backgroundColor = [UIColor whiteColor];
  143. [self.tableBody addSubview:_setBaseView2];
  144. h =0;
  145. // 会员权限头
  146. iv = [self createButton1:@"会员权限" drawTop:NO drawBottom:NO icon:THESIMPLESTYLE ? @"member_promise" : @"member_promise" click:@selector(onMyBonus)];
  147. iv.frame = CGRectMake(MY_INSET,h, w-MY_INSET*2, HEIGHT);
  148. iv.userInteractionEnabled = NO;
  149. h+=iv.frame.size.height;
  150. // 1:1.27 宽高比
  151. iv = [[JXImageView alloc] initWithFrame:CGRectZero];
  152. iv.image = [UIImage imageNamed:@"member_promise_bubble"];
  153. iv.frame = CGRectMake(SEVICE_INSET,h, 120, 120*1.27);
  154. [_setBaseView2 addSubview:iv];
  155. UITapGestureRecognizer *bubbleFontClick = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(bubbleFontClick)];
  156. [iv addGestureRecognizer:bubbleFontClick];
  157. iv.userInteractionEnabled = YES;
  158. h+=iv.frame.size.height;
  159. // 更多服务头
  160. iv = [self createButton1:@"更多服务" drawTop:NO drawBottom:NO icon:THESIMPLESTYLE ? @"more_service" : @"more_service" click:nil];
  161. iv.frame = CGRectMake(MY_INSET,h, w-MY_INSET*2, HEIGHT);
  162. iv.userInteractionEnabled = NO;
  163. h+=iv.frame.size.height;
  164. // 1:0.5 宽高比
  165. CGFloat more_serviceW = (JX_SCREEN_WIDTH-3*SEVICE_INSET)/2;
  166. CGFloat more_serviceH = more_serviceW * 0.5;
  167. iv = [[JXImageView alloc] initWithFrame:CGRectZero];
  168. iv.image = [UIImage imageNamed:@"my_boss"];
  169. iv.frame = CGRectMake(SEVICE_INSET,h, more_serviceW, more_serviceH);
  170. UITapGestureRecognizer *myBossClick = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myBossClick)];
  171. [iv addGestureRecognizer:myBossClick];
  172. iv.userInteractionEnabled = YES;
  173. [_setBaseView2 addSubview:iv];
  174. // h+=iv.frame.size.height;
  175. iv = [[JXImageView alloc] initWithFrame:CGRectZero];
  176. iv.image = [UIImage imageNamed:@"call_service"];
  177. iv.frame = CGRectMake(more_serviceW + SEVICE_INSET+ SEVICE_INSET,h, more_serviceW, more_serviceH);
  178. UITapGestureRecognizer *callServiceClick = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(callServiceClick)];
  179. [iv addGestureRecognizer:callServiceClick];
  180. iv.userInteractionEnabled = YES;
  181. [_setBaseView2 addSubview:iv];
  182. h+=iv.frame.size.height;
  183. iv = [[JXImageView alloc] initWithFrame:CGRectZero];
  184. iv.image = [UIImage imageNamed:@"my_gift"];
  185. iv.frame = CGRectMake(SEVICE_INSET,h, more_serviceW, more_serviceH);
  186. UITapGestureRecognizer *myGiftClick = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myGiftClick)];
  187. [iv addGestureRecognizer:myGiftClick];
  188. iv.userInteractionEnabled = YES;
  189. [_setBaseView2 addSubview:iv];
  190. iv = [[JXImageView alloc] initWithFrame:CGRectZero];
  191. iv.image = [UIImage imageNamed:@"video_sevice"];
  192. iv.frame = CGRectMake(more_serviceW + SEVICE_INSET+SEVICE_INSET,h, more_serviceW, more_serviceH);
  193. [_setBaseView2 addSubview:iv];
  194. UITapGestureRecognizer *videoSeviceClick = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(callServiceClick)];
  195. [iv addGestureRecognizer:videoSeviceClick];
  196. iv.userInteractionEnabled = YES;
  197. h+=iv.frame.size.height;
  198. iv = [[JXImageView alloc] initWithFrame:CGRectZero];
  199. iv.image = [UIImage imageNamed:@"Suggestions"];
  200. iv.frame = CGRectMake(SEVICE_INSET,h, more_serviceW, more_serviceH);
  201. UITapGestureRecognizer *suggestionsClick = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(suggestionsClick)];
  202. [iv addGestureRecognizer:suggestionsClick];
  203. iv.userInteractionEnabled = YES;
  204. [_setBaseView2 addSubview:iv];
  205. //------------------------------------------------------------------------
  206. h = 13;
  207. if ([g_config.enablePayModule boolValue]) {
  208. iv = [self createButton:Localized(@"JX_MyBalance") drawTop:NO drawBottom:YES icon:THESIMPLESTYLE ? @"balance_recharge_simple" : @"balance_recharge" click:@selector(onRecharge)];
  209. iv.frame = CGRectMake(MY_INSET,h, w-MY_INSET*2, HEIGHT);
  210. h+=iv.frame.size.height;
  211. }
  212. iv = [self createButton:@"我的彩金" drawTop:NO drawBottom:YES icon:THESIMPLESTYLE ? @"balance_recharge_simple" : @"balance_recharge" click:@selector(onMyBonus)];
  213. iv.frame = CGRectMake(MY_INSET,h, w-MY_INSET*2, HEIGHT);
  214. h+=iv.frame.size.height;
  215. iv = [self createButton:Localized(@"JX_MyDynamics") drawTop:NO drawBottom:YES icon:THESIMPLESTYLE ? @"my_space_simple" : @"my_space" click:@selector(onMyBlog)];
  216. iv.frame = CGRectMake(MY_INSET,h, w-MY_INSET*2, HEIGHT);
  217. h+=iv.frame.size.height;
  218. iv = [self createButton:Localized(@"JX_MyCollection") drawTop:NO drawBottom:YES icon:THESIMPLESTYLE ? @"collection_me_simple" : @"collection_me" click:@selector(onMyFavorite)];
  219. iv.frame = CGRectMake(MY_INSET,h, w-MY_INSET*2, HEIGHT);
  220. h+=iv.frame.size.height;
  221. // iv = [self createButton:Localized(@"PSMyViewController_MyAtt") drawTop:NO drawBottom:YES icon:@"my_attachment" click:@selector(onVideo)];
  222. // iv.frame = CGRectMake(0,h, w, HEIGHT);
  223. // h+=iv.frame.size.height;
  224. iv = [self createButton:Localized(@"JX_MyLecture") drawTop:NO drawBottom:YES icon:THESIMPLESTYLE ? @"my_lecture_simple" : @"my_lecture" click:@selector(onCourse)];
  225. iv.frame = CGRectMake(MY_INSET,h, w-MY_INSET*2, HEIGHT);
  226. // h+=iv.frame.size.height + marginHei;
  227. h+=iv.frame.size.height;
  228. if ([g_App.isShowApplyForWithdrawal intValue] == 0) {
  229. iv = [self createButton:@"申请提现" drawTop:NO drawBottom:YES icon:THESIMPLESTYLE ? @"balance_recharge_simple" : @"balance_recharge" click:@selector(onApplyForWithdrawal)];
  230. iv.frame = CGRectMake(MY_INSET,h, w-MY_INSET*2, HEIGHT);
  231. h+=iv.frame.size.height;
  232. }
  233. // 新年活动
  234. if ([g_App.isOpenActivity intValue] == 0) {
  235. iv = [self createButton:g_App.activityName drawTop:NO drawBottom:YES icon:THESIMPLESTYLE ? @"my_space_simple" : @"my_space" click:@selector(onActivity)];
  236. iv.frame = CGRectMake(MY_INSET,h, w-MY_INSET*2, HEIGHT);
  237. h+=iv.frame.size.height;
  238. }
  239. // iv = [self createButton:Localized(@"JXNearVC_NearHere") drawTop:NO drawBottom:YES icon:@"nearby_normal" click:@selector(onNear)];
  240. // iv.frame = CGRectMake(0,h, w, HEIGHT);
  241. // h+=iv.frame.size.height;
  242. //#ifdef Live_Version
  243. // iv = [self createButton:Localized(@"OrganizVC_Organiz") drawTop:NO drawBottom:YES icon:@"my_organizBook" click:@selector(onOrganiz)];
  244. // iv.frame = CGRectMake(0,h, w, HEIGHT);
  245. // h+=iv.frame.size.height;
  246. //#endif
  247. // iv = [self createButton:@"收藏职位" drawTop:NO drawBottom:YES icon:@"set_collect" click:@selector(onMoney)];
  248. // iv.frame = CGRectMake(0,h, w, HEIGHT);
  249. // h+=iv.frame.size.height;
  250. BOOL isShowLine = NO;
  251. #ifdef IS_SHOW_MENU
  252. #else
  253. #ifdef Meeting_Version
  254. isShowLine = YES;
  255. UIView *line1 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(iv.frame), JX_SCREEN_WIDTH, marginHei)];
  256. line1.backgroundColor = HEXCOLOR(0xF2F2F2);
  257. [_setBaseView addSubview:line1];
  258. iv = [self createButton:Localized(@"JXSettingVC_VideoMeeting") drawTop:NO drawBottom:YES icon:THESIMPLESTYLE ? @"videomeeting_simple" : @"videomeeting" click:@selector(onMeeting)];
  259. iv.frame = CGRectMake(0,h, w, HEIGHT);
  260. h+=iv.frame.size.height;
  261. isShowLine = NO;
  262. #else
  263. isShowLine = YES;
  264. #endif
  265. #ifdef Live_Version
  266. if ([g_App.isShowRedPacket intValue] == 1 ) {
  267. if (!isShowLine) {
  268. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(iv.frame), JX_SCREEN_WIDTH, marginHei)];
  269. line.backgroundColor = HEXCOLOR(0xF2F2F2);
  270. [_setBaseView addSubview:line];
  271. }
  272. UIView *line1 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(iv.frame), JX_SCREEN_WIDTH, marginHei)];
  273. line1.backgroundColor = HEXCOLOR(0xF2F2F2);
  274. [_setBaseView addSubview:line1];
  275. iv = [self createButton:Localized(@"JX_LiveDemonstration") drawTop:isShowLine drawBottom:NO icon:THESIMPLESTYLE ? @"videoshow_simple" : @"videoshow" click:@selector(onLive)];
  276. iv.frame = CGRectMake(0,h, w, HEIGHT);
  277. h+=iv.frame.size.height + marginHei;
  278. }
  279. isShowLine = YES;
  280. #else
  281. isShowLine = NO;
  282. #endif
  283. #endif
  284. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(iv.frame), JX_SCREEN_WIDTH, marginHei)];
  285. line.backgroundColor = HEXCOLOR(0xF2F2F2);
  286. [_setBaseView addSubview:line];
  287. iv = [self createButton:Localized(@"JXSettingVC_Set") drawTop:NO drawBottom:YES icon:THESIMPLESTYLE ? @"set_up_simple" : @"set_up" click:@selector(onSetting)];
  288. iv.frame = CGRectMake(MY_INSET,h, w-MY_INSET*2, HEIGHT);
  289. // h+=iv.frame.size.height;
  290. CGRect frame = _setBaseView.frame;
  291. frame.size.height = CGRectGetMaxY(iv.frame);
  292. _setBaseView.frame = frame;
  293. // if ((h + HEIGHT + 20) > self.tableBody.frame.size.height) {
  294. // self.tableBody.contentSize = CGSizeMake(self_width, CGRectGetMaxY(_setBaseView2.frame) + 20);
  295. // }
  296. // w/h = s_w/S_h
  297. UIImage *topImage = [UIImage imageNamed:@"goucaijiemian"];
  298. CGFloat topImageW = JX_SCREEN_WIDTH;
  299. CGFloat topImageH = JX_SCREEN_WIDTH*topImage.size.height/topImage.size.width;
  300. UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, -topImageH-JX_SCREEN_TOP-JX_STATUSBAR_H, topImageW, topImageH)];
  301. topView.backgroundColor=[UIColor greenColor];
  302. UIImageView *topImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, topImageW, topImageH)];
  303. topImageView.image = topImage;
  304. [topView addSubview:topImageView];
  305. [self.tableBody addSubview:topView];
  306. _topView = topView;
  307. self.tableBody.contentInset = UIEdgeInsetsMake(JX_SCREEN_TOP, 0, 0, 0);
  308. self.tableBody.contentOffset = CGPointMake(0, -JX_SCREEN_TOP-20);
  309. [g_notify addObserver:self selector:@selector(doRefresh:) name:kUpdateUserNotifaction object:nil];
  310. [g_notify addObserver:self selector:@selector(updateUserInfo:) name:kXMPPMessageUpadteUserInfoNotification object:nil];
  311. [g_notify addObserver:self selector:@selector(doRefresh:) name:kOfflineOperationUpdateUserSet object:nil];
  312. }
  313. return self;
  314. }
  315. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  316. NSLog(@"contentOffset.y = %f contentInset.top = %f", scrollView.contentOffset.y,scrollView.contentInset.top);
  317. CGFloat offsetY = scrollView.contentOffset.y;
  318. if(offsetY < 230 * -1) {
  319. self.tableBody.contentInset = UIEdgeInsetsMake(_topView.frame.size.height+JX_SCREEN_TOP, 0, 0, 0);
  320. }else {
  321. self.tableBody.contentInset = UIEdgeInsetsMake(JX_SCREEN_TOP+20, 0, 0, 0);
  322. }
  323. }
  324. - (void)updateUserInfo:(NSNotification *)noti {
  325. [g_server getUser:g_server.myself.userId toView:self];
  326. long time = (long)[[NSDate date] timeIntervalSince1970];
  327. time = (time *1000 + g_server.timeDifference);
  328. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  329. [g_server getUserVipInformation:salt andToView:self];
  330. }
  331. -(void)dealloc{
  332. NSLog(@"PSMyViewController.dealloc");
  333. [g_notify removeObserver:self name:kUpdateUserNotifaction object:nil];
  334. [g_notify removeObserver:self name:kXMPPMessageUpadteUserInfoNotification object:nil];
  335. [g_notify removeObserver:self name:kOfflineOperationUpdateUserSet object:nil];
  336. // [_image release];
  337. // [super dealloc];
  338. }
  339. - (void)didReceiveMemoryWarning
  340. {
  341. // Releases the view if it doesn't have a superview.
  342. [super didReceiveMemoryWarning];
  343. // Release any cached data, images, etc that aren't in use.
  344. }
  345. //设置状态栏颜色
  346. - (void)setStatusBarBackgroundColor:(UIColor *)color {
  347. UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
  348. if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
  349. statusBar.backgroundColor = color;
  350. }
  351. }
  352. - (void)viewDidLoad {
  353. [super viewDidLoad];
  354. }
  355. - (void)viewWillAppear:(BOOL)animated {
  356. [super viewWillAppear:animated];
  357. [self.navigationController setNavigationBarHidden:YES animated:NO];
  358. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  359. if (_friendLabel) {
  360. NSArray *friends = [[JXUserObject sharedInstance] fetchAllUserFromLocal];
  361. _friendLabel.text = [NSString stringWithFormat:@"%ld",friends.count];
  362. }
  363. if (_groupLabel) {
  364. NSArray *groups = [[JXUserObject sharedInstance] fetchAllRoomsFromLocal];
  365. _groupLabel.text = [NSString stringWithFormat:@"%ld",groups.count];
  366. }
  367. }
  368. - (void)viewWillDisappear:(BOOL)animated {
  369. [super viewWillDisappear:animated];
  370. [self.navigationController setNavigationBarHidden:NO animated:NO];
  371. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  372. }
  373. - (void)viewDidAppear:(BOOL)animated
  374. {
  375. if (self.isRefresh) {
  376. self.isRefresh = NO;
  377. }else{
  378. [super viewDidAppear:animated];
  379. [self doRefresh:nil];
  380. }
  381. }
  382. -(void)doRefresh:(NSNotification *)notifacation{
  383. _head.image = nil;
  384. [g_server getHeadImageSmall:g_server.myself.userId userName:g_server.myself.userNickname imageView:_head];
  385. //获取用户余额
  386. [g_server getUserMoenyToView:self];
  387. [g_server getUser:MY_USER_ID toView:self];
  388. long time = (long)[[NSDate date] timeIntervalSince1970];
  389. time = (time *1000 + g_server.timeDifference);
  390. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  391. [g_server getUserVipInformation:salt andToView:self];
  392. _userName.text = g_server.myself.userNickname;
  393. [_userName sizeToFit];
  394. _genderImgV.frame = CGRectMake(CGRectGetMaxX(_userName.frame)+5, CGRectGetMinY(_userName.frame)+5, 13, 13);
  395. _prettyNumberImgV.frame = CGRectMake(CGRectGetMaxX(_genderImgV.frame)+5, CGRectGetMinY(_genderImgV.frame), 13, 13);
  396. }
  397. //-(void)refreshUserDetail{
  398. // _moneyLabel.text = [NSString stringWithFormat:@"%.2f%@",g_App.myMoney,Localized(@"JX_ChinaMoney")];
  399. //}
  400. - (void)viewDidUnload
  401. {
  402. [super viewDidUnload];
  403. // Release any retained subviews of the main view.
  404. // e.g. self.myOutlet = nil;
  405. }
  406. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  407. {
  408. // Return YES for supported orientations
  409. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  410. }
  411. //服务端返回数据
  412. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  413. [_wait hide];
  414. if([aDownload.action isEqualToString:act_GetUserVipInformation]){
  415. NSDictionary * currentDictionary = [dict objectForKey:@"current"];
  416. NSString * currentLevel = [NSString stringWithFormat:@"%@",[currentDictionary objectForKey:@"name"]];
  417. if(currentLevel.length != 0 && currentLevel != nil && ![currentLevel isEqualToString:@"<null>"] && ![currentLevel isEqualToString:@"(null)"])
  418. {
  419. NSString * currentLevelGradeName = [NSString stringWithFormat:@"%@",[currentDictionary objectForKey:@"gradeName"]];
  420. _grade.text = [NSString stringWithFormat:@"会员等级: %@", currentLevelGradeName];
  421. [_grade sizeToFit];
  422. NSDictionary * nextLevelDictionary = [dict objectForKey:@"next"];
  423. NSString *nextLevelName = [nextLevelDictionary objectForKey:@"name"];
  424. NSString *upgradeCoin = [nextLevelDictionary objectForKey:@"upgradeCoin"];
  425. NSString *nextLevelMoney = [nextLevelDictionary objectForKey:@"money"];
  426. NSString *currentLevelMoney = [currentDictionary objectForKey:@"money"];
  427. NSString *totalRecharge = [dict objectForKey:@"totalRecharge"];
  428. long needMoney = nextLevelMoney.longLongValue - totalRecharge.longLongValue;
  429. if (nextLevelDictionary == nil) {
  430. _tips.hidden = YES;
  431. }else {
  432. _tips.hidden = NO;
  433. _tips.text = [NSString stringWithFormat:@"距离下次升级(%@)还需%ld可领取%@彩金", nextLevelName,needMoney,upgradeCoin];
  434. [_tips sizeToFit];
  435. }
  436. _payAmount.text = [NSString stringWithFormat:@"当前充值金额: %@", totalRecharge];
  437. [_payAmount sizeToFit];
  438. CGFloat progress = totalRecharge.doubleValue/nextLevelMoney.doubleValue ;
  439. _progressUP.frame = CGRectMake(CGRectGetMinX(_head.frame), CGRectGetMaxY(_payAmount.frame)+5, CGRectGetWidth(_progress.frame)*progress, 8);
  440. }
  441. }
  442. if( [aDownload.action isEqualToString:act_getUserMoeny] ){
  443. NSString *balance = dict[@"balance"];
  444. _jixinCoin.text = [NSString stringWithFormat:@"即信币: %@", balance];
  445. //即信币Label
  446. NSString *bString = [NSString stringWithFormat:@"即信币: %@", balance];
  447. CGFloat width = [UILabel getWidthWithTitle:bString font:[UIFont systemFontOfSize:14]];
  448. CGFloat height = [UILabel getHeightByWidth:width title:bString font:[UIFont systemFontOfSize:14]];
  449. _jixinCoin.frame = CGRectMake(CGRectGetMaxX(_cardView.frame)-width-5, CGRectGetMinY(_userDesc.frame), width, height);
  450. [_jixinCoin sizeToFit];
  451. _jixinCoinImgV.frame = CGRectMake(CGRectGetMinX(_jixinCoin.frame)-18, CGRectGetMidY(_jixinCoin.frame)-7.5, 15, 15);
  452. }
  453. if( [aDownload.action isEqualToString:act_resumeList] ){
  454. }
  455. if( [aDownload.action isEqualToString:act_UserGet] ){
  456. JXUserObject* user = [[JXUserObject alloc]init];
  457. [user getDataFromDict:dict];
  458. g_server.myself.userNickname = user.userNickname;
  459. NSRange range = [user.telephone rangeOfString:@"86"];
  460. // 性别图标
  461. if ([user.sex isEqualToNumber:@0]) {
  462. _genderImgV.image = [UIImage imageNamed:@"my_view_female_icon"];
  463. }else {
  464. _genderImgV.image = [UIImage imageNamed:@"my_view_male_icon"];
  465. }
  466. // 会员账号 membershipAccount
  467. NSString *membershipAccount = dict[@"membershipAccount"];
  468. _userDesc.text = [NSString stringWithFormat:@"即信号: %@",membershipAccount];
  469. // 生日
  470. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  471. [formatter setDateFormat:@"yyyy.MM.dd"];
  472. // stringFromDate 将日期类型格式化,转为NSString 类型
  473. NSString *birthday = [formatter stringFromDate:user.birthday];
  474. _userBirthday.text = [NSString stringWithFormat:@"生日: %@", birthday];
  475. if (range.location != NSNotFound) {
  476. g_server.myself.telephone = [user.telephone substringFromIndex:range.location + range.length];
  477. }
  478. if (self.isGetUser) {
  479. self.isGetUser = NO;
  480. PSUpdateUserVC* vc = [PSUpdateUserVC alloc];
  481. vc.headImage = [_head.image copy];
  482. vc.user = user;
  483. vc = [vc init];
  484. [g_navigation pushViewController:vc animated:YES];
  485. return;
  486. }
  487. _userName.text = user.userNickname;
  488. [g_server delHeadImage:g_server.myself.userId];
  489. [g_server getHeadImageSmall:g_server.myself.userId userName:g_server.myself.userNickname imageView:_head];
  490. }
  491. if ([aDownload.action isEqualToString:act_getUserMoeny]) {
  492. g_App.myMoney = [dict[@"balance"] doubleValue];
  493. _moneyLabel.text = [NSString stringWithFormat:@"%.2f%@",g_App.myMoney,Localized(@"JX_ChinaMoney")];
  494. }
  495. }
  496. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  497. [_wait hide]; return 0;
  498. if( [aDownload.action isEqualToString:act_UserGet] ){
  499. if (!self.isGetUser) {
  500. PSUpdateUserVC* vc = [PSUpdateUserVC alloc];
  501. vc.headImage = [_head.image copy];
  502. vc.user = g_server.myself;
  503. vc = [vc init];
  504. [g_navigation pushViewController:vc animated:YES];
  505. }
  506. }
  507. return hide_error;
  508. }
  509. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  510. [_wait hide]; return 0;
  511. if( [aDownload.action isEqualToString:act_UserGet] ){
  512. if (!self.isGetUser) {
  513. PSUpdateUserVC* vc = [PSUpdateUserVC alloc];
  514. vc.headImage = [_head.image copy];
  515. vc.user = g_server.myself;
  516. vc = [vc init];
  517. [g_navigation pushViewController:vc animated:YES];
  518. }
  519. }
  520. return hide_error;
  521. }
  522. -(void) didServerConnectStart:(JXConnection*)aDownload{
  523. // [_wait start];
  524. }
  525. -(void)actionClear{
  526. [_wait start:Localized(@"PSMyViewController_Clearing") delay:100];
  527. }
  528. #ifdef Live_Version
  529. // 直播
  530. - (void)onLive {
  531. JXLiveViewController *vc = [[JXLiveViewController alloc] init];
  532. [g_navigation pushViewController:vc animated:YES];
  533. }
  534. #endif
  535. #ifdef Meeting_Version
  536. // 视频会议
  537. - (void)onMeeting {
  538. if(g_xmpp.isLogined != 1){
  539. [g_xmpp showXmppOfflineAlert];
  540. return;
  541. }
  542. NSString *str1;
  543. NSString *str2;
  544. str1 = Localized(@"JXSettingVC_VideoMeeting");
  545. str2 = Localized(@"JX_Meeting");
  546. JXActionSheetVC *actionVC = [[JXActionSheetVC alloc] initWithImages:@[@"meeting_tel",@"meeting_video"] names:@[str2,str1]];
  547. actionVC.delegate = self;
  548. [self presentViewController:actionVC animated:NO completion:nil];
  549. }
  550. - (void)actionSheet:(JXActionSheetVC *)actionSheet didButtonWithIndex:(NSInteger)index {
  551. if (index == 0) {
  552. [self onGroupAudioMeeting:nil];
  553. }else if(index == 1){
  554. [self onGroupVideoMeeting:nil];
  555. }
  556. }
  557. -(void)onGroupAudioMeeting:(JXMessageObject*)msg{
  558. self.isAudioMeeting = YES;
  559. [self onInvite];
  560. // [g_meeting startAudioMeeting:no roomJid:s];
  561. }
  562. -(void)onGroupVideoMeeting:(JXMessageObject*)msg{
  563. self.isAudioMeeting = NO;
  564. [self onInvite];
  565. // [g_meeting startVideoMeeting:no roomJid:s];
  566. }
  567. -(void)onInvite{
  568. NSMutableSet* p = [[NSMutableSet alloc]init];
  569. JXSelectFriendsVC* vc = [JXSelectFriendsVC alloc];
  570. vc.isNewRoom = NO;
  571. vc.isShowMySelf = NO;
  572. vc.type = JXSelUserTypeSelFriends;
  573. // vc.room = _room;
  574. vc.existSet = p;
  575. vc.delegate = self;
  576. vc.didSelect = @selector(meetingAddMember:);
  577. vc = [vc init];
  578. // [g_window addSubview:vc.view];
  579. [g_navigation pushViewController:vc animated:YES];
  580. }
  581. -(void)meetingAddMember:(JXSelectFriendsVC*)vc{
  582. int type;
  583. if (self.isAudioMeeting) {
  584. type = kWCMessageTypeAudioMeetingInvite;
  585. }else {
  586. type = kWCMessageTypeVideoMeetingInvite;
  587. }
  588. for(NSNumber* n in vc.set){
  589. JXUserObject *user;
  590. if (vc.seekTextField.text.length > 0) {
  591. user = vc.searchArray[[n intValue] % 100000-1];
  592. }else{
  593. user = [[vc.letterResultArr objectAtIndex:[n intValue] / 100000-1] objectAtIndex:[n intValue] % 100000-1];
  594. }
  595. NSString* s = [NSString stringWithFormat:@"%@",user.userId];
  596. [g_meeting sendMeetingInvite:s toUserName:user.userNickname roomJid:MY_USER_ID callId:nil type:type];
  597. }
  598. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  599. if (g_meeting.isMeeting) {
  600. return;
  601. }
  602. JXAVCallViewController *avVC = [[JXAVCallViewController alloc] init];
  603. avVC.roomNum = MY_USER_ID;
  604. avVC.isAudio = self.isAudioMeeting;
  605. avVC.isGroup = YES;
  606. avVC.toUserName = MY_USER_NAME;
  607. avVC.view.frame = [UIScreen mainScreen].bounds;
  608. [g_window addSubview:avVC.view];
  609. });
  610. }
  611. #endif
  612. - (void)onApplyForWithdrawal {
  613. JLApplyForWithdrawalViewController *vc = [[JLApplyForWithdrawalViewController alloc] init];
  614. [g_App.navigation pushViewController:vc animated:YES];
  615. }
  616. - (void)onActivity {
  617. // 活动
  618. webpageVC * webVC = [webpageVC alloc];
  619. webVC.url = g_App.activityUrl;
  620. webVC.isSend = NO;
  621. webVC = [webVC init];
  622. // [g_navigation.navigationView addSubview:webVC.view];
  623. [g_navigation pushViewController:webVC animated:YES];
  624. }
  625. -(void)onMyBlog{
  626. userWeiboVC* vc = [userWeiboVC alloc];
  627. vc.user = g_myself;
  628. vc.isGotoBack = YES;
  629. vc = [vc init];
  630. // [g_window addSubview:vc.view];
  631. [g_navigation pushViewController:vc animated:YES];
  632. }
  633. -(void)onNear{
  634. JXNearVC * nearVc = [[JXNearVC alloc] init];
  635. // [g_window addSubview:nearVc.view];
  636. [g_navigation pushViewController:nearVc animated:YES];
  637. }
  638. -(void)onFriend{
  639. JXFriendViewController* vc = [[JXFriendViewController alloc]init];
  640. // [g_window addSubview:vc.view];
  641. [g_navigation pushViewController:vc animated:YES];
  642. }
  643. -(void)onResume{
  644. self.isGetUser = YES;
  645. [g_server getUser:MY_USER_ID toView:self];
  646. }
  647. -(void)onSpace{
  648. // mySpaceViewController* vc = [[mySpaceViewController alloc]init];
  649. // [g_window addSubview:vc.view];
  650. }
  651. -(void)onVideo{
  652. myMediaVC* vc = [[myMediaVC alloc] init];
  653. // [g_window addSubview:vc.view];
  654. [g_navigation pushViewController:vc animated:YES];
  655. }
  656. -(void)onMyFavorite{
  657. WeiboViewControlle * collection = [[WeiboViewControlle alloc] initCollection];
  658. // [g_window addSubview:collection.view];
  659. [g_navigation pushViewController:collection animated:YES];
  660. }
  661. - (void)onCourse {
  662. JXCourseListVC *vc = [[JXCourseListVC alloc] init];
  663. // [g_window addSubview:vc.view];
  664. [g_navigation pushViewController:vc animated:YES];
  665. }
  666. -(void)onRecharge{
  667. JXMyMoneyViewController * moneyVC = [[JXMyMoneyViewController alloc] init];
  668. // [g_window addSubview:moneyVC.view];
  669. [g_navigation pushViewController:moneyVC animated:YES];
  670. }
  671. - (void)onMyBonus {
  672. JLMyBonusViewController *myBonusVC = [[JLMyBonusViewController alloc] init];
  673. [g_navigation pushViewController:myBonusVC animated:YES];
  674. }
  675. -(void)onOrganiz{
  676. OrganizTreeViewController * organizVC = [[OrganizTreeViewController alloc] init];
  677. // [g_window addSubview:organizVC.view];
  678. [g_navigation pushViewController:organizVC animated:YES];
  679. }
  680. -(void)onMyLove{
  681. }
  682. -(void)onMoney{
  683. }
  684. -(void)onSetting{
  685. JXSettingVC* vc = [[JXSettingVC alloc]init];
  686. // [g_window addSubview:vc.view];
  687. [g_navigation pushViewController:vc animated:YES];
  688. }
  689. - (void)onAdd {
  690. JX_SelectMenuView *menuView = [[JX_SelectMenuView alloc] initWithTitle:@[Localized(@"JX_SendImage"),Localized(@"JX_SendVoice"),Localized(@"JX_SendVideo"),Localized(@"JX_SendFile")]image:@[@"menu_add_msg",@"menu_add_voice",@"menu_add_video",@"menu_add_file",@"menu_add_reply"]cellHeight:45];
  691. menuView.delegate = self;
  692. [g_App.window addSubview:menuView];
  693. }
  694. - (void)didMenuView:(JX_SelectMenuView *)MenuView WithIndex:(NSInteger)index {
  695. switch (index) {
  696. case 0:
  697. case 1:
  698. case 2:
  699. case 3:{
  700. addMsgVC* vc = [[addMsgVC alloc] init];
  701. vc.dataType = (int)index + 2;
  702. [g_navigation pushViewController:vc animated:YES];
  703. }
  704. break;
  705. default:
  706. break;
  707. }
  708. }
  709. -(JXImageView*)createHeadButtonclick:(SEL)click{
  710. JXImageView* btn = [[JXImageView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 500)];
  711. //btn.backgroundColor = [UIColor gre];
  712. // btn.image = [UIImage imageNamed:@"my_view_head_bg"];
  713. btn.contentMode = UIViewContentModeScaleAspectFit;
  714. btn.userInteractionEnabled = YES;
  715. btn.didTouch = click;
  716. btn.delegate = self;
  717. [self.tableBody addSubview:btn];
  718. self.tableBody.delegate = self;
  719. // UIColor *color;
  720. // if (THESIMPLESTYLE) {
  721. // color = [UIColor whiteColor];
  722. // }else {
  723. // color = THEMECOLOR;
  724. // }
  725. // [self setupView:btn colors:@[(__bridge id)color.CGColor,(__bridge id)[color colorWithAlphaComponent:0.5].CGColor]];
  726. // UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, THE_DEVICE_HAVE_HEAD ? 24+TOP_ADD_HEIGHT : 40+TOP_ADD_HEIGHT, JX_SCREEN_WIDTH, 20)];
  727. // title.text = Localized(@"JX_PersonalCenter");
  728. // title.font = SYSFONT(18);
  729. // title.textColor = [UIColor whiteColor];
  730. // title.textAlignment = NSTextAlignmentCenter;
  731. // [btn addSubview:title];
  732. UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0, TOP_ADD_HEIGHT-JX_SCREEN_TOP, JX_SCREEN_WIDTH, 173+JX_SCREEN_TOP)];
  733. [btn addSubview:baseView];
  734. UIImageView *baseBgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 173+JX_SCREEN_TOP)];
  735. baseBgImageView.image = [UIImage imageNamed:@"my_view_head_bg"];
  736. [baseView addSubview:baseBgImageView];
  737. // 7: 1
  738. UIImageView *pullView = [[UIImageView alloc] initWithFrame:CGRectMake((JX_SCREEN_WIDTH-105)/2, [UIApplication sharedApplication].statusBarFrame.size.height, 105, 15)];
  739. pullView.image = [UIImage imageNamed:@"pull_image"];
  740. [baseView addSubview:pullView];
  741. UIImageView *cardView = [[UIImageView alloc] initWithFrame:CGRectMake(20, [UIApplication sharedApplication].statusBarFrame.size.height+25, JX_SCREEN_WIDTH - 40, 300 -JX_SCREEN_TOP)];
  742. cardView.image = [UIImage imageNamed:@"my_view_head_card_bg"];
  743. _cardView = cardView;
  744. [baseView addSubview:cardView];
  745. baseView.clipsToBounds = YES;
  746. // // 头像阴影
  747. // JXImageView *shadow = [[JXImageView alloc]initWithFrame:CGRectMake(13, (baseView.frame.size.height-84)/2-5, 100, 100)];
  748. // shadow.image = [UIImage imageNamed:@"my_icon_shadow"];
  749. // shadow.didTouch = @selector(onResume);
  750. // shadow.delegate = self;
  751. // [baseView addSubview:shadow];
  752. // UIButton *addBtn = [[UIButton alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15*2-18, THE_DEVICE_HAVE_HEAD ? 59-15 : 35-15, 18+15*2, 18+15*2)];
  753. // [addBtn setImage:[UIImage imageNamed:@"my_add_white"] forState:UIControlStateNormal];
  754. // [addBtn addTarget:self action:@selector(onAdd) forControlEvents:UIControlEventTouchUpInside];
  755. // [baseView addSubview:addBtn];
  756. UIButton *addBtn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(cardView.frame) - (18+15*2)/2, CGRectGetMinY(cardView.frame) - (18+15*2)/2, 18+15*2, 18+15*2)];
  757. [addBtn setImage:[UIImage imageNamed:@"my_view_setting_icon"] forState:UIControlStateNormal];
  758. [addBtn addTarget:self action:@selector(onSetting) forControlEvents:UIControlEventTouchUpInside];
  759. [baseView addSubview:addBtn];
  760. //头像
  761. _head = [[JXImageView alloc]initWithFrame:CGRectMake(CGRectGetMinX(cardView.frame)+10, CGRectGetMinY(cardView.frame)+10, 60, 60)];
  762. _head.layer.cornerRadius = 5;
  763. _head.layer.masksToBounds = YES;
  764. // _head.layer.borderWidth = 3.f;
  765. // _head.layer.borderColor = [UIColor whiteColor].CGColor;
  766. _head.didTouch = @selector(onResume);
  767. _head.delegate = self;
  768. [baseView addSubview:_head];
  769. //名字Label
  770. NSString *aString = g_server.myself.userNickname;
  771. CGSize titleSize = [aString sizeWithFont:SYSFONT(20) constrainedToSize:CGSizeMake(MAXFLOAT, 22)];
  772. UILabel* p = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_head.frame)+10, CGRectGetMinY(_head.frame), titleSize.width, 22)];
  773. p.font = SYSFONT(20);
  774. p.text = MY_USER_NAME;
  775. p.textColor = [UIColor blackColor];
  776. p.backgroundColor = [UIColor clearColor];
  777. [baseView addSubview:p];
  778. _userName = p;
  779. // 性别
  780. UIImageView *genderImgV = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(p.frame)+5, CGRectGetMinY(p.frame)+5, 13, 13)];
  781. genderImgV.image = [UIImage imageNamed:@"my_view_male_icon"];
  782. _genderImgV = genderImgV;
  783. [baseView addSubview:genderImgV];
  784. // 靓号
  785. UIImageView *prettyNumberImgV = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(genderImgV.frame)+5, CGRectGetMinY(genderImgV.frame), 13, 13)];
  786. prettyNumberImgV.image = [UIImage imageNamed:@"my_view_prettyNumber_inactivated"];
  787. _prettyNumberImgV = prettyNumberImgV;
  788. [baseView addSubview:prettyNumberImgV];
  789. //即信号Label
  790. p = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(p.frame), CGRectGetMaxY(p.frame)+12, 150, 14)];
  791. p.font = SYSFONT(14);
  792. // p.text = g_server.myself.telephone;
  793. p.text = [NSString stringWithFormat:@"即信号:"];
  794. p.textColor = [UIColor lightGrayColor];
  795. p.backgroundColor = [UIColor clearColor];
  796. [baseView addSubview:p];
  797. _userDesc = p;
  798. //即信币Label
  799. NSString *bString = @"即信币:";
  800. CGFloat width = [UILabel getWidthWithTitle:bString font:[UIFont systemFontOfSize:14]];
  801. CGFloat height = [UILabel getHeightByWidth:width title:bString font:[UIFont systemFontOfSize:14]];
  802. UILabel* jixinCoin = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(cardView.frame)-width-5, CGRectGetMinY(p.frame), width, height)];
  803. jixinCoin.font = SYSFONT(14);
  804. jixinCoin.text = bString;
  805. jixinCoin.textColor = [UIColor blackColor];
  806. jixinCoin.backgroundColor = [UIColor clearColor];
  807. [jixinCoin sizeToFit];
  808. _jixinCoin = jixinCoin;
  809. [baseView addSubview:jixinCoin];
  810. // 即信币图标
  811. UIImageView *jixinCoinImgV = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMinX(jixinCoin.frame)-18, CGRectGetMidY(jixinCoin.frame)-7.5, 15, 15)];
  812. jixinCoinImgV.image = [UIImage imageNamed:@"jixin_coin"];
  813. _jixinCoinImgV = jixinCoinImgV;
  814. [baseView addSubview:jixinCoinImgV];
  815. // 提现按钮
  816. UIButton *withdrawBtn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(cardView.frame) - 60 -5, CGRectGetMaxY(jixinCoin.frame)+12, 60, height)];
  817. [withdrawBtn setImage:[UIImage imageNamed:@"withDraw"] forState:UIControlStateNormal];
  818. [withdrawBtn setTitle:@"提现" forState:(UIControlStateNormal)];
  819. [withdrawBtn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
  820. [withdrawBtn setFont:[UIFont systemFontOfSize:14]];
  821. withdrawBtn.layer.cornerRadius = height*0.5;
  822. withdrawBtn.clipsToBounds = YES;
  823. withdrawBtn.layer.borderWidth = 0.5;
  824. withdrawBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
  825. withdrawBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
  826. [withdrawBtn addTarget:self action:@selector(onApplyForWithdrawal) forControlEvents:UIControlEventTouchUpInside];
  827. [baseView addSubview:withdrawBtn];
  828. // 充值按钮
  829. UIButton *payBtn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(cardView.frame) - 60 -5, CGRectGetMaxY(withdrawBtn.frame)+12, 60, height)];
  830. [payBtn setImage:[UIImage imageNamed:@"pay"] forState:UIControlStateNormal];
  831. [payBtn setTitle:@"充值" forState:(UIControlStateNormal)];
  832. [payBtn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
  833. [payBtn setFont:[UIFont systemFontOfSize:14]];
  834. payBtn.layer.cornerRadius = height*0.5;
  835. payBtn.clipsToBounds = YES;
  836. payBtn.layer.borderWidth = 0.5;
  837. payBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
  838. payBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
  839. [payBtn addTarget:self action:@selector(onRecharge) forControlEvents:UIControlEventTouchUpInside];
  840. [baseView addSubview:payBtn];
  841. //生日Label
  842. p = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(p.frame), CGRectGetMaxY(p.frame)+12, 150, 14)];
  843. p.font = SYSFONT(14);
  844. // p.text = g_server.myself.telephone;
  845. p.text = [NSString stringWithFormat:@"生日:"];
  846. p.textColor = [UIColor lightGrayColor];
  847. p.backgroundColor = [UIColor clearColor];
  848. _userBirthday = p;
  849. [baseView addSubview:p];
  850. //会员等级Label
  851. p = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(p.frame), CGRectGetMaxY(p.frame)+12, 150, 14)];
  852. p.font = SYSFONT(14);
  853. // p.text = g_server.myself.telephone;
  854. p.text = [NSString stringWithFormat:@"会员等级:"];
  855. p.textColor = [UIColor lightGrayColor];
  856. p.backgroundColor = [UIColor clearColor];
  857. _grade = p;
  858. [baseView addSubview:p];
  859. //当前充值金额Label
  860. p = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(_head.frame), CGRectGetMaxY(p.frame)+12, 150, 14)];
  861. p.font = SYSFONT(12);
  862. // p.text = g_server.myself.telephone;
  863. p.text = [NSString stringWithFormat:@"当前充值金额: "];
  864. p.textColor = THEMECOLOR;
  865. p.backgroundColor = [UIColor clearColor];
  866. [p sizeToFit];
  867. _payAmount = p;
  868. [baseView addSubview:p];
  869. // [self gradentWith:CGRectMake(CGRectGetMinX(p.frame), CGRectGetMaxY(p.frame)+12, 150, 14) view:cardView];
  870. // 进度条背景
  871. UIImageView* progress = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMinX(_head.frame), CGRectGetMaxY(p.frame)+5, CGRectGetWidth(cardView.frame)-20, 8)];
  872. progress.image = [UIImage imageNamed:@"my_view_progress_bg"];
  873. [baseView addSubview:progress];
  874. _progress = progress;
  875. // 进度条
  876. UIImageView* progressUP = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMinX(_head.frame), CGRectGetMaxY(p.frame)+5, CGRectGetWidth(progress.frame)*0, 8)];
  877. progressUP.image = [UIImage imageNamed:@"my_view_progress_fill_bg"];
  878. progressUP.layer.cornerRadius = 4;
  879. progressUP.clipsToBounds = YES;
  880. [baseView addSubview:progressUP];
  881. _progressUP = progressUP;
  882. //距离下次升级Label
  883. p = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(_head.frame), CGRectGetMaxY(progressUP.frame)+5, CGRectGetWidth(progress.frame), 14)];
  884. p.font = SYSFONT(12);
  885. // p.text = g_server.myself.telephone;
  886. p.text = [NSString stringWithFormat:@"距离下次升级"];
  887. p.textColor = THEMECOLOR;
  888. p.backgroundColor = [UIColor clearColor];
  889. [p sizeToFit];
  890. _tips = p;
  891. [baseView addSubview:p];
  892. UIImageView* qrImgV = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-20-35, JX_SCREEN_TOP+65, 13, 13)];
  893. qrImgV.image = [UIImage imageNamed:@"my_qrcode"];
  894. // [baseView addSubview:qrImgV];
  895. UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-6, CGRectGetMinY(qrImgV.frame), 6, 12)];
  896. iv.image = [UIImage imageNamed:@"my_next_white"];
  897. // [baseView addSubview:iv];
  898. return btn;
  899. }
  900. - (void)onPay {
  901. }
  902. - (void)onWithdraw {
  903. }
  904. // 画圆角
  905. - (void)setPartRoundWithView:(UIView *)view corners:(UIRectCorner)corners cornerRadius:(float)cornerRadius {
  906. CAShapeLayer *shapeLayer = [CAShapeLayer layer];
  907. shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)].CGPath;
  908. view.layer.mask = shapeLayer;
  909. }
  910. - (void)onColleagues:(UITapGestureRecognizer *)tap {
  911. // 防止好友、群组同时调用
  912. if (_isSelected)
  913. return;
  914. _isSelected = YES;
  915. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  916. _isSelected = NO;
  917. });
  918. switch (tap.view.tag) {
  919. case 0:{
  920. JXFriendViewController *friendVC = [JXFriendViewController alloc];
  921. friendVC.isMyGoIn = YES;
  922. friendVC = [friendVC init];
  923. [g_navigation pushViewController:friendVC animated:YES];
  924. }
  925. break;
  926. case 1:{
  927. JXGroupViewController *groupVC = [[JXGroupViewController alloc] init];
  928. [g_navigation pushViewController:groupVC animated:YES];
  929. }
  930. break;
  931. default:
  932. break;
  933. }
  934. }
  935. - (UIButton *)createViewWithFrame:(CGRect)frame title:(NSString *)title icon:(NSString *)icon index:(CGFloat)index showLine:(BOOL)isShow{
  936. UIButton *view = [[UIButton alloc] init];
  937. [view setBackgroundImage:[UIImage createImageWithColor:[UIColor whiteColor]] forState:UIControlStateNormal];
  938. [view setBackgroundImage:[UIImage createImageWithColor:HEXCOLOR(0xF6F5FA)] forState:UIControlStateHighlighted];
  939. view.frame = frame;
  940. view.tag = index;
  941. [self.tableBody addSubview:view];
  942. int imgH = 40.5;
  943. UIImageView *imgV = [[UIImageView alloc] init];
  944. imgV.frame = CGRectMake((view.frame.size.width-imgH)/2, (view.frame.size.height-imgH-15-3)/2, imgH, imgH);
  945. imgV.image = [UIImage imageNamed:icon];
  946. [view addSubview:imgV];
  947. UILabel *label = [[UILabel alloc] init];
  948. label.frame = CGRectMake(0, CGRectGetMaxY(imgV.frame)+3, view.frame.size.width, 15);
  949. label.text = title;
  950. label.textAlignment = NSTextAlignmentCenter;
  951. label.font = SYSFONT(15);
  952. label.textColor = HEXCOLOR(0x323232);
  953. [view addSubview:label];
  954. if (index == 0) {
  955. _friendLabel = label;
  956. }else {
  957. _groupLabel = label;
  958. }
  959. if (isShow) {
  960. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(view.frame.size.width-LINE_WH, (view.frame.size.height-24)/2, LINE_WH, 24)];
  961. line.backgroundColor = THE_LINE_COLOR;
  962. [view addSubview:line];
  963. }
  964. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onColleagues:)];
  965. [view addGestureRecognizer:tap];
  966. return view;
  967. }
  968. -(JXImageView*)createButton1:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom icon:(NSString*)icon click:(SEL)click{
  969. JXImageView* btn = [[JXImageView alloc] init];
  970. btn.backgroundColor = [UIColor whiteColor];
  971. btn.userInteractionEnabled = YES;
  972. btn.didTouch = click;
  973. btn.delegate = self;
  974. [_setBaseView2 addSubview:btn];
  975. JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(45, 0, self_width-35-20-5, HEIGHT)];
  976. p.text = title;
  977. p.font = [UIFont systemFontOfSize:18 weight:(UIFontWeightBold)];;
  978. p.backgroundColor = [UIColor clearColor];
  979. p.textColor = HEXCOLOR(0x323232);
  980. [btn addSubview:p];
  981. if(icon){
  982. UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(15, (HEIGHT-23)/2, 23, 23)];
  983. iv.image = [UIImage imageNamed:icon];
  984. [btn addSubview:iv];
  985. }
  986. if(drawTop){
  987. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(53,0,JX_SCREEN_WIDTH-53,LINE_WH)];
  988. line.backgroundColor = THE_LINE_COLOR;
  989. [btn addSubview:line];
  990. }
  991. if(drawBottom){
  992. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(53,HEIGHT-0.3,JX_SCREEN_WIDTH-53,LINE_WH)];
  993. line.backgroundColor = THE_LINE_COLOR;
  994. [btn addSubview:line];
  995. }
  996. if(click){
  997. UIImageView* iv;
  998. iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, (HEIGHT-13)/2, 7, 13)];
  999. iv.image = [UIImage imageNamed:@"next_icon"];
  1000. [btn addSubview:iv];
  1001. }
  1002. return btn;
  1003. }
  1004. -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom icon:(NSString*)icon click:(SEL)click{
  1005. JXImageView* btn = [[JXImageView alloc] init];
  1006. btn.backgroundColor = [UIColor whiteColor];
  1007. btn.userInteractionEnabled = YES;
  1008. btn.didTouch = click;
  1009. btn.delegate = self;
  1010. [_setBaseView addSubview:btn];
  1011. JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(53, 0, self_width-35-20-5, HEIGHT)];
  1012. p.text = title;
  1013. p.font = g_factory.font16;
  1014. p.backgroundColor = [UIColor clearColor];
  1015. p.textColor = HEXCOLOR(0x323232);
  1016. [btn addSubview:p];
  1017. if(icon){
  1018. UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(15, (HEIGHT-23)/2, 23, 23)];
  1019. iv.image = [UIImage imageNamed:icon];
  1020. [btn addSubview:iv];
  1021. }
  1022. if(drawTop){
  1023. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(53,0,JX_SCREEN_WIDTH-53,LINE_WH)];
  1024. line.backgroundColor = THE_LINE_COLOR;
  1025. [btn addSubview:line];
  1026. }
  1027. if(drawBottom){
  1028. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(53,HEIGHT-0.3,JX_SCREEN_WIDTH-53,LINE_WH)];
  1029. line.backgroundColor = THE_LINE_COLOR;
  1030. [btn addSubview:line];
  1031. }
  1032. if(click){
  1033. UIImageView* iv;
  1034. iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, (HEIGHT-13)/2, 7, 13)];
  1035. iv.image = [UIImage imageNamed:@"new_icon_>"];
  1036. [btn addSubview:iv];
  1037. }
  1038. return btn;
  1039. }
  1040. //内存泄漏,为啥?
  1041. -(void)onHeadImage{
  1042. [g_server delHeadImage:g_myself.userId];
  1043. JXImageScrollVC * imageVC = [[JXImageScrollVC alloc]init];
  1044. imageVC.imageSize = CGSizeMake(JX_SCREEN_WIDTH, JX_SCREEN_WIDTH);
  1045. imageVC.iv = [[JXImageView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_WIDTH)];
  1046. imageVC.iv.center = imageVC.view.center;
  1047. [g_server getHeadImageLarge:g_myself.userId userName:g_myself.userNickname imageView:imageVC.iv];
  1048. [self addTransition:imageVC];
  1049. [self presentViewController:imageVC animated:YES completion:^{
  1050. self.isRefresh = YES;
  1051. }];
  1052. // [imageVC release];
  1053. }
  1054. - (void)setupView:(UIView *)view colors:(NSArray *)colors {
  1055. CAGradientLayer *gradientLayer = [CAGradientLayer layer];
  1056. gradientLayer.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, 266+TOP_ADD_HEIGHT-86); // 设置显示的frame
  1057. gradientLayer.colors = colors; // 设置渐变颜色
  1058. gradientLayer.startPoint = CGPointMake(0, 0);
  1059. gradientLayer.endPoint = CGPointMake(1, 0);
  1060. [view.layer addSublayer:gradientLayer];
  1061. }
  1062. //添加VC转场动画
  1063. - (void) addTransition:(JXImageScrollVC *) siv
  1064. {
  1065. self.scaleTransition = [[DMScaleTransition alloc]init];
  1066. [siv setTransitioningDelegate:self.scaleTransition];
  1067. }
  1068. //-(void)onSearch{
  1069. // JXNearVC* vc = [[JXNearVC alloc] init];
  1070. // [g_window addSubview:vc.view];
  1071. // [vc onSearch];
  1072. //}
  1073. @end