Browse Source

H5,H6 修改

Fly 4 months ago
parent
commit
0c67a47e53

+ 1 - 0
App.vue

@@ -20,6 +20,7 @@
 		margin: 0;
 		box-sizing: border-box;
 	}
+	 
 	.one-row{
 		display: inline-block;
 		white-space:nowrap;

+ 2 - 0
api/map.js

@@ -14,5 +14,7 @@ export const getMaptypeList_Api = (params) => http.get('/h5/biz/maptype/list' ,
 
 // 获取地图点位服务
 export const getMapMatterList_Api = (params) => http.get('/h5/biz/map/matterList' , {params:params})
+// 获取地图点位服务
+export const getMapMatterListH6_Api = (params) => http.get('/h6/biz/map/matterList' , {params:params})
 
 

+ 41 - 7
components/tiandituMap/tiandituMap.vue

@@ -28,6 +28,7 @@
 		},
 		data() {
 			return {
+				checkedDot:false,
 				Tmap: null,
 				option: {
 					type: '',
@@ -122,6 +123,7 @@
 				}
 			}
 		},
+		
 		mounted() {
 
 		},
@@ -138,6 +140,7 @@
 				// 	}
 				// 	console.log("this.MyLngLat = " , this.MyLngLat)
 				// 	this.setMyIcon()
+				
 				EventBus.$emit('TianDiTuSearch', (res) => {
 					const { longitude, latitude } = res;
 					this.SelectedDot({ longitude, latitude })
@@ -145,7 +148,7 @@
 						lng: longitude,
 						lat: latitude
 					}
-					this.setMyIcon()
+					this.clearIcon()
 				})
 
 			},
@@ -172,10 +175,21 @@
 			// 移动地图,获取中心点
 			MapMoveend(e) {
 				try {
-					const v = e.target.getCenter()
-					const Lng = v.getLng();
-					const Lat = v.getLat();
-					this.$emit("moveMap", { Lng, Lat })
+					console.log('------------------')
+					// 地图移动,判断是否缩放/移动地图,还是通过点位定位
+					if(!this.checkedDot){
+						// 自然缩放移动,刷新接口
+						const v = e.target.getCenter()
+						const Lng = v.getLng();
+						const Lat = v.getLat();
+						this.$emit("moveMap", { Lng, Lat })
+					}else{
+						// 点位移动,做处理
+						this.$nextTick(() => {
+							this.checkedDot = false;
+						})
+					}
+					
 				} catch (error) {
 					//TODO handle the exception
 				}
@@ -213,15 +227,34 @@
 						projection: 'EPSG:4326',
 					});
 				} catch (error) {
+					console.log('Tmap error= ', error)
 					//TODO handle the exception
 				}
 			},
