<template>
	<view class="pages">

		<view class="top">

			<view class="top-item">
				<view class="top-item-drop"></view>
				<view class="top-item-text">
					<text class="top-item-text1">仓库名称：</text>
					<text class="top-item-text2">{{info.warehouseName}}</text>
				</view>
			</view>

			<view class="top-item" style="margin-top: 20px;">
				<view class="top-item-drop"></view>
				<view class="top-item-text">
					<text class="top-item-text1">异常时间：</text>
					<text class="top-item-text2">{{info.exceptionTime}}</text>
				</view>

			</view>

			<view class="top-item" style="margin-top: 20px;">

				<view class="top-item-bom">
					<text class="top-item-bom-text1" @click="textClick('1')">库房详情</text>
					<text class="top-item-bom-text2" @click="textClick('2')">工作派单</text>
				</view>


			</view>

		</view>

		<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
			@scrolltolower="lower" @scroll="scroll">

			<view style="padding-bottom: 50px;">

				<view v-for="(item,index) in info.linkers" class="newslist">


					<view class="item" :class="{'item2':index+1== info.linkers.length}">
						<view class="item-lift">
							<text class="item-lift-text">联系人：{{item.name}}</text>
							<text class="item-lift-text">联系电话：{{item.mobile}}</text>
						</view>

						<image class="item-img" src="https://supervise.yxtsoft.com/img/base/lxkf.png"
							@click="makeCall(item.mobile)"></image>

					</view>

				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				info: {
					warehouseSid: "",
					warehouseName: "",
					exceptionTime: "",
					linkers: [],
				}
			}
		},
		onLoad(option) {
			console.log("option", option)

			console.log("info", option.info)
			console.log("info22", JSON.parse(option.info))

			var data = JSON.parse(option.info)

			this.info = {

				warehouseSid: data.warehouseSid,
				warehouseName: data.warehouseName,
				exceptionTime: data.exceptionTime,
				linkers: data.linkers,
			}
		},
		methods: {
			// 禁止滑动
			preventHandler() {
				return
			},
			upper: function(e) {
				console.log(e)
			},
			lower: function(e) {
				console.log(e)
			},
			scroll: function(e) {
				console.log(e)
				this.old.scrollTop = e.detail.scrollTop
			},
			textClick(index) {
				switch (index) {
					case "1":
						// 库房详情
						uni.navigateTo({
								url: 'WarehouseDetaile?sid='+this.info.warehouseSid
						});
						break;
					case "2":
						// 工作派单
						uni.showToast({
							icon: "none",
							title: '工作派单',
							duration: 2000,
						});
						// uni.navigateTo({
						// 	url: '../index/ReadWork'
						// });
						break;
					default:
						break;
				}
			},
			makeCall(mobile) {
				wx.makePhoneCall({
					//仅为示例，并非真实的电话号码
					phoneNumber: mobile
				})
			}
		}
	}
</script>

<style lang="scss">
	.pages {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		position: fixed;
		overflow: auto;

		.top {
			display: flex;
			flex-direction: column;
			padding: 15px 20px;

			.top-item {
				display: flex;
				flex-direction: row;
				align-items: center;

				.top-item-drop {
					background: #1684FC;
					border-radius: 50%;
					width: 8px;
					height: 8px;
				}

				.top-item-text {
					margin-left: 10px;
					display: flex;
					flex-direction: row;
					align-items: center;

					.top-item-text1 {
						font-size: 15px;
						color: #666;
					}

					.top-item-text2 {
						font-size: 18px;
						color: #000;
						font-weight: 600;
						font-family: sans-serif;
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp: 1;
						-webkit-box-orient: vertical;
					}
				}

				.top-item-bom {
					display: flex;
					flex-direction: row;
					width: 100%;
					margin-left: 30px;
					margin-right: 30px;
					justify-content: space-between;

					.top-item-bom-text1 {
						padding: 5px 20px;
						color: #2F96E1;
						font-size: 14px;
						border: 1px solid #2F96E1;
						border-radius: 5px;

					}

					.top-item-bom-text2 {
						padding: 5px 20px;
						color: #fff;
						font-size: 14px;
						background: #2F96E1;
						border-radius: 5px;
					}
				}

			}
		}

		.scroll-Y {
			overflow-y: hidden;
			height: 90vh;
			background: #fff;

			.newslist {
				margin-top: 10px;
				display: flex;
				flex-direction: column;
				padding-left: 10px;
				padding-right: 10px;

				.item {
					display: flex;
					flex-direction: row;
					border-bottom: 1px solid #eee;
					padding: 10px;
					align-items: center;

					.item-lift {
						flex: 1;
						display: flex;
						flex-direction: column;

						.item-lift-text {
							margin-top: 10px;
							font-size: 14px;
							color: #777777;
						}
					}

					.item-img {
						margin-left: 20px;
						width: 35px;
						height: 35px;
					}
				}

				.item2 {
					display: flex;
					flex-direction: row;
					padding: 10px;
					align-items: center;
					border-bottom: none;
				}
			}
		}

	}
</style>