Fly 5 ヶ月 前
コミット
bb24b23be6

+ 6 - 0
App.vue

@@ -20,4 +20,10 @@
 		margin: 0;
 		box-sizing: border-box;
 	}
+	.one-row{
+		display: inline-block;
+		white-space:nowrap;
+		overflow: hidden;
+		text-overflow: ellipsis; 
+	}
 </style>

+ 8 - 2
api/map.js

@@ -1,8 +1,14 @@
 import http from "@/utils/request.js";
 
 // 获取地图中心点
-export const getMapCenterPoint_Api = (params) => http.get('/h5/biz/map/getCenterPoint')
+export const getMapCenterPoint_Api = () => http.get('/h5/biz/map/getCenterPoint')
  
  
 // 获取地图列表
-export const getMapList_Api = (params) => http.get('/h5/biz/map/list' , params)
+export const getMapList_Api = (params) => http.get('/h5/biz/map/list' , {params:params})
+
+
+// 获取地图类型
+export const getMaptypeList_Api = (params) => http.get('/h5/biz/maptype/list' , {params:params})
+
+

+ 205 - 0
components/bab-Touchbox/bab-Touchbox.vue

@@ -0,0 +1,205 @@
+<template>
+	<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">
+			<view class="content" :style="{'height':windowHeight + 'px'}">
+				<view class="tapBoxTouchLine" v-if="showLine">
+					<view class="line" :style="{'transform': `scaleY(${lineScale})`,'width':`${lineWidth}rpx`}"></view>
+				</view>
+				<slot />
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	/**
+	 * tapBox 触摸上拉组件
+	 * @description 触摸上拉组件,类似于高德美团上拉组件
+	 * @property {String} radius 左上右上圆角
+	 * @property {Number} minHeight 最低高度 占总屏幕高度占比
+	 * @property {Number} minHeight 最高高度 占总屏幕高度占比
+	 * @property {Number} touchHeight 允许滑动区域高度默认顶部横线高度 0为任意区域可滑动,单位rpx
+	 * @property {Boolean} showLine 上否显示顶部滑动线
+	 * @event {Function} tap 点击事件
+	 * @event {Function} getstart 开始滑动时触发事件
+	 * @event {Function} getend 滑动结束事件
+	 */
+	export default {
+		name: 'tapBox',
+		data() {
+			return {
+				windowHeight: 0, // 屏幕高度
+				windowWidth: 0, // 屏幕宽度
+				firsttop: 0, // 默认高度
+				fixboxtop: 0, // 实际高度
+				phonetop: 200, // 默认滑动分界线 - 后面计算为最低与最高的一半
+				phoneMinTop: 100, // 默认滑动分界线 - 后面计算为最低与最高的一半
+				isend: false, // 触摸结束
+				isfirst: true, // 手指第一次触摸
+				tapboxtop: 0, // 手指距离顶部距离
+			};
+		},
+
+		props: {
+			// width: 120rpx;
+			// transform: scaleY(0.5);
+			lineScale: {
+				type: Number,
+				default: 1,
+			},
+			lineWidth: {
+				type: Number,
+				default: 120,
+			},
+			zIndex: {
+				type: Number,
+				default: 99,
+			},
+			radius: {
+				type: String,
+				default: '50rpx',
+			},
+			minHeight: {
+				type: Number,
+				default: 0.2,
+			},
+			smallHeight: {
+				type: Number,
+				default: 0.35,
+			},
+			maxHeight: {
+				type: Number,
+				default: 0.5,
+			},
+			touchHeight: {
+				type: Number,
+				default: 0,
+			},
+			showLine: {
+				type: Boolean,
+				default: true,
+			},
+		},
+		mounted() {
+			this.$nextTick(function() {
+				this.windowWidth = uni.getSystemInfoSync().windowWidth;
+				this.windowHeight = uni.getSystemInfoSync().windowHeight;
+				var defaultHeight = this.windowHeight * (1 - this.minHeight);
+				this.firsttop = defaultHeight;
+				this.phonetop =
+					(this.windowHeight * this.maxHeight - this.windowHeight * this.minHeight) / 2;
+				this.phoneMinTop =
+					(this.windowHeight * this.minHeight - this.windowHeight * this.smallHeight) / 2;
+				this.fixboxtop = defaultHeight;
+				this.$emit('currentHeight', this.windowHeight - this.fixboxtop);
+				this.$emit('maxtHeight', this.windowHeight * this.maxHeight);
+			});
+		},
+		onReady() {},
+		computed: {},
+		methods: {
+			tap(e) {
+				// console.log(e)
+			},
+			getstart(e) { 
+				const {clientY , screenY } = e.touches[0];
+				let Y = clientY || screenY;
+				// //#ifdef MP-WEIXIN
+				// Y = e.touches[0].clientY;
+				// //#endif
+				// //#ifndef MP-WEIXIN
+				// Y = e.touches[0].screenY;
+				// //#endif
+				// console.log(Y)
+				// 这里特殊处理 解决:在滑动框内如果存在滚动元素,则会出现滑动时滑动框和内部滚动同时滑的问题
+				if (this.touchHeight !== 0) {
+					if (Y - this.fixboxtop > this.touchHeight) {
+						return false;
+					}
+				}
+				this.isend = false;
+				if (this.isfirst) {
+					this.isfirst = false;
+					this.tapboxtop = Y - this.fixboxtop;
+				}
+				this.fixboxtop = Y - this.tapboxtop;
+				console.log('this.fixboxtop > this.firsttop = ' ,Y , this.tapboxtop)
+				if (this.fixboxtop > this.firsttop) {
+					if (this.fixboxtop >= this.windowHeight * (1 - this.smallHeight)) {
+						this.fixboxtop = this.windowHeight * (1 - this.smallHeight);
+					}
+				} else {
+					// 往上滑
+					if (this.fixboxtop <= this.windowHeight * (1 - this.maxHeight)) {
+						this.fixboxtop = this.windowHeight * (1 - this.maxHeight);
+					}
+				}
+				this.$emit('currentHeight', this.windowHeight - this.fixboxtop);
+			},
+			getend() {
+				this.isend = true;
+				this.isfirst = true;
+				//中间高度以下
+				if (this.fixboxtop > this.firsttop) {
+					//当超过平衡值
+					if (this.fixboxtop - this.firsttop >= this.phoneMinTop) {
+						this.fixboxtop = this.windowHeight * (1 - this.smallHeight);
+					} else {
+						this.fixboxtop = this.windowHeight * (1 - this.minHeight);
+					}
+				}
+				//中间高度以上
+				else {
+					//滑动距离小于平衡值
+					if (this.firsttop - this.fixboxtop <= this.phonetop) {
+						this.fixboxtop = this.firsttop;
+					} else {
+						this.fixboxtop = this.windowHeight * (1 - this.maxHeight);
+					}
+				}
+				this.$emit('currentHeight', this.windowHeight - this.fixboxtop);
+			},
+		},
+	};
+</script>
+
+<style lang="scss" scoped>
+	.tapBoxTouchLine {
+		margin-top: 20rpx;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+	}
+
+	.line {
+		margin: 0px;
+		vertical-align: middle;
+		// border-bottom: 8rpx solid rgb(214, 215, 217);
+		height: 8rpx;
+		background-color: rgb(214, 215, 217);
+		border-radius: 4rpx;
+
+		// border: 4rpx;
+		// border-top-color: rgb(214, 215, 217);
+		// border-right-color: rgb(214, 215, 217);
+		// border-left-color: rgb(214, 215, 217);
+	}
+
+	.fixedbox {
+		position: fixed;
+		left: 0;
+		background-color: #ffffff;
+		padding: 0 12px;
+	}
+
+	.fixedbox2 {
+		position: fixed;
+		left: 0;
+		background-color: #ffffff;
+		padding: 0 12px;
+		transition-property: top;
+		transition-duration: 0.8s;
+	}
+</style>

