getWarpweft() {
var that = this
uni.getLocation({
type: 'gcj02',
geocode:true,
success: function (res) {
that.longitude = res.longitude;
that.latitude = res.latitude;
that.loadCity(that.latitude,that.longitude);
},
fail: function (res) {
uni.showToast({
title: '获取地址失败,将导致部分功能不可用',
icon:'none',
duration: 2000
});
},
});
},
loadCity(latitude, longitude) {
var that = this
wx.request({
url: 'https://api.map.baidu.com/geocoder/v2/?ak=liXQzVYi9b7qDIOKPabwIurp&location=' + latitude + ',' + longitude + '&output=json',
header: {
'Content-Type': 'application/json'
},
success: function (res) {
that.city = res.data.result.addressComponent.province
},
fail: function () {
}
})
},
openSetting(){
var that = this
wx.showModal({
title:'温馨提示',
content:'小程序将获取您的授权用来显示位置信息',
success(res){
if(res.confirm){
console.log('点击了确认');
wx.openSetting({
success (res) {
console.log(res.authSetting)
that.getWarpwefts()
res.authSetting = {
"scope.userInfo": true,
"scope.userLocation": true
}
}
})
}else{
console.log('点击了取消')
}
}
})
},