fix
pyt
2025-03-18 a160568ae67ab21f7bd7fadc606ca7477ef0141c
fix
3个文件已修改
48 ■■■■ 已修改文件
H5/config/index.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/pages/location/location.vue 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/pages/location/service.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/config/index.js
@@ -1,5 +1,5 @@
export default {
    // BASE_URL: 'https://huacheng.psciio.com',
    BASE_URL: 'http://192.168.110.188:6194',
    BASE_URL: 'https://huacheng.psciio.com',
    // BASE_URL: 'http://192.168.110.188:6194',
    imageUrl: 'https://huacheng.psciio.com/api/huacheng-applets/common/uploadimages',
}
H5/pages/location/location.vue
@@ -34,7 +34,8 @@
<script>
    import {
        searchLocation
        searchLocation,
        geoconv
    } from './service'
    export default {
        data() {
@@ -111,28 +112,23 @@
            navigator.geolocation.getCurrentPosition(success, error, options);
            function success(position) {
                uni.request({
                    url: `https://api.map.baidu.com/geoconv/v2/?coords=${position.coords.longitude},${position.coords.latitude}&model=2&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
                    method: 'GET',
                    success: (res) => {
                        const latitude = res.data.result[0].y;
                        const longitude = res.data.result[0].x;
                        var point = new BMapGL.Point(longitude, latitude); // 创建点坐标
                        that.map.enableScrollWheelZoom(true);
                        that.map.centerAndZoom(point, 12);
                        var marker = new BMapGL.Marker(point);
                        that.map.addOverlay(marker);
                        that.markers.push(marker);
                        var myGeo = new BMapGL.Geocoder();
                        // 根据坐标得到地址描述
                        myGeo.getLocation(new BMapGL.Point(longitude, latitude), (result) => {
                            that.locationList = result.surroundingPois.map((item, index) => {
                                item.id = index + 1
                                return item
                            })
                geoconv({coords:`${position.coords.longitude},${position.coords.latitude}`}).then(res=>{
                    const latitude = res.data[0].y;
                    const longitude = res.data[0].x;
                    that.map.enableScrollWheelZoom(true);
                    that.map.centerAndZoom(point, 12);
                    var marker = new BMapGL.Marker(point);
                    that.map.addOverlay(marker);
                    that.markers.push(marker);
                    var myGeo = new BMapGL.Geocoder();
                    // 根据坐标得到地址描述
                    myGeo.getLocation(new BMapGL.Point(longitude, latitude), (result) => {
                        that.locationList = result.surroundingPois.map((item, index) => {
                            item.id = index + 1
                            return item
                        })
                    },
                });
                    })
                })
            }
            function error(err) {
H5/pages/location/service.js
@@ -3,4 +3,8 @@
// 地点搜索
export const searchLocation = (params) => {
    return request.get(`/api/huacheng-sangeshenbian/applet/home/search-location`, params)
}
// 地点搜索
export const geoconv = (params) => {
    return request.get(`/api/huacheng-sangeshenbian/applet/home/geoconv`, params)
}