+ 6 - 9
components/city/city.vue

@@ -18,8 +18,7 @@
 					<view class="item" v-for="(item,index) in qu" :key="index">{{item.label}}</view>
 				</picker-view-column>
 			</picker-view>
-		</div>
-
+		</div> 
 	</uni-popup>
 
 </template>
@@ -30,7 +29,7 @@
 		name: "city",
 		props: {
 			code: {
-				type: String,
+				type: String | Array,
 				default: null
 			}
 		},
@@ -39,7 +38,7 @@
 				codeValue: [],
 				labelValue:'',
 				value: [0, 0, 0],
-				sheng: cityJson,
+				sheng: [cityJson[16]],
 				shi: [],
 				qu: []
 			}
@@ -49,12 +48,10 @@
 				handler(newV, oldV) {
 					const indexArr = newV || []
 					this.shi = [];
-					this.qu = [];
-
-
+					this.qu = []; 
 					// 省
 					const sh_l = indexArr[0] || 0;
-					const sheng_ = cityJson[sh_l];
+					const sheng_ = this.sheng[sh_l];
 					let shi_ = null;
 					let qu_ = null;
 					let code = [sheng_.value];
@@ -126,7 +123,7 @@
 
 <style lang="scss" scoped>
 	.uni-popup {
-		z-index: 99999;
+		z-index: 1001;
 
 		.city-box {
 			height: 55vh;

+ 112 - 0
components/mapType/mapType.vue

@@ -0,0 +1,112 @@
+<template>
+	<uni-popup ref="mapTypePopupRef" type="bottom" border-radius="10px 10px 0 0">
+		<div class="city-box">
+			<div class="city-picker-btn">
+				<text @click.stop="cancel()">取消</text>
+				<text @click.stop="confirm()">确定</text>
+			</div>
+			<picker-view indicator-class="indicator-class" :value="value||[]" class="picker-view" @change="bindChange">
+				<picker-view-column>
+					<view class="item" v-for="(item,index) in mapTypeList" :key="index">{{item.typeName}}</view>
+				</picker-view-column>
+			</picker-view>
+		</div>
+
+	</uni-popup>
+
+</template>
+
+<script>
+	import { getMaptypeList_Api } from "@/api/map.js";
+	export default {
+		name: "mapType",
+		props: {
+			mapTypeId: {
+				type: String,
+				default: null
+			}
+		},
+		data() {
+			return {
+				value: [],
+				defaultVal:[{
+					mapTypeId:undefined,
+					typeName:'全部'
+				}],
+				mapTypeList: []
+			}
+		},
+		watch: {
+
+		},
+		created() {
+			this.init()
+		},
+		mounted() {
+
+		},
+		methods: {
+			init() {
+				const parms = { typeStatus: 'ENABLE' }
+				getMaptypeList_Api(parms).then(res => {
+					this.mapTypeList = this.defaultVal.concat(res || []);
+				})
+			},
+			open() {
+				this.$refs.mapTypePopupRef.open()
+			},
+			bindChange(val) {
+				const { value } = val.detail;
+				this.value = value || [0]
+			},
+			confirm() {
+				const in_ = this.value[0] || 0;
+				const item = this.mapTypeList[in_]; 
+				this.$emit("update:mapTypeId", item.mapTypeId);
+				this.$emit("typeName", item.typeName);
+				this.cancel();
+			},
+			cancel() {
+				this.$refs.mapTypePopupRef.close()
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.uni-popup {
+		z-index: 1001;
+
+		.city-box {
+			height: 55vh;
+			background-color: #fff;
+			border-radius: 30rpx 30rpx 0 0;
+
+			.city-picker-btn {
+				height: 100rpx;
+				display: flex;
+				justify-content: space-between;
+				align-items: center;
+				padding: 0 30rpx;
+			}
+
+			.picker-view {
+				height: calc(100% - 100rpx);
+				text-align: center;
+
+			}
+		}
+	}
+
+	/deep/ .indicator-class {
+		height: 100rpx;
+	}
+
+	/deep/ .uni-picker-view-content {
+		.item {
+			text-align: center;
+
+			line-height: 100rpx;
+		}
+	}
+</style>

+ 0 - 46
components/tiandituMap/new_file.js

@@ -1,46 +0,0 @@
-let a = 6378245.0;
-let ee = 0.00669342162296594323;
-let pi = Math.PI
-// 判断坐标点是否在中国境内
-function outOfChina(lng, lat) {
-	return (lng < 72.004 || lng > 137.8347 || lat < 0.8293 || lat > 55.8271);
-}
-// 转换经度的函数
-function transformLon(lng, lat) {
-	let ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
-	ret += (20.0 * Math.sin(6.0 * lng * Math.PI / 180.0) + 20.0 * Math.sin(2.0 * lng * Math.PI / 180.0)) * 2.0 / 3.0;
-	ret += (20.0 * Math.sin(lng * Math.PI / 180.0) + 40.0 * Math.sin(lng / 3.0 * Math.PI / 180.0)) * 2.0 / 3.0;
-	ret += (150.0 * Math.sin(lng / 12.0 * Math.PI / 180.0) + 300.0 * Math.sin(lng / 30.0 * Math.PI / 180.0)) * 2.0 /
-		3.0;
-	return ret * (a / Math.sqrt(1 - ee * Math.sin(lat * Math.PI / 180.0) * Math.sin(lat * Math.PI / 180.0))) / 100000.0;
-}
-
-// 转换纬度的函数
-function transformLat(lng, lat) {
-	let ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
-	ret += (20.0 * Math.sin(6.0 * lat * Math.PI / 180.0) + 20.0 * Math.sin(2.0 * lat * Math.PI / 180.0)) * 2.0 / 3.0;
-	ret += (20.0 * Math.sin(lat * Math.PI / 180.0) + 40.0 * Math.sin(lat / 3.0 * Math.PI / 180.0)) * 2.0 / 3.0;
-	ret += (160.0 * Math.sin(lat / 12.0 * Math.PI / 180.0) + 320.0 * Math.sin(lat / 30.0 * Math.PI / 180.0)) * 2.0 /
-		3.0;
-	return ret * (a * (1 - ee)) / Math.sqrt((1 - ee * Math.sin(lat * Math.PI / 180.0) * Math.sin(lat * Math.PI /
-		180.0)) * (1 - ee * Math.sin(lat * Math.PI / 180.0) * Math.sin(lat * Math.PI / 180.0))) / 100000.0;
-}
-
-// WGS84转GCJ02的主函数
-export const wgs84ToGCJ02 = (lng, lat) => {
-	if (outOfChina(lng, lat)) {
-		return { lng: lng, lat: lat };
-	}
-	let dLat = transformLat(lng - 105.0, lat - 35.0);
-	let dLon = transformLon(lng - 105.0, lat - 35.0);
-	let radLat = lat / 180.0 * Math.PI;
-	let magic = Math.sin(radLat);
-	magic = 1 - ee * magic * magic;
-	let sqrtMagic = Math.sqrt(magic);
-	dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * Math.PI );
-	dLon = (dLon * 180.0) / (a / sqrtMagic * Math.PI * Math.cos(radLat));
-	return {
-		lng: lng + dLon,
-		lat: lat + dLat
-	};
-}

+ 212 - 153
components/tiandituMap/tiandituMap.vue

@@ -1,10 +1,12 @@
 <template>
-	<view id="mapDiv" class="mapDiv" :apikey="apiKey" :prop="option" :change:prop="Trenderjs.initTMap"></view>
+	<view id="mapDiv" class="mapDiv" :apikey="apiKey" :prop="option" :change:prop="Trenderjs.initTMap">
+		<!-- :change:prop="Trenderjs.initTMap" -->
+	</view>
 </template>
 
-<script> 
-    import tools from './tools.js'
-import iconPath from '@/static/images/point.png'
+<script>
+	import tools from './tools.js'
+	import iconPath from '@/static/images/point.png'
 	export default {
 		name: "tianditu",
 		props: {
@@ -27,159 +29,216 @@ import iconPath from '@/static/images/point.png'
 			};
 		},
 		methods: {
-		    compliteonLoadTianDiTu() {
-		        this.$emit('onLoadTianDiTu')
-		    },
-		    initCharts(lng, lat) {
-		        this.option = {
-		            apikey: this.apiKey,
-		            lng,
-		            lat,
-		            png: this.customIcon || this.option.png,
-		            type: 'open'
-		        }
-		    },
-		    upDataCharts(lng, lat) {
-		        this.option = {
-		            ...this.option,
-		            type: 'Icon',
-		            lng,
-		            lat,
-		            png: this.customIcon || this.option.png,
-		            type: 'update'
-		        }
-		    },
-		    async nextPoint(lnglat) {
-		        var that = this;
-		        let params = {
-		            postStr: JSON.stringify({
-		                lon: lnglat.lng,
-		                lat: lnglat.lat,
-		                ver: 1,
-		            }),
-		            type: 'geocode',
-		            tk: that.apiKey
-		        }
-		        let resData = await tools.createRequest('https://api.tianditu.gov.cn/geocoder', params, true)
-		        if (resData.status === '0') {
-		            const info = tools.formatterAdressLocation(resData.result, 1)
-		            this.option = {
-		                ...this.option,
-		                apikey: this.apiKey,
-		                lng: lnglat.lng,
-		                lat: lnglat.lat,
-		                png: this.customIcon || this.option.png,
-		                type: 'update'
-		            }
-		            this.$emit('onSelect', info)
-		        } else {
-		            tools.createMessage('数据异常', 1000, false, 'error')
-		        }
-		    },
+			compliteonLoadTianDiTu() {
+				this.$emit('onLoadTianDiTu')
+			},
+			initCharts(lng, lat , iconPng) {
+				this.option = {
+					apikey: this.apiKey,
+					lng,
+					lat,
+					png: iconPng || this.option.png,
+					type: 'open'
+				}
+				// console.log()
+				// this.Trenderjs.createMap(this.apiKey)
+				setTimeout(() => {
+					this.Trenderjs.getLocation()
+				},5000)
+			},
+			upDataCharts(lng, lat) {
+				this.option = {
+					...this.option,
+					type: 'Icon',
+					lng,
+					lat,
+					png: this.customIcon || this.option.png,
+					type: 'update'
+				}
+			},
+			async nextPoint(lnglat) {
+				var that = this;
+				let params = {
+					postStr: JSON.stringify({
+						lon: lnglat.lng,
+						lat: lnglat.lat,
+						ver: 1,
+					}),
+					type: 'geocode',
+					tk: that.apiKey
+				}
+				let resData = await tools.createRequest('https://api.tianditu.gov.cn/geocoder', params, true)
+				if (resData.status === '0') {
+					const info = tools.formatterAdressLocation(resData.result, 1)
+					this.option = {
+						...this.option,
+						apikey: this.apiKey,
+						lng: lnglat.lng,
+						lat: lnglat.lat,
+						png: this.customIcon || this.option.png,
+						type: 'update'
+					}
+					this.$emit('onSelect', info)
+				} else {
+					tools.createMessage('数据异常', 1000, false, 'error')
+				}
+			},
 		}
 	}
 </script>
 <script module="Trenderjs" lang="renderjs">
-    var Tmap = null;
-    export default {
-        data() {
-            return {
-                options: {},
-            }
-        },
-        mounted() {
-            // if (typeof window.T === 'object') {
-            //     console.warn('--------天地图已加载--------');
-            // } else {
-            //     if (this.apiKey) {
-            //         const script = document.createElement('script')
-            //         script.src = 'http://api.tianditu.gov.cn/api?v=4.0&tk=' + this.apiKey
-            //         script.onload = this.initChartsRender.bind(this)
-            //         document.head.appendChild(script)
-            //     }
-            // }
-        },
-        methods: {
-            initTMap(newValue, oldValue, ownerInstance, instance) {
-                this.options = newValue
-                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.onload = this.initChartsRender.bind(this)
-                        document.head.appendChild(script)
-                    } else {
-                        const {
-                            lng,
-                            lat
-                        } = this.options
-                        Tmap = null;
-                        Tmap = new T.Map('mapDiv', {
-                            projection: 'EPSG:4326',
-                        });
-                        Tmap.centerAndZoom(new T.LngLat(lng, lat), 15);
-                        // this.setIcon(lng, lat, true)
-                        this.$ownerInstance.callMethod('nextPoint', {
-                            lng,
-                            lat
-                        })
-                        Tmap.addEventListener('click', (e) => {
-                            this.$ownerInstance.callMethod('nextPoint', e.lnglat)
-                        });
-                    }
-                } else {
-                    const {
-                        lng,
-                        lat
-                    } = newValue
-                    this.upDataChartsRender(lng, lat)
-                }
-            },
-            initChartsRender() {
-                this.$ownerInstance.callMethod('compliteonLoadTianDiTu')
-                const {
-                    lng,
-                    lat
-                } = this.options
-                var that = this;
-                Tmap = new T.Map('mapDiv', {
-                    projection: 'EPSG:4326',
-                });
-                Tmap.centerAndZoom(new T.LngLat(lng, lat), 15);
-                this.setIcon(lng, lat, true)
-                this.$ownerInstance.callMethod('nextPoint', {
-                    lng,
-                    lat
-                })
-                Tmap.addEventListener('click', (e) => {
-                    this.$ownerInstance.callMethod('nextPoint', e.lnglat)
-                });
-            },
-            upDataChartsRender(lng, lat) {
-                if (!Tmap) return
-                this.setIcon(lng, lat, true)
-                Tmap.centerAndZoom(new T.LngLat(lng, lat), 15);
-            },
-            setIcon(lng, lat, isClear) {
-                if (isClear) {
-                    Tmap.clearOverLays()
-                }
-                const icon = new T.Icon({
-                    iconUrl: this.options.png,
-                    iconSize: new T.Point(30, 30),
-                    iconAnchor: new T.Point(15, 30)
-                });
-                const marker = new T.Marker(new T.LngLat(lng, lat), {
-                    icon
-                });
-                Tmap.addOverLay(marker);
-            },
-        },
-    }
+	var Tmap = null;
+	export default {
+		data() {
+			return {
+				options: {},
+			}
+		},
+		mounted() {
+			// if (typeof window.T === 'object') {
+			//     console.warn('--------天地图已加载--------');
+			// } else {
+			//     if (this.apiKey) {
+			//         const script = document.createElement('script')
+			//         script.src = 'http://api.tianditu.gov.cn/api?v=4.0&tk=' + this.apiKey
+			//         script.onload = this.initChartsRender.bind(this)
+			//         document.head.appendChild(script)
+			//     }
+			// }
+		},
+		methods: {
+			createMap(apikey) {
+				console.log("window.T = ", window.T)
+				const script = document.createElement('script')
+				script.src = 'http://api.tianditu.gov.cn/api?v=4.0&tk=' + apikey
+				script.onload = this.initChartsRender.bind(this)
+				document.head.appendChild(script)
+			},
+			initTMap(newValue, oldValue, ownerInstance, instance) {
+				console.log("v initTMap  = ", newValue, oldValue, ownerInstance, instance)
+				this.options = newValue
+				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.onload = this.initChartsRender.bind(this)
+						document.head.appendChild(script)
+						
+						const script_gd = document.createElement('script')
+						script.src = "https://webapi.amap.com/maps?v=2.0&key=2ba8ac1dbcb55c167aee2e0bbbca8a96"
+ 
+						document.head.appendChild(script_gd)
+						
+					} else {
+						const {
+							lng,
+							lat
+						} = this.options
+						Tmap = null;
+						Tmap = new T.Map('mapDiv', {
+							projection: 'EPSG:4326',
+						});
+						Tmap.centerAndZoom(new T.LngLat(lng, lat), 15);
+						// this.setIcon(lng, lat, true)
+						this.$ownerInstance.callMethod('nextPoint', {
+							lng,
+							lat
+						})
+						Tmap.addEventListener('click', (e) => {
+							this.$ownerInstance.callMethod('nextPoint', e.lnglat)
+						});
+					}
+				} else {
+					// 选点,更新
+					// const {
+					//     lng,
+					//     lat
+					// } = newValue
+					// this.upDataChartsRender(lng, lat)
+				}
+			},
+			initChartsRender() {
+				this.$ownerInstance.callMethod('compliteonLoadTianDiTu')
+				const {
+					lng,
+					lat
+				} = this.options
+				var that = this;
+				Tmap = new T.Map('mapDiv', {
+					projection: 'EPSG:4326',
+				});
+				Tmap.centerAndZoom(new T.LngLat(lng, lat), 15);
+				this.setIcon(lng, lat, true)
+				this.$ownerInstance.callMethod('nextPoint', {
+					lng,
+					lat
+				})
+				Tmap.addEventListener('click', (e) => {
+					this.$ownerInstance.callMethod('nextPoint', e.lnglat)
+				});
+			},
+			upDataChartsRender(lng, lat) {
+				if (!Tmap) return
+				this.setIcon(lng, lat, true)
+				Tmap.centerAndZoom(new T.LngLat(lng, lat), 15);
+			},
+			setIcon(lng, lat, isClear, iconU) {
+				if (isClear) {
+					this.clearIcon()
+				}
+				const icon = new T.Icon({
+					iconUrl: iconU || this.options.png,
+					iconSize: new T.Point(30, 30),
+					iconAnchor: new T.Point(15, 30)
+				});
+				const marker = new T.Marker(new T.LngLat(lng, lat), {
+					icon
+				});
+				Tmap.addOverLay(marker);
+			},
+			clearIcon() {
+				Tmap.clearOverLays()
+			},
+			getLocation() {
+				var lo = new T.Geolocation();
+					console.log('获取定位' , lo )
+				const  fn = (e) => {
+					console.log('eeeeeeeeeeeeeeeeeeee' , e)
+					// if (this.getStatus() == 0) {
+					// 	map.centerAndZoom(e.lnglat, 15)
+					// 	alert("获取定位坐标:" + e.lnglat.lat + "," + e.lnglat.lng)
+					// 	var marker = new T.Marker(e.lnglat);
+					// 	map.addOverLay(marker);
+
+					// }
+					// if (this.getStatus() == 1) {
+					// 	map.centerAndZoom(e.lnglat, e.level)
+					// 	alert("获取定位坐标:" + e.lnglat.lat + "," + e.lnglat.lng)
+					// 	var marker = new T.Marker(e.lnglat);
+					// 	map.addOverLay(marker);
+					// }
+				}
+				lo.getCurrentPosition(fn);
+				// if (this.getStatus() == 0) {
+				// 	map.centerAndZoom(e.lnglat, 15)
+				// 	alert("获取定位坐标:" + e.lnglat.lat + "," + e.lnglat.lng)
+				// 	var marker = new T.Marker(e.lnglat);
+				// 	map.addOverLay(marker);
+
+				// }
+				// if (this.getStatus() == 1) {
+				// 	map.centerAndZoom(e.lnglat, e.level)
+				// 	alert("获取定位坐标:" + e.lnglat.lat + "," + e.lnglat.lng)
+				// 	var marker = new T.Marker(e.lnglat);
+				// 	map.addOverLay(marker);
+				// }
+			}
+		},
+	}
 </script>
 <style lang="scss">
