<template>
	<view class="park">
		<view class="park-navbar">
			<u-navbar title="物流信息" :border-bottom="false" :background="background"></u-navbar>
		</view>
		<view class="logis-box" v-if="logisticsItem">
			<image src="/static/default-logo.png" alt=""></image>
			<view class="logis-pany">
				<view class="logis-text">
					<text>物流公司：</text>{{logisticsItem.express_name}}
				</view>
				<view class="logis-text">
					<text>物流单号：</text>{{logisticsItem.express_no}}<text
						style="color: #FF6565; font-size:28rpx;margin-left: 20px;" @click="copy">复制</text>
				</view>
			</view>
		</view>
		<view class="logis-detail" v-if="logisticsItem">
			<view class="logis-item" :class="{ first: index === 0 }" v-for="(item, index) in logisticsItem.items"
				:key="index">
				<view class="logis-item-content">
					<view class="logis-item-content__describe">
						<text class="f-26">{{ item.context }}</text>
					</view>
					<view class="logis-item-content__time">
						<text class="f-22">{{ item.time }}</text>
				</view>
					</view>
			</view>
		</view>
		<u-empty text="暂无物流信息～" v-else mode="list"></u-empty>
	</view>
</template>

<script>
	import * as newFunApi from '@/api/newFun'
	export default {
		data() {
			return {
				background: {
					background: `url(${this.$picUrl}/static/news/login-bg.png) center top no-repeat`,
					backgroundSize: '100%',
				},
				traces: [],
				logisticsItem: ''
			};
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad(o) {
			this.onCheck(o.logisticsNum)
		},
		methods: {
			onBack() {
				uni.navigateBack({
					delta: 1 // 表示返回到上一页（默认为1）
				});
			},
			copy(value) {
				uni.setClipboardData({
					data: this.logisticsItem.express_no, //	这里是个坑接受字符串类型 value转化为字符串
					success: function() {
						//调用方法成功
						uni.showToast({
							title: '复制成功',
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			/**
			 * 查快递
			 */
			onCheck(logisticsNum) {
				newFunApi.expressSearch({
						expressNo: logisticsNum
					})
					.then(res => {
						if (res.status) {
							this.logisticsItem = res.data
						} else {
							uni.showToast({
								title: '查询失败',
								icon: 'none',
								duration: 2000
							})
						}
					})
					.finally()
			}
		}
	}
</script>

<style scoped lang="scss">
	::v-deep .u-empty {
		padding: 100rpx 0;
	}
	page {
		background-color: #F7F8FA;
		min-height: 100%;
		padding-bottom: 40upx;
	}

	.park {
		width: 100%;
		background: url(https://www.royaum.com.cn/static/news/login-bg.png) center 0 no-repeat;
		background-size: 100% auto;
		min-height: 100vh;
	}

	// 物流轨迹
	.logis-box {
		width: 100%;
		height: 80px;
		// background-color: #FFF;
		display: flex;
		align-items: center;
		padding: 40rpx;

		image {
			width: 60px;
			height: 60px;
			border-radius: 50%;
		}

		.logis-text {
			margin: 10px 0;
		}

		.logis-pany {
			overflow: hidden;
			margin-left: 15rpx;
			color: #000;
			font-size: 28rpx;

			text {
				color: #999;
			}
		}
	}

	.logis-detail {
		padding: 30rpx 50rpx;
		background: #fff;

		.logis-item {
			position: relative;
			padding: 10px 0 10px 25px;
			box-sizing: border-box;
			border-left: 2px solid #ccc;

			&.first {
				border-left: 2px solid #FF5050;

				&:after {
					background: #FF5050;
					color: #FF5050;
				}

				.logis-item-content {
					// background: #ff6e39;
					color: #FF5050;

					&:after {
						border-bottom-color: #FF5050;
					}
				}
			}

			&:after {
				content: ' ';
				display: inline-block;
				position: absolute;
				left: -7px;
				top: 0px;
				width: 8px;
				height: 8px;
				border-radius: 10px;
				background: #bdbdbd;
				border: 2px solid #fff;
			}

			.logis-item-content {
				position: relative;
				// background: #f9f9f9;
				padding: 10rpx 20rpx;
				box-sizing: border-box;
				color: #999;
			}
		}
	}

	.empty {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 100%;
		height: 400rpx;
		background-color: #fff;

		image {
			width: 114rpx;
			height: auto;
			margin-top: 90 0rpx;
		}
	}
</style>