-
+			setViewport() {
+				try {
+				console.log('window.devicePixelRatio = ', window.devicePixelRatio)
+					console.log('window.getResolution 1 = 1 ', Tmap , window.screen.width * window.devicePixelRatio)
+					const w =  window.screen.width * window.devicePixelRatio
+					const meta = document.createElement('meta')
+					meta.name = 'viewport'
+					meta.content = `width=device-width,initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0, user-scalable=no` 
+					// meta.content = `initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no` 
+					// meta.media = `(device-height: 568px)` 
+					
+					document.head.appendChild(meta)
+					
+					
+				} catch (err) {
+					console.log('---------- ', err)
+				}
+			},
 
 			initTMap(newValue, oldValue, ownerInstance, instance) {
 				this.options = newValue
 				if (newValue.type === 'open' && newValue.apikey) {
 					if (!window.T) {
+						// this.setViewport() 
 						const script = document.createElement('script')
 						script.src = 'https://api.tianditu.gov.cn/api?v=4.0&tk=' + this.options.apikey
 						script.onload = this.initChartsRender.bind(this)
@@ -358,7 +391,8 @@
 					console.log("天地图获取定位 = error ", error)
 				}
 			},
-			SelectedDot(res) {
+			SelectedDot(res , dot = false) {
+				this.checkedDot = dot
 				const { longitude, latitude } = res;
 				Tmap.panTo(new T.LngLat(longitude, latitude), 16); // 移动到选中的点位
 			},

+ 3 - 1
config/index.js

@@ -10,5 +10,7 @@ export default {
 	key:'f4226f3eb5a974d153652665b64b497c',
 	secretKey:'a9557f94a84a95b515bec96c3bed93f1',
 	// 天地图
-	tianKey:'1edd9c001a8425cb93631398109d5ab2'
+	tianKey:'1edd9c001a8425cb93631398109d5ab2',
+	
+	type:'H5' , // h5 / h6,  web端打包需要修改 manifest.json web配置的基础运行路径
 }

+ 2 - 1
index.html

@@ -1,7 +1,8 @@
 <!DOCTYPE html>
 <html lang="en">
   <head>
-    <meta charset="UTF-8" />
+    <meta charset="UTF-8" aaa />
+	<!-- <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> -->
     <script>
       var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
         CSS.supports('top: constant(a)'))

+ 3 - 1
main.js

@@ -1,5 +1,7 @@
 import App from './App'
 import "@/static/css/index.scss";
+import $config from "@/config/index.js"
+
  
 // #ifndef VUE3
 import Vue from 'vue'
@@ -8,7 +10,7 @@ import './uni.promisify.adaptor'
 import uView from "uview-ui";
 Vue.use(uView);
 
-
+Vue.prototype.$config = $config
 Vue.config.productionTip = false
 App.mpType = 'app'
 const app = new Vue({

+ 23 - 6
pages/map/index.vue

@@ -7,8 +7,9 @@
 			@handleMapSite="handleMapSite">
 		</tiandituMap>
 
- 
-		<Touchbox ref="TouchboxRef" :maxHeight="0.8" v-if="showMap && siteListArr && siteListArr.length > 0" :zIndex="1001" @currentHeight="e => TouchHeight = e">
+
+		<Touchbox ref="TouchboxRef" :maxHeight="0.8" v-if="showMap && siteListArr && siteListArr.length > 0"
+			:zIndex="1001" @currentHeight="e => TouchHeight = e">
 			<scroll-view :style="{'height':TouchHeight - 15  +'px' }" scroll-y="true" :show-scrollbar="false">
 				<template v-for="item in siteListArr">
 					<siteListModel :info="item" @checkSiteDetails="checkSiteDetails" />
@@ -27,7 +28,7 @@
 	import siteDetails from "./model/siteDetails.vue"
 	import $config from "@/config/index.js"
 	import { EventBus } from "@/utils/vueBus.js"
-	import { getLocation } from "@/utils/tool.js" 
+	import { getLocation } from "@/utils/tool.js"
 	export default {
 		name: 'tdtmap',
 		components: {
@@ -36,7 +37,8 @@
 			siteDetails
 		},
 		data() {
-			return { 
+			return {
+				searchDot: false,
 				showMap: false,
 				longitude: undefined,
 				latitude: undefined,
@@ -54,7 +56,7 @@
 				TouchHeight: 0,
 			}
 		},
-		created() { 
+		created() {
 			getLocation();
 
 			this.getMapCenterPoint()
@@ -85,7 +87,12 @@
 									this.$refs.tiandituMapRefs.setIcon(longitude, latitude, false,
 										mapTypeIcon,
 										el);
+									if (index === 0 && this.searchDot) {
+										this.$refs.tiandituMapRefs.Trenderjs.SelectedDot(el, true)
+									}
 								})
+
+
 							})
 						});
 					} catch (error) {}
