minorlocate.vue 2.15 KB
<template>
	<view class="page">
		<pyh-nv ref="nv" :config="nvConfig"></pyh-nv>
		<view class="listBox" :style="{'padding-top':(pageTop+'px')}">
		<view class="content">
		<view class="map" style="width: 100%;height: 100%;">
			<map :min-scale="9"  id="customMap" :scale="15" :style="'width: 100%;'+ 'height:'+screenHeight"  :markers="markers" layer-style="1" subkey="PTOBZ-QDQEG-DK3QM-QMYWN-I5WDZ-CCB6S"
				:latitude="address.latitude" :longitude="address.longitude">
			</map>
		</view>
		
		</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nvConfig:{
					title:"儿童定位",
					bgColor:"#ffffff",
					color:"#000000",
					fixedAssist:{
						hide:true,
					},
				},
				query:{
					phone: '',
					userId: ''
				},
				childData: [],
				address: {
					// 纬度
					latitude: '',
					// 经度
					longitude: ''
				},
				screenHeight:'',
				markers:[],
				
				
			}
		},
		onPageScroll(e) {this.$refs.nv.pageScroll(e)},
		computed:{
			pageTop(){return parseInt(88*uni.getSystemInfoSync().windowWidth/750) + uni.getSystemInfoSync().statusBarHeight}
		},
		onLoad() {
			var that = this;
			uni.getSystemInfo({
				success: function(res) {
					that.screenHeight = res.safeArea.height + 'px'
				}
			})
			this.getChild();
		},
		onReady() {
			uni.hideTabBar();
		},
		methods:{
			getChild() {
				this.query.phone = uni.getStorageSync("USERS_KEY").phonenumber;
				console.log("userinfo",this.query.phone);
				this.API.getChild(this.query).then(res => {
					this.childData = res.data.chiStaySosEmergencyCallPos;
					var index = this.childData[0].sendAddress.indexOf(",");
					this.address.longitude = this.childData[0].sendAddress.substring(0, index);
					this.address.latitude = this.childData[0].sendAddress.substring(index + 1, this.childData[0].sendAddress.length);
					this.address.id = this.childData[0].id;
					this.address.width = 20;
					this.address.height = 20;
					this.markers.push(this.address)
					console.log(this.markers)
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	@import 'minorlocate.scss';
</style>