|
|
@@ -23,11 +23,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
- import config from '@/config.js'
|
|
|
import { ref } from 'vue'
|
|
|
- import { useUserStore } from '@/store/user.js'
|
|
|
+ import { checkAttendance } from '@/api/mine.js'
|
|
|
+ import config from '@/config.js'
|
|
|
import $modal from '@/plugins/modal.js'
|
|
|
import $tab from '@/plugins/tab.js'
|
|
|
+ import { useUserStore } from '@/store/user.js'
|
|
|
const userStore = useUserStore()
|
|
|
const loginForm = ref({
|
|
|
username: '',
|
|
|
@@ -51,7 +52,44 @@
|
|
|
}
|
|
|
function loginSuccess() {
|
|
|
userStore.GetInfo()
|
|
|
- $tab.reLaunch('/pages/message/index')
|
|
|
+ // 是否在上班打卡时间段
|
|
|
+ if (isInTimeRange(...config.signInTimeRange)) {
|
|
|
+ const now = new Date()
|
|
|
+ const params = {
|
|
|
+ universalid: userStore.useId,
|
|
|
+ rizi: (now.getFullYear()) + '-' + (now.getMonth() + 1) + '-' + (now.getDate())
|
|
|
+ }
|
|
|
+ // 获取当天考勤信息
|
|
|
+ checkAttendance(params).then(({ returnParams }) => {
|
|
|
+ if (returnParams.list.length) {
|
|
|
+ // 已签到 跳转消息页
|
|
|
+ $tab.reLaunch('/pages/message/index')
|
|
|
+ } else {
|
|
|
+ // 未签到 跳转考勤页面
|
|
|
+ $tab.reLaunch('/pages/message/index?to=clockIn')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ $tab.reLaunch('/pages/message/index')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //判断时间是否在区间内
|
|
|
+ function 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>
|
|
|
|