邓洁:地理位置
This commit is contained in:
@@ -35,25 +35,37 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
position: '定位1'
|
||||
position: '定位12',
|
||||
location: ''
|
||||
};
|
||||
},
|
||||
options: {
|
||||
styleIsolation: 'shared', // 解除样式隔离
|
||||
},
|
||||
created() {
|
||||
console.log('createsd');
|
||||
this.open()
|
||||
console.log('location', this.location);
|
||||
},
|
||||
watch: {
|
||||
location(val) {
|
||||
console.log('foo变化了,变化后的值是', val)
|
||||
// 具体操作=>doSomething
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
console.log('onshow');
|
||||
// const location = this.open()
|
||||
// console.log('location', this.location);
|
||||
},
|
||||
methods: {
|
||||
getLocation1() {
|
||||
let qqmapsdk = new QQMapWX({
|
||||
key: 'ZRKBZ-Q7FWL-GVZPK-MCRBU-4XFB5-ATBDB'
|
||||
});
|
||||
uni.getLocation({
|
||||
uni.getFuzzyLocation({
|
||||
type: 'wgs84',
|
||||
// geocode: true, // 返回城市信息
|
||||
// enableHighAccuracy: false, // 开启高精度模式
|
||||
success: function(res) {
|
||||
success(res) {
|
||||
console.log('res.latitude', res.latitude);
|
||||
console.log('res.longitude', res.longitude);
|
||||
qqmapsdk.reverseGeocoder({
|
||||
@@ -65,24 +77,24 @@
|
||||
console.log("解析地址成功", res);
|
||||
console.log(re.result.ad_info.city, '成都市==');
|
||||
console.log(re.result.ad_info.district, '武侯区==');
|
||||
this.position = re.result.ad_info.city
|
||||
console.log('thisposition', this.position);
|
||||
this.location = re.result.ad_info
|
||||
console.log('success', this.location);
|
||||
},
|
||||
fail: (re) => {
|
||||
console.log(re, '失败信息');
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: () => {
|
||||
console.log("获取经纬度失败");
|
||||
fail(err) {
|
||||
console.log("获取经纬度失败", err);
|
||||
},
|
||||
});
|
||||
},
|
||||
//提示用户开启定位服务
|
||||
open() {
|
||||
var that=this
|
||||
var that = this
|
||||
uni.authorize({
|
||||
scope: 'scope.userLocation',
|
||||
scope: 'scope.userFuzzyLocation',
|
||||
success: function() {
|
||||
console.log('授权成功');
|
||||
that.getLocation1()
|
||||
|
||||
Reference in New Issue
Block a user