<template>
	<view class="page">
		<pyh-nv ref="nv" :config="nvConfig"></pyh-nv>
		<view class="listBox" :style="{'padding-top':(pageTop+'px')}">
			<view class="content">

				<view class="topimg">
					<map style="width: 100%;" :min-scale="9" id="customMap" :scale="15" :markers="markers"
						layer-style="1" subkey="PTOBZ-QDQEG-DK3QM-QMYWN-I5WDZ-CCB6S" :latitude="address.latitude"
						:longitude="address.longitude">
					</map>
				</view>

				<view class="message-list">
					<view class="titleall-box">
						<view class="titleall-left">
							<view class="titleall-left-line"></view>基本信息
						</view>
					</view>
					<view class="info-box">
						<view class="info-box-list">
							<view class="info-box-width">
								<view>{{info.markerNumber}}</view>
								<view class="info-box-small">界桩编号</view>
							</view>
							<view class="info-box-width">
								<view>北纬{{info.latitude}}，东经{{info.longitude}}</view>
								<view class="info-box-small">经纬度</view>
							</view>
						</view>
						<view class="info-box-list">
							<view class="info-box-width">
								<view>{{info.elevation?info.elevation:'-'}}</view>
								<view class="info-box-small">高程</view>
							</view>
							<view class="info-box-width">
								<view>{{info.location}}</view>
								<view class="info-box-small">位置</view>
							</view>
						</view>
						<view class="info-box-list">
							<view class="info-box-width">
								<view>{{info.markerType}}</view>
								<view class="info-box-small">类型</view>
							</view>
							<view class="info-box-width">
								<view>{{info.unit?info.unit:'-'}}</view>
								<view class="info-box-small">材质</view>
							</view>
						</view>
						<view class="info-box-list">
							<view class="info-box-width">
								<view>{{info.enteredTime?info.enteredTime:'-'}}</view>
								<view class="info-box-small">设立时间</view>
							</view>
							<view class="info-box-width">
								<view>{{info.updatedTime?info.updatedTime:'-'}}</view>
								<view class="info-box-small">最近更新时间</view>
							</view>
						</view>
						<view class="info-box-list" v-if="info.imageInfo">
							<view class="info-box-width">
								<view class="info-box-small">现场照片</view>
								<view class="info-box-list-img">
									<image :src="BASE_URL+info.imageInfo"></image>
								</view>
							</view>
						</view>
					</view>
				</view>

<!-- 				<view class="message-list">
					<view class="titleall-box">
						<view class="titleall-left">
							<view class="titleall-left-line"></view>区划变更
						</view>
					</view>
					<view class="info-box">
						<view class="info-box-list">
							<view class="info-box-width">
								<view>无</view>
								<view class="info-box-small">上次变更时间</view>
							</view>
							<view class="info-box-width">
								<view>无</view>
								<view class="info-box-small">变更区域</view>
							</view>
						</view>
					</view>
				</view> -->

				<view class="message-list" v-if="info1.userId">
					<view class="titleall-box">
						<view class="titleall-left">
							<view class="titleall-left-line"></view>维护巡检情况
						</view>
					</view>
					<view class="info-box">
						<view class="info-box-list">
							<view class="info-box-width">
								<view>{{info1.userId}}</view>
								<view class="info-box-small">上次巡检人</view>
							</view>
							<view class="info-box-width">
								<view>{{info1.patrolTime}}</view>
								<view class="info-box-small">巡检时间</view>
							</view>
						</view>
						<view class="info-box-list">
							<view class="info-box-width">
								<view class="green">{{info1.patrolStatus}}</view>
								<view class="info-box-small">界桩情况</view>
							</view>
						</view>
						<view class="info-box-list" v-if="info1.patrolImage">
							<view class="info-box-width">
								<view class="info-box-small">巡检照片</view>
								<view class="info-box-list-img">
									<image :src="BASE_URL+info1.patrolImage"></image>
								</view>
							</view>
						</view>
						<view class="info-box-list">
							<view class="info-box-width width100">
								<view class="info-box-small">巡检情况说明</view>
								<view class="info-box-list-sm">
									{{info1.patrolContent}}
								</view>
							</view>
						</view>

					</view>
					
				</view>

<!-- 				<view class="skip-btn">
					<view class="cart-add">
						<image src="../../static/btn3.png"></image>
						<text>资料修改</text>
					</view>
					<view class="buy-at">
						<image src="../../static/btn1.png"></image>
						<text>界桩巡检情况上报</text>
					</view>
				</view> -->

			</view>
		</view>
	</view>
</template>

<script>
	import BASE_URL from "@/common/config.js"
	export default {
		data() {
			return {
				BASE_URL,
				info: {},
				info1:{},
				nvConfig: {
					title: "HC52454【单立桩】",
					bgColor: "#ffffff",
					color: "#000000",
					fixedAssist: {
						hide: true,
					},
				},
				markers: [],
				address: {
					// 纬度
					latitude: 29.99599,
					// 经度
					longitude: 104.13412
				},
				pages:{
					pageNum:1,
					pageSize:10,
					pileId:null
				}
			};
		},
		onPageScroll(e) {
			this.$refs.nv.pageScroll(e)
		},
		computed: {
			pageTop() {
				return parseInt(88 * uni.getSystemInfoSync().windowWidth / 750) + uni.getSystemInfoSync().statusBarHeight
			}
		},
		onLoad(params) {
			this.info = JSON.parse(params.cent)
			this.nvConfig.title = this.info.markerNumber
			console.log(this.info);
			this.address.latitude = this.info.latitude
			this.address.longitude = this.info.longitude
			this.pages.pileId = this.info.markerNumber
			this.getlist()
			this.addMarkers([this.info])
		
		},
		methods: {
			getlist() {
				this.API.getpatrol(this.pages).then(res=>{
					console.log("巡检",res);
					if(res.rows.length >0) {
						this.info1 = res.rows[res.rows.length-1]
					}
					console.log("this.info1",this.info1);
				
				})
			},
			addMarkers(list) {
				const positions = []
				list.forEach((item, index) => {

					positions.push({
						latitude: item.latitude,
						longitude: item.longitude,
						title: item.markerNumber,
					})
				})
				const newMarkers = []
				positions.forEach((p, i) => {
					// console.log(i)
					newMarkers.push(
						Object.assign({}, {
							id: i,

							joinCluster: false, // 指定了该参数才会参与聚合  
							label: {
								padding: 10,
								height: 30,
								borderRadius: 10,
								bgColor: '#0098ae',
								color: '#fff',
								content: `${p.title}`
							}
						}, p)
					)
				})
				this.markers = newMarkers
				const markers = newMarkers
				this._mapContext.addMarkers({
					markers,
					clear: false,
					complete(res) {
						console.log('addMarkers', res)
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	@import 'mapstakelinedetail.scss';
</style>