修改
This commit is contained in:
parent
cc7dade9d7
commit
170c089715
@ -341,6 +341,38 @@
|
||||
// uni.$off('code');
|
||||
// },
|
||||
methods: {
|
||||
//获取当前位置
|
||||
getAddress() {
|
||||
let that = this;
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
let location = res.latitude + ',' + res.longitude
|
||||
//调用逆解析接口
|
||||
uni.request({
|
||||
url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=location', //腾讯官方逆解析接口,可直接复制
|
||||
data: {
|
||||
location: location,
|
||||
'key': "Q4DBZ-UIMC2-B63UX-CUZ6A-S3UT7-TBF3V", //自己申请的Key
|
||||
},
|
||||
method: "GET",
|
||||
success(res) {
|
||||
uni.setStorageSync('location', res.data.result.address_component.city)
|
||||
},
|
||||
fail: res => {
|
||||
console.log(res.errMsg, '解析失败返回的错误信息');
|
||||
}
|
||||
})
|
||||
},
|
||||
//失败
|
||||
fail: (res) => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '获取地址失败,请打开定位',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
...mapMutations(['scoket']),
|
||||
// 与户主关系
|
||||
nationSelect(e) {
|
||||
@ -526,6 +558,7 @@
|
||||
},
|
||||
//进入界面加载
|
||||
onLoad(options) {
|
||||
this.getAddress()
|
||||
let that = this
|
||||
// console.log(options, '00')
|
||||
uni.$on('headPictureUrl', (res) => {
|
||||
|
||||
@ -42,9 +42,9 @@
|
||||
},
|
||||
onShow() {
|
||||
var that = this
|
||||
if (!uni.getStorageSync('location') && !uni.getStorageSync('region')) {
|
||||
this.getAddress()
|
||||
}
|
||||
// if (!uni.getStorageSync('location') && !uni.getStorageSync('region')) {
|
||||
// this.getAddress()
|
||||
// }
|
||||
// this.getAddress();
|
||||
createMobileToken().then(res => {
|
||||
uni.setStorageSync("token", res.data.token)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user