<template>
	<view class="container">
		<view class="header">
			<view class="now-location">
				<u-icon name="map" size="36" class="icon"></u-icon>
				<text class="text Medium title">{{position.name}}</text>
			</view>
			<view class="selectType">
				<picker @change="bindPickerChange" :value="index" :range="typeList">
					<text class="uni-input header-type">{{typeList[index]}}</text>
				</picker>
			</view>


		</view>
		<view class="uni-common-mt">
			<view class="content">
				<map class="map" @markertap="markertap" :latitude="nowLocation.latitude"
					:longitude="nowLocation.longitude" :markers="covers" :enable-poi="true">
				</map>
			</view>
		</view>
		<view class="content2">
			<view class="no-enterprise Regular" v-if="enterpriseList.length!=0">
				附近暂无相关企业
			</view>
			<view class="warp">
				<view class="line-style"  @click="lineClick">
					<text class="top-line"></text>
				</view>
				<scroll-view :scroll-top="scrollTop" :scroll-y="isscroll" @scrolltoupper="upper" @scrolltolower="lower"
					@scroll="scroll" :class="{'active':isActive}" class="scroll-style">
					<view class="bottom-list-item">
						<img class="left-img" src="/static/location.png" alt="">
						<view class="middle">
							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
						</view>
						<text class="line"></text>
						<view class="right">
							<img class="right-img" src="/static/location.png" alt="">
							<text class="right-bottom Regular">500m</text>
						</view>
					</view>
					<view class="bottom-list-item">
						<img class="left-img" src="/static/location.png" alt="">
						<view class="middle">
							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
						</view>
						<text class="line"></text>
						<view class="right">
							<img class="right-img" src="/static/location.png" alt="">
							<text class="right-bottom Regular">500m</text>
						</view>
					</view>
					<view class="bottom-list-item">
						<img class="left-img" src="/static/location.png" alt="">
						<view class="middle">
							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
						</view>
						<text class="line"></text>
						<view class="right">
							<img class="right-img" src="/static/location.png" alt="">
							<text class="right-bottom Regular">500m</text>
						</view>
					</view>
					<view class="bottom-list-item">
						<img class="left-img" src="/static/location.png" alt="">
						<view class="middle">
							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
						</view>
						<text class="line"></text>
						<view class="right">
							<img class="right-img" src="/static/location.png" alt="">
							<text class="right-bottom Regular">500m</text>
						</view>
					</view>
					<view class="bottom-list-item">
						<img class="left-img" src="/static/location.png" alt="">
						<view class="middle">
							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
						</view>
						<text class="line"></text>
						<view class="right">
							<img class="right-img" src="/static/location.png" alt="">
							<text class="right-bottom Regular">500m</text>
						</view>
					</view>
					<view class="bottom-list-item">
						<img class="left-img" src="/static/location.png" alt="">
						<view class="middle">
							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
						</view>
						<text class="line"></text>
						<view class="right">
							<img class="right-img" src="/static/location.png" alt="">
							<text class="right-bottom Regular">500m</text>
						</view>
					</view>
					<view class="bottom-list-item">
						<img class="left-img" src="/static/location.png" alt="">
						<view class="middle">
							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
						</view>
						<text class="line"></text>
						<view class="right">
							<img class="right-img" src="/static/location.png" alt="">
							<text class="right-bottom Regular">500m</text>
						</view>
					</view>
					<view class="bottom-list-item">
						<img class="left-img" src="/static/location.png" alt="">
						<view class="middle">
							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
						</view>
						<text class="line"></text>
						<view class="right">
							<img class="right-img" src="/static/location.png" alt="">
							<text class="right-bottom Regular">500m</text>
						</view>
					</view>
					<view class="bottom-list-item">
						<img class="left-img" src="/static/location.png" alt="">
						<view class="middle">
							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
						</view>
						<text class="line"></text>
						<view class="right">
							<img class="right-img" src="/static/location.png" alt="">
							<text class="right-bottom Regular">500m</text>
						</view>
					</view>
					<view class="bottom-list-item">
						<img class="left-img" src="/static/location.png" alt="">
						<view class="middle">
							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
						</view>
						<text class="line"></text>
						<view class="right">
							<img class="right-img" src="/static/location.png" alt="">
							<text class="right-bottom Regular">500m</text>
						</view>
					</view>
				</scroll-view>

			</view>

		</view>

	</view>
