<template>
	<view class="first_main" :style="{height: screenHeight + 'px'}">
		<nav-bar title='急救设备' :backGround="false"></nav-bar>
		
		<view class="content">
			<view class="list_scoll" id="paging_id" :style="{height: scrollH + 'px'}">
				<view class="item_row" v-for="(item,index) in listData" :key="index">
					<view class="item_row_top">
						<view class="top_name">
							<view>{{item.equipmentName}}</view>
							<view class="address">存放位置：</view>
						</view>
						<view class="top_image">
							<image class="image_nav" :src="item.equipmentImageUrl"></image>
						</view>
					</view>
					<view class="item_row_bottom">
						<view v-for="(citem,cindex) in item.locationDetails" :key="cindex"
							:class="item.locationDetails.length % 2 === 0?'adres_item':cindex + 1 == item.locationDetails.length?'adres_item_ji':'adres_item'">
							<view class="adres_item_top">
								<view class="icon_img">
									<image style="width: 100%;height: 100%;" src="@/static/firstaid/location.png"></image>
								</view>
								<view class="line-1 adres_tle">{{citem.location}}</view>
							</view>
							<view class="adres_item_bom line-1">{{citem.detailLocation}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import {
		callbackRequest
	} from '@/common/util.js';
	import {
		deviceList
	} from '@/common/api.js';
	import navBar from "@/components/navBar/index.vue";
	export default {
		components: {
			navBar
		},
		data() {
			return {
				listData: [],
				screenHeight: '',
				scrollH: ''
			}
		},
		onLoad() {
			this.screenHeight = uni.getSystemInfoSync().safeArea.height
			this.getData()
		},
		mounted() {
			const query = uni.createSelectorQuery().in(this);
			query.select("#paging_id").boundingClientRect((data) => {
				this.scrollH = this.screenHeight - data.top
			}).exec();
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			getData() {
				let params = {
					method: deviceList,
					currentPage: 1,
					equipmentName: "",
					equipmentType: "1",
					isDeleted: "0",
					limit: 1000
				}
				callbackRequest(params).then((res) => {
					if (res.returnCode == 1) {
						this.listData = res.returnData.records
					} else {
						uni.showToast({
							title: res.returnMsg,
							icon: 'none'
						});
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.line-1 {
		white-space: nowrap;      /* 保证文本不会换行 */
		overflow: hidden;         /* 超出容器部分隐藏 */
		text-overflow: ellipsis;  /* 超出部分显示为省略号 */
	}
	.first_main {
		width: 100vw;
		background-image: url('@/static/firstaid/devicebj.png');
		background-size: 100% 620rpx;
		background-repeat: no-repeat;
		background-color: #F2F6FA;
	}

	.list_scoll {
		position: fixed;
		top: 420rpx;
		width: 100%;
		padding: 20rpx 48rpx;
		box-sizing: border-box;
		overflow: auto;
	}

	.item_row {
		background-color: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		border: 2rpx solid #FFFFFF;
		padding: 24rpx;
		box-sizing: border-box;
		margin-bottom: 24rpx;

		.item_row_top {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.top_name {
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 36rpx;
				color: #0E1A24;
				text-align: left;
				font-style: normal;
				text-transform: none;

				.address {
					margin-top: 24rpx;
					font-size: 28rpx;
				}
			}

			.top_image {
				width: 148rpx;
				height: 148rpx;

				.image_nav {
					width: 100%;
					height: 100%;
				}
			}
		}

		.item_row_bottom {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			.adres_item {
				margin-top: 24rpx;
				width: 290rpx;
				height: 156rpx;
				background: linear-gradient(135deg, #FFFFFF 0%, #E9FBFA 100%);
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				border: 1rpx solid #00ADA6;
				padding: 24rpx;
				box-sizing: border-box;

				.adres_item_bom {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #4B5B68;
					text-align: left;
					font-style: normal;
					text-transform: none;
					margin-top: 20rpx;
				}
			}

			.adres_item_ji {
				flex: 1;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 24rpx;
				width: 290rpx;
				height: 88rpx;
				background: linear-gradient(135deg, #FFFFFF 0%, #E9FBFA 100%);
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				border: 1rpx solid #00ADA6;
				padding: 24rpx;
				box-sizing: border-box;
				.adres_item_top{
					width: 50% !important;
				}
				.adres_item_bom {
					width: 50%;
					text-align: right;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #4B5B68;
					font-style: normal;
					text-transform: none;
				}
			}
		}
	}

.adres_item_top {
		display: flex;
		align-items: center;
		width: 100%;
		.icon_img {
			height: 28rpx;
			width: 28rpx;
			display: block;
			margin-right: 10rpx;
		}
		.adres_tle {
			flex: 1;
			font-family: PingFang SC,PingFang SC;
			font-weight: bold;
			font-size: 28rpx;
			color: #0E1A24;
			text-align: left;
			font-style: normal;
			text-transform: none;
		}
	}
</style>