<template>
	<uni-popup ref="popup" type="bottom" :mask-click="false" maskBackgroundColor="rgba(0, 0, 0, 0.6)">
		<view class="uni-popup-share">
			<view class="uni-share-title"><text class="uni-share-title-text">{{shareTitleText}}</text></view>
			<view class="uni-share-content">
				<view class="uni-share-content-box">
					<view class="uni-share-content-item" v-for="(item,index) in bottomData" :key="index"
						@click.stop="select(item,index)">
						<image class="uni-share-image" :src="item.icon" mode="aspectFill"></image>
						<text class="uni-share-text">{{item.text}}</text>
					</view>

				</view>
			</view>
			<view class="uni-share-button-box">
				<button class="uni-share-button" @click="popupClose">{{cancelText}}</button>
			</view>
		</view>
	</uni-popup>
</template>

<script>
	import { openNavigation } from '../../common/openmap';

	export default {
		name: 'UniPopupShare',
		emits: ['select'],
		props: {
			title: {
				type: String,
				default: ""
			},
			point: {
				longitude: "",
				latitude: "",
				name: "",
			}
		},
		data() {
			return {
				bottomData: [{
						id: 1,
						text: '高德地图',
						icon: '/static/logo/map_gaode.png',
					},
					{
						id: 2,
						text: '百度地图',
						icon: '/static/logo/map_baidu.png',
					},
					{
						id: 3,
						text: '腾讯地图',
						icon: '/static/logo/map_tengxun.png',
					},
				]
			}
		},
		created() {},
		computed: {
			cancelText() {
				return "取消"
			},
			shareTitleText() {
				return this.title || "请选择"
			}
		},
		methods: {
			popupOpen() {
				this.$refs.popup.open()
			},
			popupClose() {
				this.$refs.popup.close()
				// this.$emit('popup-close');
			},
			/**
			 * 选择内容
			 */
			select(item, index) {
				// this.$emit('select', {
				// 	item,
				// 	index
				// })
				
				openNavigation(item.id, this.point.longitude, this.point.latitude, this.point.name);
				this.popupClose()
			},
		}
	}
</script>
<style lang="scss">
	.uni-popup-share {
		background-color: #fff;
		border-top-left-radius: 11px;
		border-top-right-radius: 11px;
	}

	.uni-share-title {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: flex-end;
		justify-content: center;
		height: 40px;
	}

	.uni-share-title-text {
		font-size: 14px;
		color: #666;
	}

	.uni-share-content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		// align-items: center;
		padding-top: 10px;
	}

	.uni-share-content-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
		width: 90vw;
	}

	.uni-share-content-item {
		width: 90px;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		padding: 10px 0;
		align-items: center;
	}

	.uni-share-content-item:active {
		background-color: #f5f5f5;
	}

	.uni-share-image {
		width: 50px;
		height: 50px;
		border: 1px solid;
		border-color: darkgray;
		border-radius: 5px
	}

	.uni-share-text {
		margin-top: 10px;
		font-size: 14px;
		color: #3B4144;
	}

	.uni-share-button-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		padding: 10px 25px;
	}

	.uni-share-button {
		flex: 1;
		border-radius: 50px;
		color: #666;
		font-size: 16px;
	}

	.uni-share-button::after {
		border-radius: 50px;
	}
</style>