|
|
@@ -22,12 +22,14 @@
|
|
|
#import "HJClockInAPI.h"//打卡
|
|
|
#import "HJClockInInfoModel.h"
|
|
|
#import "HJClockInDataBox.h"
|
|
|
+#import <CoreLocation/CLLocationManager.h>
|
|
|
|
|
|
@interface HJClockInViewController ()
|
|
|
<
|
|
|
FBScrollLayoutViewDelegate,
|
|
|
FBAPIManagerInterceptor,
|
|
|
-FBAPIManagerDelegate
|
|
|
+FBAPIManagerDelegate,
|
|
|
+UIScrollViewDelegate
|
|
|
>
|
|
|
|
|
|
@property (nonatomic, strong) FBScrollLayoutView *scrollLayoutView;
|
|
|
@@ -65,10 +67,36 @@ FBAPIManagerDelegate
|
|
|
}
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
+
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
- self.view.backgroundColor = COLOR_F5F5F5;
|
|
|
+ self.view.backgroundColor = [UIColor whiteColor];
|
|
|
[self locationShowLoading:NO clockInAPI:NO];
|
|
|
+ self.edgesForExtendedLayout = UIRectEdgeNone;
|
|
|
+ [self locationPermissionJudgment];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - Private methods
|
|
|
+
|
|
|
+/* 设置状态了为白色 */
|
|
|
+- (UIStatusBarStyle)preferredStatusBarStyle{
|
|
|
+
|
|
|
+ return UIStatusBarStyleLightContent;
|
|
|
+}
|
|
|
+
|
|
|
+/* 定位权限判断 */
|
|
|
+- (void)locationPermissionJudgment {
|
|
|
+
|
|
|
+ if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied)
|
|
|
+ {
|
|
|
+ HJConfirmPanelViewController *vc = [[HJConfirmPanelViewController alloc] init];
|
|
|
+ vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
|
|
+ vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
|
|
|
+ self.navigationController.definesPresentationContext = NO;
|
|
|
+ [vc title:@"请前往设置打开用户定位权限" cancelTitle:@"取消" confirmTitle:@"确认" singleTitle:@"" hiddenSingleButton:YES];
|
|
|
+ [vc.confirmButton addTarget:self action:@selector(confirmButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self presentViewController:vc animated:YES completion:nil];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/* 添加视图 */
|
|
|
@@ -100,7 +128,7 @@ FBAPIManagerDelegate
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/* 定位 */
|
|
|
+/* 定位,请求信息 */
|
|
|
- (void)locationShowLoading:(BOOL)show clockInAPI:(BOOL)clockIn {
|
|
|
|
|
|
if (show)
|
|
|
@@ -127,33 +155,126 @@ FBAPIManagerDelegate
|
|
|
}
|
|
|
else
|
|
|
{ //打卡信息
|
|
|
- [self clockIninfoAPI];
|
|
|
+ [self requestClockIninfo];
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- [self.view fb_showFailureWithStatus:@"获取位置失败"];
|
|
|
[self showErrorView];
|
|
|
[self.view fb_dismiss];
|
|
|
+ [self.view fb_showFailureWithStatus:@"获取位置失败"];
|
|
|
+ [self locationPermissionJudgment];
|
|
|
+ self.stateView.clockInButton.userInteractionEnabled = YES;
|
|
|
}
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
/* 请求打卡信息 */
|
|
|
-- (void)clockIninfoAPI {
|
|
|
+- (void)requestClockIninfo {
|
|
|
|
|
|
self.clockInInfoAPI.latitude = self.latitude;
|
|
|
self.clockInInfoAPI.longitude = self.longitude;
|
|
|
[self.clockInInfoAPI start];
|
|
|
}
|
|
|
|
|
|
+/* 显示错误页面 */
|
|
|
+- (void)showErrorView {
|
|
|
+
|
|
|
+ [self.view showErrorView];
|
|
|
+ [self.view.errorView.refreshButton addTarget:self action:@selector(refreshButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+}
|
|
|
+
|
|
|
+/* 打卡的按钮的状态 */
|
|
|
+- (void)clockInButtonState {
|
|
|
+
|
|
|
+ self.infoView.timeLabel.attributedText = [self.infoView attributedText:[NSString stringWithFormat:@"%@ 小时",self.infoModel.sumDuration] DINCondensedBlod:self.infoModel.sumDuration];
|
|
|
+
|
|
|
+ self.infoView.advanceLabel.attributedText = [self.infoView attributedText:[NSString stringWithFormat:@"%.2f 元",[self.infoModel.sumMoney floatValue]] DINCondensedBlod:[NSString stringWithFormat:@"%.2f",[self.infoModel.sumMoney floatValue]]];
|
|
|
+
|
|
|
+ //上班打卡时间
|
|
|
+ if ([self.infoModel.startPunch isEqualToString:@"未完成"])
|
|
|
+ {
|
|
|
+ self.stateView.goWorkStateView.textLabel.text = self.infoModel.startPunch;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ self.stateView.goWorkStateView.textLabel.text = [HJAppService time_timestampToString:self.infoModel.startPunch withType:kTimeStampDateOnlyHMS];
|
|
|
+ }
|
|
|
+
|
|
|
+ //下班打卡时间
|
|
|
+ if ([self.infoModel.endPunch isEqualToString:@"未完成"])
|
|
|
+ {
|
|
|
+ self.stateView.afterWorkStateView.textLabel.text = self.infoModel.endPunch;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ self.stateView.afterWorkStateView.textLabel.text = [HJAppService time_timestampToString:self.infoModel.endPunch withType:kTimeStampDateOnlyHMS];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (self.infoModel.authenticationStatus == 1)
|
|
|
+ {//1:等待认证
|
|
|
+ self.stateView.stateType = HJClockInStateTypeAuthing;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if ([self.infoModel.clockType integerValue] == 1)
|
|
|
+ {
|
|
|
+ self.stateView.stateType = HJClockInStateTypeGoWork;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ([self.infoModel.clockType integerValue] == 1 && ![self.infoModel.startPunch isEqualToString: @"未完成"])
|
|
|
+ {
|
|
|
+ self.stateView.stateType = HJClockInStateTypeGoWorkComplete;
|
|
|
+ self.stateView.promptView.textLabel.text = [NSString stringWithFormat:@"上班%@小时后才能进行上班打卡",self.infoModel.dailyAvailableMinHour];
|
|
|
+ }
|
|
|
+
|
|
|
+ if ([self.infoModel.clockType integerValue] == 2)
|
|
|
+ {
|
|
|
+ self.stateView.stateType = HJClockInStateTypeAfterWork;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ([self.infoModel.clockType integerValue] == 3)
|
|
|
+ {
|
|
|
+ if ([self.infoModel.startPunch isEqualToString:@"未完成"])
|
|
|
+ {
|
|
|
+ self.stateView.stateType = HJClockInStateTypeGoWorkOutOfRange;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ self.stateView.stateType = HJClockInStateTypeAfterWorkOutOfRange;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ([self.infoModel.clockType integerValue] == 4)
|
|
|
+ {
|
|
|
+ self.stateView.stateType = HJClockInStateTypeComplete;
|
|
|
+ self.stateView.wageView.moneyLabel.text = self.infoModel.todayMoney;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - UIScrollViewDelegate
|
|
|
+
|
|
|
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
|
|
+
|
|
|
+ if (scrollView.contentOffset.y <= 0)
|
|
|
+ {
|
|
|
+ [_scrollLayoutView az_setGradientBackgroundWithColors:@[[UIColor colorFromHexString:@"016DFF"],[UIColor colorFromHexString:@"0254FF"]] locations:@[@(0.0),@(1.0f)] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ [_scrollLayoutView az_setGradientBackgroundWithColors:@[COLOR_F5F5F5,COLOR_F5F5F5] locations:@[@(0.0),@(1.0f)] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - FBScrollLayoutViewDelegate
|
|
|
|
|
|
- (void)scrollLayoutViewMakeConstraints:(FBScrollLayoutView *)scrollLayoutView {
|
|
|
|
|
|
[scrollLayoutView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
- make.left.right.top.bottom.equalTo(self.view).offset(0);
|
|
|
+ make.left.right.top.equalTo(self.view).offset(0);
|
|
|
+ make.bottom.equalTo(self.view.mas_bottom).offset(0);
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
@@ -205,6 +326,7 @@ FBAPIManagerDelegate
|
|
|
}
|
|
|
if (manager == self.clockInAPI)
|
|
|
{//打卡成功
|
|
|
+ self.stateView.clockInButton.userInteractionEnabled = YES;
|
|
|
HJClockInSuccessViewController *successVC = [[HJClockInSuccessViewController alloc] init];
|
|
|
successVC.dataDict = [manager fetchDataWithBox:self.dataBox];
|
|
|
if (self.stateView.stateType == HJClockInStateTypeGoWork)
|
|
|
@@ -217,7 +339,10 @@ FBAPIManagerDelegate
|
|
|
}
|
|
|
successVC.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
[self presentViewController:successVC animated:YES completion:nil];
|
|
|
- [self clockIninfoAPI];//打卡成功更新数据
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1*NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
|
|
|
+
|
|
|
+ [self requestClockIninfo];//打卡成功更新数据
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -229,7 +354,8 @@ FBAPIManagerDelegate
|
|
|
}
|
|
|
if (manager == self.clockInAPI)
|
|
|
{
|
|
|
- [self clockIninfoAPI];//打卡成功更新数据
|
|
|
+ [self requestClockIninfo];//打卡成功更新数据
|
|
|
+ self.stateView.clockInButton.userInteractionEnabled = YES;
|
|
|
}
|
|
|
|
|
|
id fetchData = [manager fetchDataWithBox:self.dataBox];
|
|
|
@@ -239,84 +365,6 @@ FBAPIManagerDelegate
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#pragma mark - Private methods
|
|
|
-
|
|
|
-/* 显示错误页面 */
|
|
|
-- (void)showErrorView {
|
|
|
-
|
|
|
- [self.view showErrorView];
|
|
|
- [self.view.errorView.refreshButton addTarget:self action:@selector(refreshButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
-}
|
|
|
-
|
|
|
-/* 打卡的按钮的状态 */
|
|
|
-- (void)clockInButtonState {
|
|
|
-
|
|
|
- self.infoView.timeLabel.attributedText = [self.infoView attributedText:[NSString stringWithFormat:@"%@小时",self.infoModel.sumDuration] DINCondensedBlod:self.infoModel.sumDuration];
|
|
|
-
|
|
|
- self.infoView.advanceLabel.attributedText = [self.infoView attributedText:[NSString stringWithFormat:@"%@元",self.infoModel.sumMoney] DINCondensedBlod:self.infoModel.sumMoney];
|
|
|
-
|
|
|
- //上班打卡时间
|
|
|
- if ([self.infoModel.startPunch isEqualToString:@"未完成"])
|
|
|
- {
|
|
|
- self.stateView.goWorkStateView.textLabel.text = self.infoModel.startPunch;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- self.stateView.goWorkStateView.textLabel.text = [HJAppService time_timestampToString:self.infoModel.startPunch withType:kTimeStampDateOnlyHMS];
|
|
|
- }
|
|
|
-
|
|
|
- //下班打卡时间
|
|
|
- if ([self.infoModel.endPunch isEqualToString:@"未完成"])
|
|
|
- {
|
|
|
- self.stateView.afterWorkStateView.textLabel.text = self.infoModel.endPunch;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- self.stateView.afterWorkStateView.textLabel.text = [HJAppService time_timestampToString:self.infoModel.endPunch withType:kTimeStampDateOnlyHMS];
|
|
|
- }
|
|
|
-
|
|
|
- if (self.infoModel.authenticationStatus == 1)
|
|
|
- {//1:等待认证
|
|
|
- self.stateView.stateType = HJClockInStateTypeAuthing;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if ([self.infoModel.clockType integerValue] == 1)
|
|
|
- {
|
|
|
- self.stateView.stateType = HJClockInStateTypeGoWork;
|
|
|
- }
|
|
|
-
|
|
|
- if ([self.infoModel.clockType integerValue] == 1 && ![self.infoModel.startPunch isEqualToString: @"未完成"])
|
|
|
- {
|
|
|
- self.stateView.stateType = HJClockInStateTypeGoWorkComplete;
|
|
|
- self.stateView.promptView.textLabel.text = [NSString stringWithFormat:@"上班%@小时后才能进行上班打卡",self.infoModel.dailyAvailableMinHour];
|
|
|
- }
|
|
|
-
|
|
|
- if ([self.infoModel.clockType integerValue] == 2)
|
|
|
- {
|
|
|
- self.stateView.stateType = HJClockInStateTypeAfterWork;
|
|
|
- }
|
|
|
-
|
|
|
- if ([self.infoModel.clockType integerValue] == 3)
|
|
|
- {
|
|
|
- if ([self.infoModel.startPunch isEqualToString:@"未完成"])
|
|
|
- {
|
|
|
- self.stateView.stateType = HJClockInStateTypeGoWorkOutOfRange;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- self.stateView.stateType = HJClockInStateTypeAfterWorkOutOfRange;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if ([self.infoModel.clockType integerValue] == 4)
|
|
|
- {
|
|
|
- self.stateView.stateType = HJClockInStateTypeComplete;
|
|
|
- self.stateView.wageView.moneyLabel.text = self.infoModel.todayMoney;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
#pragma mark - Notification
|
|
|
|
|
|
- (void)realNameNotification:(NSNotification *)notification {
|
|
|
@@ -337,6 +385,22 @@ FBAPIManagerDelegate
|
|
|
|
|
|
#pragma mark - event
|
|
|
|
|
|
+- (void)confirmButtonAction:(UIButton *)btn {
|
|
|
+
|
|
|
+ [self dismissViewControllerAnimated:YES completion:nil];
|
|
|
+ NSURL *url= [NSURL URLWithString:UIApplicationOpenSettingsURLString];
|
|
|
+ if( [[UIApplication sharedApplication]canOpenURL:url] )
|
|
|
+ {
|
|
|
+ if (@available(iOS 10.0, *))
|
|
|
+ {
|
|
|
+ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ [[UIApplication sharedApplication]openURL:url];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
/* 错误刷新 */
|
|
|
- (void)refreshButtonAction:(UIButton *)btn {
|
|
|
|
|
|
@@ -355,9 +419,8 @@ FBAPIManagerDelegate
|
|
|
- (void)statisticsButtonClick:(UIButton *)btn {
|
|
|
|
|
|
HJClockInStatisticViewController *statisticsVC = [[HJClockInStatisticViewController alloc] init];
|
|
|
- UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:statisticsVC];
|
|
|
- navi.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
|
- [self presentViewController:navi animated:YES completion:nil];
|
|
|
+ statisticsVC.hidesBottomBarWhenPushed = YES;
|
|
|
+ [self.navigationController pushViewController:statisticsVC animated:YES];
|
|
|
}
|
|
|
|
|
|
/* 规则 */
|
|
|
@@ -381,12 +444,14 @@ FBAPIManagerDelegate
|
|
|
|
|
|
if (self.stateView.stateType == HJClockInStateTypeGoWork)
|
|
|
{
|
|
|
+ self.stateView.clockInButton.userInteractionEnabled = NO;
|
|
|
self.clockInAPI.clockType = @"1";
|
|
|
self.clockInAPI.wsPunchClockId = @"";
|
|
|
[self locationShowLoading:YES clockInAPI:YES];
|
|
|
}
|
|
|
if (self.stateView.stateType == HJClockInStateTypeAfterWork)
|
|
|
{
|
|
|
+ self.stateView.clockInButton.userInteractionEnabled = NO;
|
|
|
self.clockInAPI.clockType = @"2";
|
|
|
self.clockInAPI.wsPunchClockId = self.infoModel.wsPunchClockId;
|
|
|
[self locationShowLoading:YES clockInAPI:YES];
|
|
|
@@ -414,9 +479,10 @@ FBAPIManagerDelegate
|
|
|
{
|
|
|
_scrollLayoutView = [[FBScrollLayoutView alloc] init];
|
|
|
_scrollLayoutView.delegate = self;
|
|
|
- _scrollLayoutView.backgroundColor = COLOR_F5F5F5;
|
|
|
+ [_scrollLayoutView az_setGradientBackgroundWithColors:@[COLOR_F5F5F5,COLOR_F5F5F5] locations:@[@(0.0),@(1.0f)] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
|
|
|
_scrollLayoutView.contentView.backgroundColor = COLOR_F5F5F5;
|
|
|
_scrollLayoutView.scrollView.mj_header = self.refreshHeader;
|
|
|
+ _scrollLayoutView.scrollView.delegate = self;
|
|
|
// 去除顶部空白
|
|
|
if (@available(iOS 11.0, *))
|
|
|
{
|
|
|
@@ -426,7 +492,6 @@ FBAPIManagerDelegate
|
|
|
{
|
|
|
self.automaticallyAdjustsScrollViewInsets = NO;
|
|
|
}
|
|
|
- self.edgesForExtendedLayout = UIRectEdgeNone;
|
|
|
}
|
|
|
return _scrollLayoutView;
|
|
|
}
|
|
|
@@ -514,6 +579,7 @@ FBAPIManagerDelegate
|
|
|
if (_refreshHeader == nil)
|
|
|
{
|
|
|
_refreshHeader = [HJRefreshHeaderView headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
|
|
|
+ _refreshHeader.backgroundColor = [UIColor clearColor];
|
|
|
}
|
|
|
return _refreshHeader;
|
|
|
}
|