|
|
@@ -26,25 +26,49 @@ export default {
|
|
|
const user = getUserInfo()
|
|
|
if (!getUserInfo()) {
|
|
|
$tab.reLaunch('/pages/login')
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
+ // 是否在上班打卡时间段
|
|
|
+ if (this.isInTimeRange('08:30:00', '10:00:00')) {
|
|
|
const now = new Date()
|
|
|
const params = {
|
|
|
universalid: user.useId,
|
|
|
rizi: (now.getFullYear()) + '-' + (now.getMonth() + 1) + '-' + (now.getDate())
|
|
|
}
|
|
|
- CheckAttendance(params).then(({ returnParams }) => { // 获取当天考勤信息
|
|
|
- if (returnParams.list.length) {
|
|
|
- // 已签到 跳转消息页面
|
|
|
+ // 获取当天考勤信息
|
|
|
+ CheckAttendance(params).then(({ returnParams }) => {
|
|
|
+ if (returnParams.list.length) {
|
|
|
+ // 已签到 跳转消息页
|
|
|
$tab.reLaunch('/pages/message/index')
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
// 未签到 跳转考勤页面
|
|
|
$tab.reLaunch('/pages/message/index?to=clockIn')
|
|
|
}
|
|
|
})
|
|
|
+ } else {
|
|
|
+ $tab.reLaunch('/pages/message/index')
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //判断时间是否在区间内
|
|
|
+ isInTimeRange(start, end) {
|
|
|
+ // 获取当前时间戳
|
|
|
+ const now = Date.now();
|
|
|
+
|
|
|
+ // 获取当前日期
|
|
|
+ const currentDate = new Date(now);
|
|
|
+ const year = currentDate.getFullYear();
|
|
|
+ const month = currentDate.getMonth();
|
|
|
+ const day = currentDate.getDate();
|
|
|
+
|
|
|
+ // 构建当天的起始时间和结束时间的时间戳
|
|
|
+ const startTime = new Date(year, month, day, ...start.split(':').map(Number)).getTime();
|
|
|
+ const endTime = new Date(year, month, day, ...end.split(':').map(Number)).getTime();
|
|
|
+
|
|
|
+ // 判断当前时间是否在范围内
|
|
|
+ return now >= startTime && now <= endTime;
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
@@ -65,6 +89,7 @@ page {
|
|
|
/* #endif */
|
|
|
.example-info {
|
|
|
font-size: 14px;
|
|
|
- color: #333; padding: 10px;
|
|
|
- }
|
|
|
+ color: #333;
|
|
|
+ padding: 10px;
|
|
|
+}
|
|
|
</style>
|