uni-app 半屏地图拖拽滚动底部半屏,仿高德搜索拖拽

2023-05-16

<template>
	<view class="event-help-details">
		<view class="back-last-page" :style="'top: ' + navTabtop + 'px'" @click="goBackPage">
			<u-icon name="arrow-left" color="#030303" size="20"></u-icon>
		</view>
		<view class="map-content" :style="'height:' + mapHeight + 'px'">
			<map class="map-gis" id="mapGis" ref="mapGis" :show-scale="true" :enable-poi="true" :show-location="false"
				:enable-building="true" :enable-3D="true" :enable-rotate="true" :enable-indoorMap="true"
				:scale="mapObj.scale" :longitude="mapObj.longitude" :latitude="mapObj.latitude"
				:markers="mapMarkers"></map>
		</view>
		<movable-area class="move-content" @touchmove.stop>
			<movable-view class="move-incontent" :style="'height:' + movableHeight + 'px'" :y="initY" inertia
				:damping="10" :friction="1" direction="vertical" :animation="false" @change="movableChange"
				@touchend="touchEnd">
				<view class="move-drag-ico" @click.stop="openHide">
					<image class="drag-img" :class="{'drag-transform':drageIco == 'down'}" src="../../static/down.png"
						mode=""></image>
				</view>
				<view class="move-infos-body" style="height: calc(100% - 50px);">
					<scroll-view style="height: 100%;" :scroll-y="initY == canDragTop">
						<view class="" v-for="i in 100">{{ i }}</view>
					</scroll-view>

				</view>

				<!-- <video src="https://grid.wanhi.com.cn:65417/file/1650703977267/grid/eventhelp/20220623/1539819981196234754.mp4"></video> -->
			</movable-view>
		</movable-area>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				navTabtop: 20,

				mapObj: {
					longitude: 121.373219,
					latitude: 31.23378,
					scale: 16
				},
				mapMarkers: [{
					id: 123132,
					longitude: 121.373219,
					latitude: 31.23378,
					iconPath: '/static/loca.png',
					width: 40,
					height: 40
				}],
				// page
				windowHeight: 800,
				mapHeight: 250,
				cHeightNum: 0,
				movableHeight: 800,
				canDragTop: 0,
				initY: 0,
				dragY: 0,
				drageIco: 'up'

			};
		},
		onLoad() {
			let menuButton = uni.getMenuButtonBoundingClientRect();
			this.navTabtop = menuButton.top;
			console.log('==============', menuButton);
			this.windowHeight = uni.getSystemInfoSync().windowHeight

			this.mapHeight = this.windowHeight - 240;
			this.movableHeight = this.windowHeight - 250
			this.cHeightNum = this.windowHeight - 240;
			this.initY = -(this.windowHeight - 250 - 240);
			this.canDragTop = -(this.windowHeight - 250 - 240)

			this.dragY = 0
		},
		methods: {
			goBackPage() {
				uni.navigateBack({
					delta: 1
				});
			},
			// S 移动拖拽
			movableChange(e) {
				let y = e.detail.y;
				this.dragY = y
				let c_h = this.cHeightNum + y;
				if (c_h >= 250) {
					this.mapHeight = c_h;
				}
				if (y > (-100)) {
					this.drageIco = 'down'
				} else {
					this.drageIco = 'up'
				}
			},
			touchEnd(e) {
				this.initY = this.dragY
				setTimeout(() => {
					if (this.dragY > (-100)) {
						this.initY = 0

					} else {
						this.initY = -(this.windowHeight - 250 - 240);
					}
				}, 100)

			},
			openHide() {
				if (this.drageIco == 'up') {
					this.initY = 0
				} else {
					this.initY = -(this.windowHeight - 250 - 240);
				}
			}
			// E 移动拖拽

		}
	};
</script>

<style lang="scss">
	.event-help-details {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		position: relative;
	}

	.back-last-page {
		width: 60rpx;
		height: 60rpx;
		position: fixed;
		left: 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 999999;
	}

	.map-content {
		width: 100%;
		background-color: #eee;
		position: absolute;
		top: 0;
		left: 0;

		.map-gis {
			width: 100%;
			height: 100%;
		}
	}

	// S 滑动块
	.move-content {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 240px;
	}

	.move-incontent {
		width: 100%;
		background-color: #fff;
	}

	.move-drag-ico {
		width: 100%;
		height: 60rpx;
		display: flex;
		align-items: center;
		justify-content: center;

		.drag-img {
			width: 50rpx;
			height: 30rpx;
			transition: all .3s;
		}

		.drag-transform {
			transform: rotate(-180deg);
		}
	}

	// 滚动内容
	.move-infos-body {}

	// E 滑动块
</style>

实现效果: 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

uni-app 半屏地图拖拽滚动底部半屏,仿高德搜索拖拽 的相关文章