-.mapDiv{
-	width: 100%;
-	height: 100%;
-}
+	.mapDiv {
+		width: 100%;
+		height: 100%;
+	}
 </style>

+ 10 - 1
manifest.json

@@ -71,6 +71,15 @@
     "vueVersion" : "2",
     "h5" : {
         "title" : "武汉公安政务服务",
-        "template" : ""
+        "template" : "",
+        "sdkConfigs" : {
+            "maps" : {
+                "amap" : {
+                    "key" : "427c1b3b7b0aaa258221992c860859f7",
+                    "securityJsCode" : "",
+                    "serviceHost" : ""
+                }
+            }
+        }
     }
 }

+ 10 - 0
package-lock.json

@@ -2,10 +2,20 @@
   "requires": true,
   "lockfileVersion": 1,
   "dependencies": {
+    "gcoord": {
+      "version": "1.0.6",
+      "resolved": "https://registry.npmmirror.com/gcoord/-/gcoord-1.0.6.tgz",
+      "integrity": "sha512-Z+uyWrD2BTWmJOUvAdEAZQdQIVA5MFwUu7P5BfBdQEpLiVAsNw9mZF3/QbDJ4ZbfcJEnFKgHXOgUFXo5r/aVPg=="
+    },
     "uview-ui": {
       "version": "2.0.38",
       "resolved": "https://registry.npmmirror.com/uview-ui/-/uview-ui-2.0.38.tgz",
       "integrity": "sha512-6egHDf9lXHKpG3hEjRE0vMx4+VWwKk/ReTf5x18KrIKqdvdPRqO3+B8Unh7vYYwrIxzAWIlmhZ9RJpKI/4UqPQ=="
+    },
+    "whichtype": {
+      "version": "1.7.0",
+      "resolved": "https://registry.npmmirror.com/whichtype/-/whichtype-1.7.0.tgz",
+      "integrity": "sha512-9NuMEddDLvMqjnb6uGza4rNLyR+1yFOvn6HsdgIdIqabu1DDyOn7Z2Ypplww29o+JJpggcE57pB5FCPwWspyDw=="
     }
   }
 }

