1
0
Fork 0
mirror of https://github.com/silenty4ng/k5web synced 2025-04-02 05:35:10 +00:00
k5web/src/views/list/satloc/index.vue
2024-07-31 07:39:45 +08:00

92 lines
No EOL
2.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="container">
<div style="background-color: #fff; padding: 10%;" v-show="state.type != 0">
请点击网页已扫码上传按钮 <br>
Please click on the "Scanned and Uploaded" button on PC page.
</div>
<div style="background-color: #fff; padding: 10%;" v-show="state.type == 0">
<p style="font-size: 1.5rem; font-weight: bold;">
获取信息Information
</p>
<a-divider />
<p>
台站经度Longitude{{ state.lng }}
</p>
<a-divider />
<p>
台站纬度Latitude{{ state.lat }}
</p>
<a-divider />
<p>
台站海拔Altitude{{ state.alt }}
</p>
<a-divider />
<a-button type="primary" @click="upload">上传Upload</a-button>
</div>
</div>
</template>
<script lang="ts" setup>
import { reactive, nextTick, onMounted, onUnmounted } from 'vue';
import { useAppStore } from '@/store';
import useLoading from '@/hooks/loading';
const state : {
lat: number,
lng: number,
alt: number,
type: number,
uuid: string | null
} = reactive({
lat: 0,
lng: 0,
alt: 0,
type: 0,
uuid: ''
})
onMounted(()=>{
state.uuid = (new URLSearchParams(location.hash.replace("#/satloc?", ""))).get("uuid");
navigator.geolocation.getCurrentPosition((e) => {
if (e.coords) {
state.lat = e.coords.latitude
state.lng = e.coords.longitude
if (e.coords.altitude) state.alt = e.coords.altitude
}
});
})
const upload = async () => {
await fetch('https://k6.vicicode.cn/api/lol', {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
func: 0,
uuid: state.uuid,
cache: JSON.stringify([state.lng, state.lat, state.alt])
})
});
state.type = 1
}
</script>
<script lang="ts">
export default {
name: 'SatLoc',
};
</script>
<style scoped lang="less">
.container {
background-color: rgb(242, 243, 245);
width: 100vw;
height: 100vh;
padding-top: 10%;
padding-left: 10%;
padding-right: 10%;
}
</style>