From c3bb39a4cbd6f172884d4d8598554ab504ea0b0f Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 26 Jan 2026 15:22:14 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
uniapps/work-app/src/store/modules/location.js | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/uniapps/work-app/src/store/modules/location.js b/uniapps/work-app/src/store/modules/location.js
index d0f6889..b68a86b 100644
--- a/uniapps/work-app/src/store/modules/location.js
+++ b/uniapps/work-app/src/store/modules/location.js
@@ -1,5 +1,6 @@
import { defineStore } from 'pinia'
import locationUtil from '@/utils/location.js'
+import { reportLocationApi } from '@/api/map.js'
const useLocationStore = defineStore('location', {
state: () => ({
@@ -12,7 +13,9 @@
// 位置更新间隔(毫秒)
updateInterval: 5000,
// 位置监听器ID
- watcherId: null
+ watcherId: null,
+ // 上次位置上报时间
+ lastReportTime: 0
}),
getters: {
@@ -115,13 +118,32 @@
},
/**
- * 位置信息上报(可根据实际需求实现)
+ * 位置信息上报
* @param {Object} location 位置信息
*/
- reportLocation(location) {
- // 这里可以添加位置信息上报到服务器的逻辑
- // 例如:api.uploadLocation(location)
- console.log('位置上报:', location);
+ async reportLocation(location) {
+
+ try {
+ const now = Date.now();
+ // 检查是否达到上报时间间隔(1分钟)
+ if (now - this.lastReportTime >= 60000) {
+ // 构造请求参数
+ const params = {
+ longitude: location.longitude,
+ latitude: location.latitude,
+ // reportTime: new Date().toISOString()
+ };
+
+ // 调用位置上报接口
+ const result = await reportLocationApi(params);
+ console.log('位置上报成功:', result);
+
+ // 更新上次上报时间
+ this.lastReportTime = now;
+ }
+ } catch (error) {
+ console.error('位置上报失败:', error);
+ }
},
/**
--
Gitblit v1.9.3