MineNewViewController.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. #import "IntroView.h"
  20. #import "ModelCardController.h"
  21. #import "RankController.h"
  22. @interface MineNewViewController ()
  23. @property(weak, nonatomic) IBOutlet UIView *headView;
  24. @property(weak, nonatomic) IBOutlet UIView *bgView;
  25. @property(weak, nonatomic) IBOutlet UILabel *nameLabel;
  26. @property (weak, nonatomic) IBOutlet UIView *avatarBg;
  27. @property(weak, nonatomic) IBOutlet UIImageView *avatarView;
  28. @property (weak, nonatomic) IBOutlet UIView *container1;
  29. @property (weak, nonatomic) IBOutlet UIView *container2;
  30. @property (weak, nonatomic) IBOutlet UIView *incomeView;
  31. @property (weak, nonatomic) IBOutlet UILabel *incomeLabel;
  32. @property (weak, nonatomic) IBOutlet UISwitch *onlineSwitch;
  33. @property (weak, nonatomic) IBOutlet UIView *modelCardView;
  34. @property (weak, nonatomic) IBOutlet UIView *skillView;
  35. @end
  36. @implementation MineNewViewController
  37. - (void)viewDidLoad {
  38. [super viewDidLoad];
  39. NSArray *constrains = self.headView.constraints;
  40. for (NSLayoutConstraint *constraint in constrains) {
  41. if (constraint.firstAttribute == NSLayoutAttributeHeight) {
  42. constraint.constant = 104 + [[UIApplication sharedApplication] statusBarFrame].size.height;
  43. }
  44. }
  45. [self.headView updateConstraints];
  46. self.nameLabel.userInteractionEnabled = YES;
  47. self.avatarBg.layer.cornerRadius = 43;
  48. self.avatarView.layer.cornerRadius = 35;
  49. self.avatarView.layer.masksToBounds = YES;
  50. self.avatarView.userInteractionEnabled = YES;
  51. self.onlineSwitch.onImage = [UIImage imageNamed:@"into_icon_shezhi_baise"];
  52. }
  53. - (void)viewWillAppear:(BOOL)animated {
  54. [self.navigationController setNavigationBarHidden:YES animated:NO];
  55. [self getDataFromNetworking];
  56. }
  57. -(void)viewDidLayoutSubviews{
  58. [super viewDidLayoutSubviews];
  59. CAGradientLayer *gl = [CAGradientLayer layer];
  60. gl.frame = CGRectMake(0, 0, self.headView.frame.size.width, 104 + [[UIApplication sharedApplication] statusBarFrame].size.height);
  61. gl.startPoint = CGPointMake(0, 0);
  62. gl.endPoint = CGPointMake(0, 1);
  63. 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];
  64. gl.locations = @[@(0), @(1.0f)];
  65. [self.headView.layer addSublayer:gl];
  66. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bgView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(30, 30)];
  67. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  68. maskLayer.frame = self.bgView.bounds;
  69. maskLayer.path = maskPath.CGPath;
  70. self.bgView.layer.mask = maskLayer;
  71. self.container1.layer.cornerRadius = 12;
  72. self.container1.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.08].CGColor;
  73. self.container1.layer.shadowOffset = CGSizeMake(0,6);
  74. self.container1.layer.shadowOpacity = 1;
  75. self.container1.layer.shadowRadius = 12;
  76. self.container2.layer.cornerRadius = 12;
  77. self.container2.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.08].CGColor;
  78. self.container2.layer.shadowOffset = CGSizeMake(0,6);
  79. self.container2.layer.shadowOpacity = 1;
  80. self.container2.layer.shadowRadius = 12;
  81. self.incomeView.layer.cornerRadius = 17;
  82. self.incomeView.layer.shadowColor = [UIColor colorWithRed:255/255.0 green:64/255.0 blue:149/255.0 alpha:0.36].CGColor;
  83. self.incomeView.layer.shadowOffset = CGSizeMake(0,8);
  84. self.incomeView.layer.shadowOpacity = 1;
  85. self.incomeView.layer.shadowRadius = 10;
  86. }
  87. - (void)viewDidAppear:(BOOL)animated {
  88. [super viewDidAppear:animated];
  89. NSNumber* intro = [[NSUserDefaults standardUserDefaults] objectForKey:@"intro"];
  90. if (!intro) {
  91. __weak MineNewViewController *this = self;
  92. IntroView* introView = [[IntroView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)
  93. confirm:^{
  94. ModelCardController *modelCardVC = [[ModelCardController alloc] init];
  95. modelCardVC.hidesBottomBarWhenPushed = YES;
  96. [this.navigationController pushViewController:modelCardVC animated:YES];
  97. }
  98. cancel:^{
  99. }];
  100. UIWindow * window=[[[UIApplication sharedApplication] delegate] window];
  101. CGRect rect1 = [self.modelCardView convertRect: self.modelCardView.bounds toView:window];
  102. introView.icon1left.constant = rect1.origin.x + rect1.size.width / 2 - 43;
  103. introView.icon1top.constant = rect1.origin.y + rect1.size.height / 2 - 43 - [[UIApplication sharedApplication] statusBarFrame].size.height;
  104. CGRect rect2 = [self.skillView convertRect: self.skillView.bounds toView:window];
  105. introView.icon2left.constant = rect2.origin.x + rect2.size.width / 2 - 43;
  106. [window addSubview:introView];
  107. [introView updateConstraints];
  108. [introView layoutIfNeeded];
  109. [[NSUserDefaults standardUserDefaults] setObject:@1 forKey:@"intro"];
  110. }
  111. }
  112. - (void)viewWillDisappear:(BOOL)animated {
  113. [self.navigationController setNavigationBarHidden:NO animated:YES];
  114. }
  115. - (void)getDataFromNetworking {
  116. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  117. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].modelpk,@"modelpk", nil];
  118. [YanCNetWorkManager requestPostWithURLStr:Url_refreshLogin(PublicUrl) parameters:dic finish:^(id dataDic) {
  119. [MBProgressHUD hideHUDForView:self.view animated:YES];
  120. NSString *issuccess = dataDic[@"msg"];
  121. if ([issuccess isEqualToString:@"success"]) {
  122. ModelUser *user = [ModelUser modelUser];
  123. [user setValuesForKeysWithDictionary:dataDic[@"data"]];
  124. user.modelpk = dataDic[@"data"][@"modelpk"];
  125. user.coin_a = dataDic[@"data"][@"coin_a"];
  126. user.coin_ir = dataDic[@"data"][@"coin_ir"];
  127. user.pk = dataDic[@"data"][@"pk"];
  128. user.qrcode = dataDic[@"data"][@"qrcode"];
  129. [ModelUser save:user];
  130. self.nameLabel.text = [NSString stringWithFormat:@"%@", dataDic[@"data"][@"pet"]];
  131. [self.avatarView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", PublicUrl, dataDic[@"data"][@"hphoto"]]] placeholderImage:[UIImage imageNamed:@"morentouxiang"]];
  132. // if ([dataDic[@"data"][@"hasred"] isEqualToString:@"1"]) {
  133. // self.notificationView.hidden = NO;
  134. // }else{
  135. // self.notificationView.hidden = YES;
  136. // }
  137. [self getIncomeFromNetworking];
  138. } else {
  139. [MBProgressHUD showInfo:@"请求失败!"];
  140. }
  141. } enError:^(NSError *error) {
  142. [MBProgressHUD hideHUDForView:self.view animated:YES];
  143. }];
  144. }
  145. -(void)getIncomeFromNetworking{
  146. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser modelUser].pk,@"memberpk", nil];
  147. [YanCNetWorkManager requestPostWithURLStr:Url_getIncomeToday(PublicUrl) parameters:dic finish:^(id dataDic) {
  148. NSString *issuccess = dataDic[@"msg"];
  149. if ([issuccess isEqualToString:@"success"]) {
  150. self.incomeLabel.text = [NSString stringWithFormat:@"今日收入 %@元", dataDic[@"count"]];
  151. }else {
  152. [MBProgressHUD showInfo:@"请求失败!"];
  153. }
  154. }enError:^(NSError *error) {
  155. [MBProgressHUD hideHUDForView:self.view animated:YES];
  156. }];
  157. }
  158. - (IBAction)handelTap:(id)sender {
  159. switch (((UITapGestureRecognizer *) sender).view.tag) {
  160. case 1: {
  161. ModelCardController *modelCardVC = [[ModelCardController alloc] init];
  162. modelCardVC.hidesBottomBarWhenPushed = YES;
  163. [self.navigationController pushViewController:modelCardVC animated:YES];
  164. break;
  165. }
  166. case 2: {
  167. MySkillsController *mySkillsVC = [[MySkillsController alloc] init];
  168. mySkillsVC.hidesBottomBarWhenPushed = YES;
  169. [self.navigationController pushViewController:mySkillsVC animated:YES];
  170. break;
  171. }
  172. case 3: {
  173. }
  174. case 4: {
  175. PromoteController* vc = [[PromoteController alloc] init];
  176. vc.hidesBottomBarWhenPushed = YES;
  177. [self.navigationController pushViewController:vc animated:YES];
  178. break;
  179. }
  180. case 5: {
  181. MyOrderController *vc = [[MyOrderController alloc] init];
  182. vc.hidesBottomBarWhenPushed = YES;
  183. [self.navigationController pushViewController:vc animated:YES];
  184. break;
  185. }
  186. case 6: {
  187. MyWalletController *myWalletVC = [[MyWalletController alloc] init];
  188. myWalletVC.hidesBottomBarWhenPushed = YES;
  189. myWalletVC.amount = [ModelUser modelUser].coin_a;
  190. [self.navigationController pushViewController:myWalletVC animated:YES];
  191. break;
  192. }
  193. case 7:{
  194. PlatformActivityController *activityVC = [[PlatformActivityController alloc] init];
  195. activityVC.hidesBottomBarWhenPushed = YES;
  196. [self.navigationController pushViewController:activityVC animated:YES];
  197. break;
  198. }
  199. case 8:{
  200. AboutUsViewController *aboutUsVC = [[AboutUsViewController alloc] init];
  201. aboutUsVC.hidesBottomBarWhenPushed = YES;
  202. [self.navigationController pushViewController:aboutUsVC animated:YES];
  203. break;
  204. }
  205. case 9:{
  206. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  207. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  208. [MBProgressHUD hideHUDForView:self.view];
  209. [MBProgressHUD showInfo:@"清理完成"];
  210. });
  211. break;
  212. }
  213. default:
  214. break;
  215. }
  216. }
  217. - (IBAction)tapSettings:(id)sender {
  218. SettingsViewController *settingsVC = [[SettingsViewController alloc] init];
  219. settingsVC.hidesBottomBarWhenPushed = YES;
  220. [self.navigationController pushViewController:settingsVC animated:YES];
  221. }
  222. - (IBAction)onlineChange:(id)sender {
  223. UISwitch *switchButton = (UISwitch*)sender;
  224. BOOL isButtonOn = [switchButton isOn];
  225. if (isButtonOn) {
  226. [MBProgressHUD showInfo:@"您已开启在线模式"];
  227. }else {
  228. [MBProgressHUD showInfo:@"您已开启离线模式,别人将无法呼叫您"];
  229. }
  230. }
  231. - (IBAction)tapRank:(id)sender {
  232. RankController* rankVC = [[RankController alloc] init];
  233. rankVC.hidesBottomBarWhenPushed = YES;
  234. [self.navigationController pushViewController:rankVC animated:YES];
  235. }
  236. - (UIStatusBarStyle)preferredStatusBarStyle {
  237. return UIStatusBarStyleLightContent;
  238. }
  239. @end