Переглянути джерело

feat(mine/clockIn): 考勤打卡、下班签退
style(login): 登录页面输入框下移

wangpx 1 рік тому
батько
коміт
67ded98d5d
9 змінених файлів з 82 додано та 44 видалено
  1. 3 0
      api/contacts.js
  2. 4 0
      api/login.js
  3. 3 0
      api/mine.js
  4. 5 0
      api/mine/checkIn.js
  5. 5 3
      api/mine/clockIn.js
  6. 1 1
      config.js
  7. 2 1
      pages/login.vue
  8. 58 39
      pages/mine/clockIn/clockIn.vue
  9. 1 0
      utils/request.js

+ 3 - 0
api/contacts.js

@@ -1,7 +1,10 @@
 import request from '@/utils/request.js'
 
+const preUrl = '/clientServices.do?iscrypt=1'
+
 export function getContactAllUser(unitId) {
 	return request({
+		url: preUrl,
 		// header: [
 			// isToken: false,
 		// 	Accept: 'application/json'

+ 4 - 0
api/login.js

@@ -1,8 +1,11 @@
 import request from '@/utils/request.js'
 
+const preUrl = '/clientServices.do?iscrypt=1'
+
 // 登录
 export function login(username, password) {
 	return request({
+		url: preUrl,
     method: 'post',
 		data: {
 			'serviceId': 'eu_2013V01login',
@@ -16,6 +19,7 @@ export function login(username, password) {
 // 获取用户信息
 export function getInfo(useId) {
 	return request({
+		url: preUrl,
     method: 'post',
 		data: {
 			'serviceId': 'eu_2013V01loadMe',

+ 3 - 0
api/mine.js

@@ -1,7 +1,10 @@
 import request from '@/utils/request.js'
 
+const preUrl = '/clientServices.do?iscrypt=1'
+
 export function getUserInfo(useId) {
 	return request({
+		url: preUrl,
     method: 'post',
 		data: {
 			'serviceId': 'eu_2013V01loadMe',

+ 5 - 0
api/mine/checkIn.js

@@ -1,7 +1,11 @@
 import request from '@/utils/request.js'
+
+const preUrl = '/clientServices.do?iscrypt=1'
+
 //检查今日考勤状况
 export function CheckAttendance(params) {
 	return request({
+		url: preUrl,
     method: 'post',
 		data: {
 			'serviceId': 'hr_2018V01CheckAttendance',
@@ -13,6 +17,7 @@ export function CheckAttendance(params) {
 //获取我的考勤数据统计
 export function getMyTotalCount(params) {
 	return request({
+		url: preUrl,
     method: 'post',
 		data: {
 			'serviceId': 'hr_2015V01getMyTotalCount',

+ 5 - 3
api/mine/clockIn.js

@@ -1,9 +1,11 @@
 import request from '@/utils/request.js'
+const preUrl = '/clientServices.do?iscrypt=1'
 //考勤打卡
-export function CreateAttendance(params) {
+export function createAttendance(params) {
 	return request({
-		'method':'post',
-		'data': {
+		url: preUrl,
+		method:'post',
+		data: {
 			'serviceId': 'hr_2018V01CreateAttendance',
 			'params': params
 		}

+ 1 - 1
config.js

@@ -1,3 +1,3 @@
 export default {
-	baseUrl: 'http://118.195.146.34:20076/ynet/clientServices.do?iscrypt=1'
+	baseUrl: 'http://localhost:8081/oa'
 }

+ 2 - 1
pages/login.vue

@@ -41,6 +41,7 @@
 			$modal.msgError("请输入您的密码")
 		} else {
 			$modal.loading("登录中,请耐心等待...")
+			// TEST: 测试登录接口
 			userStore.Login(loginForm.value).then(() => {
 				$modal.closeLoading()
 				loginSuccess()
@@ -68,7 +69,7 @@
 			width: 100%;
 			font-size: 21px;
 			text-align: center;
-			padding-top: 15%;
+			padding-top: 45%;
 
 			image {
 				border-radius: 4px;

+ 58 - 39
pages/mine/clockIn/clockIn.vue

@@ -52,6 +52,7 @@
 
 
 
+
 	// 导入地理位置相关函数
 	import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
 	import {
@@ -65,12 +66,15 @@
 	import {
 		useUserStore
 	} from '@/store/user';
+	import {createAttendance} from '@/api/mine/clockIn.js'
 	const userStore = useUserStore();
-
+	const thisUser=ref();
 	const userId = ref('')
 
 	// 组件挂载后初始化当前日期与位置
 	onMounted(() => {
+		thisUser.value=userStore.user;
+		console.log('thisUser',thisUser.value);
 		userId.value = userStore.user.useId;
 		dateInit();
 		getlocation();
@@ -102,12 +106,14 @@
 
 	//获取今天考勤状态
 	function getTodayAtt() {
+		
 		const params = {
 			universalid: userId.value,
 			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');
@@ -121,6 +127,7 @@
 		})
 	}
 
+const attType=ref(0)
 	// 上班签到
 	function signIn() {
 		const now = getNowTime();
@@ -132,8 +139,9 @@
 			});
 			return;
 		}
-		getlocation(); // 获取当前位置
-		tranAddress(); // 转换地址
+		attType.value=1;
+		
+		getAddress();
 		clockIn(); // 执行打卡
 	};
 
@@ -148,8 +156,8 @@
 			});
 			return;
 		}
-		getlocation(); // 获取当前位置
-		tranAddress(); // 转换地址
+		attType.value=2;
+		getAddress();
 		clockIn(); // 执行打卡并获取结果
 	};
 
@@ -200,8 +208,10 @@
 	// 获取当前定位经纬度
 	function getlocation() {
 		wx.getLocation({
-			type: 'gcj02',
+			// type: 'gcj02',
 			success: (res) => {
+				// console.log('当前位置的经度:' + JSON.stringify(res)); 	
+				// console.log('当前位置的经度:','gcj02' + JSON.stringify(res));
 				console.log('当前位置的经度:' + res.longitude);
 				console.log('当前位置的纬度:' + res.latitude);
 				longitude.value = res.longitude; // 保存经度
@@ -223,7 +233,7 @@
 									});
 								},
 								fail: (err) => {
-									console.log(err);
+									// console.log(err);
 								}
 							});
 						} else {
@@ -301,38 +311,47 @@
 
 	// 打卡
 	function clockIn() {
-		//发起打卡请求相关业务逻辑(暂未实现)
-		// const params = {
-		// 	user_name: user_name,
-		// 	user_id: staffId,
-		// 	kaoqin_type: kaoqin_type,
-		// 	now_date: now_date,
-		// 	longitude: longitude,
-		// 	latitude: latitude,
-		// 	address: address,
-		// 	unitId: unitId
-		// };
-		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); // 判断点是否在多边形内
-		if (f) {
-			uni.showToast({
-				title: "打卡成功",
-				icon: 'none'
-			});
-			getTodayAtt(); //更新今日考勤数据
-		} else {
-			uni.showToast({
-				title: "未在指定范围,打卡失败",
-				icon: 'none'
-			});
-		}
+		//TODO: 发起打卡请求相关业务逻辑
+		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', '');
+		const params = {
+			user_name: thisUser.value.userName,
+			user_id: thisUser.value.useId,
+			kaoqin_type: attType.value,
+			now_date: localString,
+			longitude: longitude.value,
+			latitude: latitude.value,
+			address: address.value,
+			unitId: thisUser.value.unitId
+		};
+		createAttendance(params).then(res=>{
+			// console.log('createAttendance',res);
+			if ("success"==res.returnMsg) {
+				uni.showToast({
+					title: "打卡成功",
+					icon: 'none'
+				});
+				getTodayAtt(); //更新今日考勤数据
+			} else {
+				uni.showToast({
+					title: "未在指定范围,打卡失败",
+					icon: 'none'
+				});
+			}
+		})
+		// 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); // 判断点是否在多边形内
+		
+		
 	}
 </script>
 

+ 1 - 0
utils/request.js

@@ -20,6 +20,7 @@ const request = config => {
     url = url.slice(0, -1)
     config.url = url
   }
+	console.log('request.data', config.data);
   return new Promise((resolve, reject) => {
     uni.request({
         method: config.method || 'get',