<template>
	<view class="app">

		<view class="nursetation" @tap='detailed()'>
			<text class="what">什么是护理站？</text>
			<u-icon class="icon" name="arrow-right"></u-icon>
		</view>
		<view class="map">
			<map style="width:100%; height:40vh;" scale="17" :latitude="latitude" :longitude="longitude"
				:markers="markers"></map>
		</view>


		<view class="conNew">
			<view class="addressContent" v-for="(item,index) in nursestationlist" :key="index">
				<view class="lists">
					<view class="nurse">{{item.nurseStationName}}</view>
					<view class="distance">距离您{{item.distance}}米</view>
					<view class="background">
						<image src="/static/logo.png" mode=""></image>
						<text class="qyttext">泉医通</text>
						<text class="lianmeng">济卫护理联盟NO.1</text>
					</view>
					<view class="understand" @tap='godetails(item)'>
						点击了解
					</view>
				</view>
			</view>
		</view>

		<view class="masks" style="" v-if="mask">
			<view class="mask">
				<view class="picture">
					<image src="../../static/locatinsmall.png"></image>
				</view>

				<view class="text">
					请打开系统定位
				</view>
				<view class="btns">
					<view class="bt" @tap='cancel()'>取消</view>
					<view class="btn" @tap='getsite()'>确定</view>
				</view>

			</view>
		</view>
	</view>
</template>
<script>
	import {
		nearbyList
	} from '@/api/site/site.js';
	import baseurl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				nursestationlist: [],
				mask: true,
				pageNum: 1,
				pageSize: 10,
				//map地图所需
				id: 0, // 使用 marker点击事件 需要填写id
				latitude: 39.909,
				longitude: 116.39742,
				markers: [],
				covers: []
			}
		},
		onReachBottom() {
			this.pageNum++;
			if (this.nurseTypeCode != undefined) {
				nearbyList(this.pageSize, this.pageNum, this.longitude, this.latitude, this.nurseTypeCode, this.iptVal)
					.then(res => {
						if (res.total == this.nursestationlist.length) {

						} else {
							res.rows.forEach(e => {
								this.nursestationlist.push(e)
							})
						}
					})
			} else {
				uni.request({
					url: baseurl +
						`/nurseApplet/nearbyNursingStation/nearbyList?pageSize=${this.pageSize}&pageNum=${this.pageNum}&homeLongitude=${this.longitude}&homeLatitude=${this.latitude}&nurseStationName=${this.iptVal}`, //仅为示例，并非真实接口地址。
					success: (res) => {
						if (res.data.total == this.nursestationlist.length) {} else {
							res.data.rows.forEach(e => {
								this.nursestationlist.push(e)
							})
						}
						console.log(this.nearbylist)
					}
				});
			}
		},
		watch: {
			iptVal() {
				// this.requestinfo()
			},
		},
		onShow() {},
		onLoad() {
			var that = this
			this.requestinfo()
		},
		methods: {
			requestinfo() {
				nearbyList(this.pageSize, this.pageNum, this.longitude, this.latitude, this.nurseTypeCode, ).then(res => {
					this.nursestationlist = res.rows
					// console.log(this.nursestationlist)
				})
			},
			godetails(item) {
				console.log(item)
				uni.navigateTo({
					url: `/pages/nursestation/nursestation?nurseStationId=${item.nurseStationId}`
				})
			},
			detailed() {
				uni.navigateTo({
					url: `/pages/detail/detail`
				})
			},
			cancel() {
				this.mask = false
			},
		},
	}
</script>

<style lang="scss">
@import './site.scss'
</style>
