小程序(物流、快递),接入GPS北斗获取路线以及当前车辆位置

1、前端目前的路线是在数据中定义模拟的。

2、实际使用中,需要后端接入定位系统,以及车辆硬件支持,拿到车辆的定位信息,以及后台录入的车辆号码及驾驶人信息或需要的信息。

3、当前代码复制即可使用,只需要把绑定数据切换为接口返回数据。

javascript 复制代码
<template>
	<view class="content">
		<map style="width:100%;height:100%;" :latitude="latitude" :longitude="longitude" :scale="scale"
			:markers="markers" @markertap="onMarkerTap" :polyline='polyline'>
		</map>

		<view class="content-up" v-if="mapshow">
			<view>
				<text>路程信息</text>
				<view @click="Outmapshow">
					<image src="/static/out.png" style="width: 100%;height: 100%;"></image>
				</view>
			</view>
			<view>
				<view v-for="(img, index) in images" :key="index" class="icon">
					<image src="/static/right.png" style="width: 100%; height: 100%" v-if="index<currentIndex"></image>
				</view>
			</view>
			<view>路程: {{mapupdata.km}}km</view>
			<view>预计: {{mapupdata.date}} 到达</view>
			<view>车牌号: {{mapupdata.number}}</view>
			<view>车辆状态: <view :style="{background:mapupdata.type=='暂停'?'#FF0000':'#55aa7f'}">{{mapupdata.type}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				latitude: 34.79977,
				longitude: 113.663221,
				scale: 14,
				polyline: [],
				markers: [],
				images: Array(10).fill('/static/right.png'),
				currentIndex: 0, // 当前图片索引
				mapshow: false,
				mapupdata: ''
			}
		},
		mounted() {
			this.showImages();
			setInterval(this.showImages, 1000);
		},
		created() {
			this.markers = require('../../static/markers.json');
		},
		methods: {
			Outmapshow() {
				this.mapshow = false
				this.polyline = [] //初始化
			},
			showImages() {
				this.currentIndex = (this.currentIndex + 2) % 12; // 每次增加2并对12取模  
				if (this.currentIndex === 0) {
					this.currentIndex = 2; // 如果结果为0,则设置为2  
				}
			},
			onMarkerTap(e) {
				const markerId = e.markerId;
				this.markers.forEach((item) => {
					if (item.id == markerId) {
						this.polyline = item.polyline
						this.mapupdata = item
						this.mapshow = true
						this.currentIndex = 0
						this.$forceUpdate()
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		width: 100vw;
		height: 100vh;

		.content-up {
			width: 100%;
			border-top-right-radius: 20rpx;
			border-top-left-radius: 20rpx;
			background: #FFFFFF;
			float: left;
			position: fixed;
			left: 0;
			bottom: 0;
			z-index: 99999;
			padding-bottom: 80rpx;
		}

		.content-up>view:nth-child(1) {
			width: 90%;
			height: 40rpx;
			margin: 30rpx auto 0;
			position: relative;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.content-up>view:nth-child(1)>view {
			width: 40rpx;
			height: 40rpx;
			text-align: center;
			line-height: 40rpx;
			position: absolute;
			right: 0;
			top: 0;
			z-index: 9;
		}

		.content-up>view:nth-child(2) {
			width: 630rpx;
			height: 70rpx;
			border-radius: 5rpx;
			margin: 65rpx auto 0;
			position: relative;
			display: flex;
			align-items: center;
			justify-content: center;
			background: #f3f3f3;
		}

		.icon {
			width: 60rpx;
			height: 60rpx;
		}


		.content-up>view:nth-child(3),
		.content-up>view:nth-child(4),
		.content-up>view:nth-child(5),
		.content-up>view:nth-child(6) {
			width: 630rpx;
			height: 70rpx;
			margin: 10rpx auto 0;
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: #333333;
			font-weight: bold;
		}

		.content-up>view:nth-child(6)>view {
			width: 70rpx;
			height: 50rpx;
			background: #FF0000;
			border-radius: 5rpx;
			text-align: center;
			line-height: 50rpx;
			font-size: 26rpx;
			font-weight: 500;
			color: #FFFFFF;
		}
	}
</style>

车辆图片,可自定义

相关推荐
说私域6 小时前
开源AI大模型、AI智能名片与S2B2C商城小程序:用户需求满足的底层逻辑与实践路径
人工智能·小程序·开源
2501_916007477 小时前
前端开发工具都有哪些?常用前端开发工具清单与场景化推荐
android·ios·小程序·https·uni-app·iphone·webview
2501_9159090610 小时前
iOS 应用上架全流程解析,苹果应用发布步骤、ipa 上传工具、TestFlight 测试与 App Store 审核经验
android·macos·ios·小程序·uni-app·cocoa·iphone
Nan_Shu_6141 天前
学习:uniapp全栈微信小程序vue3后台-额外/精彩报错篇
前端·学习·微信小程序·小程序·uni-app·notepad++
老华带你飞1 天前
机电公司管理小程序|基于微信小程序的机电公司管理小程序设计与实现(源码+数据库+文档)
java·数据库·vue.js·spring boot·微信小程序·小程序·机电公司管理小程序
卷Java1 天前
小程序前端功能更新说明
java·前端·spring boot·微信小程序·小程序·uni-app
CTRA王大大1 天前
【微信公众平台】小程序如何查找菜单?如何通过自定义的菜单路径生成小程序二维码?小程序二维码指定生成
小程序·微信公众平台
说私域1 天前
基于开源AI智能名片链动2+1模式S2B2C商城小程序的引流爆款设计策略研究
人工智能·小程序
weixin_lynhgworld1 天前
短剧小程序系统开发:构建便捷高效的影视观看平台
小程序·短剧
知识分享小能手1 天前
微信小程序入门学习教程,从入门到精通,微信小程序常用API(下)——知识点详解 + 案例实战(5)
前端·javascript·学习·微信小程序·小程序·vue·前端开发