<template>
	<!--<h1>{{ msg }}</h1>-->
	<!--<button @click="count++">count is: {{ count }}</button>-->
	<!--<p>Edit <code>components/HelloWorld.vue</code> to test hot module replacement.</p>-->
	<!--cookies : {{ testcookies()}}-->
	<!--    获取到的下拉选的值到父页面：{{selectValue}}-->
	<!--<deptSelector ref="abc"  @wangzhe="getHelloWorldSelectValue" :setValue="getHelloWorldSelectValue"></deptSelector>-->
	<deptSelector :setValue="getHelloWorldSelectValue"></deptSelector>
	<el-button @click="setMarkers">加载点</el-button>
	<el-button @click="setMarkersRadius">加载带范围点</el-button>
	<el-button @click="setConnectList">加载连线</el-button>
	<el-button @click="setGraphicsList">加载图形</el-button>
	<el-button @click="clearM">清除点</el-button>
	<el-button @click="clearC">清除连线</el-button>
	<el-button @click="clearG">清除图形</el-button>
	<supermaper ref="supermap" @MarkersClick="alertBind" :codes="['9fa5']" :mapSite="{}" :isSideBySide="false"
		:showLatLng="showLatLng" style="width: 100%;height: 500px; border:2px solid #ff0000 ;"></supermaper>
	<!--  {maxZoom:18,zoom: 8,editable:true,zoomControl:false}-->

</template>

<script>
	// import {getToken, setToken} from '../plugins/auth'
	// import {testReq} from '../api/hellotest/test'
	import deptSelector from "@/components/deptselector";
	import supermaper from "./supermap"



	export default {
		name: 'HelloWorld',
		data() {
			return {
				// cookieage: 0,
				// count: 0,
				selectValue: '',
				markersList: [{
						lng: 125.29,
						lat: 43.19,
						icon: 'camera',
						bindPopupHtml: "测试111",
						click: "MarkersClick"
					},
					{
						lng: 125.22,
						lat: 43.13,
						icon: 'camera',
						bindPopupHtml: "测试222",
						click: "MarkersClick"
					},
					{
						lng: 125.19,
						lat: 43.29,
						icon: 'camera',
						bindPopupHtml: "",
						click: ""
					},
					{
						lng: 125.14,
						lat: 43.22,
						icon: 'camera',
						bindPopupHtml: "",
						click: ""
					},
				],
				markersRadiusList: [{
						lng: 125.39,
						lat: 43.29,
						icon: 'camera',
						radius: 1,
						bindPopupHtml: "测试111",
						click: "MarkersClick"
					},
					{
						lng: 125.32,
						lat: 43.23,
						icon: 'camera',
						radius: 1,
						bindPopupHtml: "测试222",
						click: "MarkersClick"
					},
					{
						lng: 125.29,
						lat: 43.39,
						icon: 'camera',
						radius: 1.5,
						bindPopupHtml: "",
						click: ""
					},
					{
						lng: 125.24,
						lat: 43.32,
						icon: 'camera',
						radius: 1,
						bindPopupHtml: "",
						click: ""
					},
				],
				connectList: [{
						lat: 43.22,
						lng: 125.33
					},
					{
						lat: 43.23,
						lng: 125.22
					},
					{
						lat: 43.34,
						lng: 125.23
					},
					{
						lat: 43.22,
						lng: 125.24
					},
				],
				graphicsList: [{
						lat: 43.22,
						lng: 125.33
					},
					{
						lat: 43.22,
						lng: 125.24
					},
					{
						lat: 43.23,
						lng: 125.22
					},
					{
						lat: 43.34,
						lng: 125.23
					},
				],
			}
		},
		mounted() {
			// let arr = [{lng:"123",lat:"456"},{lng:"abc",lat:"xyz"}]
			// console.log(arr)
			//http://36.97.65.105:9090/etcc/app/main/mainPage?username=JJ099
			// this.testcookies()
			// removeToken()
			// testReq({username:"JJ099"}).then(resp =>{
			//     console.log(resp);
			// })
		},
		components: {
			deptSelector,
			supermaper
		},
		methods: {

			getHelloWorldSelectValue: function(e) {
				this.selectValue = e
				// this.$refs.abc.xxxxxx()
			},

			// testcookies: function () {
			//     setToken("eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxMDAsInVzZXJfa2V5IjoiZWQxM2I0YjItZWQ3ZS00ZGJmLTkyODUtMGZhNTQwMTc2ODM2IiwidXNlcm5hbWUiOiJzdW55aXNoaSJ9.a7ymc9M2fY-2304FpLxj7ZHZ1bZk6LDJM_DOYa9LhQyncPQ9c7-VSeThWhTr3vNMBcyvbFMz5e3egsvAIIkalA");
			//     return getToken()
			// },
			getSelectValue(value) {
				this.selectValue = value;
			},
			setMarkers() {
				this.$refs.supermap.clearM();
				this.$refs.supermap.setMarkers(this.JSON(this.markersList));
			},
			setMarkersRadius() {
				this.$refs.supermap.clearM();
				this.$refs.supermap.setMarkersRadius(this.JSON(this.markersRadiusList));
			},
			setConnectList() {
				this.$refs.supermap.clearC();
				this.$refs.supermap.setConnectList(this.JSON(this.connectList), '#fe0000');
			},
			setGraphicsList() {
				this.$refs.supermap.clearG();
				this.$refs.supermap.setGraphicsList(this.JSON(this.graphicsList), '#fe0000');
			},
			clearM() {
				this.$refs.supermap.clearM();
			},
			clearC() {
				this.$refs.supermap.clearC();
			},
			clearG() {
				this.$refs.supermap.clearG();
			},
			alertBind(aaa) {
				alert(aaa);
			},
			showLatLng(lat, lng) {
				alert(lat);
				alert(lng);
			}
		},

		// props: {
		//     msg: String
		// },
	}
</script>
