From aef408c91928a8dfeb28a3f48190ead32aeb45d1 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期五, 13 二月 2026 10:19:42 +0800
Subject: [PATCH] 非HTTPS,获取位置功能暂时隐藏

---
 src/views/personnelManagement/attendanceCheckin/index.vue |   86 +++++++++++++++++++++++++++++++++---------
 1 files changed, 67 insertions(+), 19 deletions(-)

diff --git a/src/views/personnelManagement/attendanceCheckin/index.vue b/src/views/personnelManagement/attendanceCheckin/index.vue
index 0e5b577..f2d8776 100644
--- a/src/views/personnelManagement/attendanceCheckin/index.vue
+++ b/src/views/personnelManagement/attendanceCheckin/index.vue
@@ -1,7 +1,7 @@
 <template>
   <div class="app-container">
     <!-- 鍛樺伐鎵撳崱鍖� -->
-    <el-card shadow="never"
+    <!-- <el-card shadow="never"
              class="mb16">
       <div class="attendance-header">
         <div>
@@ -58,7 +58,7 @@
           </el-tag>
         </el-descriptions-item>
       </el-descriptions>
-    </el-card>
+    </el-card> -->
     <div class="attendance-operation">
       <!-- 鏌ヨ鏉′欢锛堢鐞嗗憳鑰冨嫟鏃ユ姤锛� -->
       <el-form :model="searchForm"
@@ -159,7 +159,7 @@
                          label="澶囨敞"
                          show-overflow-tooltip />
       </el-table>
-      <pagination :total="total"
+      <pagination :total="page.total"
                   layout="total, sizes, prev, pager, next, jumper"
                   :page="page.current"
                   :limit="page.size"
@@ -302,7 +302,7 @@
     findPersonalAttendanceRecords({ ...page, ...searchForm })
       .then(res => {
         tableData.value = res.data.records;
-        page.value.total = res.data.total;
+        page.total = res.data.total;
       })
       .finally(() => {
         tableLoading.value = false;
@@ -311,9 +311,9 @@
 
   // 鏌ヨ浠婃棩鎵撳崱淇℃伅
   const fetchTodayData = () => {
-    findTodayPersonalAttendanceRecord({}).then(res => {
-      todayRecord.value = res.data;
-    });
+    // findTodayPersonalAttendanceRecord({}).then(res => {
+    //   todayRecord.value = res.data;
+    // });
   };
 
   const paginationChange = pagination => {
@@ -345,20 +345,67 @@
   // 鑾峰彇褰撳墠浣嶇疆
   const getCurrentLocation = () => {
     return new Promise((resolve, reject) => {
-      if (navigator.geolocation) {
-        navigator.geolocation.getCurrentPosition(
-          position => {
-            const { longitude, latitude } = position.coords;
-            resolve({ longitude, latitude });
-          },
-          error => {
-            console.log("鑾峰彇浣嶇疆澶辫触:", error);
-            reject(error);
-          }
-        );
-      } else {
+      if (!navigator.geolocation) {
         reject(new Error("娴忚鍣ㄤ笉鏀寔鍦扮悊瀹氫綅"));
+        return;
       }
+
+      // 妫�鏌ユ槸鍚︿娇鐢℉TTPS
+      const isSecureContext =
+        window.isSecureContext || window.location.protocol === "https:";
+      console.log(
+        "褰撳墠鍗忚:",
+        window.location.protocol,
+        "鏄惁瀹夊叏涓婁笅鏂�:",
+        isSecureContext
+      );
+
+      if (!isSecureContext) {
+        console.warn("褰撳墠涓嶆槸HTTPS鍗忚锛屽湴鐞嗕綅缃瓵PI鍙兘鍙楅檺");
+      }
+
+      navigator.geolocation.getCurrentPosition(
+        position => {
+          const { longitude, latitude } = position.coords;
+          console.log("鑾峰彇浣嶇疆鎴愬姛:", longitude, latitude);
+          resolve({ longitude, latitude });
+        },
+        error => {
+          console.log("鑾峰彇浣嶇疆澶辫触:", error);
+          let errorMessage = "鑾峰彇浣嶇疆澶辫触";
+
+          // 鏍规嵁閿欒绫诲瀷鎻愪緵鏇村叿浣撶殑鎻愮ず
+          switch (error.code) {
+            case error.PERMISSION_DENIED:
+              errorMessage =
+                "鐢ㄦ埛鎷掔粷浜嗕綅缃潈闄愯姹傦紝璇峰湪娴忚鍣ㄨ缃腑鍏佽浣嶇疆璁块棶";
+              break;
+            case error.POSITION_UNAVAILABLE:
+              errorMessage = "浣嶇疆淇℃伅涓嶅彲鐢紝璇锋鏌ヨ澶囧畾浣嶅姛鑳�";
+              break;
+            case error.TIMEOUT:
+              errorMessage = "鑾峰彇浣嶇疆瓒呮椂锛岃閲嶈瘯";
+              break;
+            case error.UNKNOWN_ERROR:
+              errorMessage = "鑾峰彇浣嶇疆鏃跺彂鐢熸湭鐭ラ敊璇�";
+              break;
+            default:
+              errorMessage = `鑾峰彇浣嶇疆澶辫触: ${error.message}`;
+          }
+
+          // 妫�鏌ユ槸鍚︽槸HTTPS闂
+          if (error.code === error.PERMISSION_DENIED && !isSecureContext) {
+            errorMessage += "锛堟敞鎰忥細鐢熶骇鐜闇�瑕佷娇鐢℉TTPS鍗忚鎵嶈兘鑾峰彇浣嶇疆锛�";
+          }
+
+          reject(new Error(errorMessage));
+        },
+        {
+          enableHighAccuracy: true,
+          timeout: 10000,
+          maximumAge: 0,
+        }
+      );
     });
   };
 
@@ -366,6 +413,7 @@
   const handleCheckInOut = () => {
     getCurrentLocation()
       .then(location => {
+        console.log("浣嶇疆鎴愬姛");
         createPersonalAttendanceRecord(location).then(res => {
           fetchData();
           fetchTodayData();

--
Gitblit v1.9.3