<template>
	<view class="app-content">
		<Navs :navname.sync="navname" @fall="fall"></Navs>
		<img :src="icon" alt="" class="tuku">
		<view class="scanning">
			<view class="scanning_cds">
				<input class="input" v-model.trim="currentLuggageNum" disabled="true" @tap="baggageEntry" type="text"
					placeholder-style="font-size:.8125rem;color:rgb(189, 214, 231);display:flex;justify-content: start;"
					placeholder="请输入行李号" />
				<view class="log_l"></view>
				<uni-icons type="clear" size="30" @tap="clear()" color="#fff"></uni-icons>
			</view>
		</view>
		<view class="content">
			<view class="content_bootom" style="top:0">
				<view class="">
					<uni-segmented-control :current="current" :values="items" style-type="text" active-color="#007aff"
						@clickItem="onClickItem" />
				</view>
				<scroll-view scroll-y="true" class="scroll-Y">
					<view class="up" v-for="(item, index) in listdata" :key="index" @tap="toDetail(item.luggageNum)">
						<view class="list">
							<p>{{ item.luggageNum }}</p>
						</view>
						<view class="normal">
							{{item.carrierFlights}}
						</view>
						<view class="normal2">
							{{item.carrierFlightsDate}}
						</view>
						<view :class="item.specialType != 'RUSH'?'error':'normal'">
							{{item.specialType}}</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script>
	import Navs from '../../components/header/navs.vue'
	export default {
		data() {
			return {
				items: ["速运","改签"],
				current:0,
				isShow: true,
				navname: '速运/改签',
				icon: 'static/beijing.png',
				action: true,
				listdata: [],
				exceptionList: [{
						"type": null,
						"name": "无"
					},
					{
						"type": "RUSH",
						"name": "速运"
					},
					{
						"type": "REBOOK",
						"name": "改签"
					}
				],
				airport: null,
				currentLuggageNum: null,
				specialTypeList: {
					"AVIH": "装笼动物",
					"CREW": "机组行李",
					"RFAG": "易碎行李",
					"HVY": "重型行李",
					"PRIO": "优先行李",
					"RUSH": "无人行李",
					"SCON": "急转行李",
					"SPEQ": "运动装备",
					"VIP": "VIP行李",
					"WCHR": "轮椅",
					"WFAP": "武器枪支",
					"SJ05": "到港行李破损",
					"SJ34": "超大柜台接收",
				}
			}
		},
		created(option) {},
		onLoad(option) {
			this.airport = this.$storage.get("airportName")
			// this.getluggageList(this.airport)
		},
		onUnload() {
			uni.$off("scancodemsg");
		},
		onShow() {
			if (this.airport) {
				this.getluggageList(this.airport)
			}
			uni.$on("scancodemsg", (data) => {
				if (data.msg.length > 9) {
					uni.navigateTo({
						url: "/pages/baggagecheck/index?luggageNum=" + data.msg
					})
				}
			});
		},
		onHide() {
			uni.$off("scancodemsg");
		},
		mounted() {},
		computed: {},
		components: {
			Navs,
		},
		methods: {
			onClickItem(e){
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
				}
				this.getluggageList(this.airport)
			},
			async getluggageList(airport) {
				console.log(this.$storage.getJson("users"))
				let type = ""
				if(this.current == 0){
					type = "RUSH"
				}
				else{
					type = "REBOOK"
				}
				let data = {
					"serviceId": 3012,
					"dataContent": [{
						"specialType": type,
						"agentNumber": this.$storage.getJson("users").user_name
						// "agentNumber": "syq"
					}],
					"event": "0"
				}
				await this.$http.httpPost('/openApi/query', data).then(res => {
					console.log(res)
					if (res.code == "0") {
						res.returnData.map(item => {
							this.exceptionList.map(item2 => {
								if (item.exception_type == item2.type) {
									item["exception_name"] = item2.name
								}
							})
						})
						this.listdata = res.returnData;
					}

				})
			},
			// toDetail(luggageNum){
			// 	this.currentLuggageNum = luggageNum;
			// 	uni.navigateTo({
			// 		url: "/pages/baggagecheck/index?luggageNum="+this.currentLuggageNum
			// 	})
			// },
			async getluggage(n, t) {
				let data = {
					"serviceId": 3002,
					"page": 1,
					"pageSize": 1,
					"dataContent": {
						"luggageNum": n, //行李号
					},
					"event": "0"
				}
				await this.$http.httpPost('/openApi/query', data).then(res => {
					if (res.code == "0" && res.returnData.length > 0) {
						uni.navigateTo({
							url: "/pages/express/info?luggageNum=" + n
						})
					} else {
						this.$scanAudio.src = "../../static/hqxl.mp3"
						this.$scanAudio.play()
						uni.showToast({
							icon: 'none',
							title: "未查询到" + this.currentLuggageNum + "行李信息",
							duration: 5000
						});
					}
				})
			},
			baggageEntry() {
				uni.navigateTo({
					url: "/pages/baggageEntry/index"
				})
			},
			fall() {
				uni.navigateBack({
					delta: 1
				})
			},
			clear() {
				this.currentLuggageNum = null
			}
		},
	}
