修复定位问题

This commit is contained in:
aixianling
2024-10-14 17:59:33 +08:00
parent 9e4cd7f2f4
commit 622e073878

View File

@@ -32,7 +32,7 @@
</template> </template>
<script> <script>
import {mapState, mapActions} from 'vuex' import {mapActions, mapState} from 'vuex'
export default { export default {
name: 'Add', name: 'Add',
@@ -63,7 +63,7 @@ export default {
this.forms.girdName = this.user.girdName this.forms.girdName = this.user.girdName
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' // this.forms.lng = '114.305000'
// this.forms.lat = '30.592800' // this.forms.lat = '30.592800'
this.getLocation() this.getLocation()
@@ -95,26 +95,25 @@ export default {
this.forms.typeName = e[0].label this.forms.typeName = e[0].label
}, },
getLocation() { getLocation() {
this.injectJWeixin('getLocation').then(() => { this.injectJWeixin("getLocation").then(() => {
const {wx} = window
wx.getLocation({ wx.getLocation({
type: 'wgs84', type: 'wgs84',
success: res2 => { success: res2 => {
console.log('获取当前定位信息:', res2)
this.forms.lng = res2.longitude this.forms.lng = res2.longitude
this.forms.lat = res2.latitude this.forms.lat = res2.latitude
this.$http.post('/api/appdvcpconfig/apiForward', null, { this.$http.post('/app/appdvcpconfig/apiForward', null, {
params: { params: {
url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${this.forms.lat},${this.forms.lng}&key=3RZBZ-LZUCF-CT6J5-NWKZH-FCWOQ-UUFKY&get_poi=1` url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${this.forms.lat},${this.forms.lng}&key=3RZBZ-LZUCF-CT6J5-NWKZH-FCWOQ-UUFKY&get_poi=1`
} }
}).then(res => { }).then(res => {
console.log("获取详细地址信息:", res)
if (res?.code == 0) { if (res?.code == 0) {
this.forms.address = res.data.result.address this.forms.address = res.data.result.address
} }
}) })
}, },
error: err => { error: err => {
console.log(err) console.log("获取位置失败:", err)
} }
}) })
}) })