xy 1 year ago
parent 52ff93a69a
commit a3901bef8c

File diff suppressed because one or more lines are too long

@ -67,6 +67,7 @@ import { throttle } from '@/utils'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import MonthStatics from './components/MonthStatics' import MonthStatics from './components/MonthStatics'
import axios from "axios"; import axios from "axios";
import * as uni from "@/assets/uni.webview.1.5.6";
import { PopupManager } from "element-ui/lib/utils/popup"; import { PopupManager } from "element-ui/lib/utils/popup";
export default { export default {
@ -75,6 +76,7 @@ export default {
}, },
data() { data() {
return { return {
isInUni: false,
// start // start
loading: false, loading: false,
action: process.env.VUE_APP_UPLOAD_API, action: process.env.VUE_APP_UPLOAD_API,
@ -159,7 +161,16 @@ export default {
}, 1000, true), }, 1000, true),
clockIn: throttle(async function() { clockIn: throttle(async function() {
try { try {
if (!this.isInUni) {
await this.getLocation() await this.getLocation()
} else {
uni.postMessage({
data: {
action: 'getLocation'
}
});
return
}
if(!this.isGetLocation) return if(!this.isGetLocation) return
if(this.isOutSign) { if(this.isOutSign) {
this.isShow = true this.isShow = true
@ -234,8 +245,48 @@ export default {
console.error(err) console.error(err)
} }
}, },
async getAppLocation(latitude, longitude, first = false) {
try {
this.pos.lng = longitude
this.pos.lat = latitude
this.isGetLocation = true
if(this.pos.lat && this.pos.lng && this.isGetLocation) {
await this.pos2Address(this.pos.lat, this.pos.lng)
const res = await preDistance({
location: `${this.pos.lng},${this.pos.lat}`
})
this.isOutSign = res.distance > Number(res.max_distance)
this.maxDistance = res.max_distance
this.nowDistance = res.distance
if (first) return
if(!this.isGetLocation) return
if(this.isOutSign) {
this.isShow = true
return
}
const res1 = await sign({
location: `${this.pos.lng},${this.pos.lat}`,
address: this.pos.address
})
this.$message.success('打卡成功')
await this.$refs['MonthStatics'].getData()
console.log(res1)
}
} catch (err) {
}
},
getLocation() { getLocation() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (/uni-app/.test(navigator.userAgent)) {
this.isInUni = true
uni.postMessage({
data: {
action: 'getLocation'
}
});
} else {
navigator.geolocation.getCurrentPosition((pos) => { navigator.geolocation.getCurrentPosition((pos) => {
this.isGetLocation = true this.isGetLocation = true
console.log('经度', pos.coords.latitude); console.log('经度', pos.coords.latitude);
@ -301,12 +352,16 @@ export default {
} }
} }
}); });
}
}) })
}, },
}, },
mounted() { mounted() {
this.getMyDuty() this.getMyDuty()
this.isAuthPermission() this.isAuthPermission()
},
created() {
window.getAppLocation = this.getAppLocation
} }
} }
</script> </script>

@ -230,7 +230,7 @@
<el-table-column <el-table-column
label="操作" label="操作"
header-align="center" header-align="center"
min-width="122" min-width="150"
fixed="right" fixed="right"
> >
<template #default="{ row }"> <template #default="{ row }">

Loading…
Cancel
Save