+ 146 - 52
pages/map/index.vue

@@ -1,84 +1,166 @@
 <template>
 	<view class="map-box">
-		<search />
+
+		<search @handleSearch="handleSearch" v-if="showMap" />
 		<tiandituMap ref="tiandituMapRefs" @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">
+			<scroll-view :style="{'height':TouchHeight - 40  +'px' }" scroll-y="true" :show-scrollbar="false">
+				<template v-for="item in siteList">
+					<siteListModel :info="item" />
+				</template>
+			</scroll-view>
+		</bab-Touchbox>
 	</view>
 </template>
 <script>
 	import tools from '@/components/tiandituMap/tools.js'
 	import search from "./model/search.vue"
-	import { wgs84ToGCJ02 } from '@/components/tiandituMap/new_file.js'
-	import { getMapCenterPoint_Api } from "@/api/map.js"
+	import siteListModel from "./model/siteList.vue";
+	import { getMapCenterPoint_Api, getMapList_Api } from "@/api/map.js"
 	export default {
 		name: 'tdtmap',
 		components: {
 			// tiandituMap,
 			search,
+			siteListModel
 		},
 		data() {
 			return {
+				showMap: false,
+				longitude: undefined,
+				latitude: undefined,
 				apiKey: '1edd9c001a8425cb93631398109d5ab2',
 				winWidth: 0,
 				winHeight: 0,
 				winTop: 0,
 				datalist: [],
 				startY: 0,
-				domMaxHeight: '50vh',
-				domMinHeight: '0vh',
+				// domMaxHeight: '50vh',
+				// domMinHeight: '0vh',
 				selectItem: {},
 				iStatusBarHeight: 0,
 				option: {
 					apikey: '123123',
-				}
+				},
+
+				siteList: [],
+				TouchHeight: 0,
 			}
 		},
 		created() {
-
-			// var that = this
-
-			// uni.getSystemInfo({
-			//     success: function(res) {
-			//         that.winWidth = res.windowWidth
-			//         that.winHeight = res.windowHeight
-			//         that.winTop = res.windowTop
-			//     }
-			// });
+			// 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
+			// //     }
+			// // });
 		},
 		mounted() {
 			// this.open(114.294, 30.534)
 			this.getMapCenterPoint()
 		},
