accountDetails.m 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #import "accountDetails.h"
  2. #import "Config.h"
  3. #import <WebKit/WebKit.h>
  4. @interface accountDetails ()<WKNavigationDelegate>
  5. {
  6. WKWebView *wevView;
  7. NSURL *url;
  8. //四个下划线
  9. UILabel *label1;
  10. UILabel *label2;
  11. UILabel *label3;
  12. UILabel *label4;
  13. UIView *shadowView;
  14. }
  15. @end
  16. @implementation accountDetails
  17. -(void)navtion{
  18. UIView *navtion = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 64 + statusbarHeight)];
  19. navtion.backgroundColor = Normal_Color;
  20. UIButton *returnBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  21. returnBtn.frame = CGRectMake(8,24 + statusbarHeight,40,40);
  22. returnBtn.imageEdgeInsets = UIEdgeInsetsMake(12.5, 0, 12.5, 25);
  23. [returnBtn setImage:[UIImage imageNamed:@"pub_back"] forState:UIControlStateNormal];
  24. [returnBtn addTarget:self action:@selector(doReturn) forControlEvents:UIControlEventTouchUpInside];
  25. [navtion addSubview:returnBtn];
  26. [self.view addSubview:navtion];
  27. UISegmentedControl *segment = [[UISegmentedControl alloc]initWithItems:@[YZMsg(@"收益明细"),YZMsg(@"提现明细")]];
  28. segment.frame = CGRectMake(_window_width*0.15,25 + statusbarHeight, _window_width*0.7,30);
  29. if (@available(iOS 13.0, *)) {
  30. segment.selectedSegmentTintColor = [UIColor clearColor];
  31. } else {
  32. segment.tintColor = [UIColor clearColor];
  33. }
  34. NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17],NSFontAttributeName,RGB_COLOR(@"#777777", 1), NSForegroundColorAttributeName, nil];
  35. [segment setTitleTextAttributes:attributes forState:UIControlStateNormal];
  36. NSDictionary *highlightedAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17],NSFontAttributeName,[UIColor whiteColor], NSForegroundColorAttributeName, nil];
  37. [segment setTitleTextAttributes:highlightedAttributes forState:UIControlStateSelected];
  38. segment.selectedSegmentIndex = 0;
  39. [segment addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];
  40. [navtion addSubview:segment];
  41. }
  42. //segment事件
  43. -(void)change:(UISegmentedControl *)segment{
  44. if (segment.selectedSegmentIndex == 0) {
  45. [wevView stopLoading];
  46. //商城
  47. NSString *paths;
  48. if([self.fromType isEqual:@"red"]){
  49. paths = [h5url stringByAppendingFormat:@"/appapi/cash/redrecord?uid=%@&token=%@",[Config getOwnID],[Config getOwnToken]];
  50. }else{
  51. paths = [h5url stringByAppendingFormat:@"/appapi/cash/record?uid=%@&token=%@",[Config getOwnID],[Config getOwnToken]];
  52. }
  53. paths = [paths stringByAppendingFormat:@"&lang=%@",[YBLanguageTools serviceLang]];
  54. url = [NSURL URLWithString:paths];
  55. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  56. [wevView removeObserver:self forKeyPath:@"title"];
  57. [wevView removeFromSuperview];
  58. wevView = nil;
  59. wevView = [[WKWebView alloc] init];
  60. [wevView loadRequest:request];
  61. wevView.backgroundColor = Normal_Color;
  62. wevView.frame = CGRectMake(0,64 + statusbarHeight, _window_width, _window_height-64 - statusbarHeight);
  63. wevView.navigationDelegate = self;
  64. [self.view addSubview:wevView];
  65. }
  66. else if (segment.selectedSegmentIndex == 1){
  67. [wevView stopLoading];
  68. NSString *paths;
  69. if([self.fromType isEqual:@"red"]){
  70. paths = [h5url stringByAppendingFormat:@"/appapi/cash/redcash?uid=%@&token=%@",[Config getOwnID],[Config getOwnToken]];
  71. }else{
  72. paths = [h5url stringByAppendingFormat:@"/appapi/cash/cash?uid=%@&token=%@",[Config getOwnID],[Config getOwnToken]];
  73. }
  74. paths = [paths stringByAppendingFormat:@"&lang=%@",[YBLanguageTools serviceLang]];
  75. url = [NSURL URLWithString:paths];
  76. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  77. [wevView removeObserver:self forKeyPath:@"title"];
  78. [wevView removeFromSuperview];
  79. wevView = nil;
  80. wevView = [[WKWebView alloc] init];
  81. [wevView loadRequest:request];
  82. wevView.backgroundColor = Normal_Color;
  83. wevView.frame = CGRectMake(0,64 + statusbarHeight, _window_width, _window_height-64 - statusbarHeight);
  84. wevView.navigationDelegate = self;
  85. [self.view addSubview:wevView];
  86. }
  87. [wevView addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL];
  88. shadowView.hidden = NO;
  89. [self.view bringSubviewToFront:shadowView];
  90. }
  91. -(void)doReturn{
  92. [self.navigationController popViewControllerAnimated:YES];
  93. [self dismissViewControllerAnimated:YES completion:nil];
  94. }
  95. - (void)viewDidLoad {
  96. [super viewDidLoad];
  97. self.naviView.hidden = YES;
  98. [self navtion];
  99. // NSString *paths = [h5url stringByAppendingFormat:@"/appapi/cash/record?uid=%@&token=%@",[Config getOwnID],[Config getOwnToken]];
  100. NSString *paths;
  101. if([self.fromType isEqual:@"red"]){
  102. paths = [h5url stringByAppendingFormat:@"/appapi/cash/redrecord?uid=%@&token=%@",[Config getOwnID],[Config getOwnToken]];
  103. }else{
  104. paths = [h5url stringByAppendingFormat:@"/appapi/cash/record?uid=%@&token=%@",[Config getOwnID],[Config getOwnToken]];
  105. }
  106. paths = [paths stringByAppendingFormat:@"&lang=%@",[YBLanguageTools serviceLang]];
  107. url = [NSURL URLWithString:paths];
  108. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  109. wevView = [[WKWebView alloc] init];
  110. [wevView loadRequest:request];
  111. wevView.backgroundColor = Normal_Color;
  112. wevView.frame = CGRectMake(0,64 + statusbarHeight, _window_width, _window_height-64 - statusbarHeight);
  113. wevView.navigationDelegate = self;
  114. [self.view addSubview:wevView];
  115. self.view.backgroundColor = Normal_Color;
  116. shadowView = [[UIView alloc]initWithFrame:CGRectMake(0,64 + statusbarHeight, _window_width, _window_height-64 - statusbarHeight)];
  117. shadowView.backgroundColor = Normal_Color;
  118. [self.view addSubview:shadowView];
  119. [wevView addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL];
  120. }
  121. - (void)dealloc
  122. {
  123. [wevView removeObserver:self forKeyPath:@"title"];
  124. }
  125. -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
  126. if ([keyPath isEqualToString:@"title"]){
  127. if (object == wevView){
  128. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  129. shadowView.hidden = YES;
  130. });
  131. }else{
  132. [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
  133. }
  134. }else{
  135. [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
  136. }
  137. }
  138. @end