Bladeren bron

no message

Fly 5 maanden geleden
bovenliggende
commit
f44a121376

+ 11 - 5
components/bab-Touchbox/bab-Touchbox.vue

@@ -2,7 +2,7 @@
 	<view>
 		<view :class="isend?'fixedbox2' :'fixedbox'"
 			:style="{'height':windowHeight + 'px','width':windowWidth + 'px','top':fixboxtop +'px','border-top-left-radius':radius,'border-top-right-radius':radius,'z-index':zIndex}"
-			@touchmove="getstart($event)" @tap="tap" @touchend="getend" ref="fixbox">
+			@touchmove="getstart" @tap="tap" @touchend="getend" ref="fixbox">
 			<view class="content" :style="{'height':windowHeight + 'px'}">
 				<view class="tapBoxTouchLine" v-if="showLine">
 					<view class="line" :style="{'transform': `scaleY(${lineScale})`,'width':`${lineWidth}rpx`}"></view>
@@ -51,7 +51,7 @@
 			},
 			lineWidth: {
 				type: Number,
-				default: 120,
+				default: 220,
 			},
 			zIndex: {
 				type: Number,
@@ -100,10 +100,16 @@
 		onReady() {},
 		computed: {},
 		methods: {
+			// 隐藏
+			concealList(){
+				const H_ = uni.getSystemInfoSync().windowHeight;
+				this.fixboxtop = H_ - uni.upx2px(200)
+			},
 			tap(e) {
 				// console.log(e)
 			},
-			getstart(e) { 
+			getstart(e) {  
+				e.preventDefault();
 				const {clientY , screenY } = e.touches[0];
 				let Y = clientY || screenY;
 				// //#ifdef MP-WEIXIN
@@ -166,11 +172,11 @@
 </script>
 
 <style lang="scss" scoped>
-	.tapBoxTouchLine {
-		margin-top: 20rpx;
+	.tapBoxTouchLine { 
 		display: flex;
 		align-items: center;
 		justify-content: center;
+		padding: 20rpx 0 30rpx;
 	}
 
 	.line {

+ 1 - 1
components/city/city.vue

@@ -123,7 +123,7 @@
 
 <style lang="scss" scoped>
 	.uni-popup {
-		z-index: 1001;
+		z-index: 1002;
 
 		.city-box {
 			height: 55vh;

+ 1 - 1
components/mapType/mapType.vue

@@ -75,7 +75,7 @@
 
 <style lang="scss" scoped>
 	.uni-popup {
-		z-index: 1001;
+		z-index: 1002;
 
 		.city-box {
 			height: 55vh;

File diff suppressed because it is too large
+ 116 - 41
components/tiandituMap/tiandituMap.vue


+ 2 - 1
config/index.js

@@ -1,3 +1,4 @@
 export default {
-	baseURL: "http://192.168.0.152:8282"
+	baseURL: "https://ditu.qqzzhou.com/oa",
+	// baseURL: "http://192.168.0.152:8282" 
 }

+ 1 - 2
index.html

@@ -9,8 +9,7 @@
         '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
         (coverSupport ? ', viewport-fit=cover' : '') + '" />')
     </script>
-	<script src="http://api.tianditu.gov.cn/api?v=4.0&tk=1edd9c001a8425cb93631398109d5ab2" type="text/javascript"></script>
-    <title></title>
+	<title></title>
     <!--preload-links-->
     <!--app-context-->
   </head>

+ 4 - 7
manifest.json

@@ -73,13 +73,10 @@
         "title" : "武汉公安政务服务",
         "template" : "",
         "sdkConfigs" : {
-            "maps" : {
-                "amap" : {
-                    "key" : "427c1b3b7b0aaa258221992c860859f7",
-                    "securityJsCode" : "",
-                    "serviceHost" : ""
-                }
-            }
+            "maps" : {}
+        },
+        "router" : {
+            "base" : "/h5/"
         }
     }
 }

+ 5 - 0
package-lock.json

@@ -2,6 +2,11 @@
   "requires": true,
   "lockfileVersion": 1,
   "dependencies": {
+    "@amap/amap-jsapi-loader": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmmirror.com/@amap/amap-jsapi-loader/-/amap-jsapi-loader-1.0.1.tgz",
+      "integrity": "sha512-nPyLKt7Ow/ThHLkSvn2etQlUzqxmTVgK7bIgwdBRTg2HK5668oN7xVxkaiRe3YZEzGzfV2XgH5Jmu2T73ljejw=="
+    },
     "gcoord": {
       "version": "1.0.6",
       "resolved": "https://registry.npmmirror.com/gcoord/-/gcoord-1.0.6.tgz",

+ 0 - 337
pages/map/index - 副本 (2).vue

@@ -1,337 +0,0 @@
-<template>
-    <view>
-        <view v-if="visible" class="mask" :style="{ height: (winHeight)+ 'px',width: winWidth+'px',top: winTop+'px'}">
-      <!--      <tiandituSearchVue :showSearch="search"
-                :searchStyle="{ height: iStatusBarHeight ?  iStatusBarHeight + 'px' : 'fitcontent', paddingTop: iStatusBarHeight ?  '20px' : '0' }"
-                @onSearch="tianidtuSearch" :searchType="searchType" @onClose="close" @onConfirm="onConfirm">
-            </tiandituSearchVue> -->
-			<tiandituMap ref="tiandituMapRefs" @onLoadTianDiTu="initMaps" @onSelect="selectPoint" :apiKey="apiKey"
-			    :customIcon="icon">
-			</tiandituMap>
-            <!-- footer -->
-            <view class="list-boxd" ref="listBox" :style="{minHeight: domMinHeight, maxHeight: domMaxHeight}">
-                <view class="list-header" @touchstart="start" @touchend="end"></view>
-                <view class="list-content">
-                    <view v-for="(item, index) in datalist" :key="index" @click="selectCard(item)">
-                        <!-- #ifdef MP-WEIXIN -->
-                        <slot name="cards" :row="item" :index="selectItem"></slot>
-                        <!-- #endif -->
-                        <!-- #ifdef H5  -->
-                        <slot name="cards" :row="item" :index="selectItem" @click="selectCard(item)"></slot>
-                        <!-- #endif -->
-                        <!-- #ifdef APP  -->
-                        <slot name="cards" :row="item" :index="selectItem" @click="selectCard(item)"></slot>
-                        <!-- #endif -->
-                        <view class="card"
-                            :style="{background: item.address === selectItem.address ?'#f3f4f6' :'#FFFFFF'}"
-                            v-if="!$slots.cards">
-                            <view class="card-left">
-                                <view class="card-title">{{item.address}}{{item.name && `(${item.name})`}}</view>
-                                <view class="card-text">({{item.location.lon}},{{item.location.lat}})</view>
-                            </view>
-                            <view class="card-right">
-                                <view class="arrow"></view>
-                            </view>
-                        </view>
-                    </view>
-                </view>
-            </view>
-        </view>
-    </view>
-</template>
-<script>
-    // import tiandituMap from './tianditu-map.vue'
-    // import tiandituSearchVue from './tianditu-search.vue'
-    import tools from '@/components/tiandituMap/tools.js'
-    export default {
-        name: 'tdtmap',
-        // components: {
-        //     // tiandituMap,
-        //     tiandituSearchVue,
-        // },
-        props: {
-            apiKey: {
-                type: String, 
-                default: '1edd9c001a8425cb93631398109d5ab2'
-            },
-            searchType: {
-                type: Number,
-                default: 0
-            },
-            search: {
-                type: Boolean,
-                default: true
-            },
-            icon: {
-                type: String,
-                default: ''
-            }
-        },
-        data() {
-            return {
-                winWidth: 0,
-                winHeight: 0,
-                winTop: 0,
-                visible: false,
-                datalist: [],
-                startY: 0,
-                domMaxHeight: '50vh',
-                domMinHeight: '0vh',
-                selectItem: {},
-                iStatusBarHeight: 0,
-                option: {
-                    apikey: 123123,
-                }
-            }
-        },
-        created() {
-			
-            // var that = this
-             
-            // uni.getSystemInfo({
-            //     success: function(res) {
-            //         that.winWidth = res.windowWidth
-            //         that.winHeight = res.windowHeight
-            //         that.winTop = res.windowTop
-            //     }
-            // });
-        },
-		mounted() {
-			this.open(104.397894, 31.126855)
-		},
-        methods: {
-            open(lon, lat) {
-                if (lon && lat) {
-                    this.visible = true
-                    this.$nextTick(() => {
-                        this.$refs.tiandituMapRefs.initCharts(lon, lat)
-                    })
-                } else {
-                    console.error('请传入lon, lat')
-                }
-
-            },
-            close() {
-                this.visible = false
-            },
-            onConfirm() {
-                if (Object.keys(this.selectItem).length) {
-                    this.visible = false
-                    this.$emit('onSelect', this.selectItem)
-                } else {
-                    tools.createMessage('请选择位置')
-                }
-            },
-            upDateLonLat(lon, lat) {
-                if (lon && lat) {
-                    this.$refs.tiandituMapRefs.upDataCharts(lon, lat)
-                } else {
-                    console.error('请传入lon, lat')
-                }
-            },
-            tianidtuSearch(value) {
-                if (value.city) {
-                    this.cityInfoSearch(value)
-                } else {
-                    this.infoSearch(value)
-                }
-            },
-            async infoSearch(value) { // 地理编码查询
-                let params = {
-                    ds: {
-                        "keyWord": value.keyword,
-                    },
-                    tk: this.apiKey,
-                }
-                let resData = await tools.createRequest('http://api.tianditu.gov.cn/geocoder', params, true)
-                if (resData.status === '0') {
-                    const location = resData.location
-                    const formateOne = tools.formatterAdressLocation(resData, 3)
-                    this.datalist = [formateOne]
-                    this.selectItem = datalist
-                    this.$refs.tiandituMapRefs.upDataCharts(location.lon, location.lat)
-                }
-            },
-            async cityInfoSearch(value) { // 地名搜索2.0
-                let params = {
-                    postStr: {
-                        "keyWord": value.keyword,
-                        "queryType": 12,
-                        "start": 0,
-                        "count": 10,
-                        "specify": value.city.value
-                    },
-                    type: 'query',
-                    tk: this.apiKey,
-                }
-                let resData = await tools.createRequest('http://api.tianditu.gov.cn/v2/search', params, true)
-                if (resData.status.infocode === 1000) {
-                    const {
-                        pois: aPoints,
-                        count
-                    } = resData
-                    if (count === '0' || !aPoints || !aPoints.length) {
-                        return tools.createMessage('没有找到该地址')
-                    }
-                    const {
-                        pois,
-                        keyWord,
-                        lonlat
-                    } = aPoints[0]
-                    const formateData = aPoints.map((item) => tools.formatterAdressLocation(item, 2))
-                    this.datalist = formateData
-                    this.selectItem = formateData[0]
-                    const [lon, lat] = lonlat.split(',')
-                    this.$refs.tiandituMapRefs.upDataCharts(lon, lat)
-                } else {
-                    tools.createMessage('数据异常', 1000, false, 'error')
-                }
-            },
-            selectListItem(item) {
-                this.$refs.tiandituMapRefs.upDataCharts(item.location.lon, item.location.lat)
-            },
-            selectPoint(e) {
-                this.domMinHeight = '0vh'
-                this.datalist = [e]
-                this.selectItem = e
-            },
-            initMaps() {
-                console.warn('--------天地图加载完成--------');
-                this.$emit('onLoad')
-            },
-            start(e) {
-                const clientY = e.changedTouches[0].clientY
-                this.startY = clientY
-            },
-            end(e) {
-                const transformY = e.changedTouches[0].clientY - this.startY;
-                switch (true) {
-                    case transformY > 50:
-                        console.log('下划')
-                        this.domMaxHeight = '20vh'
-                        this.domMinHeight = '0vh'
-                        break;
-                    case transformY < -50:
-                        console.log('上划')
-                        this.domMaxHeight = '50vh'
-                        this.domMinHeight = '50vh'
-                        break;
-                    default:
-                        break;
-                }
-
-            },
-            selectCard(item) {
-                this.domMaxHeight = '20vh'
-                this.domMinHeight = '0vh'
-                this.selectItem = item
-                this.selectListItem(item)
-            }
-        }
-    }
-</script>
-
-
-
-<style scope>
-    .mask {
-        /* overflow: hidden; */
-        position: fixed;
-        left: 0;
-        background-color: #FFFFFF;
-        z-index: 399;
-    }
-
-    /* footer */
-    .list-boxd {
-        position: absolute;
-        bottom: 0;
-        left: 0;
-        z-index: 401;
-        right: 0;
-        border-radius: 14px 14px 0 0;
-        background: #FFFFFF;
-        transition: all 1s;
-    }
-
-    .list-header {
-        height: 20px;
-        position: relative;
-        border-bottom: 1px solid #f3f4f6;
-        cursor: pointer;
-    }
-
-    .list-header::after {
-        position: absolute;
-        left: 50%;
-        top: 50%;
-        transform: translate(-50%, -50%);
-        content: '';
-        height: 6px;
-        width: 60px;
-        border-top: 1px solid #e8e8e8;
-        border-bottom: 1px solid #e8e8e8;
-    }
-
-    .list-content {
-        max-height: 50vh;
-        overflow-y: scroll;
-    }
-
-    .card {
-        min-height: 44px;
-        padding: 12px;
-        position: relative;
-        display: flex;
-        justify-content: space-between;
-        align-items: center;
-
-    }
-
-    .card-left {
-        display: flex;
-        flex-direction: column;
-        justify-content: center;
-    }
-
-    .card-right {
-        padding-right: 10px;
-    }
-
-    .arrow {
-        border-top: 2px solid #666666;
-        border-right: 2px solid #666666;
-        width: 10px;
-        height: 10px;
-        transform: rotate(45deg);
-    }
-
-
-    .card:active {
-        background-color: #f3f4f6;
-    }
-
-
-    .card::after {
-        position: absolute;
-        content: '';
-        bottom: 0;
-        height: 1px;
-        background-color: #e8e8e8;
-        width: 90%;
-    }
-
-    .card:last-child::after {
-        height: 0;
-        background-color: #FFFFFF;
-    }
-
-    .card-title {
-        font-size: 18px;
-    }
-
-    .card-text {
-        color: #e8e8e8;
-        font-size: 13px;
-    }
-</style>

+ 0 - 24
pages/map/index - 副本.vue

@@ -1,24 +0,0 @@
-<template>
-	<zhuo-tianditu-select ref="tMap" api-key="1edd9c001a8425cb93631398109d5ab2"></zhuo-tianditu-select>
-</template>
-
-<script>
-	export default{
-		data(){
-			return{
-				
-			}
-		},
-		methods:{
-			
-		},
-		mounted() {
-			this.$refs.tMap.open(104.397894, 31.126855)
-		}
-		
-		
-	}
-</script>
-
-<style>
-</style>

+ 84 - 79
pages/map/index.vue

@@ -1,17 +1,21 @@
 <template>
 	<view class="map-box">
 
-		<search @handleSearch="handleSearch" v-if="showMap" />
-		<tiandituMap ref="tiandituMapRefs" @onLoadTianDiTu="initMaps" @onSelect="selectPoint" :apiKey="apiKey">
+		<search ref="searchRef" @handleSearch="handleSearch" v-if="showMap" />
+		<tiandituMap ref="tiandituMapRefs" @handleSearch="handleSearch" @clickMap="handleClickMap" @moveMap="moveMapSearch"
+			@onLoadTianDiTu="initMaps" @onSelect="selectPoint" :apiKey="apiKey">
 		</tiandituMap>
-		<bab-Touchbox v-if="showMap && siteList && siteList.length > 0" :zIndex="1001" :minHeight="0.35" :maxHeight="0.8" :touchHeight="64"
-			@currentHeight="setTouchHeight" @maxtHeight="setScrollMaxHeight">
+		<bab-Touchbox ref="TouchboxRef" v-if="showMap && siteListArr && siteListArr.length > 0" :zIndex="1001"
+			:minHeight="0.35" :maxHeight="0.8" :touchHeight="64" @currentHeight="setTouchHeight"
+			@maxtHeight="setScrollMaxHeight">
 			<scroll-view :style="{'height':TouchHeight - 40  +'px' }" scroll-y="true" :show-scrollbar="false">
-				<template v-for="item in siteList">
+				<template v-for="item in siteListArr">
 					<siteListModel :info="item" />
 				</template>
 			</scroll-view>
 		</bab-Touchbox>
+
+		<siteDetails ref="siteDetailsRef" />
 	</view>
 </template>
 <script>
@@ -19,15 +23,19 @@
 	import search from "./model/search.vue"
 	import siteListModel from "./model/siteList.vue";
 	import { getMapCenterPoint_Api, getMapList_Api } from "@/api/map.js"
+	import { getLocation } from "@/utils/tool.js"
+	import siteDetails from "./model/siteDetails.vue"
 	export default {
 		name: 'tdtmap',
 		components: {
-			// tiandituMap,
 			search,
-			siteListModel
+			siteListModel,
+			siteDetails
 		},
 		data() {
 			return {
+				selfLatitude: undefined,
+				selfLongitude: undefined,
 				showMap: false,
 				longitude: undefined,
 				latitude: undefined,
@@ -45,113 +53,108 @@
 					apikey: '123123',
 				},
 
-				siteList: [],
+				siteListArr: [],
 				TouchHeight: 0,
 			}
 		},
 		created() {
-			// if (navigator.geolocation) {
-			//   navigator.geolocation.getCurrentPosition(function(position) {
-			//     var latitude = position.coords.latitude;
-			//     var longitude = position.coords.longitude;
-			//     // 在这里处理获取到的经纬度
-			// 	console.log("Longitude is :", latitude , longitude);
-			//   });
-			// } else {
-			//   // 处理不支持 Geolocation 的情况
-			//   console.error("Error Code = " + error.code + " - " + error.message);
-			// }
-			// try {
-			// 	uni.getLocation({
-			// 		type:'wgs84',
-			// 		cacheTimeout: 30 * 60,
-			// 		success: Location => {
-			// 			console.log("getLocation" , Location)
-			// 			// const address = Location.address;
-			// 			// // 缓存全局的定位信息
-			// 			// app.globalData.location = address;
-			// 			// this.location = address;
-			// 			// if (!address.city) {
-			// 			// 	uni.showToast({
-			// 			// 		title: '获取定位失败',
-			// 			// 		icon: 'none'
-			// 			// 	})
-			// 			// } else {
-			// 			// 	uni.showToast({
-			// 			// 		title: '获取定位成功,请开始抽奖',
-			// 			// 		icon: 'none'
-			// 			// 	})
-			// 			// }
-
-			// 		},
-			// 		fail: LocationErr => {
-			// 			 console.log("LocationErr = " , LocationErr)
-			// 		} 
-			// 	})
-			// } catch (error) {
-			// 	console.log("LocationErr = catch" , LocationErr)
-			// }
-			// // uni.getSystemInfo({
-			// //     success: function(res) {
-			// //         that.winWidth = res.windowWidth
-			// //         that.winHeight = res.windowHeight
-			// //         that.winTop = res.windowTop
-			// //     }
-			// // });
+			console.log('获取位置失败 22211---------------');
+			try {
+				navigator.geolocation.getCurrentPosition(function(position) {
+					console.log("Latitude is :", position.coords.latitude);
+					console.log("Longitude is :", position.coords.longitude);
+				}, function(error) {
+					console.error("Error Code = " + error.code + " - " + error.message);
+				});
+			} catch (error) {
+				//TODO handle the exception
+				console.log('获取位置失败 999999999999 ---------------', error);
+			}
+			console.log('获取位置失败 22233---------------');
+			this.getMapCenterPoint()
 		},
 		mounted() {
-			// this.open(114.294, 30.534)
-			this.getMapCenterPoint()
+
+			getLocation().then(res => {
+				this.selfLatitude = res.longitude;
+				this.selfLongitude = res.latitude;
+			})
 		},
 		watch: {
-			siteList: {
+			siteListArr: {
 				handler(newArr) {
-					this.$refs.tiandituMapRefs.clearIcon();
-					(newArr || []).forEach(el => {
-						const { longitude, latitude, mapTypeIcon } = el
-						this.$refs.tiandituMapRefs.setIcon(longitude, latitude, false, mapTypeIcon);
+					console.log('newArr === ' , newArr)
+					try {
+						this.$refs.tiandituMapRefs.clearIcon();
+					} catch (error) {}
+					this.$nextTick(() => {
+						(newArr || []).forEach(el => {
+							const { longitude, latitude, mapTypeIcon } = el
+							this.$refs.tiandituMapRefs.setIcon(longitude, latitude, false, mapTypeIcon);
+						})
 					})
 				},
 				deep: true
 			}
 		},
 		methods: {
+			// 点击地图
+			handleClickMap() {
+				if (this.$refs.TouchboxRef) {
+					this.$refs.TouchboxRef.concealList()
+				}
+			},
 			// 获取地图中心点
 			getMapCenterPoint() {
 				uni.showLoading()
 				this.showMap = false;
 				getMapCenterPoint_Api().then(res => {
-					const { longitude, latitude , mapTypeIcon } = res || {};
+					const { longitude, latitude, mapTypeIcon } = res || {};
 					this.longitude = longitude;
 					this.latitude = latitude;
-					this.open(longitude, latitude , mapTypeIcon)
-					
+					this.open(longitude, latitude, mapTypeIcon)
+					// this.$nextTick(() => {
+					// 	this.handleSearch()
+					// })
 				}).catch(err => { this.open(null, null) }).finally(() => {
 					uni.hideLoading()
 				})
 			},
- 
+			moveMapSearch(parms) {
+				const { Lng, Lat } = parms;
+				this.longitude = Lng;
+				this.latitude = Lat;
+				this.$refs.searchRef.onSearchFocus()
+				// console.log("moveMapSearch", Lng, Lat)
+			},
 			handleSearch(val = {}) {
-				const parms = { ...val, longitude: this.longitude, latitude: this.latitude };
+				const parms = {
+					...val,
+					longitude: this.longitude,
+					latitude: this.latitude,
+					radius: 5000,
+					selfLatitude: this.selfLatitude,
+					selfLongitude: this.selfLongitude
+				};
 				getMapList_Api(parms).then(res => {
-					if(!res || res.length === 0){
+					if (!res || res.length === 0) {
 						uni.showToast({
-							title:"搜索结果为空",
-							icon:'none'
+							title: "当前区域无服务",
+							icon: 'none'
 						})
 					}
-					this.siteList = res || [];
+					this.siteListArr = res || [];
 				}).catch(err => {
-					this.siteList = [];
+					this.siteListArr = [];
 				})
 			},
 
 
 
-			open(lon, lat , mapTypeIcon) {
+			open(lon, lat, mapTypeIcon) {
 				if (lon && lat) {
 					this.$nextTick(() => {
-						this.$refs.tiandituMapRefs.initCharts(lon, lat , mapTypeIcon)
+						this.$refs.tiandituMapRefs.initCharts(lon, lat, mapTypeIcon)
 						this.showMap = true;
 					})
 				} else {
@@ -159,7 +162,7 @@
 						title: '提示',
 						content: '地图中心点获取错误,请联系管理员!',
 						success: res => {
-							console.log("showModal == ", res)
+							// console.log("showModal == ", res)
 							if (res.confirm) {}
 						}
 					})
@@ -198,7 +201,7 @@
 					},
 					tk: this.apiKey,
 				}
-				let resData = await tools.createRequest('http://api.tianditu.gov.cn/geocoder', params, true)
+				let resData = await tools.createRequest('https://api.tianditu.gov.cn/geocoder', params, true)
 				if (resData.status === '0') {
 					const location = resData.location
 					const formateOne = tools.formatterAdressLocation(resData, 3)
@@ -219,7 +222,7 @@
 					type: 'query',
 					tk: this.apiKey,
 				}
-				let resData = await tools.createRequest('http://api.tianditu.gov.cn/v2/search', params, true)
+				let resData = await tools.createRequest('https://api.tianditu.gov.cn/v2/search', params, true)
 				if (resData.status.infocode === 1000) {
 					const {
 						pois: aPoints,
@@ -286,7 +289,7 @@
 
 
 			setTouchHeight(val) {
-				console.log('setScrollHeight = ', val)
+				// console.log('setScrollHeight = ', val)
 				// 实时返回的滑动组件高度
 				this.TouchHeight = val;
 			},
@@ -294,6 +297,8 @@
 				//最大高度
 				this.scrollMaxHeight = val;
 			},
+
+
 		}
 	}
 </script>

+ 6 - 3
pages/map/model/search.vue

@@ -61,10 +61,13 @@
 					pms.areaCode = this.params.code[2] || undefined
 				}
 				pms.mapTypeId = this.params.mapTypeId;
-				pms.searchKey = this.searchKey;
-				console.log("-------搜索--------")
+				pms.searchKey = this.searchKey; 
 				this.$emit("handleSearch" , pms)
-				
+			},
+			getVal(){
+				return {
+					
+				}
 			},
 			getMapList() {
 

File diff suppressed because it is too large
+ 176 - 0
pages/map/model/siteDetails.vue


+ 39 - 27
pages/map/model/siteList.vue

@@ -1,11 +1,11 @@
 <template>
-	<view class="site-item">
+	<view class="site-item" @click.stop="openSite(info)">
 		<view class="site-name">{{info.locationName}}</view>
 		<view class="site-info">
 			<view class="site-left">
 				<!-- class="one-row" -->
-				<text class="one-row">{{`${info.provinceName}${info.cityName}${info.areaName}${info.address}`}}</text>
-				<text class="one-row">距离{{getDistance(info.distance)}}</text>
+				<text class="">{{`${info.provinceName}${info.cityName}${info.areaName}${info.address}`}}</text>
+				<text class="">距离{{getDistance(info.distance)}}</text>
 			</view>
 			<view class="site-right">
 				<view class="site-btn" @click.stop="getPhoneCall(info.outerPhone)">
@@ -35,15 +35,15 @@
 		</view>
 		<view class="site-time">
 			<text>办公时间</text>
-			<text>{{info.workTimeRemark}}</text>
+			<text class="site-time-val">{{info.workTimeRemark}}</text>
 		</view>
 	</view>
 </template>
-<script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=427c1b3b7b0aaa258221992c860859f7"></script>
+<!-- <script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=427c1b3b7b0aaa258221992c860859f7"></script> -->
 <script>
 	import { distanceCalculate, PhoneCall, getMapLocation } from "@/utils/tool.js";
 	import { openMap } from "@/utils/openApp.js"
-
+	import { EventBus } from "@/utils/vueBus.js"
 	export default {
 		props: {
 			info: {
@@ -58,18 +58,7 @@
 			}
 		},
 		mounted() {
-			setTimeout(function() {
-				var gps = [116.3, 39.9]; //需要转换的gps类型的坐标
-				//参数说明:需要转换的坐标或者坐标组,需要转换的坐标类型,转换成功后的回调函数
-				AMap.convertFrom(gps, "gps", function (status, result) {
-				  //status:complete 表示查询成功,no_data 为查询无结果,error 代表查询错误
-				  //查询成功时,result.locations 即为转换后的高德坐标系
-				  if (status === "complete" && result.info === "ok") {
-				    var lnglats = result.locations; //转换后的高德坐标 Array.<LngLat>
-				    console.log("lnglatslnglats = " ,result );
-				  }
-				});
-			}, 5000);
+
 		},
 		methods: {
 			getDistance(num) {
@@ -79,13 +68,14 @@
 				PhoneCall(tel)
 			},
 			openLocation(info) {
-				const name = `${info.provinceName}${info.cityName}${info.areaName}${info.address}`;
-				const latitude = info.latitude;
-				const longitude = info.longitude;
-				// latitude, longitude, name, detailedAddress 
-				// getMapLocation({ name, latitude, longitude, detailedAddress })
-				openMap({ longitude, latitude, name, mapApp: "baidu" })
-				// openMap(116.404, 39.915, "目的地", "baidu");
+				const { areaCode, cityCode, provinceCode, provinceName, cityName, areaName, address } = info
+				const name = `${provinceName}${cityName}${areaName}${address}`;
+				const code = areaCode || cityCode || provinceCode
+
+				openMap({ name, code: code, type: "baidu" })
+			},
+			openSite(info) {
+				EventBus.$emit('TianDiTuSite', info)
 			}
 		}
 	}
@@ -95,10 +85,13 @@
 	.site-item {
 		width: 100%;
 		padding-bottom: 20rpx;
-
+		background-color: #f7f7f7;
+		// box-shadow: 1px 1px 1px 1px #ccc;
 		// background-color: #ccc;
 		.site-name {
+			padding-top: 30rpx;
 			font-size: 30rpx;
+			padding-bottom: 5rpx;
 			background-color: #fff;
 		}
 
@@ -107,6 +100,7 @@
 			display: flex;
 			justify-content: space-between;
 			align-items: center;
+			color: #8e8c8c;
 
 			.site-left {
 				width: 1px;
@@ -114,6 +108,7 @@
 				display: flex;
 				flex-direction: column;
 				font-size: 28rpx;
+				padding-bottom: 15rpx;
 			}
 
 			.site-right {
@@ -157,11 +152,28 @@
 		.site-time {
 			background-color: #fff;
 			border-top: 1rpx solid #F0F0F0;
-			padding: 10rpx 0;
+			padding: 15rpx 0;
 			display: flex;
 			justify-content: space-between;
 			font-size: 28rpx;
 			color: #7D7D7D;
+
+			text {
+				flex-shrink: 0;
+			}
+
+			.site-time-val {
+				width: 1rpx;
+				flex: 1;
+				padding-left: 30rpx;
+				// text-align: right;
+			}
+		}
+		&:first-child{
+			.site-name {
+				padding-top: 0; 
+			}
+			
 		}
 	}
 </style>

File diff suppressed because it is too large
+ 1 - 0
static/images/定位.svg


+ 2 - 2
uni_modules/zhuo-tianditu-select/components/zhuo-tianditu-select/tianditu-map.vue

@@ -101,7 +101,7 @@
             // } else {
             //     if (this.apiKey) {
             //         const script = document.createElement('script')
-            //         script.src = 'http://api.tianditu.gov.cn/api?v=4.0&tk=' + this.apiKey
+            //         script.src = 'https://api.tianditu.gov.cn/api?v=4.0&tk=' + this.apiKey
             //         script.onload = this.initChartsRender.bind(this)
             //         document.head.appendChild(script)
             //     }
@@ -113,7 +113,7 @@
                 if (newValue.type === 'open' && newValue.apikey) {
                     if (!window.T) {
                         const script = document.createElement('script')
-                        script.src = 'http://api.tianditu.gov.cn/api?v=4.0&tk=' + this.options.apikey
+                        script.src = 'https://api.tianditu.gov.cn/api?v=4.0&tk=' + this.options.apikey
                         script.onload = this.initChartsRender.bind(this)
                         document.head.appendChild(script)
                     } else {

+ 2 - 2
uni_modules/zhuo-tianditu-select/components/zhuo-tianditu-select/zhuo-tianditu-select.vue

@@ -153,7 +153,7 @@
                     },
                     tk: this.apiKey,
                 }
-                let resData = await tools.createRequest('http://api.tianditu.gov.cn/geocoder', params, true)
+                let resData = await tools.createRequest('https://api.tianditu.gov.cn/geocoder', params, true)
                 if (resData.status === '0') {
                     const location = resData.location
                     const formateOne = tools.formatterAdressLocation(resData, 3)
@@ -174,7 +174,7 @@
                     type: 'query',
                     tk: this.apiKey,
                 }
-                let resData = await tools.createRequest('http://api.tianditu.gov.cn/v2/search', params, true)
+                let resData = await tools.createRequest('https://api.tianditu.gov.cn/v2/search', params, true)
                 if (resData.status.infocode === 1000) {
                     const {
                         pois: aPoints,

+ 52 - 117
utils/LonLatConvert.js

@@ -1,121 +1,56 @@
-//转换常数
-const x_pi = 3.14159265358979324 * 3000.0 / 180.0
-const pi = 3.14159265358979324
-const a = 6378245.0
-const ee = 0.00669342162296594323
+import AMapLoader from '@amap/amap-jsapi-loader';
 
-function transformLon(x, y) {
-	var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
-	ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
-	ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
-	ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0;
-	return ret;
-}
-
-function transformLat(x, y) {
-	var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
-	ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
-	ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
-	ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
-	return ret;
-}
-// 判断是否在国内
-function outOfChina(lat, lon) {
-	if (lon < 72.004 || lon > 137.8347)
-		return true;
-	if (lat < 0.8293 || lat > 55.8271)
-		return true;
-	return false;
-}
-
-/* 
- WGS-84转换GCJ-02
-(即 天地图转高德、腾讯地图)
- */
-export const wgs_gcj_encrypts = (latlon) => {
-	 var dLat = transformLat(latlon.lng - 105.0, latlon.lat - 35.0);
-	 var dLon = transformLon(latlon.lng - 105.0, latlon.lat - 35.0);
-	 var radLat = latlon.lat / 180.0 * pi;
-	 var magic = Math.sin(radLat);
-	 magic = 1 - ee * magic * magic;
-	 var sqrtMagic = Math.sqrt(magic);
-	 dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
-	 dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
-	 var lat = latlon.lat + dLat;
-	 var lng = latlon.lng + dLon;
-	 return {lng , lat}
-}
-
-/* 
- BD-09转换GCJ-02
- (即 百度转高德、腾讯地图)
- */
-export const bd_google_encrypt = (latlons) => {
-	var point = [];
-	for (const latlon of latlons) {
-		var x = latlon.lng - 0.0065;
-		var y = latlon.lat - 0.006;
-		var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
-		var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
-		var gg_lon = z * Math.cos(theta);
-		var gg_lat = z * Math.sin(theta);
-		point.push({
-			lat: gg_lon,
-			lng: gg_lat
-		})
-	}
-	return point;
-}
+export const getCoord = (parmas) => {
+	return new Promise((reslove, reject) => {
+		const { name, code, type } = parmas;
+		window._AMapSecurityConfig = {
+			securityJsCode: "a9557f94a84a95b515bec96c3bed93f1",
+		};
+		// 配置高德API的key
+		AMapLoader.load({
+				"key": "f4226f3eb5a974d153652665b64b497c",
+				"version": "2.0",
+				"plugins": []
+			})
+			.then((AMap) => { 
+				AMap.plugin('AMap.Geocoder', function() {
+					var geocoder = new AMap.Geocoder({
+						city: code // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode
+					});
 
-/* 
- GCJ-02转换BD-09
- (即 高德、腾讯转百度地图)
- */
-export const google_bd_encrypt = (latlons) => {
-	var point = [];
-	for (const latlon of latlons) {
-		var x = latlon.lng;
-		var y = latlon.lat;
-		var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
-		var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
-		var bd_lon = z * Math.cos(theta) + 0.0065;
-		var bd_lat = z * Math.sin(theta) + 0.006;
-		point.push({
-			lat: bd_lat,
-			lng: bd_lon
-		})
-	}
-	return point;
-}
+					var addresses = [name];
+					// 使用高德逆编码,将天地图转换成高德地图
+					geocoder.getLocation(addresses, function(status, result) { 
+						if (status === 'complete' && result.info === 'OK') {
+							const val = result.geocodes[0];
+							reslove(val.location) 
+						}else{
+							reject()
+						}
+					});
+				});
 
-/* 
- GCJ-02 到 WGS-84 的转换
- (即 高德、腾讯转天地图)
- */
-export const gcj_wgs_encrypts = (latlons) => {
-	var point = [];
-	for (const latlon of latlons) {
-		if (outOfChina(latlon.lat, latlon.lng)) {
-			point.push({
-				lat: latlon.lat,
-				lng: latlon.lng
+				// var gps = [longitude, latitude]; //需要转换的gps类型的坐标
+				// // var gps = [116.3, 39.9]; //需要转换的gps类型的坐标
+				// // 初始化地图实例
+				// console.log('AMap =', AMap, gps)
+				// // window.map = new AMap.Map('container', {
+				// //   zoom: 10, // 设置地图显示的缩放级别
+				// //   center: [116.397428, 39.90923] // 设置地图中心点坐标
+				// // });
+				// //参数说明:需要转换的坐标或者坐标组,需要转换的坐标类型,转换成功后的回调函数
+				// AMap.convertFrom(gps, "gps", function(status, result) {
+				// 	console.log('status, result =', status, result)
+				// 	//status:complete 表示查询成功,no_data 为查询无结果,error 代表查询错误
+				// 	//查询成功时,result.locations 即为转换后的高德坐标系
+				// 	if (status === "complete" && result.info === "ok") {
+				// 		var lnglats = result.locations; //转换后的高德坐标 Array.<LngLat>
+				// 		console.log(lnglats);
+				// 	}
+				// });
 			})
-			return point;
-		}
-		var dLat = transformLat(latlon.lng - 105.0, latlon.lat - 35.0);
-		var dLon = transformLon(latlon.lng - 105.0, latlon.lat - 35.0);
-		var radLat = latlon.lat / 180.0 * pi;
-		var magic = Math.sin(radLat);
-		magic = 1 - ee * magic * magic;
-		var sqrtMagic = Math.sqrt(magic);
-		dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
-		dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
-		var lat = dLat;
-		var lng = dLon;
-		point.push({
-			lat: lat,
-			lng: lng
-		})
-	}
-	return point;
-}
+			.catch(e => {
+				reject()
+			});
+	})
+}

+ 34 - 0
utils/a.js

@@ -0,0 +1,34 @@
+// 引入高德地图JSAPI(请确保已经在项目中引入了高德地图JSAPI)
+const AMap = require('@amap-jsapi-biz/src/amap-wx');
+ 
+export default {
+  data() {
+    return {
+      // 假设这是从天地图获取的坐标点
+      tianDiTuCoord: [116.397428, 39.90923], // 天地图坐标点, 经度, 纬度
+    };
+  },
+  methods: {
+    convertCoord() {
+      // 初始化高德地图JSAPI
+      new AMap.AMapWX({
+        key: '你的高德地图Web服务API Key', // 替换为你的高德地图Web服务API Key
+      });
+ 
+      // 调用坐标转换服务
+      AMap.convertFrom({
+        coordType: 'wgs84', // 坐标类型,可选值:'gcj02', 'bd09', 'bd09ll', 'wgs84', 'google', 'sogou', 'mapbar', 'geocoder', 'auto', 'mars', 'openstreetmap', 'tianjd'
+        locations: this.tianDiTuCoord, // 待转换坐标数组
+      }).then((data) => {
+        // 转换成功,data.locations为转换后的坐标数组
+        console.log('转换后的坐标:', data.locations);
+      }).catch((err) => {
+        // 转换失败的处理逻辑
+        console.error('坐标转换失败:', err);
+      });
+    },
+  },
+  onLoad() {
+    this.convertCoord();
+  },
+};

+ 27 - 22
utils/openApp.js

@@ -1,37 +1,45 @@
-
 import gcoord from "gcoord";
-import { wgs_gcj_encrypts } from "@/utils/LonLatConvert.js"
+import { getCoord } from "@/utils/LonLatConvert.js"
+// gaode
 export const openMap = (parmas = {}) => {
-	const { longitude, latitude, name, mapApp } = parmas;
-	var geojson = {
-	  "type": "Point",
-	  "coordinates": [longitude, latitude]
-	}
-	let result = gcoord.transform(geojson,gcoord.WGS84,gcoord.GCJ02);
-	// console.log(result , wgs_gcj_encrypts({lng:longitude,lat:latitude})); 
-	// console.log('wgs84Togcj02 = ' , longitude, latitude ,wgs84Togcj02(longitude, latitude))
- 
+	const { name, code, type } = parmas;
+	uni.showLoading()
+	getCoord({ name, code }).then(res => {
+		const { lng, lat } = res; 
+		openApp({ lng, lat , type , name })
+	}).catch(err => {
+		uni.hideLoading()
+		uni.showToast({
+			title: '打开导航失败',
+			icon: "none"
+		})
+	})
+}
+
+
+const openApp = (parmas = {}) => {
+		uni.hideLoading()
+	const { lng, lat , type , name } = parmas; 
 	let url;
-	switch (mapApp) {
+	switch (type) {
 		case 'baidu':
 			url =
-				`baidumap://map/marker?location=${latitude},${longitude}&title=${encodeURIComponent(name)}&content=${encodeURIComponent(name)}&src=webapp`;
+				`baidumap://map/marker?location=${lat},${lat}&title=${encodeURIComponent(name)}&content=${encodeURIComponent(name)}&src=webapp`;
 			break;
-		case 'gaode': 
-		const {lng ,lat} = wgs_gcj_encrypts({lng:longitude,lat:latitude})
+		case 'gaode':
 			url =
 				`iosamap://navi?sourceApplication=webapp&backScheme=myapp://&lat=${lat}&lon=${lng}&name=${encodeURIComponent(name)}&dev=0`;
 			break;
 		case 'tencent':
 			url =
-				`qqmap://map/rgeo?location=${latitude},${longitude}&name=${encodeURIComponent(name)}&coord_type=1&policy=0`;
+				`qqmap://map/rgeo?location=${lat},${lat}&name=${encodeURIComponent(name)}&coord_type=1&policy=0`;
 			break;
 		default:
 			console.error('不支持的地图类型');
 			return;
-	}
+	} 
 
-	// 使用iframe打开URL Scheme,避免直接跳转导致页面卡死
+	// 使用iframe打开URL Scheme, 避免直接跳转导致页面卡死
 	const iframe = document.createElement('iframe');
 	iframe.style.display = 'none';
 	iframe.src = url;
@@ -44,7 +52,7 @@ export const openMap = (parmas = {}) => {
 	// 定时器检测是否唤起成功,如果失败则跳转到网页版地图
 	let timer = setTimeout(() => {
 		window.location.href =
-			`https://uri.amap.com/marker?position=${longitude},${latitude}&name=${encodeURIComponent(name)}&src=mypage&coordinate=gaode&callnative=0`; // 默认跳转高德网页版
+			`https://uri.amap.com/marker?position=${lng},${lat}&name=${encodeURIComponent(name)}&src=mypage&coordinate=gaode&callnative=0`; // 默认跳转高德网页版
 	}, 2000);
 
 	window.addEventListener('blur', () => {
@@ -52,6 +60,3 @@ export const openMap = (parmas = {}) => {
 	});
 
 }
-
-
-// openMap(116.404, 39.915, "目的地", "baidu");

+ 25 - 0
utils/tool.js

@@ -36,4 +36,29 @@ export const getMapLocation = (parmas = {}) => {
 		address: detailedAddress, // 要去的地址详情说明
 		scale: 16, // 地图缩放级别,整形值,范围从1~28。默认为最大
 	});
+}
+
+export const getLocation = () => {
+	return new Promise((resolve, reject) => {
+		try {
+			uni.getLocation({
+				type: 'wgs84', // 返回可以用于uni.openLocation的经纬度
+				success: (res) => {
+					console.log("getLocation = " , res)
+					// this.selfLatitude = res.longitude;
+					// this.selfLongitude = res.latitude;
+					resolve(res)
+				},
+				fail: (err) => {
+					console.log('获取位置失败2 :', err);
+				},
+				fail: () => {
+					console.log('获取位置失败3 :');
+				}
+			});
+		} catch (error) {
+			console.log('获取位置失败 1:', error);
+			//TODO handle the exception
+		}
+	})
 }

+ 3 - 0
utils/vueBus.js

@@ -0,0 +1,3 @@
+// event-bus.js
+import Vue from 'vue';
+export const EventBus = new Vue();