diff --git a/package.json b/package.json index 23d1da7..0e72579 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "mqtt": "^2.18.9", "normalize.css": "^8.0.1", "nprogress": "^0.2.0", + "geodist": "^0.2.1", "vue": "^2.6.11", "vue-router": "^3.6.5", "vue-template-compiler": "^2.7.16", @@ -38,7 +39,6 @@ "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.0", "eslint-plugin-vue": "^6.2.2", - "geodist": "^0.2.1", "sass": "^1.64.1", "sass-loader": "^8.0.2" }, @@ -46,4 +46,4 @@ "main": ".eslintrc.js", "author": "", "license": "ISC" -} +} \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index e20ed9a..b16ed4a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -304,7 +304,13 @@ const store = new Vuex.Store({ res.data.airList.forEach(plane => { plane.planeState = { // 飞机状态初始化字段 flyDataMark: false, // 飞机解锁标记成真 - flyDataSave: [], // 飞机加锁截至 待上传飞行数据之后 再清空此值 + flyDataSave: { // 飞机加锁截至 待上传飞行数据之后 再清空此值 + startTime: null, // 解锁时的时间戳(秒) + endTime: null, // 加锁时的时间戳(秒) + startBattery: null, // 解锁时的电池电量(百分比) + endBattery: null, // 加锁时的电池电量(百分比) + path: [] // 飞行路径数组,每项是 [lon, lat, alt] + }, heartBeat: null, // 心跳 heartRandom: null, // 每次接收到心跳创建一个随机数 用于watch监听 voltagBattery: null, // 电压信息 diff --git a/src/utils/api/table.js b/src/utils/api/table.js index 13d78b7..9701265 100644 --- a/src/utils/api/table.js +++ b/src/utils/api/table.js @@ -179,8 +179,14 @@ export async function getFlyData (idArr, startTime, endTime) { return res } /** - *@abstract 上传保存飞机 飞行数据 检测心跳 解锁开始记录数据 加锁上传数据 + * @abstract 上传保存飞机飞行数据(解锁至加锁 即飞行结束触发) + * @param {Object} data 包含 id, start_time, end_time, gps_path, distance, power_used */ -export async function saveFlyData () { - +export async function saveFlyData (data) { + const params = new URLSearchParams() + for (const key in data) { + params.append(key, data[key]) + } + const res = await api.post('saveFlyData', params, 'Plane') + return res } diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue index 56cc9d5..790bf2c 100644 --- a/src/views/layout/index.vue +++ b/src/views/layout/index.vue @@ -19,6 +19,8 @@