|
|
@@ -22,7 +22,7 @@
|
|
|
<a href="https://uri.amap.com/marker?position=115.387261,28.788671&name=南昌交通学院智慧公寓">
|
|
|
<image class="uni-map" @click="mapDaohang('115.387261','28.788671')" src="../../static/index/index_map.svg"></image>
|
|
|
</a>
|
|
|
- <br><text class="uni-body2">距离我{{distance}}km</text>
|
|
|
+ <!-- <br><text class="uni-body2">距离我{{distance}}km</text> -->
|
|
|
</view>
|
|
|
<!-- 第二层工具 -->
|
|
|
<!-- <view class="item-list">
|
|
|
@@ -358,7 +358,7 @@
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
- this.getLocationInfo()
|
|
|
+ // this.getLocationInfo()
|
|
|
this.getAllset()
|
|
|
},
|
|
|
onLoad() {
|
|
|
@@ -390,48 +390,49 @@
|
|
|
this.startWeek = getDate(new Date()).sWeek
|
|
|
this.endWeek = getDate(new Date(),1).eWeek
|
|
|
}, 1)
|
|
|
- this.getLocationInfo()
|
|
|
+ // this.getLocationInfo()
|
|
|
// wx请求获取位置权限
|
|
|
this.getAuthorize()
|
|
|
.then(() => {
|
|
|
- // 同意后获取
|
|
|
- this.getLocationInfo();
|
|
|
+ 同意后获取
|
|
|
+ // this.getLocationInfo();
|
|
|
})
|
|
|
.catch(() => {
|
|
|
- const that = this;
|
|
|
- uni.getLocation({
|
|
|
- type: "gcj02",
|
|
|
- success: function(res) {
|
|
|
- // alert(res.latitude)
|
|
|
- // 暂时
|
|
|
- that.longitude = res.longitude;
|
|
|
- that.latitude = res.latitude;
|
|
|
- var long = 0;
|
|
|
- var lat = 0;
|
|
|
- //小数点保留六位 经度
|
|
|
- if (that.longitude.toString().indexOf('.') > 0) {
|
|
|
- const longlatsplit = that.longitude.toString().split('.');
|
|
|
- if (longlatsplit.length >= 2) {
|
|
|
- long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,6));
|
|
|
- }
|
|
|
- }
|
|
|
- if (that.latitude.toString().indexOf('.') > 0) {
|
|
|
- const longlatsplit1 = that.latitude.toString().split('.');
|
|
|
- if (longlatsplit1.length >= 2) {
|
|
|
- lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,6));
|
|
|
- }
|
|
|
- }
|
|
|
- that.distance = that.getMapDistance(lat,long,'28.788671','115.387261');
|
|
|
- that.markers = [{
|
|
|
- id: "",
|
|
|
- latitude: res.latitude,
|
|
|
- longitude: res.longitude,
|
|
|
- iconPath: "../../static/img/phone.png",
|
|
|
- width: that.markerHeight, //宽
|
|
|
- height: that.markerHeight, //高
|
|
|
- }, ];
|
|
|
- },
|
|
|
- });
|
|
|
+ // const that = this;
|
|
|
+ // uni.getLocation({
|
|
|
+ // type: "gcj02",
|
|
|
+ // success: function(res) {
|
|
|
+ // console.log(res,'经纬度22')
|
|
|
+ // alert(res.latitude)
|
|
|
+ // // 暂时
|
|
|
+ // that.longitude = res.longitude;
|
|
|
+ // that.latitude = res.latitude;
|
|
|
+ // var long = 0;
|
|
|
+ // var lat = 0;
|
|
|
+ // //小数点保留六位 经度
|
|
|
+ // if (that.longitude.toString().indexOf('.') > 0) {
|
|
|
+ // const longlatsplit = that.longitude.toString().split('.');
|
|
|
+ // if (longlatsplit.length >= 2) {
|
|
|
+ // long = parseFloat(longlatsplit[0] === "" ? 0 : longlatsplit[0]) + parseFloat("." + longlatsplit[1].slice(0,6));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (that.latitude.toString().indexOf('.') > 0) {
|
|
|
+ // const longlatsplit1 = that.latitude.toString().split('.');
|
|
|
+ // if (longlatsplit1.length >= 2) {
|
|
|
+ // lat = parseFloat(longlatsplit1[0] === "" ? 0 : longlatsplit1[0]) + parseFloat("." + longlatsplit1[1].slice(0,6));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // that.distance = that.getMapDistance(lat,long,'28.788671','115.387261');
|
|
|
+ // that.markers = [{
|
|
|
+ // id: "",
|
|
|
+ // latitude: res.latitude,
|
|
|
+ // longitude: res.longitude,
|
|
|
+ // iconPath: "../../static/img/phone.png",
|
|
|
+ // width: that.markerHeight, //宽
|
|
|
+ // height: that.markerHeight, //高
|
|
|
+ // }, ];
|
|
|
+ // },
|
|
|
+ // });
|
|
|
// 不同意给出弹框,再次确认
|
|
|
// this.openConfirm()
|
|
|
// .then(() => {
|
|
|
@@ -1047,7 +1048,7 @@
|
|
|
}) // 传参带入号码即可
|
|
|
},
|
|
|
|
|
|
- // 初次位置授权
|
|
|
+ // 初次位置授权//uni-app不可用
|
|
|
getAuthorize() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
uni.authorize({
|
|
|
@@ -1063,12 +1064,17 @@
|
|
|
},
|
|
|
// 确认授权后,获取用户位置
|
|
|
getLocationInfo() {
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取',
|
|
|
+ icon:'none'
|
|
|
+ });
|
|
|
const that = this;
|
|
|
uni.getLocation({
|
|
|
- type: "wgs84",
|
|
|
- geocode: true,
|
|
|
- highAccuracyExpireTime: 100,
|
|
|
+ type: "gcj02",//gcj02,wgs84
|
|
|
+ // geocode: true,
|
|
|
+ // highAccuracyExpireTime: 100,
|
|
|
success: function(res) {
|
|
|
+ alert('location',res)
|
|
|
// 暂时
|
|
|
that.longitude = res.longitude; //118.787575;
|
|
|
that.latitude = res.latitude; //32.05024;
|
|
|
@@ -1100,14 +1106,18 @@
|
|
|
height: that.markerHeight, //高
|
|
|
}, ];
|
|
|
},
|
|
|
- fail: function () {
|
|
|
- uni.showToast({
|
|
|
- title: '获取地址失败,将导致部分功能不可用',
|
|
|
- icon:'none'
|
|
|
- });
|
|
|
- }
|
|
|
+ fail: function (err) {
|
|
|
+ uni.showModal({
|
|
|
+ content:'获取地址失败,将导致部分功能不可用'+JSON.stringify(err),
|
|
|
+ })
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '获取地址失败,将导致部分功能不可用'+JSON.stringify(err),
|
|
|
+ // icon:'none'
|
|
|
+ // });
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
+ // 天地图获取经纬度
|
|
|
// 拒绝授权后,弹框提示是否手动打开位置授权
|
|
|
openConfirm() {
|
|
|
return new Promise((resolve, reject) => {
|