JXGoldenManagerViewController.m 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. //
  2. // JXGoldenManagerViewController.m
  3. // shiku_im
  4. //
  5. // Created by qiudezheng on 2020/4/28.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXGoldenManagerViewController.h"
  9. #import "JXBigReelVc.h"
  10. #import "JXActiveDetailVc.h"
  11. @interface JXGoldenManagerViewController ()
  12. @property(strong,nonatomic)UIView * navigationView;
  13. @property(strong,nonatomic)UILabel * userInfoLabel;
  14. @property(strong,nonatomic)UILabel * moneyLabel;
  15. @property(strong,nonatomic)UILabel * weekLabel;
  16. @property(strong,nonatomic)UILabel * dayLabel;
  17. @property(strong,nonatomic)UILabel * nextLevelLabel;
  18. @property(strong,nonatomic)UILabel * nextWeekLabel;
  19. @property(strong,nonatomic)UILabel * monthLabel;
  20. @property(strong,nonatomic)UIScrollView * scrollView;
  21. @property(strong,nonatomic)UIButton * getButton;
  22. @property(strong,nonatomic)UIImageView * lastImage;
  23. @property(strong,nonatomic)UIButton * backButton;
  24. @end
  25. @implementation JXGoldenManagerViewController
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. self.view.backgroundColor = [UIColor colorWithRed:172/255.0f green:6/255.0f blue:16/255.0f alpha:1.0f];
  29. [self initNavigationView];
  30. [self initComponents];
  31. [self initDataSource];
  32. }
  33. -(void)backButtonClicked:(UIButton *)sender
  34. {
  35. [g_navigation dismissViewController:self animated:YES];
  36. }
  37. -(void)initDataSource
  38. {
  39. [SVProgressHUD show];
  40. long time = (long)[[NSDate date] timeIntervalSince1970];
  41. time = (time *1000 + g_server.timeDifference);
  42. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  43. [g_server getUserVipInformation:salt andToView:self];
  44. }
  45. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  46. // [_wait hide];
  47. [SVProgressHUD dismiss];
  48. if([aDownload.action isEqualToString:act_GetUserVipInformation])
  49. {
  50. NSDictionary * currentDictionary = [dict objectForKey:@"current"];
  51. NSString * currentLevel = [NSString stringWithFormat:@"%@",[currentDictionary objectForKey:@"name"]];
  52. if(currentLevel.length != 0 && currentLevel != nil && ![currentLevel isEqualToString:@"<null>"] && ![currentLevel isEqualToString:@"(null)"])
  53. {
  54. //self.userInfoLabel.text = [NSString stringWithFormat:@"当前昵称:%@ 当前等级:%@", [g_default objectForKey:kMY_USER_NICKNAME],currentLevel];
  55. NSString *tileStr = [NSString stringWithFormat:@"当前昵称:%@ 当前等级:%@", dict[@"membershipAccount"],currentLevel];
  56. //self.userInfoLabel.text=tileStr;
  57. NSMutableAttributedString *balanceStr = [[NSMutableAttributedString alloc] initWithString:tileStr];
  58. NSRange range2=[[balanceStr string]rangeOfString:dict[@"membershipAccount"]];
  59. [balanceStr addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:range2];
  60. NSRange range3=[[balanceStr string]rangeOfString:currentLevel];
  61. [balanceStr addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:range3];
  62. self.userInfoLabel.attributedText = balanceStr;
  63. // [balanceStr addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(5,[NSString stringWithFormat:@"%@",[g_default objectForKey:kMY_USER_NICKNAME]].length)];
  64. // [balanceStr addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(self.userInfoLabel.text.length - currentLevel.length,currentLevel.length)];
  65. //
  66. // [balanceStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0f] range:NSMakeRange(5,[NSString stringWithFormat:@"%@",[g_default objectForKey:kMY_USER_NICKNAME]].length)];
  67. // [balanceStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0f] range:NSMakeRange(self.userInfoLabel.text.length - currentLevel.length,currentLevel.length)];
  68. // self.userInfoLabel.attributedText = balanceStr;
  69. }
  70. if ([dict[@"isGetUpgrade"] intValue]==0&&[dict[@"isGetMonth"] intValue]==0&&[dict[@"isGetWeek"] intValue]==0) {
  71. _getButton.hidden=YES;
  72. }else{
  73. _getButton.hidden=NO;
  74. }
  75. NSString * upgradeCoin = [NSString stringWithFormat:@"%@",[currentDictionary objectForKey:@"upgradeCoin"]];
  76. NSString * isGetUpgrade = [NSString stringWithFormat:@"%@",[dict objectForKey:@"isGetUpgrade"]];
  77. if(upgradeCoin.length != 0 && upgradeCoin != nil && ![upgradeCoin isEqualToString:@"<null>"] && ![upgradeCoin isEqualToString:@"(null)"])
  78. {
  79. self.moneyLabel.text = [NSString stringWithFormat:@"晋升彩金:%@ %@",upgradeCoin,isGetUpgrade.intValue==1?@"未领取":@"已领取"];
  80. }
  81. NSString * weekCoin = [NSString stringWithFormat:@"%@",[currentDictionary objectForKey:@"weekRedPackageCoin"]];
  82. NSString * isGetWeek = [NSString stringWithFormat:@"%@",[dict objectForKey:@"isGetWeek"]];
  83. if(weekCoin.length != 0 && weekCoin != nil && ![weekCoin isEqualToString:@"<null>"] && ![weekCoin isEqualToString:@"(null)"])
  84. {
  85. self.weekLabel.text = [NSString stringWithFormat:@"周俸禄:%@ %@",weekCoin,isGetWeek.intValue==1?@"未领取":@"已领取"];
  86. }
  87. NSString * monthRedPackageCoin = [NSString stringWithFormat:@"%@",[currentDictionary objectForKey:@"monthRedPackageCoin"]];
  88. NSString * isGetMonth = [NSString stringWithFormat:@"%@",[dict objectForKey:@"isGetMonth"]];
  89. if(monthRedPackageCoin.length != 0 && monthRedPackageCoin != nil && ![monthRedPackageCoin isEqualToString:@"<null>"] && ![monthRedPackageCoin isEqualToString:@"(null)"])
  90. {
  91. self.dayLabel.text = [NSString stringWithFormat:@"月俸禄:%@ %@",monthRedPackageCoin,isGetMonth.intValue==1?@"未领取":@"已领取"];
  92. }
  93. NSDictionary * nextDictionary = [dict objectForKey:@"next"];
  94. NSString * nextLevel = [NSString stringWithFormat:@"%@",[nextDictionary objectForKey:@"name"]];
  95. if(nextLevel.length != 0 && nextLevel != nil && ![nextLevel isEqualToString:@"<null>"] && ![nextLevel isEqualToString:@"(null)"])
  96. {
  97. self.nextLevelLabel.text = [NSString stringWithFormat:@"下一等级:%@",nextLevel];
  98. }
  99. NSString * nextweekRedPackageCoin = [NSString stringWithFormat:@"%@",[nextDictionary objectForKey:@"weekRedPackageCoin"]];
  100. if(nextweekRedPackageCoin.length != 0 && nextweekRedPackageCoin != nil && ![nextweekRedPackageCoin isEqualToString:@"<null>"] && ![nextweekRedPackageCoin isEqualToString:@"(null)"])
  101. {
  102. self.nextWeekLabel.text = [NSString stringWithFormat:@"周俸禄:%@",nextweekRedPackageCoin];
  103. }
  104. NSString * nextMonth = [NSString stringWithFormat:@"%@",[nextDictionary objectForKey:@"monthRedPackageCoin"]];
  105. if(nextMonth.length != 0 && nextMonth != nil && ![nextMonth isEqualToString:@"<null>"] && ![nextMonth isEqualToString:@"(null)"])
  106. {
  107. self.monthLabel.text = [NSString stringWithFormat:@"月俸禄:%@",nextMonth];
  108. }
  109. if(isGetUpgrade.intValue == 0 || isGetWeek.intValue == 0 || isGetMonth.intValue == 0)
  110. {
  111. int totalCoin = upgradeCoin.intValue + weekCoin.intValue + monthRedPackageCoin.intValue;
  112. if(totalCoin == 0)
  113. {
  114. self.getButton.alpha = 0.0f;
  115. self.lastImage.frame = CGRectMake(10, self.getButton.frame.origin.y, JX_SCREEN_WIDTH - 20, 7.94 * (JX_SCREEN_WIDTH - 20));
  116. }
  117. else
  118. {
  119. self.getButton.alpha = 1.0f;
  120. self.lastImage.frame = CGRectMake(10, self.getButton.frame.origin.y + self.getButton.frame.size.height + 45, JX_SCREEN_WIDTH - 20, 7.94 * (JX_SCREEN_WIDTH - 20));
  121. }
  122. }
  123. else
  124. {
  125. self.getButton.alpha = 0.0f;
  126. self.lastImage.frame = CGRectMake(10, self.getButton.frame.origin.y, JX_SCREEN_WIDTH - 20, 7.94 * (JX_SCREEN_WIDTH - 20));
  127. }
  128. self.scrollView.contentSize = CGSizeMake(JX_SCREEN_WIDTH, self.lastImage.frame.origin.y + self.lastImage.frame.size.height+62);
  129. }
  130. else if([aDownload.action isEqualToString:act_GainUserCoin])
  131. {
  132. [SVProgressHUD dismiss];
  133. UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"领取成功" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
  134. [alert show];
  135. long time = (long)[[NSDate date] timeIntervalSince1970];
  136. time = (time *1000 + g_server.timeDifference);
  137. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  138. [g_server getUserVipInformation:salt andToView:self];
  139. }
  140. }
  141. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  142. NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]];
  143. if([errorCode isEqualToString:@"权限验证失败"])
  144. {
  145. if([aDownload.action isEqualToString:act_GetUserVipInformation])
  146. {
  147. long time = (long)[[NSDate date] timeIntervalSince1970];
  148. time = (time *1000 + g_server.timeDifference);
  149. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  150. [g_server getUserVipInformation:salt andToView:self];
  151. }
  152. else if([aDownload.action isEqualToString:act_GainUserCoin])
  153. {
  154. long time = (long)[[NSDate date] timeIntervalSince1970];
  155. time = (time *1000 + g_server.timeDifference);
  156. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  157. [g_server vipGainCoin:salt andToView:self];
  158. }
  159. }
  160. else
  161. {
  162. [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]];
  163. }
  164. if( [aDownload.action isEqualToString:act_UserLogout] ){
  165. [self performSelector:@selector(doSwitch) withObject:nil afterDelay:1];
  166. }
  167. return hide_error;
  168. }
  169. - (void)doSwitch:(id)xx{}
  170. -(void)initNavigationView
  171. {
  172. self.navigationView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT>=812?88:64)];
  173. self.navigationView.backgroundColor = [UIColor whiteColor];
  174. [self.view addSubview:self.navigationView];
  175. UILabel * titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, JX_SCREEN_TOP - 40, JX_SCREEN_WIDTH, 40)];
  176. titleLabel.text = @"金管家";
  177. titleLabel.textColor = [UIColor blackColor];
  178. titleLabel.font = [UIFont systemFontOfSize:18.0f];
  179. titleLabel.textAlignment = NSTextAlignmentCenter;
  180. [self.navigationView addSubview:titleLabel];
  181. self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
  182. self.backButton.frame = CGRectMake(15, 30, 30, 30);
  183. if(JX_SCREEN_HEIGHT >= 812)
  184. {
  185. self.backButton.frame = CGRectMake(15, 45, 30, 30);
  186. }
  187. [self.backButton setImage:[UIImage imageNamed:@"title_back_black"] forState:UIControlStateNormal];
  188. [self.backButton addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
  189. [self.navigationView addSubview:self.backButton];
  190. }
  191. -(void)viewWillDisappear:(BOOL)animated
  192. {
  193. [SVProgressHUD dismiss];
  194. }
  195. -(void)buttonClicked:(UIButton *)sender
  196. {
  197. [SVProgressHUD show];
  198. long time = (long)[[NSDate date] timeIntervalSince1970];
  199. time = (time *1000 + g_server.timeDifference);
  200. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  201. [g_server vipGainCoin:salt andToView:self];
  202. }
  203. -(void)initComponents
  204. {
  205. self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, self.navigationView.frame.origin.y + self.navigationView.frame.size.height, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-(self.navigationView.frame.origin.y + self.navigationView.frame.size.height))];
  206. self.scrollView.backgroundColor = self.view.backgroundColor;
  207. [self.view addSubview:self.scrollView];
  208. // UIButton *lefImg= [[UIButton alloc]initWithFrame:CGRectMake(15,JX_SCREEN_HEIGHT-42-10, 140, 42)];
  209. // lefImg.layer.cornerRadius = 12;
  210. // lefImg.backgroundColor = [UIColor whiteColor];
  211. // [lefImg setTitleColor:kRGBColor(91, 19, 19) forState:UIControlStateNormal];
  212. // [lefImg setTitle:@"活动详情" forState:UIControlStateNormal];
  213. // lefImg.tag=0;
  214. // [self.view addSubview:lefImg];
  215. // [lefImg addTarget:self action:@selector(lefIMGClick:) forControlEvents:UIControlEventTouchUpInside];
  216. //
  217. // UIButton *rightImg= [[UIButton alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-140-15, JX_SCREEN_HEIGHT-42-10, 140, 42)];
  218. // rightImg.tag=1;
  219. // rightImg.layer.cornerRadius = 12;
  220. // rightImg.backgroundColor = [UIColor whiteColor];
  221. // [rightImg setTitle:@"我要参与" forState:UIControlStateNormal];
  222. // [rightImg setTitleColor:kRGBColor(91, 19, 19) forState:UIControlStateNormal];
  223. // // [rightImg setBackgroundImage:[UIImage imageNamed:@"huodongxq"] forState:UIControlStateNormal];
  224. // [self.view addSubview:rightImg];
  225. // [rightImg addTarget:self action:@selector(lefIMGClick:) forControlEvents:UIControlEventTouchUpInside];
  226. UIImageView * bannerImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 0, JX_SCREEN_WIDTH - 20, 0.533*(JX_SCREEN_WIDTH - 20))];
  227. bannerImage.image = [UIImage imageNamed:@"goldenBanner"];
  228. [self.scrollView addSubview:bannerImage];
  229. UIView * backView = [[UIView alloc]initWithFrame:CGRectMake(10, bannerImage.frame.origin.y + bannerImage.frame.size.height + 15, JX_SCREEN_WIDTH - 20, 0.564*(JX_SCREEN_WIDTH - 20))];
  230. backView.backgroundColor = [UIColor colorWithRed:244/255.0f green:79/255.0f blue:51/255.0f alpha:1.0f];
  231. [self.scrollView addSubview:backView];
  232. self.getButton = [UIButton buttonWithType:UIButtonTypeCustom];
  233. self.getButton.frame = CGRectMake(JX_SCREEN_WIDTH / 2 - 50, backView.frame.origin.y + backView.frame.size.height + 15, 100, 30);
  234. [self.getButton setBackgroundColor:[UIColor colorWithRed:253/255.0f green:219/255.0f blue:173/255.0f alpha:1.0f]];
  235. [self.getButton setTitle:@"领取俸禄" forState:UIControlStateNormal];
  236. [self.getButton setTitleColor:self.view.backgroundColor forState:UIControlStateNormal];
  237. [self.getButton.titleLabel setFont:[UIFont systemFontOfSize:13.0f]];
  238. [self.getButton.layer setCornerRadius:15.0f];
  239. _getButton.hidden=YES;
  240. [self.getButton.layer setMasksToBounds:YES];
  241. [self.getButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
  242. [self.scrollView addSubview:self.getButton];
  243. self.lastImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, self.getButton.frame.origin.y + self.getButton.frame.size.height + 45, JX_SCREEN_WIDTH - 20, 7.94 * (JX_SCREEN_WIDTH - 20))];
  244. self.self.lastImage.image = [UIImage imageNamed:@"lastImage.jpeg"];
  245. [self.scrollView addSubview:self.self.lastImage];
  246. self.scrollView.contentSize = CGSizeMake(JX_SCREEN_WIDTH, self.lastImage.frame.origin.y + self.lastImage.frame.size.height+62);
  247. UIView * splineView = [[UIView alloc]initWithFrame:CGRectMake(30, 0.6 * backView.frame.size.height, backView.frame.size.width - 60, 1)];
  248. splineView.backgroundColor = [UIColor colorWithRed:232/255.0f green:199/255.0f blue:164/255.0f alpha:1.0f];
  249. [backView addSubview:splineView];
  250. self.userInfoLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 8, backView.frame.size.width, backView.frame.size.height * 0.6 * 0.2)];
  251. self.userInfoLabel.text = @"";
  252. self.userInfoLabel.textColor = [UIColor whiteColor];
  253. self.userInfoLabel.font = [UIFont systemFontOfSize:13.0f];
  254. self.userInfoLabel.textAlignment = NSTextAlignmentCenter;
  255. [backView addSubview:self.userInfoLabel];
  256. self.moneyLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.userInfoLabel.frame.origin.y + self.userInfoLabel.frame.size.height, backView.frame.size.width, backView.frame.size.height * 0.6 * 0.2)];
  257. self.moneyLabel.text = @"";
  258. self.moneyLabel.textColor = [UIColor colorWithRed:253/255.0f green:219/255.0f blue:173/255.0f alpha:1.0f];
  259. self.moneyLabel.font = [UIFont systemFontOfSize:13.0f];
  260. self.moneyLabel.textAlignment = NSTextAlignmentCenter;
  261. [backView addSubview:self.moneyLabel];
  262. self.weekLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.moneyLabel.frame.origin.y + self.moneyLabel.frame.size.height, backView.frame.size.width, backView.frame.size.height * 0.6 * 0.2)];
  263. self.weekLabel.text = @"";
  264. self.weekLabel.textColor = [UIColor colorWithRed:253/255.0f green:219/255.0f blue:173/255.0f alpha:1.0f];
  265. self.weekLabel.font = [UIFont systemFontOfSize:13.0f];
  266. self.weekLabel.textAlignment = NSTextAlignmentCenter;
  267. [backView addSubview:self.weekLabel];
  268. self.dayLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.weekLabel.frame.origin.y + self.weekLabel.frame.size.height, backView.frame.size.width, backView.frame.size.height * 0.6 * 0.2)];
  269. self.dayLabel.text = @"";
  270. self.dayLabel.textColor = [UIColor colorWithRed:253/255.0f green:219/255.0f blue:173/255.0f alpha:1.0f];
  271. self.dayLabel.font = [UIFont systemFontOfSize:13.0f];
  272. self.dayLabel.textAlignment = NSTextAlignmentCenter;
  273. [backView addSubview:self.dayLabel];
  274. //
  275. self.nextLevelLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, backView.frame.size.height * 0.6 + 10, backView.frame.size.width, backView.frame.size.height * 0.4 * 0.25)];
  276. self.nextLevelLabel.text = @"";
  277. self.nextLevelLabel.textColor = [UIColor colorWithRed:254/255.0f green:216/255.0f blue:54/255.0f alpha:1.0f];
  278. self.nextLevelLabel.font = [UIFont systemFontOfSize:13.0f];
  279. self.nextLevelLabel.textAlignment = NSTextAlignmentCenter;
  280. [backView addSubview:self.nextLevelLabel];
  281. self.nextWeekLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.nextLevelLabel.frame.origin.y + self.nextLevelLabel.frame.size.height , backView.frame.size.width, backView.frame.size.height * 0.4 * 0.25)];
  282. self.nextWeekLabel.text = @"";
  283. self.nextWeekLabel.textColor = [UIColor colorWithRed:254/255.0f green:216/255.0f blue:54/255.0f alpha:1.0f];
  284. self.nextWeekLabel.font = [UIFont systemFontOfSize:13.0f];
  285. self.nextWeekLabel.textAlignment = NSTextAlignmentCenter;
  286. [backView addSubview:self.nextWeekLabel];
  287. self.monthLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.nextWeekLabel.frame.origin.y + self.nextWeekLabel.frame.size.height, backView.frame.size.width, backView.frame.size.height * 0.4 * 0.25)];
  288. self.monthLabel.text = @"";
  289. self.monthLabel.textColor = [UIColor colorWithRed:254/255.0f green:216/255.0f blue:54/255.0f alpha:1.0f];
  290. self.monthLabel.font = [UIFont systemFontOfSize:13.0f];
  291. self.monthLabel.textAlignment = NSTextAlignmentCenter;
  292. [backView addSubview:self.monthLabel];
  293. }
  294. -(void)lefIMGClick:(UIButton *)sender{
  295. // [SVProgressHUD showWithStatus:@"暂未开发"];
  296. // [SVProgressHUD dismissWithDelay:1.0];
  297. // return;
  298. // if (sender.tag==0) {
  299. // JXActiveDetailVc *vc=[JXActiveDetailVc new];
  300. // [g_navigation pushViewController:vc animated:YES];
  301. // }else{
  302. // JXBigReelVc *vc=[JXBigReelVc new];
  303. // [g_navigation pushViewController:vc animated:YES];
  304. //
  305. //
  306. // }
  307. }
  308. @end