|
|
|
@ -7,7 +7,9 @@
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
<div class="sign-statsu">
|
|
|
|
<div class="sign-statsu">
|
|
|
|
<div>打卡状态 <el-tag size="small" effect="dark" type="primary">{{ isGetLocation ? '可打卡' : '不可打卡' }}</el-tag></div>
|
|
|
|
<div>打卡状态 <el-tag size="small" effect="dark" type="primary">{{ isGetLocation ? '可打卡' : '不可打卡' }}</el-tag></div>
|
|
|
|
<div>当前位置: <span v-if="isGetLocation">({{pos.lng}},{{pos.lat}})</span></div>
|
|
|
|
<div>当前位置: <span v-if="isGetLocation">
|
|
|
|
|
|
|
|
<el-tag size="small" type="primary" effect="dark">{{pos.address}}</el-tag>
|
|
|
|
|
|
|
|
({{pos.lng}},{{pos.lat}})</span></div>
|
|
|
|
<div>当前距离:</div>
|
|
|
|
<div>当前距离:</div>
|
|
|
|
<div>最大打卡范围:</div>
|
|
|
|
<div>最大打卡范围:</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@ -22,6 +24,7 @@
|
|
|
|
import { sign } from '@/api/attendance'
|
|
|
|
import { sign } from '@/api/attendance'
|
|
|
|
import { throttle } from '@/utils'
|
|
|
|
import { throttle } from '@/utils'
|
|
|
|
import MonthStatics from './components/MonthStatics'
|
|
|
|
import MonthStatics from './components/MonthStatics'
|
|
|
|
|
|
|
|
import axios from "axios";
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
components: {
|
|
|
|
MonthStatics
|
|
|
|
MonthStatics
|
|
|
|
@ -31,7 +34,8 @@ export default {
|
|
|
|
isGetLocation: false,
|
|
|
|
isGetLocation: false,
|
|
|
|
pos: {
|
|
|
|
pos: {
|
|
|
|
lng: '',
|
|
|
|
lng: '',
|
|
|
|
lat: ''
|
|
|
|
lat: '',
|
|
|
|
|
|
|
|
address: ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -39,7 +43,10 @@ export default {
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
clockIn: throttle(async function() {
|
|
|
|
clockIn: throttle(async function() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const res = await sign()
|
|
|
|
const res = await sign({
|
|
|
|
|
|
|
|
location: `${this.pos.lng},${this.pos.lat}`,
|
|
|
|
|
|
|
|
address: this.pos.address
|
|
|
|
|
|
|
|
})
|
|
|
|
console.log(res)
|
|
|
|
console.log(res)
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err)
|
|
|
|
console.error(err)
|
|
|
|
@ -54,6 +61,28 @@ export default {
|
|
|
|
this.getLocation()
|
|
|
|
this.getLocation()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
async pos2Address(lat, lng) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// const res = await axios.get('https://apis.map.qq.com/ws/geocoder/v1/',{
|
|
|
|
|
|
|
|
// params: {
|
|
|
|
|
|
|
|
// location: lat + "," + lng,
|
|
|
|
|
|
|
|
// key: "D5EBZ-C3BWP-HZIDG-VO6BE-P2MN5-ESFZO",
|
|
|
|
|
|
|
|
// output: "jsonp"
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
const res = await this.$jsonp('https://apis.map.qq.com/ws/geocoder/v1/',{
|
|
|
|
|
|
|
|
location: lat + "," + lng,
|
|
|
|
|
|
|
|
key: "D5EBZ-C3BWP-HZIDG-VO6BE-P2MN5-ESFZO",
|
|
|
|
|
|
|
|
output: "jsonp"
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log(res)
|
|
|
|
|
|
|
|
if(!res.status) {
|
|
|
|
|
|
|
|
this.pos.address = res.result.address
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
console.error(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
getLocation() {
|
|
|
|
getLocation() {
|
|
|
|
navigator.geolocation.getCurrentPosition((pos) => {
|
|
|
|
navigator.geolocation.getCurrentPosition((pos) => {
|
|
|
|
this.isGetLocation = true
|
|
|
|
this.isGetLocation = true
|
|
|
|
@ -61,6 +90,9 @@ export default {
|
|
|
|
console.log('纬度', pos.coords.longitude);
|
|
|
|
console.log('纬度', pos.coords.longitude);
|
|
|
|
this.pos.lng = pos.coords.longitude
|
|
|
|
this.pos.lng = pos.coords.longitude
|
|
|
|
this.pos.lat = pos.coords.latitude
|
|
|
|
this.pos.lat = pos.coords.latitude
|
|
|
|
|
|
|
|
if(this.pos.lat && this.pos.lng && this.isGetLocation) {
|
|
|
|
|
|
|
|
this.pos2Address(this.pos.lat, this.pos.lng)
|
|
|
|
|
|
|
|
}
|
|
|
|
}, (error) => {
|
|
|
|
}, (error) => {
|
|
|
|
console.log(error)
|
|
|
|
console.log(error)
|
|
|
|
if (error.code) {
|
|
|
|
if (error.code) {
|
|
|
|
|