<template>
	<view class="content">
		<view id="map" class="map">
			<map @updated='mapChange' id="map_1" ref='map_1' style="width:750rpx; height: 600rpx" :latitude="latitude"
			 :longitude="longitude" ></map>
		</view>
	</view>
</template>

<script>
	import {
		getcomAddress
		// getdis,
		// tocall
	} from '@/api/index.js';
	export default{
		data() {
			return{
				// longitude:'',
				// latitude:'',
				// longitude:39.909,
				// latitude: 116.39742,
			}
		},
		onLoad() {
			// window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`
			// window.location.href = `https://apis.map.qq.com/ws/geocoder/v1/?location=39.984154,116.307490&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&get_poi=1`
			window.location.href = `https://apis.map.qq.com/tools/locpicker?search=1&type=0&backurl=http://3gimg.qq.com/lightmap/components/locationPicker2/back.html&key=yourkey&referer=myapp`
			console.log(window.location.href)
			
				// let obj = this;
				// console.log('开始加载事件');
				// uni.showLoading({
				// 	title: '加载中',
				// 	mask: true
				// });
				// try {
				// 	let locationAddress
				// 	// #ifdef H5
				// 	let wxOjb = require('jweixin-module');
				// 	locationAddress = wxOjb.getLocation;
				// 	// #endif
				// 	// #ifdef MP
				// 	locationAddress = uni.getLocation;
				// 	// #endif
				// 	wxOjb.ready(()=>{
				// 		console.log('加载完毕注册事件');
				// 		locationAddress({
				// 			type: 'gcj02',
				// 			success: function(res) {
				// 				console.log('获取经纬度', res);
				// 				obj.longitude = res.longitude
				// 				obj.latitude = res.latitude
				// 				obj.loadData();
				// 			},
				// 			fail(e) {
				// 				console.log('失败', e);
				// 				window.location.reload();
				// 			}
				// 		});
				// 	})
					
				// } catch (e) {
				// 	console.log(e);
				// 	let locationAddress
				// 	// #ifdef H5
				// 	let  wxOjb = require('jweixin-module');
				// 	locationAddress = wxOjb.getLocation;
				// 	// #endif
				// 	// #ifdef MP
				// 	locationAddress = uni.getLocation;
				// 	// #endif
				// 	wxOjb.ready(()=>{
				// 		console.log('加载完毕注册事件');
						
				// 		locationAddress({
				// 			type: 'gcj02',
				// 			success: function(res) {
				// 				uni.showModal({
				// 					title:'获取经纬度',
				// 					content: JSON.stringify(res)
				// 				})
				// 				console.log('获取经纬度', res);
				// 				obj.longitude = res.longitude
				// 				obj.latitude = res.latitude
				// 				obj.loadData();
				// 			},
				// 			fail(e) {
				// 				console.log('失败', e);
				// 			}
				// 		});
				// 	})
					
				// }
			this.loadData()
		},
		methods:{
			// 地图渲染完毕事件
			mapChange(e) {
				console.log(e);
			},
			async loadData() {
				let obj = this;
				//  get_commonly
				console.log('进入loadData')
				getcomAddress({
					longitude:39.909,
					latitude: 116.39742,
					common_address:'首都'
				}).then((res) => {
					console.log(res)
					console.log('进入getcomAddress的成功')
					let data = res.data;
					uni.hideLoading();
					console.log('请求数据', data);
					// data = data.map(d => {
					// 	return {
					// 		...d,
					// 		iscall: true
					// 	}
					// })
					// obj.list = data;
				}).catch(err => {
					console.log('进入getcomAddress的失败')
					console.log(err);
					uni.hideLoading();
					uni.showModal({
						title: '失败',
						content: JSON.stringify()
					});
				});
			},
		}
	}
</script>

<style>
</style>