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 +++++++++++++++++++++++++++++++++---------
src/views/personnelManagement/attendanceCheckin/checkinRules/components/form.vue | 6 +-
2 files changed, 70 insertions(+), 22 deletions(-)
diff --git a/src/views/personnelManagement/attendanceCheckin/checkinRules/components/form.vue b/src/views/personnelManagement/attendanceCheckin/checkinRules/components/form.vue
index 12de46c..11e21bc 100644
--- a/src/views/personnelManagement/attendanceCheckin/checkinRules/components/form.vue
+++ b/src/views/personnelManagement/attendanceCheckin/checkinRules/components/form.vue
@@ -43,13 +43,13 @@
<div class="map-container">
<div class="map-header"
style="margin-bottom: 10px">
- <el-button @click="getCurrentLocation">
+ <!-- <el-button @click="getCurrentLocation">
<el-icon>
<Position />
</el-icon>
褰撳墠浣嶇疆
- </el-button>
- <span style="margin-left: 10px; color: #909399;font-size: 12px;">鐐瑰嚮鍦板浘閫夋嫨浣嶇疆</span>
+ </el-button> -->
+ <!-- <span style="margin-left: 10px; color: #909399;font-size: 12px;">鐐瑰嚮鍦板浘閫夋嫨浣嶇疆</span> -->
</div>
<div id="map-container"
class="map"
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