Browse Source

no message

Fly 1 month ago
parent
commit
2beddfbb9b

+ 6 - 2
pages/map/index.vue

@@ -50,7 +50,7 @@
 	import { EventBus } from "@/utils/vueBus.js"
 	import { getLocation } from "@/utils/tool.js"
 	import serviceCenter from "./model/service-center.vue"
-	import HintContent from "./model/hint.vue"
+	import HintContent from "./model/hint.vue" 
 	export default {
 		name: 'tdtmap',
 		components: {
@@ -58,7 +58,7 @@
 			siteListModel,
 			serviceCenter,
 			siteDetails,
-			HintContent
+			HintContent, 
 		},
 		data() {
 			return {
@@ -102,6 +102,10 @@
 			this.getMapCenterPoint()
 		},
 		mounted() {
+			// setTimeout(() => {
+			// 	console.log("this.$refs.SelectMapNavigationRef = " , this.$refs.SelectMapNavigationRef)
+			// 	this.$refs.SelectMapNavigationRef.open()
+			// }, 3000)
 			this.disableScroll()
 		},
 		beforeDestroy() {

+ 72 - 0
pages/map/model/SelectMapNavigation.vue

@@ -0,0 +1,72 @@
+<template>
+	<uni-popup ref="SelectMap" :isMaskClick='true' type="bottom" border-radius="10px 10px 0 0"
+		maskBackgroundColor='rgba(0, 0, 0, 0.1)'>
+		<view class="map-list">
+			<view class="title">请选择地图</view>
+			<view class="map-item" @click.stop="goNavigation(item.value)" v-for="item in MapTypeList">
+				{{item.label}}
+			</view>
+			<view class="map-item cancel">
+				取消
+			</view>
+		</view>
+	</uni-popup>
+</template>
+
+<script>
+	import { MapTypeList } from "@/utils/openApp.js"
+	import { openMap } from "@/utils/openApp.js"
+	export default {
+		data() {
+			return {
+				MapTypeList,
+				siteInfo: undefined
+			};
+		},
+		mounted() {
+			// setTimeout(() => {
+			// 	this.open()
+			// }, 1000)
+		},
+		methods: {
+			open(info) {
+				this.siteInfo = info;
+				this.$refs.SelectMap.open()
+
+			},
+			goNavigation(type) {
+				const { areaCode, cityCode, provinceCode, provinceName, cityName, areaName, address } =  this.siteInfo
+				const name = `${provinceName}${cityName}${areaName}${address}`;
+				const code = areaCode || cityCode || provinceCode
+				openMap({ name, code,  type, info: this.siteInfo })
+				this.$refs.SelectMap.close()
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.map-list {
+		width: 100%;
+		// height: 30vh;
+		background-color: #fff;
+		border-radius: 20rpx 20rpx 0 0;
+		text-align: center;
+
+		.title {
+			width: 100%;
+			text-align: center;
+			padding: 30rpx 20rpx 50rpx 20rpx;
+			font-size: 28rpx;
+		}
+
+		.map-item {
+			width: 100%;
+			padding: 30rpx 20rpx;
+		}
+
+		.cancel {
+			padding: 50rpx 30rpx;
+		}
+	}
+</style>

+ 10 - 6
pages/map/model/siteList.vue

@@ -43,15 +43,17 @@
 			</view>
 		</view>
 		<telList ref="telListRef" />
+		<!-- 选择地图 -->
+		<SelectMapNavigation ref="SelectMapNavigationRef" />
 	</view>
 </template>
 
 <script>
 	import { distanceCalculate, getMapLocation } from "@/utils/tool.js";
-	import { openMap } from "@/utils/openApp.js"
 	import { EventBus } from "@/utils/vueBus.js"
 	import telList from "./telList.vue"
 	import map from "./../map.js"
+	import SelectMapNavigation from "./SelectMapNavigation.vue"
 	export default {
 		mixins: [map],
 		props: {
@@ -66,7 +68,7 @@
 				default: () => {}
 			}
 		},
-		components: { telList },
+		components: { telList , SelectMapNavigation },
 		data() {
 			return {
 				isExceed: false,
@@ -118,11 +120,13 @@
 				this.$refs.telListRef.open({ tel })
 			},
 			openLocation(info) {
-				const { areaCode, cityCode, provinceCode, provinceName, cityName, areaName, address } = info
-				const name = `${provinceName}${cityName}${areaName}${address}`;
-				const code = areaCode || cityCode || provinceCode
+				// const { areaCode, cityCode, provinceCode, provinceName, cityName, areaName, address } = info
+				// const name = `${provinceName}${cityName}${areaName}${address}`;
+				// const code = areaCode || cityCode || provinceCode
 
-				openMap({ name, code, type: "gaode", info })
+				// openMap({ name, code, type: "gaode", info })
+				// this.$emit("openMap" ,info )
+				this.$refs.SelectMapNavigationRef.open(info)
 			},
 			openSite(info) {
 				this.$emit('checkSiteDetails', info)

+ 1 - 0
pages/map/model/telList.vue

@@ -29,6 +29,7 @@
 		methods: {
 			open(parmas = {}) {
 				const { tel } = parmas;
+				console.log('-------打开地图列表-------' , this.$refs.telRef)
 				if (tel) {
 					if (tel.length === 1 && !tel[0].remark) {
 						this.onPhoneCall(tel[0].phone)

+ 17 - 17
uni_modules/uni-popup/components/uni-popup/uni-popup.vue

@@ -87,7 +87,7 @@
 				type: String,
 				default: 'rgba(0, 0, 0, 0.4)'
 			},
-			borderRadius:{
+			borderRadius: {
 				type: String,
 			}
 		},
@@ -247,11 +247,11 @@
 		},
 		// #endif
 		activated() {
-   	  this.setH5Visible(!this.showPopup);
-    },
-    deactivated() {
-      this.setH5Visible(true);
-    },
+			this.setH5Visible(!this.showPopup);
+		},
+		deactivated() {
+			this.setH5Visible(true);
+		},
 		created() {
 			// this.mkclick =  this.isMaskClick || this.maskClick
 			if (this.isMaskClick === null && this.maskClick === null) {
@@ -274,7 +274,7 @@
 			setH5Visible(visible = true) {
 				// #ifdef H5
 				// fix by mehaotian 处理 h5 滚动穿透的问题
-				document.getElementsByTagName('body')[0].style.overflow =  visible ? "visible" : "hidden";
+				document.getElementsByTagName('body')[0].style.overflow = visible ? "visible" : "hidden";
 				// #endif
 			},
 			/**
@@ -355,7 +355,7 @@
 					left: 0,
 					right: 0,
 					backgroundColor: this.bg,
-					borderRadius:this.borderRadius || "0"
+					borderRadius: this.borderRadius || "0"
 				}
 				// TODO 兼容 type 属性 ,后续会废弃
 				if (type) return
@@ -381,7 +381,7 @@
 					bottom: 0,
 					paddingBottom: this.safeAreaInsets + 'px',
 					backgroundColor: this.bg,
-					borderRadius:this.borderRadius || "0",
+					borderRadius: this.borderRadius || "0",
 				}
 				// TODO 兼容 type 属性 ,后续会废弃
 				if (type) return
@@ -394,10 +394,10 @@
 				this.popupstyle = 'center'
 				//微信小程序下,组合动画会出现文字向上闪动问题,再此做特殊处理
 				// #ifdef MP-WEIXIN
-					this.ani = ['fade']
+				this.ani = ['fade']
 				// #endif
 				// #ifndef MP-WEIXIN
-					this.ani = ['zoom-out', 'fade']
+				this.ani = ['zoom-out', 'fade']
 				// #endif
 				this.transClass = {
 					position: 'fixed',
@@ -411,7 +411,7 @@
 					top: 0,
 					justifyContent: 'center',
 					alignItems: 'center',
-					borderRadius:this.borderRadius || "0"
+					borderRadius: this.borderRadius || "0"
 				}
 				// TODO 兼容 type 属性 ,后续会废弃
 				if (type) return
@@ -426,7 +426,7 @@
 					bottom: 0,
 					top: 0,
 					backgroundColor: this.bg,
-					borderRadius:this.borderRadius || "0",
+					borderRadius: this.borderRadius || "0",
 					/* #ifndef APP-NVUE */
 					display: 'flex',
 					flexDirection: 'column'
@@ -445,7 +445,7 @@
 					right: 0,
 					top: 0,
 					backgroundColor: this.bg,
-					borderRadius:this.borderRadius || "0",
+					borderRadius: this.borderRadius || "0",
 					/* #ifndef APP-NVUE */
 					display: 'flex',
 					flexDirection: 'column'
@@ -455,8 +455,8 @@
 				if (type) return
 				this.showPoptrans()
 			},
-			showPoptrans(){
-				this.$nextTick(()=>{
+			showPoptrans() {
+				this.$nextTick(() => {
 					this.showPopup = true
 					this.showTrans = true
 				})
@@ -515,4 +515,4 @@
 	.fixforpc-top {
 		top: 0;
 	}
-</style>
+</style>

+ 19 - 47
utils/LonLatConvert.js

@@ -7,59 +7,31 @@ export const getCoord = (parmas) => {
 		const { name, code, type, longitude, latitude } = parmas;
 		switch (type) {
 			case 'gaode':
-				const convertedCoords = gcoord.transform(
+				const gaode_ = gcoord.transform(
 					[longitude, latitude],
 					gcoord.WGS84, // 输入坐标系
 					gcoord.GCJ02 // 输出坐标系
 				);
-				console.log('convertedCoords = ', convertedCoords)
-				const data = {
-					lng: convertedCoords[0],
-					lat: convertedCoords[1]
+				console.log('gaode_ = ', gaode_)
+				const gaode_site = {
+					lng: gaode_[0],
+					lat: gaode_[1]
 				}
-				reslove(data)
+				reslove(gaode_site);
+				break;
+			case 'baidu':
+				const baidu_ = gcoord.transform(
+					[longitude, latitude],
+					gcoord.WGS84, // 输入坐标系
+					gcoord.BD09 // 输出坐标系
+				);
+				console.log('baidu_ = ', baidu_)
+				const baidu_site = {
+					lng: baidu_[0],
+					lat: baidu_[1]
+				}
+				reslove(baidu_site)
 
 		}
 	})
-}
-
-
-
-function wgs84ToGcj02(lat, lon) {
-	const a = 6378245.0;
-	const ee = 0.00669342162296594323;
-
-	function transform(lat, lon) {
-		let dLat = transformLat(lon - 105.0, lat - 35.0);
-		let dLon = transformLon(lon - 105.0, lat - 35.0);
-		const radLat = lat / 180.0 * Math.PI;
-		let magic = Math.sin(radLat);
-		magic = 1 - ee * magic * magic;
-		const sqrtMagic = Math.sqrt(magic);
-		dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * Math.PI);
-		dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * Math.PI);
-		return [lat + dLat, lon + dLon];
-	}
-
-	function transformLat(x, y) {
-		let ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y;
-		ret += (20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0 / 3.0;
-		ret += (20.0 * Math.sin(y * Math.PI) + 40.0 * Math.sin(y / 3.0 * Math.PI)) * 2.0 / 3.0;
-		ret += (160.0 * Math.sin(y / 12.0 * Math.PI) + 320 * Math.sin(y * Math.PI / 30.0)) * 2.0 / 3.0;
-		return ret;
-	}
-
-	function transformLon(x, y) {
-		let 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 * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0 / 3.0;
-		ret += (20.0 * Math.sin(x * Math.PI) + 40.0 * Math.sin(x / 3.0 * Math.PI)) * 2.0 / 3.0;
-		ret += (150.0 * Math.sin(x / 12.0 * Math.PI) + 300.0 * Math.sin(x / 30.0 * Math.PI)) * 2.0 / 3.0;
-		return ret;
-	}
-
-	if (lon < 72.004 || lon > 137.8347 || lat < 0.8293 || lat > 55.8271) {
-		return [lat, lon]; // 不在国内,不转换
-	}
-
-	return transform(lat, lon);
 }

+ 18 - 17
utils/openApp.js

@@ -1,35 +1,36 @@
 import gcoord from "gcoord";
 import { getCoord } from "@/utils/LonLatConvert.js"
-// gaode
+
+export const MapTypeList = [
+	{
+		label:'高德地图',
+		value:'gaode'
+	},
+	{
+		label:'百度地图',
+		value:'baidu'
+	}
+]
+
 // ‌天地图使用的坐标系是CGCS2000(中国大地坐标系统2000)
 export const openMap = (parmas = {}) => {
-	const { name, code, type, info: { longitude, latitude } } = parmas;
+	const { name, code, type, info: { longitude, latitude , locationName } } = parmas;
 	// console.log("name, code, type = ", name, code, type, longitude, latitude)
 	uni.showLoading()
-	getCoord({ name, code, type, longitude, latitude }).then(res => {
+	getCoord({ name, code, type, longitude, latitude }).then(res => { 
 		const { lng, lat } = res;
-		openApp({ lng, lat, type, name })
+		openApp({ lng, lat, type, name , locationName})
 	})
-	// getCoord({ name, code , type longitude, latitude}).then(res => {
-	// 	const { lng, lat } = res; 
-	// 	openApp({ lng, lat , type , name })
-	// }).catch(err => {
-	// 	uni.hideLoading()
-	// 	uni.showToast({
-	// 		title: '打开导航失败',
-	// 		icon: "none"
-	// 	})
-	// })
 }
 
 
 const openApp = (parmas = {}) => {
-	const { lng, lat, type, name } = parmas;
+	const { lng, lat, type, name , locationName} = parmas; 
 	let url;
 	switch (type) {
 		case 'baidu':
-			url =
-				`baidumap://map/marker?location=${lat},${lat}&title=${encodeURIComponent(name)}&content=${encodeURIComponent(name)}&src=webapp`;
+			url = `http://api.map.baidu.com/marker?location=${lat},${lng}&title=${encodeURIComponent(locationName)}&content=${encodeURIComponent(name)}&output=html&src=webapp.baidu.openAPIdemo`
+			 
 			break;
 		case 'gaode':
 			url =