|
@@ -32,7 +32,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { clzConfirm, saveImgToAliOss,getGpsLocation } from '@/libs/tools.js';
|
|
|
-import { validTaskPosition } from '@/api/task.js';
|
|
|
+import { validTaskPosition, tencentAddressInfo } from '@/api/task.js';
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -56,16 +56,36 @@ export default {
|
|
|
// 获取当前位置
|
|
|
getLocation() {
|
|
|
const _this = this;
|
|
|
+ // 获取系统信息同步接口
|
|
|
+ const res = uni.getSystemInfoSync()
|
|
|
getGpsLocation(function(gps){
|
|
|
console.log(gps)
|
|
|
- _this.position = {
|
|
|
- latitude:gps[1],
|
|
|
- longitude:gps[0],
|
|
|
+ // 安卓手机需要转格式,ios不需要
|
|
|
+ if(res.platform == 'android'){ // 安卓
|
|
|
+ _this.position = { latitude: gps[1], longitude: gps[0] }
|
|
|
+ // 反解析拿到地址
|
|
|
+ _this.getAddressInfo({ lat: gps[1], lng: gps[0] })
|
|
|
+ }else if(res.platform == 'ios'){ // ios
|
|
|
+ _this.position = { latitude: gps.latitude, longitude: gps.longitude }
|
|
|
+ const province = gps.address.province ? gps.address.province : '' // 省份名称
|
|
|
+ const city = gps.address.city ? gps.address.city : '' // 城市名称
|
|
|
+ const district = gps.address.district ? gps.address.district : '' // 区(县)名称
|
|
|
+ const poiName = gps.address.poiName ? gps.address.poiName : '' // POI信息
|
|
|
+ const street = gps.address.street ? gps.address.street : '' // 街道信息
|
|
|
+ const streetNum = gps.address.streetNum ? gps.address.streetNum : '' // 获取街道门牌号信息
|
|
|
+ _this.location = province + city + district + poiName + '(' + street + streetNum + ')'
|
|
|
}
|
|
|
- // 反解析拿到地址
|
|
|
- // this.location
|
|
|
})
|
|
|
},
|
|
|
+ // 根据经纬度获取具体位置
|
|
|
+ getAddressInfo(params) {
|
|
|
+ tencentAddressInfo(params).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.location = res.data.province + res.data.city + res.data.district + res.data.address;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
// 签到拍照
|
|
|
goPhotograph() {
|
|
|
const _this = this;
|
|
@@ -107,8 +127,7 @@ export default {
|
|
|
}
|
|
|
// 存储当前签到信息
|
|
|
this.$u.vuex('vuex_sceneTaskSignIn',{
|
|
|
- inspectorPositionAddr: '',
|
|
|
- inspectorPositionPhotoBasePath:'',
|
|
|
+ inspectorPositionAddr: this.location,
|
|
|
inspectorPositionPhotoPath: this.photograph
|
|
|
})
|
|
|
// 判断是否超出签到范围
|