+		watch: {
+			siteList: {
+				handler(newArr) {
+					this.$refs.tiandituMapRefs.clearIcon();
+					(newArr || []).forEach(el => {
+						const { longitude, latitude, mapTypeIcon } = el
+						this.$refs.tiandituMapRefs.setIcon(longitude, latitude, false, mapTypeIcon);
+					})
+				},
+				deep: true
+			}
+		},
 		methods: {
 			// 获取地图中心点
 			getMapCenterPoint() {
 				uni.showLoading()
+				this.showMap = false;
 				getMapCenterPoint_Api().then(res => {
-					const { longitude, latitude } = res || {};
-					this.open(longitude, latitude)
+					const { longitude, latitude , mapTypeIcon } = res || {};
+					this.longitude = longitude;
+					this.latitude = latitude;
+					this.open(longitude, latitude , mapTypeIcon)
+					
 				}).catch(err => { this.open(null, null) }).finally(() => {
 					uni.hideLoading()
 				})
 			},
+ 
+			handleSearch(val = {}) {
+				const parms = { ...val, longitude: this.longitude, latitude: this.latitude };
+				getMapList_Api(parms).then(res => {
+					if(!res || res.length === 0){
+						uni.showToast({
+							title:"搜索结果为空",
+							icon:'none'
+						})
+					}
+					this.siteList = res || [];
+				}).catch(err => {
+					this.siteList = [];
+				})
+			},
 
 
 
-
-
-
-			open(lon, lat) {
+			open(lon, lat , mapTypeIcon) {
 				if (lon && lat) {
 					this.$nextTick(() => {
-						this.$refs.tiandituMapRefs.initCharts(lon, lat)
+						this.$refs.tiandituMapRefs.initCharts(lon, lat , mapTypeIcon)
+						this.showMap = true;
 					})
 				} else {
 					uni.showModal({
-						title:'提示',
-						content:'地图中心点获取错误,请联系管理员!',
-						success:res => {
-							console.log("showModal == " , res)
-							if(res.confirm){}
+						title: '提示',
+						content: '地图中心点获取错误,请联系管理员!',
+						success: res => {
+							console.log("showModal == ", res)
+							if (res.confirm) {}
 						}
 					})
 				}
@@ -172,34 +254,46 @@
 				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;
-				}
-
-			},
+			// 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)
-			}
+			},
+
+
+
+			setTouchHeight(val) {
+				console.log('setScrollHeight = ', val)
+				// 实时返回的滑动组件高度
+				this.TouchHeight = val;
+			},
+			setScrollMaxHeight(val) {
+				//最大高度
+				this.scrollMaxHeight = val;
+			},
 		}
 	}
 </script>