@@ -127,7 +134,7 @@
 			// 查看点位详情
 			checkSiteDetails(info) {
 				if (info) {
-					this.$refs.tiandituMapRefs.Trenderjs.SelectedDot(info)
+					this.$refs.tiandituMapRefs.Trenderjs.SelectedDot(info, true)
 					// EventBus.$emit('TianDiTuSite', info)
 					this.handleClickMap();
 					this.$refs.siteDetailsRef.openDetails(info)
@@ -160,6 +167,16 @@
 					latitude: this.latitude,
 					radius: 5000
 				};
+				// 判断是否通过收索
+				this.searchDot = parms.search
+				// 如果存在收索条件,则去掉 范围 和 中心点
+				if (parms.locationName || parms.mapTypeId || parms.areaCode) {
+					delete parms.radius
+					delete parms.latitude
+					delete parms.longitude
+				}
+				delete parms.search
+				console.log('parms  ', parms)
 				getMapList_Api(parms).then(res => {
 					if (!res || res.length === 0) {
 						uni.showToast({

+ 5 - 4
pages/map/model/search.vue

@@ -10,7 +10,7 @@
 					</path>
 				</svg>
 				<input confirm-type="search" ref="searchInputRef" class="search-input" :auto-blur="true" type="text"
-					placeholder="请输入关键字" v-model="locationName" @blur="onSearchFocus()" />
+					placeholder="请输入关键字" v-model="locationName" @blur="onSearchFocus(true)" />
 			</view>
 			<view class="search-select">
 				<view class="select-item" @click.stop="$refs.cityRef.open()">
@@ -95,7 +95,7 @@
 			 * 
 			 */
 
-			handleSearch(callBack) {
+			handleSearch(callBack) { 
 				try {
 					uni.showLoading({
 						mask: true
@@ -121,7 +121,7 @@
 					//TODO handle the exception
 				}
 			},
-			onSearchFocus() {
+			onSearchFocus(search = false) {
 				try {
 					clearTimeout(this.SearchTimeout)
 					this.SearchTimeout = null;
@@ -135,6 +135,7 @@
 							pms.selfLatitude = this.selfLatitude;
 							pms.selfLongitude = this.selfLongitude;
 							pms.locationName = this.locationName;
+							pms.search = search
 						} catch (error) {
 							console.log("定位收索11 error", error)
 							//TODO handle the exception
@@ -160,7 +161,7 @@
 		watch: {
 			params: {
 				handler(newV, oldV) {
-					this.handleSearch()
+					this.onSearchFocus(true)
 				},
 				deep: true
 			}

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

@@ -17,8 +17,10 @@
 							</view>
 						</view> 
 						<view class="sever-box" :style="{'height':serveH  +'px' }">
-							<template v-if="serveH">
-								<siteServe :height="serveH" :mapLocationId="info.mapLocationId" />
+							<template v-if="serveH"> 
+								<siteServe v-if="$config.type === 'H5'" :height="serveH" :mapLocationId="info.mapLocationId" />
+								
+								<siteServeH6 v-if="$config.type === 'H6'" :height="serveH" :mapLocationId="info.mapLocationId" />
 							</template>
 						</view>
 					</template>
@@ -61,6 +63,7 @@
 	import { distanceCalculate } from "@/utils/tool.js";
 	import telList from "./telList.vue"
 	import siteServe from "./siteServe.vue"
+	import siteServeH6 from "./siteServeH6.vue"
 	export default {
 		data() {
 			return {
@@ -69,7 +72,7 @@
 				info: null,
 			}
 		},
-		components: { telList, siteServe },
+		components: { telList, siteServe , siteServeH6 },
 		created() {
 
 		},

+ 2 - 0
pages/map/model/siteServe.vue

@@ -132,6 +132,8 @@
 				}, 200)
 			},
 			scrollService(event) {
+				// console.log('stopPropagation  ' , event)
+				// event.stopPropagation();
 				if (!this.scrollStatus) return
 				const { scrollTop } = event.detail;
 				let scrollNums = scrollTop;

+ 353 - 0
pages/map/model/siteServeH6.vue

@@ -0,0 +1,353 @@
+<template>
+	<view class="serve-content" :style="{'height':height  +'px' }">
+		<view class="serve-title">可以办事项</view>
+		<view class="serve-search">
+			<input confirm-type="search" ref="searchInputRef" class="search-input" :auto-blur="true" type="text"
+				placeholder="搜索服务事项" v-model="matterName" @confirm="getMatterList" />
+			<view class="search-btn" @click.stop="getMatterList"> 搜 索 </view>
+		</view>
+		<view class="matter-loading" v-if="MatterListLoading">
+			<u-loading-icon />
+		</view>
+		<view class="serve" :style="{'height':scrollH  +'px' }" v-else-if="MatterList">
+			<scroll-view class="scroll-lable" :style="{'height':scrollH  +'px' }" scroll-y="true"
+				:show-scrollbar="false">
+				<template v-for="(value, key , index) in MatterList">
+					<view :class="['lable one-row' , index === activeIndex ? 'active-lable' : '' ]"
+						@click.stop="openTyle(index)">{{ key }}</view>
+				</template>
+			</scroll-view>
+			<scroll-view class="scroll-val" :scroll-into-view="scrollIntoView" @scroll="scrollService"
+				:style="{'height':scrollH  +'px' }" scroll-y="true" :show-scrollbar="false">
+				<template v-for="(value, key , index) in MatterList">
+					<view class="val-content" :id="`service_${index}`">
+						<view class="val-name">{{key}}</view>
+						<template v-for="(t_v, t_k , t_i) in (value || [])">
+							<!-- @click.stop="LookMatterDetails(item)" -->
+							<view class="val">
+								<view class="val-label val-item" @click.stop="setShowKey(index  , t_i)">
+									<text class="val-text one-row">{{ t_k }}</text>
+									<template v-if="t_v && t_v.length">
+										<svg t="1734508422065"
+											:class="['val-icon' , showKey === getShowKey(index  , t_i ) ? 'avtive-icon' : '']"
+											viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
+											p-id="4279" xmlns:xlink="http://www.w3.org/1999/xlink">
+											<path
+												d="M492.675886 904.817574L885.696074 511.797385 492.675886 118.777197c-12.258185-12.258185-12.432147-32.892131 0.187265-45.51052 12.707416-12.707416 32.995485-12.703323 45.511543-0.187265l411.660734 411.660734c7.120165 7.120165 10.163477 17.065677 8.990768 26.624381 1.500167 9.755178-1.5104 20.010753-8.990768 27.491121L538.374694 950.515359c-12.258185 12.258185-32.892131 12.432147-45.511543-0.187265-12.707416-12.707416-12.703323-32.995485-0.187265-45.51052z"
+												p-id="4280"></path>
+										</svg>
+									</template>
+								</view>
+								<!-- showKey -->
+								<template v-if="showKey === getShowKey(index  , t_i )">
+									<view class="val-item" v-for="item in (t_v || [])">
+										{{item.name}}
+									</view>
+								</template>
+							</view>
+						</template>
+					</view>
+				</template>
+			</scroll-view>
+		</view>
+		<view v-else class="matter-loading">
+			<u-empty mode="data" :iconSize="emptySize" text="暂无可办事项" />
+		</view>
+	</view>
+</template>
+
+<script>
+	import { getMapMatterListH6_Api } from "@/api/map.js"
+	export default {
+		props: {
+			height: {
+				type: Number,
+				default: 0
+			},
+			mapLocationId: {
+				type: Number | String,
+				default: null
+			}
+		},
+		data() {
+			return {
+				showKey: '',
+				scrollH: 0,
+				matterName: '',
+				MatterList: null,
+				MatterListLoading: false,
+				activeIndex: undefined,
+				scrollIntoView: undefined,
+				scrollStatus: true,
+				oldScrollNum: 0,
+				RightTopArr: [],
+
+				emptySize: uni.upx2px(130)
+			}
+		},
+		watch: {
+			height: {
+				handler(newH) {
+					// 区域高度 - 标题高度 - 搜索区域高度
+					this.scrollH = newH - uni.upx2px(60) - uni.upx2px(100);
+				},
+				immediate: true
+			},
+			mapLocationId: {
+				handler(newId) {
+					this.getMatterList(newId)
+				},
+				immediate: true
+			},
+		},
+		created() {
+
+		},
+		methods: {
+			getShowKey(k_1, k_2) {
+				return `${k_1}${k_2}`
+			},
+			setShowKey(index, t_i) {
+				const k = this.getShowKey(index, t_i);
+				if (!this.showKey || this.showKey !== k) {
+					this.showKey = k;
+				} else {
+					this.showKey = ''
+				};
+			},
+			getLabel(item) {
+				console.log("getLabel = ", item)
+				const label = Object.keys(item)[0];
+				return label;
+			},
+			getMatterList() {
+				this.MatterListLoading = true;
+				const parmas = {
+					mapLocationId: this.mapLocationId,
+					matterName: this.matterName
+				};
+				getMapMatterListH6_Api(parmas).then(res => {
+					const keys = Object.keys(res || {});
+					if (keys && keys.length > 0) {
+						this.MatterList = res;
+						this.activeIndex = 0;
+						this.getNodesInfo()
+					} else {
+						this.MatterList = null;
+						this.activeIndex = undefined;
+					}
+				}).catch(err => {
+					this.MatterList = null;
+					this.activeIndex = undefined;
+				}).finally(() => {
+					setTimeout(() => {
+						this.MatterListLoading = false;
+					}, 300)
+				})
+			},
+
+			openTyle(index) {
+				this.scrollStatus = false;
+				this.activeIndex = index
+				this.scrollIntoView = `service_${index}`
+				setTimeout(() => {
+					this.scrollStatus = true;
+				}, 200)
+			},
+			scrollService(event) {
+				// console.log('stopPropagation  ' , event)
+				// event.stopPropagation();
+				if (!this.scrollStatus) return
+				const { scrollTop } = event.detail;
+				let scrollNums = scrollTop;
+				if (this.oldScrollNum > scrollTop) {
+					scrollNums = scrollTop + 80;
+				};
+				try {
+					this.RightTopArr.forEach((el, index) => {
+						let data = this.RightTopArr[index];
+						if (scrollNums >= data.height && index == this.RightTopArr.length - 1 ? true :
+							scrollNums < this.RightTopArr[parseInt(index) + 1].height) {
+							this.activeIndex = index;
+							throw new Error()
+						}
+					})
+				} catch (e) {
+					//TODO handle the exception
+				}
+
+				this.oldScrollNum = scrollTop;
+
+
+			},
+			// 查看事项详情
+			LookMatterDetails(item) {
+				// pages/map/matterDetails
+				// 在起始页面跳转到test.vue页面,并监听test.vue发送过来的事件数据
+				uni.navigateTo({
+					url: '/pages/map/matterDetails',
+					success: function(res) {
+						// 通过eventChannel向被打开页面传送数据
+						res.eventChannel.emit('acceptDataFromOpenerPage', item)
+					}
+				})
+			},
+
+			getNodesInfo() {
+				new Promise(resolve => {
+					let selectorQuery = uni.createSelectorQuery();
+					// 获取节点的位置信息
+					selectorQuery.selectAll('.val-content').boundingClientRect((rects) => {
+						// 如果节点尚未生成,rects值为[](因为用selectAll,所以返回的是数组),循环调用执行
+						if (!rects.length) {
+							setTimeout(() => {
+								this.$nextTick(() => {
+									this.getNodesInfo();
+								})
+							}, 10);
+							return;
+						}
+						this.RightTopArr = [];
+						// 生成之后开始添加进去数组
+						rects.forEach((rect) => {
+							// 这里减去rects[0].top,是因为第一项顶部不是贴到导航栏=>每一个商品距离顶部的高度,如果此页面顶部没有其他的view那就不用减去rects[0].top,自己视情况而定。
+							let tops = rect.top - rects[0].top;
+							this.RightTopArr.push({
+								height: tops,
+								id: rect.id
+							});
+						})
+						resolve();
+					}).exec()
+				});
+			},
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.serve-content {
+		border-top: 1rpx solid #F0F0F0;
+
+		.serve-title {
+			color: #7D7D7D;
+			font-size: 32rpx;
+			height: 60rpx;
+			line-height: 60rpx;
+		}
+
+		.serve-search {
+			width: 100%;
+			padding: 20rpx 0;
+			display: flex;
+			justify-content: space-between;
+			align-items: stretch;
+
+			.search-input {
+				flex: 1;
+				height: 60rpx;
+				border: 1rpx solid #F0F0F0;
+				border-radius: 10rpx;
+				padding: 0 15rpx;
+				font-size: 28rpx;
+			}
+
+			.search-btn {
+				width: 120rpx;
+				background-color: #3291F8;
+				margin-left: 20rpx;
+				line-height: 60rpx;
+				text-align: center;
+				color: #fff;
+				font-size: 28rpx;
+				border-radius: 10rpx;
+			}
+		}
+
+		.serve {
+			width: 100%;
+			overflow: hidden;
+			display: flex;
+			align-items: stretch;
+
+			.scroll-lable {
+				width: 160rpx;
+
+				.lable {
+					width: 100%;
+					height: 80rpx;
+					font-size: 30rpx;
+					line-height: 80rpx;
+					text-align: center;
+					border-left: 6rpx solid transparent;
+					padding: 0 10rpx;
+				}
+
+				.active-lable {
+					color: #3291F8;
+					font-weight: 600;
+					border-left-color: #3291F8;
+				}
+			}
+
+			.scroll-val {
+				width: calc(100% - 160rpx);
+				padding: 0 0 0 20rpx;
+
+				.val-content {
+					// height: 300px;
+				}
+
+				.val-name {
+					font-size: 30rpx;
+					padding: 15rpx 0;
+					font-weight: 600;
+				}
+				.val {
+					width: 100%; 
+					border: 1rpx solid #F0F0F0;
+					margin-bottom: 20rpx;
+					transition: height 1s;
+				
+					.val-item {
+						width: 100%;
+						min-height: 100rpx;
+						padding: 10rpx 20rpx;
+						display: flex;
+						justify-content: space-between;
+						align-items: center;
+						border-top: 1rpx solid #F0F0F0;
+						&:first-child{
+							border-top:none;
+						}
+					}
+
+					.val-label {
+					font-weight: 600;
+						.val-text {
+							flex: 1;
+							width: 1px;
+							font-size: 30rpx;
+						}
+
+						.val-icon {
+							width: 34rpx;
+							height: 34rpx;
+							transition: transform 0.3s;
+						}
+						.avtive-icon{
+							transform: rotate(90deg);
+						}
+					}
+				}
+				 
+			}
+		}
+
+		.matter-loading {
+			padding-top: 50rpx;
+			text-align: center;
+		}
+
+	}
+</style>

+ 2 - 2
utils/request.js

@@ -120,7 +120,7 @@ http.interceptors.response.use((res) => {
 	// 获取错误信息
 	const msg = errorCode[code] || res.data.msg || errorCode['default']
 	const { data } = res.data
-	console.log("msg =============== ", res)
+	// console.log("msg =============== ", res)
 	// console.log("data res= ", res)
 	if (code === 401) {
 		onLogin("登录状态已过期")
@@ -145,7 +145,7 @@ http.interceptors.response.use((res) => {
 
 	// }
 }, (response) => {
-	console.log("msg ======111111111111========= ", response.data)
+	// console.log("msg ======111111111111========= ", response.data)
 	const res = response.data || {};
 	let { message } = response;
 	if (res?.msg) {