|
|
@@ -36,7 +36,7 @@
|
|
|
</atl-map>
|
|
|
<!-- 打卡按钮 -->
|
|
|
<view class="footer">
|
|
|
- <button type="primary" @click="signIn">上班签到</button>
|
|
|
+ <button type="primary" @click="signIn" :disabled="isSignInDisabled">上班签到</button>
|
|
|
<button type="default" @click="signOut">下班签退</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -44,403 +44,425 @@
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
-import { onMounted,reactive,ref} from 'vue';
|
|
|
-// 导入地理位置相关函数
|
|
|
-import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
|
|
-import {point,polygon} from "@turf/helpers";
|
|
|
-import {useUserStore} from '@/store/user';
|
|
|
-import $modal from '@/plugins/modal.js'
|
|
|
-import $tab from '@/plugins/tab.js';
|
|
|
-import config from '@/config.js';
|
|
|
-import {createAttendance,TranAddress,CheckAttendance} from '@/api/mine.js'
|
|
|
-const userStore = useUserStore();
|
|
|
-const thisUser = userStore.user;
|
|
|
-
|
|
|
-// 组件挂载后初始化当前日期与位置
|
|
|
-onMounted(() => {
|
|
|
- dateInit();
|
|
|
- getlocation();
|
|
|
-});
|
|
|
-
|
|
|
-
|
|
|
-// 当前日期和时间相关信息
|
|
|
-const currentDate = ref('2023-04-01');
|
|
|
-const currentDay = ref('星期三');
|
|
|
-const clockInStatus = ref(''); // 打卡状态
|
|
|
-const weekArr = reactive(['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']); // 星期数组
|
|
|
-const signInTime = ref(''); // 上班签到时间
|
|
|
-const signOutTime = ref(''); // 下班签到时间
|
|
|
-
|
|
|
-// 初始化日期
|
|
|
-function dateInit() {
|
|
|
- const nowDate = new Date();
|
|
|
- const year = nowDate.getFullYear(); // 获取年份
|
|
|
- const month = nowDate.getMonth() + 1; // 获取月份
|
|
|
- const day = nowDate.getDate(); // 获取日期
|
|
|
- // 格式化月份和日期为两位数
|
|
|
- const formattedMonth = month < 10 ? '0' + month : month;
|
|
|
- const formattedDay = day < 10 ? '0' + day : day;
|
|
|
- currentDate.value = `${year}-${formattedMonth}-${formattedDay}`; // 设置当前日期
|
|
|
- const dayOfWeek = nowDate.getDay(); // 获取当前星期
|
|
|
- currentDay.value = weekArr[dayOfWeek]; // 设置当前星期
|
|
|
- getTodayAtt();
|
|
|
-}
|
|
|
-
|
|
|
-//获取今天考勤状态
|
|
|
-function getTodayAtt() {
|
|
|
-
|
|
|
- const params = {
|
|
|
- universalid: thisUser.useId,
|
|
|
- rizi: currentDate.value
|
|
|
+ import {
|
|
|
+ onMounted,
|
|
|
+ reactive,
|
|
|
+ ref
|
|
|
+ } from 'vue';
|
|
|
+ // 导入地理位置相关函数
|
|
|
+ import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
|
|
+ import {
|
|
|
+ point,
|
|
|
+ polygon
|
|
|
+ } from "@turf/helpers";
|
|
|
+ import {
|
|
|
+ useUserStore
|
|
|
+ } from '@/store/user';
|
|
|
+ import $modal from '@/plugins/modal.js'
|
|
|
+ import $tab from '@/plugins/tab.js';
|
|
|
+ import config from '@/config.js';
|
|
|
+ import {
|
|
|
+ createAttendance,
|
|
|
+ TranAddress,
|
|
|
+ CheckAttendance
|
|
|
+ } from '@/api/mine.js'
|
|
|
+ const userStore = useUserStore();
|
|
|
+ const thisUser = userStore.user;
|
|
|
+
|
|
|
+ // 组件挂载后初始化当前日期与位置
|
|
|
+ onMounted(() => {
|
|
|
+ dateInit();
|
|
|
+ getlocation();
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ // 当前日期和时间相关信息
|
|
|
+ const currentDate = ref('2023-04-01');
|
|
|
+ const currentDay = ref('星期三');
|
|
|
+ const clockInStatus = ref(''); // 打卡状态
|
|
|
+ const weekArr = reactive(['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']); // 星期数组
|
|
|
+ const signInTime = ref(''); // 上班签到时间
|
|
|
+ const signOutTime = ref(''); // 下班签到时间
|
|
|
+
|
|
|
+ // 初始化日期
|
|
|
+ function dateInit() {
|
|
|
+ const nowDate = new Date();
|
|
|
+ const year = nowDate.getFullYear(); // 获取年份
|
|
|
+ const month = nowDate.getMonth() + 1; // 获取月份
|
|
|
+ const day = nowDate.getDate(); // 获取日期
|
|
|
+ // 格式化月份和日期为两位数
|
|
|
+ const formattedMonth = month < 10 ? '0' + month : month;
|
|
|
+ const formattedDay = day < 10 ? '0' + day : day;
|
|
|
+ currentDate.value = `${year}-${formattedMonth}-${formattedDay}`; // 设置当前日期
|
|
|
+ const dayOfWeek = nowDate.getDay(); // 获取当前星期
|
|
|
+ currentDay.value = weekArr[dayOfWeek]; // 设置当前星期
|
|
|
+ getTodayAtt();
|
|
|
}
|
|
|
- CheckAttendance(params).then(res => {
|
|
|
- if ("success" == res.returnMsg) {
|
|
|
- // console.log("kaoqin",res);
|
|
|
- const attList = res.returnParams.list;
|
|
|
- const time1 = attList.find(item => item.att_type_id === '1');
|
|
|
- const time2 = attList.find(item => item.att_type_id === '2');
|
|
|
- if (time1 !== undefined) {
|
|
|
- signInTime.value = time1.att_time.split(' ')[1];
|
|
|
- }
|
|
|
- if (time2 !== undefined) {
|
|
|
- signOutTime.value = time2.att_time.split(' ')[1];
|
|
|
+
|
|
|
+ //获取今天考勤状态
|
|
|
+ function getTodayAtt() {
|
|
|
+
|
|
|
+ const params = {
|
|
|
+ universalid: thisUser.useId,
|
|
|
+ rizi: currentDate.value
|
|
|
+ }
|
|
|
+ CheckAttendance(params).then(res => {
|
|
|
+ if ("success" == res.returnMsg) {
|
|
|
+ // console.log("kaoqin",res);
|
|
|
+ const attList = res.returnParams.list;
|
|
|
+ const time1 = attList.find(item => item.att_type_id === '1');
|
|
|
+ const time2 = attList.find(item => item.att_type_id === '2');
|
|
|
+ if (time1 !== undefined) {
|
|
|
+ signInTime.value = time1.att_time.split(' ')[1];
|
|
|
+ }
|
|
|
+ if (time2 !== undefined) {
|
|
|
+ signOutTime.value = time2.att_time.split(' ')[1];
|
|
|
+ }
|
|
|
}
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // const attType = ref(0)
|
|
|
+ // 上班签到
|
|
|
+ const isSignInDisabled=ref(false)
|
|
|
+ function signIn() {
|
|
|
+ const now = getNowTime();
|
|
|
+ //判断打卡时间是否符合
|
|
|
+ if (!isTimeInRange(now, '08:30:00', '10:00:00')) {
|
|
|
+ $modal.msg('不在签到时间8:30--10:00内')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // attType.value=1;
|
|
|
+ var attType = 1;
|
|
|
+ getAddress();
|
|
|
+ if(clockIn(attType)){
|
|
|
+ isSignInDisabled.value=true
|
|
|
}
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// const attType = ref(0)
|
|
|
-// 上班签到
|
|
|
-function signIn() {
|
|
|
- const now = getNowTime();
|
|
|
- //判断打卡时间是否符合
|
|
|
- if (!isTimeInRange(now, '08:30:00', '10:00:00')) {
|
|
|
- $modal.msg('不在签到时间8:30--10:00内')
|
|
|
- return;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 下班签退
|
|
|
+ function signOut() {
|
|
|
+ const now = getNowTime();
|
|
|
+ //判断打卡时间是否符合
|
|
|
+ if (!isTimeInRange(now, '15:00:00', '20:00:00')) {
|
|
|
+ $modal.msg('不在签退时间15:00--20:00内')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var attType = 2;
|
|
|
+ getAddress();
|
|
|
+ clockIn(attType); // 执行打卡并获取结果
|
|
|
+ };
|
|
|
+
|
|
|
+ //获取当前时间
|
|
|
+ function getNowTime() {
|
|
|
+ var now = new Date();
|
|
|
+ // 获取小时、分钟和秒
|
|
|
+ var hours = now.getHours(); // 获取小时(0-23)
|
|
|
+ var minutes = now.getMinutes(); // 获取分钟(0-59)
|
|
|
+ var seconds = now.getSeconds(); // 获取秒(0-59)
|
|
|
+ // 将小时、分钟或秒格式化为两位数
|
|
|
+ hours = hours < 10 ? '0' + hours : hours;
|
|
|
+ minutes = minutes < 10 ? '0' + minutes : minutes;
|
|
|
+ seconds = seconds < 10 ? '0' + seconds : seconds;
|
|
|
+ return `${hours}:${minutes}:${seconds}`;
|
|
|
}
|
|
|
- // attType.value=1;
|
|
|
- var attType = 1;
|
|
|
- getAddress();
|
|
|
- clockIn(attType); // 执行打卡
|
|
|
-};
|
|
|
-
|
|
|
-// 下班签退
|
|
|
-function signOut() {
|
|
|
- const now = getNowTime();
|
|
|
- //判断打卡时间是否符合
|
|
|
- if (!isTimeInRange(now, '15:00:00', '20:00:00')) {
|
|
|
- $modal.msg('不在签退时间15:00--20:00内')
|
|
|
- return;
|
|
|
+
|
|
|
+ //判断时间是否在区间内
|
|
|
+ function isTimeInRange(time, startTime, endTime) {
|
|
|
+ // 将时间字符串转换为Date对象
|
|
|
+ var timeObj = new Date('1970-01-01T' + time + 'Z');
|
|
|
+ var startObj = new Date('1970-01-01T' + startTime + 'Z');
|
|
|
+ var endObj = new Date('1970-01-01T' + endTime + 'Z');
|
|
|
+ // 比较时间
|
|
|
+ return timeObj >= startObj && timeObj <= endObj;
|
|
|
}
|
|
|
|
|
|
- var attType = 2;
|
|
|
- getAddress();
|
|
|
- clockIn(attType); // 执行打卡并获取结果
|
|
|
-};
|
|
|
-
|
|
|
-//获取当前时间
|
|
|
-function getNowTime() {
|
|
|
- var now = new Date();
|
|
|
- // 获取小时、分钟和秒
|
|
|
- var hours = now.getHours(); // 获取小时(0-23)
|
|
|
- var minutes = now.getMinutes(); // 获取分钟(0-59)
|
|
|
- var seconds = now.getSeconds(); // 获取秒(0-59)
|
|
|
- // 将小时、分钟或秒格式化为两位数
|
|
|
- hours = hours < 10 ? '0' + hours : hours;
|
|
|
- minutes = minutes < 10 ? '0' + minutes : minutes;
|
|
|
- seconds = seconds < 10 ? '0' + seconds : seconds;
|
|
|
- return `${hours}:${minutes}:${seconds}`;
|
|
|
-}
|
|
|
-
|
|
|
-//判断时间是否在区间内
|
|
|
-function isTimeInRange(time, startTime, endTime) {
|
|
|
- // 将时间字符串转换为Date对象
|
|
|
- var timeObj = new Date('1970-01-01T' + time + 'Z');
|
|
|
- var startObj = new Date('1970-01-01T' + startTime + 'Z');
|
|
|
- var endObj = new Date('1970-01-01T' + endTime + 'Z');
|
|
|
- // 比较时间
|
|
|
- return timeObj >= startObj && timeObj <= endObj;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-// 地图配置信息
|
|
|
-// const mapKey = config.mapKey; // 地图API密钥
|
|
|
-const mapType = ref('tmap'); // 地图类型
|
|
|
-const address = ref(''); // 初始化地址
|
|
|
-
|
|
|
-// 打卡定位信息
|
|
|
-const longitude = ref(0); // 经度
|
|
|
-const latitude = ref(0); // 纬度
|
|
|
-
|
|
|
-// 标记信息
|
|
|
-const marker = reactive({
|
|
|
- id: 1,
|
|
|
- latitude: 25.958812,
|
|
|
- longitude: 119.213036,
|
|
|
- width: 50, // 标记宽度
|
|
|
- height: 50, // 标记高度
|
|
|
- title: '宇光同行' // 标记标题
|
|
|
-});
|
|
|
-
|
|
|
-// 获取当前定位经纬度
|
|
|
-function getlocation() {
|
|
|
- wx.getLocation({
|
|
|
- // type: 'gcj02',
|
|
|
- success: (res) => {
|
|
|
- longitude.value = res.longitude; // 保存经度
|
|
|
- latitude.value = res.latitude; // 保存纬度
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- // 获取位置失败时提示用户打开权限
|
|
|
- uni.showModal({
|
|
|
- content: '检测到您没打开获取位置功能权限,是否去设置打开?',
|
|
|
- confirmText: "确认",
|
|
|
- cancelText: '取消',
|
|
|
- success: (res) => {
|
|
|
- console.log('res.confirm', res.confirm);
|
|
|
- if (res.confirm) {
|
|
|
- uni.openSetting({
|
|
|
- success: (res) => {
|
|
|
- $modal.msg('授权后请重新打开此页面')
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- // console.log(err);
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: '获取地理位置授权失败',
|
|
|
- icon: 'none',
|
|
|
- success: () => {
|
|
|
- // 返回上一页
|
|
|
- setTimeout(() => {
|
|
|
- // $modal.msg('返回上一页')
|
|
|
- $tab.navigateBack()
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
+
|
|
|
+ // 地图配置信息
|
|
|
+ // const mapKey = config.mapKey; // 地图API密钥
|
|
|
+ const mapType = ref('tmap'); // 地图类型
|
|
|
+ const address = ref(''); // 初始化地址
|
|
|
+
|
|
|
+ // 打卡定位信息
|
|
|
+ const longitude = ref(0); // 经度
|
|
|
+ const latitude = ref(0); // 纬度
|
|
|
+
|
|
|
+ // 标记信息
|
|
|
+ const marker = reactive({
|
|
|
+ id: 1,
|
|
|
+ latitude: 25.958812,
|
|
|
+ longitude: 119.213036,
|
|
|
+ width: 50, // 标记宽度
|
|
|
+ height: 50, // 标记高度
|
|
|
+ title: '宇光同行' // 标记标题
|
|
|
});
|
|
|
-}
|
|
|
-
|
|
|
-// 获取当前位置地址
|
|
|
-async function getAddress() {
|
|
|
- getlocation(); // 获取当前位置
|
|
|
- tranAddress(); // 执行地址转换
|
|
|
-}
|
|
|
-
|
|
|
-// 经纬度转地址
|
|
|
-function tranAddress() {
|
|
|
- let locationStr = latitude.value + ',' + longitude.value; // 组合经纬度
|
|
|
- TranAddress(locationStr).then(res => {
|
|
|
- console.log('请求成功', res);
|
|
|
- address.value = res.result.address; // 保存地址
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.error('请求失败', err); // 请求错误处理
|
|
|
- })
|
|
|
|
|
|
- // uni.request({
|
|
|
- // url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + locationStr + '&key=' + mapKey.value +
|
|
|
- // '&get_poi=1',
|
|
|
- // method: 'GET',
|
|
|
- // success: function(res) {
|
|
|
- // console.log('请求成功', res.data);
|
|
|
- // address.value = res.data.result.address; // 保存地址
|
|
|
- // },
|
|
|
- // fail: function(err) {
|
|
|
- // console.error('请求失败', err); // 请求错误处理
|
|
|
- // }
|
|
|
- // });
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-// 多边形区域设置
|
|
|
-const polygons = reactive([{
|
|
|
- points: [{
|
|
|
- latitude: 25.9591401,
|
|
|
- longitude: 119.21292356
|
|
|
- },
|
|
|
- {
|
|
|
- latitude: 25.95828592,
|
|
|
- longitude: 119.21261955
|
|
|
- },
|
|
|
- {
|
|
|
- latitude: 25.9576709,
|
|
|
- longitude: 119.21458294
|
|
|
- },
|
|
|
- {
|
|
|
- latitude: 25.95845106,
|
|
|
- longitude: 119.21486162
|
|
|
- },
|
|
|
- {
|
|
|
- latitude: 25.9591401,
|
|
|
- longitude: 119.21292356
|
|
|
+ // 获取当前定位经纬度
|
|
|
+ function getlocation() {
|
|
|
+ wx.getLocation({
|
|
|
+ // type: 'gcj02',
|
|
|
+ success: (res) => {
|
|
|
+ longitude.value = res.longitude; // 保存经度
|
|
|
+ latitude.value = res.latitude; // 保存纬度
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ if (err.errMsg.includes("频繁调用")) {
|
|
|
+ $modal.msg('请勿频繁调用');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 获取位置失败时提示用户打开权限
|
|
|
+ uni.showModal({
|
|
|
+ content: '检测到您没打开获取位置功能权限,是否去设置打开?',
|
|
|
+ confirmText: "确认",
|
|
|
+ cancelText: '取消',
|
|
|
+ success: (res) => {
|
|
|
+ console.log('res.confirm', res.confirm);
|
|
|
+ if (res.confirm) {
|
|
|
+ uni.openSetting({
|
|
|
+ success: (res) => {
|
|
|
+ $modal.msg('授权后请重新打开此页面')
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取地理位置授权失败',
|
|
|
+ icon: 'none',
|
|
|
+ success: () => {
|
|
|
+ // 返回上一页
|
|
|
+ setTimeout(() => {
|
|
|
+ // $modal.msg('返回上一页')
|
|
|
+ $tab.navigateBack()
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
}
|
|
|
- ],
|
|
|
- strokeWidth: 1, // 边框宽度
|
|
|
- strokeColor: "#ff000066", // 边框颜色
|
|
|
- fillColor: "#ff000016", // 填充颜色
|
|
|
-}]);
|
|
|
-
|
|
|
-// 打卡
|
|
|
-function clockIn(attType) {
|
|
|
- // 发起打卡请求相关业务逻辑
|
|
|
- //判断是否已经打过卡
|
|
|
- if (isClockIn(attType)) {
|
|
|
- return;
|
|
|
+
|
|
|
+ // 获取当前位置地址
|
|
|
+ function getAddress() {
|
|
|
+ getlocation(); // 获取当前位置
|
|
|
+ tranAddress(); // 执行地址转换
|
|
|
}
|
|
|
- var now = new Date();
|
|
|
- // 使用toISOString()获取一个ISO格式的字符串,然后替换T为空格,并去除最后的Z(表示UTC时间)
|
|
|
- var formatted = now.toISOString().replace('T', ' ').replace('Z', '');
|
|
|
- var localString = new Date(formatted + '-08:00').toISOString().replace('T', ' ').replace('Z', '');
|
|
|
- // console.log('nowtime',formatted,localString);
|
|
|
- const params = {
|
|
|
- user_name: thisUser.userName,
|
|
|
- user_id: thisUser.useId,
|
|
|
- kaoqin_type: attType,
|
|
|
- now_date: localString,
|
|
|
- longitude: longitude.value,
|
|
|
- latitude: latitude.value,
|
|
|
- address: address.value,
|
|
|
- unitId: thisUser.unitId
|
|
|
- };
|
|
|
- createAttendance(params).then(res => {
|
|
|
- // console.log('createAttendance',res);
|
|
|
- if ("success" == res.returnMsg) {
|
|
|
- uni.showToast({
|
|
|
- title: "打卡成功",
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- getTodayAtt(); //更新今日考勤数据
|
|
|
- } else {
|
|
|
+
|
|
|
+ // 经纬度转地址
|
|
|
+ function tranAddress() {
|
|
|
+ let locationStr = latitude.value + ',' + longitude.value; // 组合经纬度
|
|
|
+ TranAddress(locationStr).then(res => {
|
|
|
+ console.log('请求成功', res);
|
|
|
+ address.value = res.result.address; // 保存地址
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error('请求失败', err); // 请求错误处理
|
|
|
+ })
|
|
|
+
|
|
|
+ // uni.request({
|
|
|
+ // url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + locationStr + '&key=' + mapKey.value +
|
|
|
+ // '&get_poi=1',
|
|
|
+ // method: 'GET',
|
|
|
+ // success: function(res) {
|
|
|
+ // console.log('请求成功', res.data);
|
|
|
+ // address.value = res.data.result.address; // 保存地址
|
|
|
+ // },
|
|
|
+ // fail: function(err) {
|
|
|
+ // console.error('请求失败', err); // 请求错误处理
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 多边形区域设置
|
|
|
+ const polygons = reactive([{
|
|
|
+ points: [{
|
|
|
+ latitude: 25.9591401,
|
|
|
+ longitude: 119.21292356
|
|
|
+ },
|
|
|
+ {
|
|
|
+ latitude: 25.95828592,
|
|
|
+ longitude: 119.21261955
|
|
|
+ },
|
|
|
+ {
|
|
|
+ latitude: 25.9576709,
|
|
|
+ longitude: 119.21458294
|
|
|
+ },
|
|
|
+ {
|
|
|
+ latitude: 25.95845106,
|
|
|
+ longitude: 119.21486162
|
|
|
+ },
|
|
|
+ {
|
|
|
+ latitude: 25.9591401,
|
|
|
+ longitude: 119.21292356
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ strokeWidth: 1, // 边框宽度
|
|
|
+ strokeColor: "#ff000066", // 边框颜色
|
|
|
+ fillColor: "#ff000016", // 填充颜色
|
|
|
+ }]);
|
|
|
+
|
|
|
+ // 打卡
|
|
|
+ function clockIn(attType) {
|
|
|
+ // 发起打卡请求相关业务逻辑
|
|
|
+ //判断是否已经打过卡
|
|
|
+ if (isClockIn(attType)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var now = new Date();
|
|
|
+ // 使用toISOString()获取一个ISO格式的字符串,然后替换T为空格,并去除最后的Z(表示UTC时间)
|
|
|
+ var formatted = now.toISOString().replace('T', ' ').replace('Z', '');
|
|
|
+ var localString = new Date(formatted + '-08:00').toISOString().replace('T', ' ').replace('Z', '');
|
|
|
+ // console.log('nowtime',formatted,localString);
|
|
|
+ const params = {
|
|
|
+ user_name: thisUser.userName,
|
|
|
+ user_id: thisUser.useId,
|
|
|
+ kaoqin_type: attType,
|
|
|
+ now_date: localString,
|
|
|
+ longitude: longitude.value,
|
|
|
+ latitude: latitude.value,
|
|
|
+ address: address.value,
|
|
|
+ unitId: thisUser.unitId
|
|
|
+ };
|
|
|
+ createAttendance(params).then(res => {
|
|
|
+ // console.log('createAttendance',res);
|
|
|
+ if ("success" == res.returnMsg) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "打卡成功",
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ getTodayAtt(); //更新今日考勤数据
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: "未在指定范围,打卡失败",
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // const _polygons = polygons.map((polygon) => {
|
|
|
+ // return polygon.points.map((i) => [
|
|
|
+ // Number(i.longitude),
|
|
|
+ // Number(i.latitude),
|
|
|
+ // ]);
|
|
|
+ // });
|
|
|
+ // const _point = point([longitude.value, latitude.value]); // 用当前坐标创建点
|
|
|
+ // const _polygon = polygon(_polygons); // 创建多边形
|
|
|
+ // const f = booleanPointInPolygon(_point, _polygon); // 判断点是否在多边形内
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断是否已经打卡
|
|
|
+ function isClockIn(attType) {
|
|
|
+ var attTypeData = '';
|
|
|
+ switch (attType) {
|
|
|
+ case 1:
|
|
|
+ attTypeData = signInTime.value;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ console.log('attTypeData', attTypeData);
|
|
|
+ if ('' !== attTypeData) {
|
|
|
uni.showToast({
|
|
|
- title: "未在指定范围,打卡失败",
|
|
|
+ title: "请勿重复打卡",
|
|
|
icon: 'none'
|
|
|
});
|
|
|
+ return true;
|
|
|
}
|
|
|
- })
|
|
|
- // const _polygons = polygons.map((polygon) => {
|
|
|
- // return polygon.points.map((i) => [
|
|
|
- // Number(i.longitude),
|
|
|
- // Number(i.latitude),
|
|
|
- // ]);
|
|
|
- // });
|
|
|
- // const _point = point([longitude.value, latitude.value]); // 用当前坐标创建点
|
|
|
- // const _polygon = polygon(_polygons); // 创建多边形
|
|
|
- // const f = booleanPointInPolygon(_point, _polygon); // 判断点是否在多边形内
|
|
|
-}
|
|
|
-
|
|
|
-//判断是否已经打卡
|
|
|
-function isClockIn(attType) {
|
|
|
- var attTypeData = '';
|
|
|
- switch (attType) {
|
|
|
- case 1:
|
|
|
- attTypeData = signInTime.value;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- break;
|
|
|
- }
|
|
|
- console.log('attTypeData', attTypeData);
|
|
|
- if ('' !== attTypeData) {
|
|
|
- uni.showToast({
|
|
|
- title: "请勿重复打卡",
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- return true;
|
|
|
+ return false;
|
|
|
}
|
|
|
- return false;
|
|
|
-}
|
|
|
</script>
|
|
|
|
|
|
<style>
|
|
|
-@import "@/static/font/ygoa/iconfont.css";
|
|
|
-
|
|
|
-.ygoa-icon {
|
|
|
- margin-right: 20rpx;
|
|
|
- font-size: 50rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.container {
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- align-items: center;
|
|
|
- padding: 20rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.header {
|
|
|
- width: 100%;
|
|
|
- height: 200rpx;
|
|
|
- background-color: #f8f8f8;
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
-}
|
|
|
-
|
|
|
-.day {
|
|
|
- font-size: 55rpx;
|
|
|
- font-weight: bold;
|
|
|
-}
|
|
|
-
|
|
|
-.date {
|
|
|
- font-size: 30rpx;
|
|
|
- color: #666;
|
|
|
-}
|
|
|
-
|
|
|
-.status {
|
|
|
- font-size: 24rpx;
|
|
|
- color: black;
|
|
|
-}
|
|
|
-
|
|
|
-.record {
|
|
|
- width: 100%;
|
|
|
- margin-top: 20rpx;
|
|
|
- border-top: 1px solid #ddd;
|
|
|
- border-bottom: 1px solid #ddd;
|
|
|
- padding: 0 15rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.record-item {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- height: 100rpx;
|
|
|
- border-bottom: 1px solid #eee;
|
|
|
-}
|
|
|
-
|
|
|
-.icon {
|
|
|
- width: 50rpx;
|
|
|
- height: 50rpx;
|
|
|
- margin-right: 10rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.title {
|
|
|
- font-size: 28rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.time {
|
|
|
- font-size: 24rpx;
|
|
|
- color: #999;
|
|
|
- margin-left: auto;
|
|
|
-}
|
|
|
-
|
|
|
-.map {
|
|
|
- width: 100%;
|
|
|
- height: 500rpx;
|
|
|
- margin-top: 20rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.footer {
|
|
|
- width: 100%;
|
|
|
- margin-top: 20rpx;
|
|
|
- display: flex;
|
|
|
- justify-content: space-around;
|
|
|
-}
|
|
|
-
|
|
|
-button {
|
|
|
- width: 45%;
|
|
|
-}
|
|
|
+ @import "@/static/font/ygoa/iconfont.css";
|
|
|
+
|
|
|
+ .ygoa-icon {
|
|
|
+ margin-right: 20rpx;
|
|
|
+ font-size: 50rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .container {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ padding: 20rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .header {
|
|
|
+ width: 100%;
|
|
|
+ height: 200rpx;
|
|
|
+ background-color: #f8f8f8;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .day {
|
|
|
+ font-size: 55rpx;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+
|
|
|
+ .date {
|
|
|
+ font-size: 30rpx;
|
|
|
+ color: #666;
|
|
|
+ }
|
|
|
+
|
|
|
+ .status {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: black;
|
|
|
+ }
|
|
|
+
|
|
|
+ .record {
|
|
|
+ width: 100%;
|
|
|
+ margin-top: 20rpx;
|
|
|
+ border-top: 1px solid #ddd;
|
|
|
+ border-bottom: 1px solid #ddd;
|
|
|
+ padding: 0 15rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .record-item {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ height: 100rpx;
|
|
|
+ border-bottom: 1px solid #eee;
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon {
|
|
|
+ width: 50rpx;
|
|
|
+ height: 50rpx;
|
|
|
+ margin-right: 10rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .title {
|
|
|
+ font-size: 28rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .time {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #999;
|
|
|
+ margin-left: auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ .map {
|
|
|
+ width: 100%;
|
|
|
+ height: 500rpx;
|
|
|
+ margin-top: 20rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .footer {
|
|
|
+ width: 100%;
|
|
|
+ margin-top: 20rpx;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-around;
|
|
|
+ }
|
|
|
+
|
|
|
+ button {
|
|
|
+ width: 45%;
|
|
|
+ }
|
|
|
</style>
|