随机推荐

  • Android 中的 Lottie 动画入门

    增强应用程序的用户体验是任何开发人员的首要任务之一 与图像和文本描述相比 xff0c 为某些描述提供动画总是可以增强应用程序的用户体验 xff01 Lottie是用于移动应用程序的库之一 xff0c 有助于以更简单的方式提供动画 如何开始在
  • Java实现文件上传到本地(自定义保存路径)

    首先基于 springboot 实现的 xff0c 其他场景下可以引入相应的 jar 包后进行整合 首先写入一个方法 xff0c 方法的参数为传入的文件 xff0c 方法的返回值自定义 xff0c 这里返回类型为 String 返回文件的存
  • 关于Qt中使用QFile打开文件时遇到问题的分析

    项目场景 xff1a 在文件打开的时候 xff0c 使用QFile的QIODevice的不同模式 xff0c 会出现不同的表现 xff08 这是我一个同事当时遇到的问题 xff0c 现在拿来分析分析 xff0c 以下的所有事例代码均用于示范
  • vue+vue_cli3 + typeScript + echarts热力图

    vue 43 vue cli3 43 typeScript 43 echarts热力图 准备工作 准备工作 1 申请百度地图秘钥http lbsyun baidu com apiconsole key create 注 xff1a 如果是运
  • forEach循环 当满足条件时跳出当前循环

    forEach循环 当满足条件时跳出该循环 使用try catch try this menuData forEach item any 61 gt if toPath as string indexOf item url 61 61 61
  • vue3.0 学习笔记

    vue3学习笔记 vue3 0六大亮点vue3 0 如何变快的 xff1f vue3 0六大亮点 performance xff1a 性能比vue2 0快1 2 2倍tree shaking support xff1a 按需编译 xff0c
  • 从后台读取以文件流的形式加载图片

    span class token comment html span span class token operator lt span img span class token operator span src span class t
  • element-ui el-transfer添加拖拽排序功能

    html 部分 lt el card class 61 34 box card 34 gt lt el transfer render content 61 34 renderFunc 34 v model 61 34 value 34 d
  • Mac系统装android开发环境无法创建SD卡解决方案

    无法创建SD卡是小事 xff0c 但是引起的问题却是大事 xff0c 模拟器无SD卡则android项目无法正常生成R文件 xff0c 导致HelloWorld都无法跑起来 xff0c 头大 xff0c 折腾了几天 xff0c 终于找到原因
  • audio报错DOMException: play() failed because the user didn‘t interact with the document first

    chrome66版本之后禁掉了声音的自动播放 xff0c 这句报错提示 xff0c 调用play方法之前 xff0c 请先与页面进行交互 我们自己来封装一个可以自动播放的Audio xff0c 功能包含 xff1a 自动播放 暂停 循环播放
  • iview中Table的render用法大全

    1 日期格式化 xff08 yyyy MM dd hh mm s xff09 title 34 格式化时间 34 key 34 time 34 render h params 61 gt let temp 61 39 39 if param
  • Vue添加中间层--service层

    Vue添加中间层 service层 在单页面应用中 xff0c 为了方便代码的管理 xff0c 提高可读性 xff0c 还有一个原因就是 xff0c 在项目开发工程中 xff0c 前端人员与后端开发人员的进程是不同步的 xff0c 在不同步
  • Vue is not defined

    Vue is not defined 场景再现 xff1a 在Vue的自定义组件中 xff0c 想要调用在 static serverconfig json中配置的全局地址ApiUrl 在自定义组件中 console log Vue pro
  • Vue中进行pdf的预览下载 vue-pdf

    1 使用npm 下载vue pdf npm install span class token operator span save vue span class token operator span pdf 2 封装pdf组件 span
  • C# 的基本代码规范

    个人遵守的通用 C 代码规范 xff0c 其中参考了微软的代码规范 实际上在是使用一些框架开发时 例如 ASP NET Core 也应该遵循一定的模式规范 xff0c 但是本文只讨论一些比较通用的代码规范 文章将从下面的几个方面来谈论规范
  • ubuntu 文件夹消失怎么办

    点击文件夹 xff0c 然后摁F9
  • ffmpeg花屏解决(修改源码,丢弃不完整帧和解码错误帧)

    linux下模拟丢帧的命令 因为帧之间的参考关系 实测如果是1 几乎没有完好的帧 tc只能对发出的包做处理 但它还可以做延时抖动处理 sudo tc qdisc add dev enp0s31f6 root netem loss span
  • 使用SDF对ROS-Gazebo中模型进行编辑修改

    什么是SDF文件 SDF是一种XML格式 xff0c 能够描述机器人 静态和动态物体 照明 地形甚至物理学的各方面的信息 SDF可以精确描述机器人的各类性质 xff0c 除了传统的运动学特性之外 xff0c 还可以为机器人定义传感器 表面属
  • Ubuntu16.04桌面图标消失

    项目场景 xff1a 提示 xff1a 这里简述项目相关背景 xff1a 例如 xff1a Ubuntu16 04用了挺久 问题描述 xff1a 提示 xff1a 这里描述项目中遇到的问题 xff1a Ubuntu16 04重启后 xff0
  • uni-app 半屏地图拖拽滚动底部半屏,仿高德搜索拖拽

    lt template gt lt view class 61 34 event help details 34 gt lt view class 61 34 back last page 34 style 61 34 39 top 39