|
@@ -47,6 +47,9 @@ import {useUserStore} from '@/store/modules/user';
|
|
import router from '../router';
|
|
import router from '../router';
|
|
import {useVuelidate} from '@vuelidate/core'
|
|
import {useVuelidate} from '@vuelidate/core'
|
|
import {required, minLength} from '@vuelidate/validators'
|
|
import {required, minLength} from '@vuelidate/validators'
|
|
|
|
+import {present} from "@ionic/core/dist/types/utils/overlays";
|
|
|
|
+import dayjs from "dayjs";
|
|
|
|
+import {saveLongitudeLatitude} from "@/api/position";
|
|
|
|
|
|
const {appContext: {config: {globalProperties}}} = getCurrentInstance();
|
|
const {appContext: {config: {globalProperties}}} = getCurrentInstance();
|
|
|
|
|
|
@@ -73,6 +76,7 @@ const rules = computed(() => {
|
|
const userStore = useUserStore();
|
|
const userStore = useUserStore();
|
|
const user = ref(userStore.getUserInfo);
|
|
const user = ref(userStore.getUserInfo);
|
|
const isDev = ref(false);
|
|
const isDev = ref(false);
|
|
|
|
+const lonLat = ref(userStore.getLonLat);
|
|
|
|
|
|
const v$ = useVuelidate(rules, state.formInline);
|
|
const v$ = useVuelidate(rules, state.formInline);
|
|
|
|
|
|
@@ -109,6 +113,11 @@ const handleSubmit = async () => {
|
|
const userReq = userStore.login(state.formInline);
|
|
const userReq = userStore.login(state.formInline);
|
|
userReq.then((data: any) => {
|
|
userReq.then((data: any) => {
|
|
state.loading = false;
|
|
state.loading = false;
|
|
|
|
+ // 获取经纬度并保存
|
|
|
|
+ sendPosition()
|
|
|
|
+ // 设置定时器实时记录经纬度
|
|
|
|
+ const time = setInterval(sendPosition, 1000 * 60 * 10);
|
|
|
|
+ userStore.setTimer(time);
|
|
router.push('/tabs/tabMain');
|
|
router.push('/tabs/tabMain');
|
|
}, (err) => {
|
|
}, (err) => {
|
|
state.loading = false;
|
|
state.loading = false;
|
|
@@ -117,6 +126,48 @@ const handleSubmit = async () => {
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+// 发送经纬度到后端
|
|
|
|
+const sendPosition = function (){
|
|
|
|
+ getPosition().then((data: any) => {
|
|
|
|
+ console.log("当前经度:" + data.longitude + "\n 当前纬度:" + data.latitude)
|
|
|
|
+ if (userStore.getUserInfo.userID && data.longitude && data.latitude){
|
|
|
|
+ const sendData = {
|
|
|
|
+ userId: userStore.getUserInfo.userID,
|
|
|
|
+ time: Date.now(),
|
|
|
|
+ longitude: data.longitude,
|
|
|
|
+ latitude: data.latitude,
|
|
|
|
+ }
|
|
|
|
+ // 发送请求
|
|
|
|
+ saveLongitudeLatitude(sendData);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 获取经纬度
|
|
|
|
+function getPosition () {
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
+ if (navigator.geolocation) {
|
|
|
|
+ navigator.geolocation.getCurrentPosition(function (position) {
|
|
|
|
+ const latitude = position.coords.latitude.toFixed(5)
|
|
|
|
+ const longitude = position.coords.longitude.toFixed(5)
|
|
|
|
+ const data = {
|
|
|
|
+ latitude: latitude,
|
|
|
|
+ longitude: longitude
|
|
|
|
+ }
|
|
|
|
+ resolve(data)
|
|
|
|
+ }, function () {
|
|
|
|
+ // eslint-disable-next-line prefer-rest-params
|
|
|
|
+ reject(arguments)
|
|
|
|
+ }, {
|
|
|
|
+ enableHighAccuracy: true,
|
|
|
|
+ timeout: 5000
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ reject('你的浏览器不支持当前地理位置信息获取')
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
onIonViewDidEnter(() => {
|
|
onIonViewDidEnter(() => {
|
|
state.formInline.password = '';
|
|
state.formInline.password = '';
|
|
});
|
|
});
|