<template>
	<view class="first_main" :style="{height: screenHeight + 'px'}">
		<nav-bar title='工具共享'></nav-bar>
		
		<view class="content">
			<view class="list_scoll" id="paging_id" :style="{height: scrollH + 'px'}">
				<view class="item_row" >
					<view class="item_row_top">
						<view class="top_name">
							<view>工具柜存放位置</view>
						</view>
					</view>
					<view class="item_row_bottom">
						<view 
							v-for="(item,index) in listData" 
							:key="index" 
							:class="listData.length % 2 === 0?'adres_item':index + 1 == listData.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">{{item.sharingAddress}}</view>
							</view>
							<view class="adres_item_bom line-1">{{item.storageLocation}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {callbackRequest} from '@/common/util.js';
	import {toolShareList} 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:toolShareList,
					sharingAddress: '',
					isDeleted: '0',
					currentPage: 1,
					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">
	.content {
		height: calc(100% - 100rpx);
		width: 100%;
		background-image: url('@/static/firstaid/share.png');
		background-size: 100% 386rpx;
		background-repeat: no-repeat;
	}
	.content::-webkit-scrollbar {
		width: 0;
		height: 0;
	}
	
.line-1 {
	white-space: nowrap;      /* 保证文本不会换行 */
	overflow: hidden;         /* 超出容器部分隐藏 */
	text-overflow: ellipsis;  /* 超出部分显示为省略号 */
}
.first_main {
	width: 100vw;
	// background-image: url('@/static/firstaid/share.png');
	// background-size: 100% 386rpx;
	//  background-repeat: no-repeat;
	 background-color: #F2F6FA;
	 padding-top: 100rpx;
}

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

.list_scoll::-webkit-scrollbar {
	width: 0;
	height: 0;
}

.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 {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #4B5B68;
				text-align: left;
				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>
