修复初次定位异常的问题

This commit is contained in:
aixianling
2024-10-15 11:15:04 +08:00
parent 9696e62d79
commit 369002d676

View File

@@ -64,12 +64,10 @@ export default {
this.forms.girdId = this.user.girdId
this.forms.girdMemberId = this.user.girdMemberId
this.$dict.load('wyGirdNewsType')
// this.forms.lng = '114.305000'
// this.forms.lat = '30.592800'
this.getLocation()
setTimeout(() => this.getLocation(), 500)
},
methods: {
...mapActions(['injectJWeixin', 'agentSign']),
...mapActions(['injectSDK', 'agentSign']),
submit() {
if (this.flag) return
if (!this.forms.content) {
@@ -95,7 +93,8 @@ export default {
this.forms.typeName = e[0].label
},
getLocation() {
this.injectJWeixin("getLocation").then(() => {
uni.showLoading({title: "获取位置中..."})
this.injectSDK("getLocation").then(() => new Promise((resolve, reject) => {
const {wx} = window
wx.getLocation({
type: 'wgs84',
@@ -108,15 +107,16 @@ export default {
}
}).then(res => {
if (res?.code == 0) {
this.forms.address = res.data.result.address
return this.$set(this.forms, 'address', res.data.result.address)
}
})
}).finally(resolve)
},
error: err => {
console.log("获取位置失败:", err)
reject("获取位置失败")
}
})
})
})).finally(() => this.$hideLoading())
},
},
}