|
|
@ -17,6 +17,7 @@ |
|
|
|
<script> |
|
|
|
import { mapState, mapActions } from 'vuex'; |
|
|
|
import { formatQuery } from 'utils/util'; |
|
|
|
import { showToast, showLoading, hideLoading, showModal } from 'utils/ui'; |
|
|
|
import { SCAN_SIGN } from 'api/api'; |
|
|
|
|
|
|
|
export default { |
|
|
@ -27,9 +28,9 @@ export default { |
|
|
|
siteName: '', |
|
|
|
success: false, |
|
|
|
type: 0, // 0进 / 1出 |
|
|
|
timer: null, |
|
|
|
latitude: 37.80079, |
|
|
|
longitude: 112.58679, |
|
|
|
timer: null, |
|
|
|
latitude: '', |
|
|
|
longitude: '', |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
@ -42,8 +43,8 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
onLoad(options) { |
|
|
|
this.init(options); |
|
|
|
this.getLocation(); |
|
|
|
this.init(options); |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
@ -82,18 +83,24 @@ export default { |
|
|
|
this.getSiteByQrId(params); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前的地址位置 |
|
|
|
// 注意用国测局的数据 map只支持gcj02 |
|
|
|
getLocation() { |
|
|
|
showLoading(); |
|
|
|
uni.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
// type: 'gcj02', |
|
|
|
success: res => { |
|
|
|
this.longitude = res.longitude; |
|
|
|
this.latitude = res.latitude; |
|
|
|
hideLoading(); |
|
|
|
console.log('当前位置的经度:' + res.longitude); |
|
|
|
console.log('当前位置的纬度:' + res.latitude); |
|
|
|
}, |
|
|
|
fail: err => { |
|
|
|
showModal('获取定位失败, 请打开GPS后重试'); |
|
|
|
console.error(err); |
|
|
|
}, |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
@ -103,7 +110,12 @@ export default { |
|
|
|
*/ |
|
|
|
async handleSign(siteId) { |
|
|
|
try { |
|
|
|
const params = { param: { siteId, locationLatitude: this.latitude, locationLongitude: this.longitude } }; |
|
|
|
if (!this.latitude || !this.longitude) { |
|
|
|
showToast('位置信息有误, 请打开定位后重试'); |
|
|
|
} |
|
|
|
const params = { |
|
|
|
param: { siteId, locationLatitude: this.latitude, locationLongitude: this.longitude }, |
|
|
|
}; |
|
|
|
await this.sign(params); |
|
|
|
this.success = true; |
|
|
|
} catch (error) { |
|
|
|