</script>

<style lang="scss" scoped>
	.app-content {
		position: relative;
		background: rgb(49, 85, 99);
		width: 100vw;
		height: 100vh;
		overflow: hidden;

		>.tuku {
			position: absolute;
			z-index: -1;
			width: 100%;
			top: -250px;
			let: 20px;
		}

		>.scanning {
			// height: 12rem;
			padding: 0 1.5rem 0 1.5rem;
			opacity: 1;
			transition: all 3s;

			.scanning_cds {
				width: 100%;
				height: 3rem;
				opacity: 1;
				transition: all 3s;
				background: rgb(51, 161, 165);
				margin-top: 1rem;
				margin-bottom: .5rem;
				border-radius: 4px;
				display: flex;
				justify-content: center;
				align-items: center;
				color: rgb(255, 255, 255);
				font-family: Noto Sans SC;
				font-size: 16px;

				>.log {
					width: .875rem;
					height: .875rem;
					background: url('../../static/saoma.png') no-repeat;
					background-size: 100% 100%;
					margin-left: 1rem;
				}

				>.log_l {
					width: .125rem;
					height: 1.3125rem;
					margin-left: 4rem;
					margin-right: .7rem;
					background: rgb(255, 255, 255);
				}
			}
		}

		>.content {
			width: 100%;
			height: calc(100vh - 7.5rem);
			position: relative;
			margin-top: 2.5rem;

			// overflow: hidden;
			// background: rgb(49, 85, 99);
			>.content_top {
				width: 100%;
				// background: rgb(49, 85, 99);
				padding-bottom: 1.3125rem;

				>.craid {
					// width: 100%;
					height: 5.625rem;
					padding: 0 2.5625rem 0 2.5625rem;
					display: flex;
					justify-content: space-between;
					flex-wrap: wrap;
					align-items: center;

					>.craid_data {
						display: flex;
						flex-direction: column;
						justify-content: center;
						align-items: start;

						>p {
							color: rgb(255, 255, 255);
							font-family: Noto Sans SC;
							font-size: 18px;
							font-weight: 700;
						}

						>span {
							color: rgb(255, 255, 255);
							font-family: Noto Sans SC;
							font-size: 13px;
							font-weight: 500;
						}
					}

					>.aircraft {
						width: 1.75rem;
						height: 1.75rem;
						background: url('../../static/hang.png') no-repeat;
						background-size: 100% 100%;
					}
				}
			}

			>.content_bootom {
				width: 100%;
				// height: calc(100vh - 20.9375rem - 4.375rem);
				padding-bottom: 0;
				position: absolute;
				bottom: 0;
				top: 20.75rem;
				// border-radius: 6px 6px 0px 0px;
				overflow: hidden;
				background: rgb(255, 255, 255);
				padding: 0 10px;
				box-sizing: border-box;

				.up {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-left: 1rem;
					border-bottom: 1px solid rgb(238, 238, 238);

					// transform: all 3s;
					>.down_up {
						width: .875rem;
						height: .875rem;
						background: url('../../static/xia.png') no-repeat;
						background-size: 100% 100%;
					}

					>.error {
						width: 60px;
						color: red
					}

					>.normal {
						width: 110px;
						color: #4682b4;
						margin-left: 10px;
					}
					>.normal2 {
						width: 180px;
						color: #4682b4;
						margin-left: 5px;
					}
					>.list {
						position: relative;
						height: 3rem;
						display: flex;
						align-items: center;
						transform: all 3s;
						right: 0;
						color: rgb(0, 0, 0);
						font-family: Noto Sans SC;
						font-size: 16px;
						font-weight: 500;
					}

					>.delete {
						width: 3.75rem;
						height: 3.75rem;
						background: rgb(237, 101, 101);
						display: flex;
						align-items: center;
						justify-content: center;
						position: relative;
						right: -3.75rem;
						transform: all 3s;

						>.log {
							width: .875rem;
							height: .875rem;
							background: url('../../static/vector@1x.png') no-repeat;
							background-size: 100% 100%;
						}
					}
				}

				.scroll-Y {
					// height: calc(100% - 2.5rem - 2.75rem - 2.25rem - 2.25rem);
					height: calc(100% - 2.5rem - 2.75rem);
				}

				.but {
					width: 20.5625rem;
					height: 2.5rem;
					background: linear-gradient(179.10deg, rgba(51, 161, 165, 1.00) 11.326%, rgba(59, 111, 142, 1.00) 119.032%, rgba(59, 111, 142, 1.00) 119.032%, rgba(59, 111, 142, 1.00) 119.032%);
					border-radius: .25rem;
					color: rgb(255, 255, 255);
					font-family: Noto Sans SC;
					font-size: 1rem;
					margin: 0 auto;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-top: 0.25rem;
					margin-bottom: 2.25rem;
				}
			}
		}
	}
</style>