From 7502e761d845348282bf72b17a4cc3f24572f013 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期三, 11 二月 2026 15:23:47 +0800
Subject: [PATCH] 打卡签到传参

---
 src/pages/humanResources/attendance/checkin.vue |   69 ++++++++++++++++++++++++----------
 src/utils/request.ts                            |    8 +++
 2 files changed, 55 insertions(+), 22 deletions(-)

diff --git a/src/pages/humanResources/attendance/checkin.vue b/src/pages/humanResources/attendance/checkin.vue
index e5f4e6e..a3eb33a 100644
--- a/src/pages/humanResources/attendance/checkin.vue
+++ b/src/pages/humanResources/attendance/checkin.vue
@@ -236,26 +236,52 @@
       // #endif
     });
   };
+  const form = ref({
+    longitude: "",
+    latitude: "",
+  });
 
-  // 鑾峰彇褰撳墠浣嶇疆
   const getCurrentLocation = () => {
-    return new Promise((resolve, reject) => {
-      uni.getLocation({
-        type: "wgs84",
-        success: res => {
-          currentLocation.value = res;
-          // 妯℃嫙妫�鏌ユ槸鍚﹀湪鎵撳崱鑼冨洿鍐咃紙瀹為檯椤圭洰涓簲鏍规嵁鍏徃浣嶇疆鍜屽厑璁哥殑鍗婂緞杩涜璁$畻锛�
-          // 杩欓噷绠�鍗曟ā鎷熶负濮嬬粓鍦ㄨ寖鍥村唴
-          inCheckRange.value = true;
-          resolve(res);
-        },
-        fail: err => {
-          console.error("鑾峰彇浣嶇疆澶辫触:", err);
-          // 澶辫触鏃堕粯璁ゅ厑璁告墦鍗★紙瀹為檯椤圭洰涓簲鏍规嵁涓氬姟闇�姹傚鐞嗭級
-          inCheckRange.value = true;
-          reject(err);
-        },
-      });
+    uni.showLoading({ title: "鑾峰彇浣嶇疆涓�..." });
+
+    uni.getLocation({
+      type: "gcj02",
+      success: res => {
+        uni.hideLoading();
+        form.value.latitude = res.latitude;
+        form.value.longitude = res.longitude;
+      },
+      fail: err => {
+        uni.hideLoading();
+        console.error("鑾峰彇浣嶇疆澶辫触:", err);
+
+        // 鏄剧ず閿欒鎻愮ず骞跺紩瀵肩敤鎴锋鏌ユ潈闄�
+        showToast("鑾峰彇浣嶇疆澶辫触锛岃妫�鏌ュ畾浣嶆潈闄�");
+
+        // 寮曞鐢ㄦ埛妫�鏌ユ潈闄愯缃�
+        uni.showModal({
+          title: "浣嶇疆鏉冮檺鎻愮ず",
+          content:
+            "鑾峰彇浣嶇疆澶辫触锛屽彲鑳芥槸鍥犱负浣嶇疆鏉冮檺鏈紑鍚紝璇峰湪璁惧璁剧疆涓鏌ュ苟寮�鍚綅缃潈闄愩��",
+          confirmText: "鐭ラ亾浜�",
+          cancelText: "鍙栨秷",
+          success: res => {
+            if (res.confirm) {
+              // 鍙互灏濊瘯鎵撳紑璁剧疆椤甸潰锛堝鏋滄敮鎸侊級
+              if (uni.openSetting) {
+                uni.openSetting({
+                  success: settingRes => {
+                    console.log("璁剧疆缁撴灉:", settingRes);
+                  },
+                });
+              }
+            }
+          },
+        });
+
+        // 澶辫触鏃舵樉绀洪敊璇俊鎭�
+        form.value.visitAddress = "浣嶇疆鑾峰彇澶辫触";
+      },
     });
   };
 
@@ -318,7 +344,9 @@
     }
 
     // 璋冪敤鎵撳崱API
-    createPersonalAttendanceRecord({})
+    createPersonalAttendanceRecord({
+      ...form.value,
+    })
       .then(res => {
         // 璁板綍鎵撳崱鏃堕棿
         lastCheckInTime.value = Date.now();
@@ -331,7 +359,6 @@
         fetchTodayData();
       })
       .catch(error => {
-        console.error("鎵撳崱澶辫触:", error);
         uni.showToast({
           title: error.msg || "鎵撳崱澶辫触锛岃閲嶈瘯",
           icon: "none",
@@ -347,7 +374,7 @@
 
     // 鑾峰彇浣嶇疆鏉冮檺骞舵鏌ヤ綅缃�
     try {
-      await getLocationPermission();
+      // await getLocationPermission();
       await getCurrentLocation();
     } catch (error) {
       console.error("浣嶇疆鏉冮檺鑾峰彇澶辫触:", error);
diff --git a/src/utils/request.ts b/src/utils/request.ts
index 7e40c06..46ac305 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -54,6 +54,11 @@
       //   code: code,
       //   data: data
       // })
+      console.log('鎺ユ敹鍒扮殑鍙傛暟:', {
+        url: (config.baseUrl || baseUrl) + config.url,
+        code: code,
+        data: data
+      })
       if (code === 401) {
         showConfirm('鐧诲綍鐘舵�佸凡杩囨湡锛屾偍鍙互缁х画鐣欏湪璇ラ〉闈紝鎴栬�呴噸鏂扮櫥褰�?').then(res => {
           if (res.confirm) {
@@ -65,7 +70,8 @@
         reject('鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�')
       } else if (code === 500) {
         toast(msg)
-        reject('500')
+        console.error('500閿欒:', data)
+        reject(data)
       } else if (code !== 200) {
         toast(msg)
         reject(code)

--
Gitblit v1.9.3