+ 57 - 25
pages/map/model/search.vue

@@ -1,5 +1,5 @@
 <template>
-	<view class="">
+	<view class="search-content">
 		<view class="search-box">
 			<view class="search-input-box">
 				<svg t="1733904658291" class="search-icon" viewBox="0 0 1024 1024" version="1.1"
@@ -10,43 +10,73 @@
 					</path>
 				</svg>
 				<input confirm-type="search" ref="searchInputRef" class="search-input" :auto-blur="true" type="text"
-					placeholder="请输入关键字" v-model="keyword" @focus="onSearchFocus()" @blur="onSearchBlur()"
-					@confirm="getMapList" />
+					placeholder="请输入关键字" v-model="searchKey"  @blur="onSearchBlur()"
+					@confirm="onSearchFocus()" />
 			</view>
 			<view class="search-select">
-				<view class="select-item" @click.stop="$refs.cityRef.open()" >
-					<text class="item-text">{{codeLabel || '办理区域'}}</text>
+				<view class="select-item" @click.stop="$refs.cityRef.open()">
+					<text class="item-text one-row">{{params.codeLabel || '办理区域'}}</text>
 					<u-icon name="arrow-down-fill" color="#101010" size="16"></u-icon>
 				</view>
-				<view class="select-item">
-					<text class="item-text">位置类型</text>
+				<view class="select-item" @click.stop="$refs.mapTypeRef.open()">
+					<text class="item-text one-row">{{ params.typeName || '位置类型'}}</text>
 					<u-icon name="arrow-down-fill" color="#101010" size="16"></u-icon>
 				</view>
 			</view>
 		</view>
