| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- //
- // MineViewController.m
- // 千模
- //
- // Created by Drew on 2018/10/24.
- // Copyright © 2018 MUMEI. All rights reserved.
- //
- #import "MineNewViewController.h"
- #import "MyWalletController.h"
- #import "MySkillsController.h"
- #import "MyOrderController.h"
- #import "ModelDataController.h"
- #import "PlatformActivityController.h"
- #import "AboutUsViewController.h"
- #import "ModelCodeController.h"
- #import "PromoteController.h"
- #import "SettingsViewController.h"
- #import "ShareViewController.h"
- @interface MineNewViewController ()
- @property(weak, nonatomic) IBOutlet UIView *headView;
- @property(weak, nonatomic) IBOutlet UIView *bgView;
- @property(weak, nonatomic) IBOutlet UILabel *nameLabel;
- @property (weak, nonatomic) IBOutlet UIView *avatarBg;
- @property(weak, nonatomic) IBOutlet UIImageView *avatarView;
- @property(weak, nonatomic) IBOutlet UIView *shadowView;
- @property (weak, nonatomic) IBOutlet UIView *menus;
- @property (weak, nonatomic) IBOutlet UIView *incomeView;
- @property (weak, nonatomic) IBOutlet UILabel *incomeLabel;
- @property (weak, nonatomic) IBOutlet UISwitch *onlineSwitch;
- @end
- @implementation MineNewViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- NSArray *constrains = self.headView.constraints;
- for (NSLayoutConstraint *constraint in constrains) {
- if (constraint.firstAttribute == NSLayoutAttributeHeight) {
- constraint.constant = 104 + [[UIApplication sharedApplication] statusBarFrame].size.height;
- }
- }
- [self.headView updateConstraints];
- self.nameLabel.userInteractionEnabled = YES;
- self.avatarBg.layer.cornerRadius = 43;
- self.avatarView.layer.cornerRadius = 35;
- self.avatarView.layer.masksToBounds = YES;
- self.avatarView.userInteractionEnabled = YES;
-
- self.onlineSwitch.onImage = [UIImage imageNamed:@"into_icon_shezhi_baise"];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [self.navigationController setNavigationBarHidden:YES animated:NO];
- [self getDataFromNetworking];
- }
- -(void)viewDidLayoutSubviews{
- [super viewDidLayoutSubviews];
- CAGradientLayer *gl = [CAGradientLayer layer];
- gl.frame = CGRectMake(0, 0, self.headView.frame.size.width, 104 + [[UIApplication sharedApplication] statusBarFrame].size.height);
- gl.startPoint = CGPointMake(0, 0);
- gl.endPoint = CGPointMake(0, 1);
- 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];
- gl.locations = @[@(0), @(1.0f)];
- [self.headView.layer addSublayer:gl];
-
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bgView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(30, 30)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = self.bgView.bounds;
- maskLayer.path = maskPath.CGPath;
- self.bgView.layer.mask = maskLayer;
-
- self.menus.layer.cornerRadius = 12;
- self.menus.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.08].CGColor;
- self.menus.layer.shadowOffset = CGSizeMake(0,6);
- self.menus.layer.shadowOpacity = 1;
- self.menus.layer.shadowRadius = 12;
-
- self.incomeView.layer.cornerRadius = 17;
- self.incomeView.layer.shadowColor = [UIColor colorWithRed:255/255.0 green:64/255.0 blue:149/255.0 alpha:0.36].CGColor;
- self.incomeView.layer.shadowOffset = CGSizeMake(0,8);
- self.incomeView.layer.shadowOpacity = 1;
- self.incomeView.layer.shadowRadius = 10;
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [self.navigationController setNavigationBarHidden:NO animated:YES];
- }
- - (void)getDataFromNetworking {
- [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].modelpk,@"modelpk", nil];
- [YanCNetWorkManager requestPostWithURLStr:Url_refreshLogin(PublicUrl) parameters:dic finish:^(id dataDic) {
- [MBProgressHUD hideHUDForView:self.view animated:YES];
-
- NSString *issuccess = dataDic[@"msg"];
- if ([issuccess isEqualToString:@"success"]) {
- ModelUser *user = [ModelUser modelUser];
- [user setValuesForKeysWithDictionary:dataDic[@"data"]];
- user.modelpk = dataDic[@"data"][@"modelpk"];
- user.coin_a = dataDic[@"data"][@"coin_a"];
- user.coin_ir = dataDic[@"data"][@"coin_ir"];
- user.pk = dataDic[@"data"][@"pk"];
- user.qrcode = dataDic[@"data"][@"qrcode"];
- [ModelUser save:user];
-
- self.nameLabel.text = [NSString stringWithFormat:@"%@", dataDic[@"data"][@"pet"]];
- [self.avatarView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", PublicUrl, dataDic[@"data"][@"hphoto"]]] placeholderImage:[UIImage imageNamed:@"morentouxiang"]];
-
- // if ([dataDic[@"data"][@"hasred"] isEqualToString:@"1"]) {
- // self.notificationView.hidden = NO;
- // }else{
- // self.notificationView.hidden = YES;
- // }
-
- [self getIncomeFromNetworking];
- } else {
- [MBProgressHUD showInfo:@"请求失败!"];
- }
- } enError:^(NSError *error) {
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- }];
- }
- -(void)getIncomeFromNetworking{
-
- NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser modelUser].pk,@"memberpk", nil];
- [YanCNetWorkManager requestPostWithURLStr:Url_getIncomeToday(PublicUrl) parameters:dic finish:^(id dataDic) {
- NSString *issuccess = dataDic[@"msg"];
- if ([issuccess isEqualToString:@"success"]) {
- self.incomeLabel.text = [NSString stringWithFormat:@"今日收入 %@元", dataDic[@"count"]];
- }else {
- [MBProgressHUD showInfo:@"请求失败!"];
- }
- }enError:^(NSError *error) {
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- }];
- }
- - (IBAction)handelTap:(id)sender {
- switch (((UITapGestureRecognizer *) sender).view.tag) {
- case 1: {
- MyWalletController *myWalletVC = [[MyWalletController alloc] init];
- myWalletVC.hidesBottomBarWhenPushed = YES;
- myWalletVC.amount = [ModelUser modelUser].coin_a;
- [self.navigationController pushViewController:myWalletVC animated:YES];
- break;
- }
- case 2: {
- MySkillsController *mySkillsVC = [[MySkillsController alloc] init];
- mySkillsVC.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:mySkillsVC animated:YES];
- break;
- }
- case 3: {
- ModelDataController *modelDataVC = [[ModelDataController alloc] init];
- modelDataVC.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:modelDataVC animated:YES];
- break;
- }
- case 4: {
- PlatformActivityController *activityVC = [[PlatformActivityController alloc] init];
- activityVC.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:activityVC animated:YES];
- break;
- }
- case 5: {
- PromoteController* vc = [[PromoteController alloc] init];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- break;
- }
- case 6: {
- AboutUsViewController *aboutUsVC = [[AboutUsViewController alloc] init];
- aboutUsVC.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:aboutUsVC animated:YES];
- break;
- }
- default:
- break;
- }
- }
- - (IBAction)tapSettings:(id)sender {
- SettingsViewController *settingsVC = [[SettingsViewController alloc] init];
- settingsVC.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:settingsVC animated:YES];
- }
- - (IBAction)onlineChange:(id)sender {
- UISwitch *switchButton = (UISwitch*)sender;
- BOOL isButtonOn = [switchButton isOn];
- if (isButtonOn) {
- [MBProgressHUD showInfo:@"您已开启在线模式"];
- }else {
- [MBProgressHUD showInfo:@"您已开启离线模式,别人将无法呼叫您"];
- }
- }
- - (UIStatusBarStyle)preferredStatusBarStyle {
- return UIStatusBarStyleLightContent;
- }
- @end
|