Merge pull request '邓洁:位置定位' (#29) from dengjie into master
Reviewed-on: http://git.feashow.cn/odjbin/city-store-transfer/pulls/29
This commit is contained in:
@@ -31,62 +31,85 @@
|
|||||||
"https://alifei01.cfp.cn/creative/vcg/800/new/VCG41175510742.jpg"
|
"https://alifei01.cfp.cn/creative/vcg/800/new/VCG41175510742.jpg"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
|
||||||
position: {
|
|
||||||
type: String,
|
|
||||||
default () {
|
|
||||||
return '定位'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
position: '定位1'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
styleIsolation: 'shared', // 解除样式隔离
|
styleIsolation: 'shared', // 解除样式隔离
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// this.getLocation()
|
this.open()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getLocation() {
|
getLocation1() {
|
||||||
|
let qqmapsdk = new QQMapWX({
|
||||||
|
key: 'ZRKBZ-Q7FWL-GVZPK-MCRBU-4XFB5-ATBDB'
|
||||||
|
});
|
||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: 'wgs84',
|
type: 'wgs84',
|
||||||
// geocode: true, // 返回城市信息
|
// geocode: true, // 返回城市信息
|
||||||
// enableHighAccuracy: false, // 开启高精度模式
|
// enableHighAccuracy: false, // 开启高精度模式
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
let qqmapsdk = new QQMapWX({
|
console.log('res.latitude', res.latitude);
|
||||||
key: 'ZRKBZ-Q7FWL-GVZPK-MCRBU-4XFB5-ATBDB'
|
console.log('res.longitude', res.longitude);
|
||||||
});
|
|
||||||
qqmapsdk.reverseGeocoder({
|
qqmapsdk.reverseGeocoder({
|
||||||
location: {
|
location: {
|
||||||
latitude: res.latitude,
|
latitude: res.latitude,
|
||||||
longitude: res.longitude
|
longitude: res.longitude
|
||||||
},
|
},
|
||||||
success: (re) => {
|
success: (re) => {
|
||||||
|
console.log("解析地址成功", res);
|
||||||
console.log(re.result.ad_info.city, '成都市==');
|
console.log(re.result.ad_info.city, '成都市==');
|
||||||
console.log(re.result.ad_info.district, '武侯区==');
|
console.log(re.result.ad_info.district, '武侯区==');
|
||||||
|
this.position = re.result.ad_info.city
|
||||||
|
console.log('thisposition', this.position);
|
||||||
},
|
},
|
||||||
fail: (re) => {
|
fail: (re) => {
|
||||||
console.log(re, '失败信息');
|
console.log(re, '失败信息');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
fail: () => {
|
||||||
|
console.log("获取经纬度失败");
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//提示用户开启定位服务
|
//提示用户开启定位服务
|
||||||
open() {
|
open() {
|
||||||
// uni.authorize({
|
var that=this
|
||||||
// scope: 'scope.userLocation',
|
uni.authorize({
|
||||||
// success: function() {
|
scope: 'scope.userLocation',
|
||||||
// console.log('授权成功');
|
success: function() {
|
||||||
// },
|
console.log('授权成功');
|
||||||
// fail: function() {
|
that.getLocation1()
|
||||||
// console.log('授权失败');
|
},
|
||||||
// }
|
fail: function() {
|
||||||
// })
|
console.log('授权失败');
|
||||||
|
uni.showModal({
|
||||||
|
content: '检测到您没打开获取信息功能权限,是否去设置打开?',
|
||||||
|
confirmText: "确认",
|
||||||
|
cancelText: '取消',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
uni.openSetting({
|
||||||
|
success: (res) => {
|
||||||
|
console.log(res);
|
||||||
|
that.getLocation1();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('取消');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
// wx.getSetting({
|
// wx.getSetting({
|
||||||
// success: (res) => {
|
// success: (res) => {
|
||||||
// if (res.authSetting['scope.userLocation'] === false) {
|
// if (res.authSetting['scope.userLocation'] === false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user