修复初次定位异常的问题

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