MineNewViewController.m 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. //
  2. // MineViewController.m
  3. // 千模
  4. //
  5. // Created by Drew on 2018/10/24.
  6. // Copyright © 2018 MUMEI. All rights reserved.
  7. //
  8. #import "MineNewViewController.h"
  9. #import "MyWalletController.h"
  10. #import "MySkillsController.h"
  11. #import "MyOrderController.h"
  12. #import "ModelDataController.h"
  13. #import "PlatformActivityController.h"
  14. #import "AboutUsViewController.h"
  15. #import "ModelCodeController.h"
  16. #import "PromoteController.h"
  17. #import "SettingsViewController.h"
  18. #import "ShareViewController.h"
  19. @interface MineNewViewController ()
  20. @property(weak, nonatomic) IBOutlet UIView *headView;
  21. @property(weak, nonatomic) IBOutlet UIView *bgView;
  22. @property(weak, nonatomic) IBOutlet UILabel *nameLabel;
  23. @property (weak, nonatomic) IBOutlet UIView *avatarBg;
  24. @property(weak, nonatomic) IBOutlet UIImageView *avatarView;
  25. @property(weak, nonatomic) IBOutlet UIView *shadowView;
  26. @property (weak, nonatomic) IBOutlet UIView *menus;
  27. @property (weak, nonatomic) IBOutlet UIView *incomeView;
  28. @property (weak, nonatomic) IBOutlet UILabel *incomeLabel;
  29. @property (weak, nonatomic) IBOutlet UISwitch *onlineSwitch;
  30. @end
  31. @implementation MineNewViewController
  32. - (void)viewDidLoad {
  33. [super viewDidLoad];
  34. NSArray *constrains = self.headView.constraints;
  35. for (NSLayoutConstraint *constraint in constrains) {
  36. if (constraint.firstAttribute == NSLayoutAttributeHeight) {
  37. constraint.constant = 104 + [[UIApplication sharedApplication] statusBarFrame].size.height;
  38. }
  39. }
  40. [self.headView updateConstraints];
  41. self.nameLabel.userInteractionEnabled = YES;
  42. self.avatarBg.layer.cornerRadius = 43;
  43. self.avatarView.layer.cornerRadius = 35;
  44. self.avatarView.layer.masksToBounds = YES;
  45. self.avatarView.userInteractionEnabled = YES;
  46. self.onlineSwitch.onImage = [UIImage imageNamed:@"into_icon_shezhi_baise"];
  47. }
  48. - (void)viewWillAppear:(BOOL)animated {
  49. [self.navigationController setNavigationBarHidden:YES animated:NO];
  50. [self getDataFromNetworking];
  51. }
  52. -(void)viewDidLayoutSubviews{
  53. [super viewDidLayoutSubviews];
  54. CAGradientLayer *gl = [CAGradientLayer layer];
  55. gl.frame = CGRectMake(0, 0, self.headView.frame.size.width, 104 + [[UIApplication sharedApplication] statusBarFrame].size.height);
  56. gl.startPoint = CGPointMake(0, 0);
  57. gl.endPoint = CGPointMake(0, 1);
  58. gl.colors = @[(__bridge id) [UIColor colorWithRed:251 / 255.0 green:92 / 255.0 blue:163 / 255.0 alpha:1].CGColor, (__bridge id) [UIColor colorWithRed:253 / 255.0 green:127 / 255.0 blue:141 / 255.0 alpha:1].CGColor];
  59. gl.locations = @[@(0), @(1.0f)];
  60. [self.headView.layer addSublayer:gl];
  61. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bgView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(30, 30)];
  62. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  63. maskLayer.frame = self.bgView.bounds;
  64. maskLayer.path = maskPath.CGPath;
  65. self.bgView.layer.mask = maskLayer;
  66. self.menus.layer.cornerRadius = 12;
  67. self.menus.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.08].CGColor;
  68. self.menus.layer.shadowOffset = CGSizeMake(0,6);
  69. self.menus.layer.shadowOpacity = 1;
  70. self.menus.layer.shadowRadius = 12;
  71. self.incomeView.layer.cornerRadius = 17;
  72. self.incomeView.layer.shadowColor = [UIColor colorWithRed:255/255.0 green:64/255.0 blue:149/255.0 alpha:0.36].CGColor;
  73. self.incomeView.layer.shadowOffset = CGSizeMake(0,8);
  74. self.incomeView.layer.shadowOpacity = 1;
  75. self.incomeView.layer.shadowRadius = 10;
  76. }
  77. - (void)viewWillDisappear:(BOOL)animated {
  78. [self.navigationController setNavigationBarHidden:NO animated:YES];
  79. }
  80. - (void)getDataFromNetworking {
  81. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  82. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].modelpk,@"modelpk", nil];
  83. [YanCNetWorkManager requestPostWithURLStr:Url_refreshLogin(PublicUrl) parameters:dic finish:^(id dataDic) {
  84. [MBProgressHUD hideHUDForView:self.view animated:YES];
  85. NSString *issuccess = dataDic[@"msg"];
  86. if ([issuccess isEqualToString:@"success"]) {
  87. ModelUser *user = [ModelUser modelUser];
  88. [user setValuesForKeysWithDictionary:dataDic[@"data"]];
  89. user.modelpk = dataDic[@"data"][@"modelpk"];
  90. user.coin_a = dataDic[@"data"][@"coin_a"];
  91. user.coin_ir = dataDic[@"data"][@"coin_ir"];
  92. user.pk = dataDic[@"data"][@"pk"];
  93. user.qrcode = dataDic[@"data"][@"qrcode"];
  94. [ModelUser save:user];
  95. self.nameLabel.text = [NSString stringWithFormat:@"%@", dataDic[@"data"][@"pet"]];
  96. [self.avatarView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", PublicUrl, dataDic[@"data"][@"hphoto"]]] placeholderImage:[UIImage imageNamed:@"morentouxiang"]];
  97. // if ([dataDic[@"data"][@"hasred"] isEqualToString:@"1"]) {
  98. // self.notificationView.hidden = NO;
  99. // }else{
  100. // self.notificationView.hidden = YES;
  101. // }
  102. [self getIncomeFromNetworking];
  103. } else {
  104. [MBProgressHUD showInfo:@"请求失败!"];
  105. }
  106. } enError:^(NSError *error) {
  107. [MBProgressHUD hideHUDForView:self.view animated:YES];
  108. }];
  109. }
  110. -(void)getIncomeFromNetworking{
  111. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser modelUser].pk,@"memberpk", nil];
  112. [YanCNetWorkManager requestPostWithURLStr:Url_getIncomeToday(PublicUrl) parameters:dic finish:^(id dataDic) {
  113. NSString *issuccess = dataDic[@"msg"];
  114. if ([issuccess isEqualToString:@"success"]) {
  115. self.incomeLabel.text = [NSString stringWithFormat:@"今日收入 %@元", dataDic[@"count"]];
  116. }else {
  117. [MBProgressHUD showInfo:@"请求失败!"];
  118. }
  119. }enError:^(NSError *error) {
  120. [MBProgressHUD hideHUDForView:self.view animated:YES];
  121. }];
  122. }
  123. - (IBAction)handelTap:(id)sender {
  124. switch (((UITapGestureRecognizer *) sender).view.tag) {
  125. case 1: {
  126. MyWalletController *myWalletVC = [[MyWalletController alloc] init];
  127. myWalletVC.hidesBottomBarWhenPushed = YES;
  128. myWalletVC.amount = [ModelUser modelUser].coin_a;
  129. [self.navigationController pushViewController:myWalletVC animated:YES];
  130. break;
  131. }
  132. case 2: {
  133. MySkillsController *mySkillsVC = [[MySkillsController alloc] init];
  134. mySkillsVC.hidesBottomBarWhenPushed = YES;
  135. [self.navigationController pushViewController:mySkillsVC animated:YES];
  136. break;
  137. }
  138. case 3: {
  139. ModelDataController *modelDataVC = [[ModelDataController alloc] init];
  140. modelDataVC.hidesBottomBarWhenPushed = YES;
  141. [self.navigationController pushViewController:modelDataVC animated:YES];
  142. break;
  143. }
  144. case 4: {
  145. PlatformActivityController *activityVC = [[PlatformActivityController alloc] init];
  146. activityVC.hidesBottomBarWhenPushed = YES;
  147. [self.navigationController pushViewController:activityVC animated:YES];
  148. break;
  149. }
  150. case 5: {
  151. PromoteController* vc = [[PromoteController alloc] init];
  152. vc.hidesBottomBarWhenPushed = YES;
  153. [self.navigationController pushViewController:vc animated:YES];
  154. break;
  155. }
  156. case 6: {
  157. AboutUsViewController *aboutUsVC = [[AboutUsViewController alloc] init];
  158. aboutUsVC.hidesBottomBarWhenPushed = YES;
  159. [self.navigationController pushViewController:aboutUsVC animated:YES];
  160. break;
  161. }
  162. default:
  163. break;
  164. }
  165. }
  166. - (IBAction)tapSettings:(id)sender {
  167. SettingsViewController *settingsVC = [[SettingsViewController alloc] init];
  168. settingsVC.hidesBottomBarWhenPushed = YES;
  169. [self.navigationController pushViewController:settingsVC animated:YES];
  170. }
  171. - (IBAction)onlineChange:(id)sender {
  172. UISwitch *switchButton = (UISwitch*)sender;
  173. BOOL isButtonOn = [switchButton isOn];
  174. if (isButtonOn) {
  175. [MBProgressHUD showInfo:@"您已开启在线模式"];
  176. }else {
  177. [MBProgressHUD showInfo:@"您已开启离线模式,别人将无法呼叫您"];
  178. }
  179. }
  180. - (UIStatusBarStyle)preferredStatusBarStyle {
  181. return UIStatusBarStyleLightContent;
  182. }
  183. @end