</template>
<script>
	// import amap from '@/js_sdk/js-amap/amap-wx.130.js'
	export default {
		data() {
			return {
				isscroll: true,
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				"isActive": false,
				position: {},
				nowLocation: {
					latitude: 39.9085,
					longitude: 116.39747,
				},
				showType: false,
				enterpriseList: [],
				// typeStr: '全部类型',
				index: 0,
				typeList: ['全部类型', '粮仓', '加工厂'],
				title: 'map',
				covers: [{
					id: 0,
					latitude: 39.9085,
					longitude: 116.39747,
					iconPath: '../../../static/img/location.png',
				}]
			}
		},
		onShow() {

		},
		onLoad(e) {
			if(e.position){
				this.position =  JSON.parse(e.position)
				console.log("地点",this.position)
				this.nowLocation.latitude = this.position.location.split(',')[1]
				this.nowLocation.longitude = this.position.location.split(',')[0]
			}
			//获取标记点
			this.getMarkers()
		},
		methods: {
			getMarkers(){
				//点击列表标记改变颜色，显示气泡提示
				// this.$api.doRequest('get', '/settledCompanyInfo/selectSettledCompanyInfo', {
				// 	pageSize: this.pageSize,
				// 	currentPage: this.currentPage,
				// }).then(res => {
				// 	if (res.data.code == 200) {
				// 		this.datalist = res.data.data.records
				// 	}
				// })
			},
			lineClick(){
				this.isActive= !this.isActive
				// this.isscroll = !this.isscroll
			},
			upper: function(e) {
				console.log(e)
			},
			lower: function(e) {
				console.log(e)
			},
			scroll: function(e) {
				console.log(e)
				this.old.scrollTop = e.detail.scrollTop
			},
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.target)
				this.index = e.detail.value
			},
			confirm() {
				console.log('确定')
				this.showType = false
			},
			cancel() {
				console.log('取消')
				this.showType = false
			},
			selectType() {
				this.showType = true
				console.log(1)
			},
			// typeConfirm(e) {
			// 	console.log(e)
			// 	this.typeStr = this.typeList[e[0]].name

			// },
			getLocation() {
				let that = this;
				// uni.getLocation({
				// 	type: 'gcj02',
				// 	geocode: true,
				// 	success: function(res) {
				// 		that.nowLocation.longitude = res.longitude
				// 		that.nowLocation.latitude = res.latitude
				// 		that.covers[0].longitude = res.longitude
				// 		that.covers[0].latitude = res.latitude
				// 		let _coverrsData = []
				// 		for (let i = 0; i < 50; i++) {
				// 			let _obj = {
				// 				id: i,
				// 				latitude: res.latitude += 0.00150,
				// 				longitude: res.longitude + 0.00150,
				// 				iconPath: '../../../static/img/location.png',
				// 				width: 30,
				// 				height: 30,
				// 				callout: {
				// 					content: '中天昊元粮库',
				// 					color: '#333333',
				// 					fontSize: 12,
				// 					borderRadius: 20,
				// 					padding: 4,
				// 					bgColor: 'white',
				// 					display: 'ALWAYS',
				// 				},
				// 			}
				// 			_coverrsData.push(_obj)
				// 		}
				// 		that.covers = _coverrsData
				// 		console.log('获取位置数据：', res);
				// 		console.log('当前位置的经度：' + res.longitude);
				// 		console.log('当前位置的纬度：' + res.latitude);
				// 		//拼接当前定位回显地址

				// 		// #ifdef APP-PLUS
				// 		let _address = res.address
				// 		that.address = _address.province + _address.city + _address.district + _address.poiName
				// 		console.log(that.address)
				// 		// #endif
				// 	}
				// });
			},
			markertap(e) {
				console.log(e)
				uni.showToast({
					title: "点击id为" + e.detail.markerId + "的坐标",
					icon: 'none',
					duration: 2000
				})
			},
			getLst() {
				console.log("加载数据")
			}

		}
	}
</script>
<style scoped>
	.active {
		height: 583rpx!important;
	}

	.header {
		flex-direction: row;
		justify-content: space-between;
		margin-bottom: 20rpx;
		padding: 20rpx;
	}

	.title {
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.content {
		width: 750px;
		flex: 1;
	}

	.map {
		height: 1350rpx;
	}

	.content2 {
		position: fixed;
		bottom: 0;
		width: 750rpx;
		flex: 1;
		font-size: 34rpx;
		background: white;
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
	}

	.warp {
		/* 		flex-direction: row;
		justify-content: center; */
	}

	.header-type {
		font-size: 26rpx;
		font-weight: 400;
		color: #333333;
	}

	.alert {
		flex: 1;
	}

	.select-alert {
		background-color: green;
		position: fixed;
		bottom: 0;
		width: 750rpx;
		flex: 1;
	}

	.select-top {
		flex-direction: row;
		align-items: center;
		justify-content: space-around;
		background: yellow;
		height: 80rpx;
	}


	.select {
		width: 750rpx;
		flex: 1;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		background: white;
	}

	.cancel {
		font-size: 24rpx;
		color: white;
		font-weight: bold;
	}

	.confirm {
		font-size: 24rpx;
		color: green;
		font-weight: bold;
	}

	.select-item {
		font-size: 24rpx;
	}

	.warp {}

	.bottom-list-item {
		flex-direction: row;
		justify-content: space-between;
		margin-bottom: 20rpx;
		padding-bottom: 20rpx;
		margin-top: 20rpx;
		border-bottom: 1px solid #EEEEEE;
	}

	.left {}

	.left-img {
		width: 102rpx;
		height: 106rpx;
	}

	.localtion {
		font-size: 24rpx;
		font-weight: 400;
		color: #AFB3BF;
	}

	.localtion {

		flex-direction: column;
	}

	.right-img {
		width: 21rpx;
		height: 26rpx;
		background: #AFB3BF;
	}

	.right {
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.middle {
		flex-direction: column;
		justify-content: center;
	}

	.warp {
		padding: 20rpx;
	}

	.right-bottom {
		font-size: 24rpx;
		font-weight: 400;
		color: #AFB3BF;
	}

	.top-line {
		width: 68px;
		height: 8px;
		background: #B4B7C3;
		border-radius: 4px;
		flex-direction: row;
		margin-bottom: 30rpx;
	}

	.line-style {
		flex-direction: row;
		justify-content: center;
	}

	.scroll-style {
		height: 130rpx;
	}
</style>