-		
+
 		<!-- 选择地址 -->
-		<city ref="cityRef" @cityName="e => codeLabel = e" @onConfirm="onSearchFocus"/>
+		<city ref="cityRef" :code.sync="params.code" @cityName="e => params.codeLabel = e" />
+		<!-- 选择位置类型 -->
+		<mapType ref="mapTypeRef" :mapTypeId.sync="params.mapTypeId" @typeName="e => params.typeName = e" />
 	</view>
 </template>
 
 <script>
 	import { getMapList_Api } from "@/api/map.js"
 	export default {
-		data() {
+		data() { 
 			return {
-				keyword: undefined,
-				code:'',
-				codeLabel:'河北省/石家庄市/长安区 河北省/石家庄市/长安区'
+				searchKey: undefined,
+
+				params: {
+					code: undefined,
+					codeLabel: undefined,
+
+					mapTypeId: undefined,
+					typeName: undefined,
+				}
 			}
 		},
 		methods: {
+			init() {
+
+			},
+			onSearchBlur(){},
 			onSearchFocus() {
-				// 
+				let pms = {};
+				if(this.params.code ){
+					pms.provinceCode = this.params.code[0] || undefined
+					pms.cityCode = this.params.code[1] || undefined
+					pms.areaCode = this.params.code[2] || undefined
+				}
+				pms.mapTypeId = this.params.mapTypeId;
+				pms.searchKey = this.searchKey;
+				console.log("-------搜索--------")
+				this.$emit("handleSearch" , pms)
+				
 			},
 			getMapList() {
 
 			}
+		},
+		watch: {
+			params: {
+				handler(newV, oldV) {
+					this.onSearchFocus()
+				},
+				deep: true
+			}
 		}
 	}
 </script>
@@ -56,31 +86,34 @@
 	$heig_: 80rpx;
 
 	.search-box {
-		padding: 20rpx 20rpx 0;
+		// padding: 20rpx 20rpx 0;
 		position: fixed;
-		left: 0;
-		top: 0;
-		right: 0;
+		left: 20rpx;
+		top: 20rpx;
+		right: 20rpx;
 		z-index: 999;
+		background-color: #fff;
+		border-radius: $radius_ ;
+		overflow: hidden;
 
 		.search-input-box {
 			width: 100%;
 			height: $heig_;
-			background-color: #fff;
-			border-radius: $radius_ $radius_ 0 0;
 			display: flex;
 			align-items: center;
 			padding: 0 10px;
 			color: #020202;
+
 			.search-icon {
-				width:45rpx;
-				height:45rpx;
+				width: 45rpx;
+				height: 45rpx;
 
 				path {
 					fill: #020202;
 				}
 			}
-			.search-input{
+
+			.search-input {
 				padding-left: 10px;
 			}
 		}
@@ -89,8 +122,6 @@
 			border-top: 1rpx solid #E8E8E8;
 			width: 100%;
 			height: $heig_;
-			background-color: #fff;
-			border-radius: 0 0 $radius_ $radius_ ;
 			display: flex;
 			justify-content: space-between;
 			align-items: center;
@@ -101,6 +132,7 @@
 				justify-content: center;
 				align-items: center;
 				font-size: 30rpx;
+				padding: 0 10rpx;
 
 				.item-text {
 					display: inline-block;

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


+ 1 - 0
static/images/导航.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1733972953937" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8440" xmlns:xlink="http://www.w3.org/1999/xlink" width="128" height="128"><path d="M894.185422 128.023792 129.814578 445.743994 445.99982 577.744353 571.860343 893.929596Z" fill="#272636" p-id="8441"></path></svg>

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


+ 121 - 0
utils/LonLatConvert.js

@@ -0,0 +1,121 @@
+//转换常数
+const x_pi = 3.14159265358979324 * 3000.0 / 180.0
+const pi = 3.14159265358979324
+const a = 6378245.0
+const ee = 0.00669342162296594323
+
+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;
+}
+
+/* 
+ 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;
+}
+
+/* 
+ 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
+			})
+			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;
+}

+ 57 - 0
utils/openApp.js

@@ -0,0 +1,57 @@
+
+import gcoord from "gcoord";
+import { wgs_gcj_encrypts } from "@/utils/LonLatConvert.js"
+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))
+ 
+	let url;
+	switch (mapApp) {
+		case 'baidu':
+			url =
+				`baidumap://map/marker?location=${latitude},${longitude}&title=${encodeURIComponent(name)}&content=${encodeURIComponent(name)}&src=webapp`;
+			break;
+		case 'gaode': 
+		const {lng ,lat} = wgs_gcj_encrypts({lng:longitude,lat:latitude})
+			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`;
+			break;
+		default:
+			console.error('不支持的地图类型');
+			return;
+	}
+
+	// 使用iframe打开URL Scheme,避免直接跳转导致页面卡死
+	const iframe = document.createElement('iframe');
+	iframe.style.display = 'none';
+	iframe.src = url;
+	document.body.appendChild(iframe);
+	setTimeout(() => {
+		document.body.removeChild(iframe);
+	}, 1000);
+
+
+	// 定时器检测是否唤起成功,如果失败则跳转到网页版地图
+	let timer = setTimeout(() => {
+		window.location.href =
+			`https://uri.amap.com/marker?position=${longitude},${latitude}&name=${encodeURIComponent(name)}&src=mypage&coordinate=gaode&callnative=0`; // 默认跳转高德网页版
+	}, 2000);
+
+	window.addEventListener('blur', () => {
+		clearTimeout(timer)
+	});
+
+}
+
+
+// openMap(116.404, 39.915, "目的地", "baidu");

+ 4 - 4
utils/request.js

@@ -51,7 +51,7 @@ const onLogin = (msg) => {
 }
 
 
-console.log("$config = ", $config)
+// console.log("$config = ", $config)
 http.setConfig((config) => {
 	/* config 为默认全局配置*/
 	config.baseURL = $config.baseURL; /* 根域名 */
@@ -75,7 +75,7 @@ http.setConfig((config) => {
 	// 单商户
 	// config.header['merchant-id'] = uni.getStorageSync('merchantId') || 1;
 	// return config;
-	console.log("config = ", config)
+	// console.log("config = ", config)
 	return config
 })
 
@@ -113,14 +113,14 @@ http.interceptors.request.use((config) => { // 可使用async await 做异步操
 
 // 响应拦截
 http.interceptors.response.use((res) => {
-	console.log("res = ", res)
+	// console.log("res = ", res)
 	/* 对响应成功做点什么 可使用async await 做异步操作*/
 	// 未设置状态码则默认成功状态
 	const code = res.data.code || 200;
 	// 获取错误信息
 	const msg = errorCode[code] || res.data.msg || errorCode['default']
 	const { data } = res.data
-	console.log("data res= ", res)
+	// console.log("data res= ", res)
 	if (code === 401) {
 		onLogin("登录状态已过期")
 		return Promise.reject()

+ 39 - 0
utils/tool.js

@@ -0,0 +1,39 @@
+// 计算点位距离
+export const distanceCalculate = (num) => {
+	const num_ = Number(num);
+	if (typeof num_ === 'number') {
+		if (num_ < 1000) {
+			return `${num_.toFixed(1)}米`
+		} else {
+			const n = (num_ / 1000).toFixed(1);
+			return `${n}公里`
+		};
+	}
+	return num_ || num
+}
+
+// 拨打电话
+
+export const PhoneCall = (tel) => {
+	if (tel) {
+		uni.makePhoneCall({
+			phoneNumber: tel + ''
+		});
+	} else {
+		uni.showToast({
+			title: '暂未设置电话'
+		});
+	}
+}
+
+// 导航
+export const getMapLocation = (parmas = {}) => {
+	const { latitude, longitude, name, detailedAddress } = parmas
+	uni.openLocation({
+		latitude: parseFloat(latitude), // 要去的地址经度,浮点数
+		longitude: parseFloat(longitude), // 要去的地址纬度,浮点数
+		name: name, // 位置名
+		address: detailedAddress, // 要去的地址详情说明
+		scale: 16, // 地图缩放级别,整形值,范围从1~28。默认为最大
+	});
+}