|
@@ -7,14 +7,14 @@
|
|
<ion-item>
|
|
<ion-item>
|
|
<!-- <ion-icon :icon="personOutline" mode="md"></ion-icon>-->
|
|
<!-- <ion-icon :icon="personOutline" mode="md"></ion-icon>-->
|
|
<!-- <ion-input v-model="state.formInline.username" type="text" placeholder="请输入用户名"></ion-input>-->
|
|
<!-- <ion-input v-model="state.formInline.username" type="text" placeholder="请输入用户名"></ion-input>-->
|
|
- <input v-model="state.formInline.username" type="text" placeholder="请输入用户名"/>
|
|
|
|
|
|
+ <input v-model="state.formInline.username" placeholder="请输入用户名" type="text"/>
|
|
</ion-item>
|
|
</ion-item>
|
|
</div>
|
|
</div>
|
|
<div class="login-item">
|
|
<div class="login-item">
|
|
<ion-item>
|
|
<ion-item>
|
|
<!-- <ion-icon :icon="lockClosedOutline" mode="md"></ion-icon>-->
|
|
<!-- <ion-icon :icon="lockClosedOutline" mode="md"></ion-icon>-->
|
|
<!-- <ion-input v-model="state.formInline.password" type="password" placeholder="请输入密码"></ion-input>-->
|
|
<!-- <ion-input v-model="state.formInline.password" type="password" placeholder="请输入密码"></ion-input>-->
|
|
- <input v-model="state.formInline.password" type="password" placeholder="请输入密码"/>
|
|
|
|
|
|
+ <input v-model="state.formInline.password" placeholder="请输入密码" type="password"/>
|
|
</ion-item>
|
|
</ion-item>
|
|
</div>
|
|
</div>
|
|
<div class="login-btn">
|
|
<div class="login-btn">
|
|
@@ -24,7 +24,7 @@
|
|
</ion-button>
|
|
</ion-button>
|
|
</ion-buttons>
|
|
</ion-buttons>
|
|
</div>
|
|
</div>
|
|
- <ion-label class="error-label" v-show="state.errorShow || v$.username.$error || v$.password.$error">
|
|
|
|
|
|
+ <ion-label v-show="state.errorShow || v$.username.$error || v$.password.$error" class="error-label">
|
|
<p v-if="v$.username.$error || v$.password.$error">用户名或密码不能为空</p>
|
|
<p v-if="v$.username.$error || v$.password.$error">用户名或密码不能为空</p>
|
|
<p v-if="state.errorShow && !(v$.username.$error || v$.password.$error)">
|
|
<p v-if="state.errorShow && !(v$.username.$error || v$.password.$error)">
|
|
{{ state.msg }}
|
|
{{ state.msg }}
|
|
@@ -33,23 +33,21 @@
|
|
<ion-loading
|
|
<ion-loading
|
|
:is-open="state.loading"
|
|
:is-open="state.loading"
|
|
message="登陆中..."
|
|
message="登陆中..."
|
|
- @didDismiss="setOpen(false)" >
|
|
|
|
|
|
+ @didDismiss="setOpen(false)">
|
|
</ion-loading>
|
|
</ion-loading>
|
|
</div>
|
|
</div>
|
|
</ion-content>
|
|
</ion-content>
|
|
</ion-page>
|
|
</ion-page>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
-<script setup lang="ts">
|
|
|
|
-import {reactive, ref, toRef, computed, onMounted, getCurrentInstance, onActivated} from 'vue';
|
|
|
|
|
|
+<script lang="ts" setup>
|
|
|
|
+import {computed, getCurrentInstance, onMounted, reactive, ref} from 'vue';
|
|
import {alertController, onIonViewDidEnter} from '@ionic/vue';
|
|
import {alertController, onIonViewDidEnter} from '@ionic/vue';
|
|
import {useUserStore} from '@/store/modules/user';
|
|
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 {present} from "@ionic/core/dist/types/utils/overlays";
|
|
|
|
-import dayjs from "dayjs";
|
|
|
|
-import {saveLongitudeLatitude} from "@/api/position";
|
|
|
|
|
|
+import {minLength, required} from '@vuelidate/validators'
|
|
|
|
+import {sendPosition, setPositionInterval} from "@/utils/position";
|
|
|
|
|
|
const {appContext: {config: {globalProperties}}} = getCurrentInstance();
|
|
const {appContext: {config: {globalProperties}}} = getCurrentInstance();
|
|
|
|
|
|
@@ -116,8 +114,7 @@ const handleSubmit = async () => {
|
|
// 获取经纬度并保存
|
|
// 获取经纬度并保存
|
|
sendPosition()
|
|
sendPosition()
|
|
// 设置定时器实时记录经纬度
|
|
// 设置定时器实时记录经纬度
|
|
- const time = setInterval(sendPosition, 1000 * 60 * 10);
|
|
|
|
- userStore.setTimer(time);
|
|
|
|
|
|
+ setPositionInterval()
|
|
router.push('/tabs/tabMain');
|
|
router.push('/tabs/tabMain');
|
|
}, (err) => {
|
|
}, (err) => {
|
|
state.loading = false;
|
|
state.loading = false;
|
|
@@ -126,48 +123,6 @@ 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 = '';
|
|
});
|
|
});
|
|
@@ -251,7 +206,7 @@ ion-content {
|
|
outline: none;
|
|
outline: none;
|
|
}
|
|
}
|
|
|
|
|
|
- input::placeholder{
|
|
|
|
|
|
+ input::placeholder {
|
|
color: #b4b4b7;
|
|
color: #b4b4b7;
|
|
}
|
|
}
|
|
|
|
|