<template>
	<view>
		<map style="width: 100%; height: 100vh;position: relative;" @markertap="markertap" :latitude="info.latitude"
			:longitude="info.longitude" :markers="covers"></map>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {},
				covers: [],
			}
		},
		onLoad() {
			this.openlocation();
		},
		onShareAppMessage() {
			return this.util.shareInfo
		},
		methods: {
			markertap() {
				this.openlocation();
			},
			openlocation() {
				this.loadInfo(function(res) {
					uni.openLocation({
						latitude: res.latitude,
						longitude: res.longitude,
						name: res.name,
						address: res.address
					});
				})
			},
			loadInfo(cb) {
				var that = this;
				this.util.request({
					api: '/api/mobile/visit/introduce',
					utilSuccess: function(res) {
						res.latitude = parseFloat(res.latitude);
						res.longitude = parseFloat(res.longitude);
						that.info = res;
						that.covers.push({
							latitude: res.latitude,
							longitude: res.longitude,
							width: 70,
							height: 70,
							iconPath: '/static/img/location.png'
						});
						cb(res);
					},
					utilFail: function(res) {

					}
				})

			},
		}
	}
</script>

<style>

</style>
