| | |
| | | <van-list v-else :finished="finished" :finished-text="finishedText"> |
| | | <van-cell v-for="item in list" :key="item" @click="flyToAddress(item)"> |
| | | <template #title>{{ item.name }}</template> |
| | | <template #value>{{ item.district }}</template> |
| | | <template #value>{{ item?.pname }}{{ item?.cityname }}{{ item?.adname }}</template> |
| | | </van-cell> |
| | | </van-list> |
| | | </van-floating-panel> |
| | |
| | | import { showToast } from 'vant' |
| | | import _ from 'lodash' |
| | | import { searchWithPlugin } from '@/utils/util' |
| | | import { getPlace } from '@/api/map/address' |
| | | import { useStore } from 'vuex' |
| | | import EventBus from '@/utils/eventBus' |
| | | import { gcj02ToWgs84 } from '@/utils/coordinateTransformation' |
| | |
| | | const height = ref(anchors[0]) |
| | | const curSearchType = ref(1) // 固定为地址搜索 |
| | | |
| | | // 获取地址搜索结果 |
| | | const getAddressList = () => { |
| | | // 使用插件搜索地址 |
| | | const searchWithPluginAPI = () => { |
| | | searchWithPlugin(searchVal.value, selectedAreaCode.value, (err, data) => { |
| | | if (data && data.length > 0) { |
| | | list.value = data |
| | |
| | | loadingTest.value = false |
| | | }, 800) |
| | | }) |
| | | } |
| | | |
| | | // 使用新接口搜索地址 |
| | | const searchWithNewAPI = () => { |
| | | getPlace({ keyworld: searchVal.value }).then(res => { |
| | | const data = res.data.data.pois || [] |
| | | if (data && data.length > 0) { |
| | | list.value = data |
| | | finishedText.value = '' |
| | | } else { |
| | | finishedText.value = '暂无数据' |
| | | } |
| | | |
| | | setTimeout(() => { |
| | | finished.value = true |
| | | loadingTest.value = false |
| | | }, 800) |
| | | }).catch(err => { |
| | | console.error('地址搜索失败:', err) |
| | | finishedText.value = '搜索失败' |
| | | setTimeout(() => { |
| | | finished.value = true |
| | | loadingTest.value = false |
| | | }, 800) |
| | | }) |
| | | } |
| | | |
| | | // 获取地址搜索结果 |
| | | const getAddressList = () => { |
| | | searchWithNewAPI() |
| | | } |
| | | |
| | | const tooltipText = computed(() => { |
| | |
| | | showToast('当前地址无坐标信息') |
| | | return |
| | | } |
| | | |
| | | const [longitude, latitude] = gcj02ToWgs84(item.location.lng, item.location.lat) |
| | | const location = typeof item.location === 'string' |
| | | ? item.location.split(',').map(Number) |
| | | : [item.location.lng, item.location.lat]; |
| | | const [longitude, latitude] = gcj02ToWgs84(location[0], location[1]) |
| | | |
| | | height.value = anchors[0] |
| | | |
| | | searchVal.value = item.name |
| | | inputSelect() |
| | | |
| | | EventBus.emit('mapAddMarker', { |
| | | lat: latitude, |
| | |
| | | name: searchVal.value, |
| | | customClassName: 'address-marker', |
| | | }) |
| | | } |
| | | |
| | | const scanCode = () => { |
| | | const transmitData = { data: { type: 'scanCode' } } |
| | | wx.miniProgram.navigateTo({ url: "/subPackages/qrCode/index" }) |
| | | wx.miniProgram.postMessage(transmitData) |
| | | uni.postMessage(transmitData) |
| | | } |
| | | |
| | | watch( |