<template>
	<view class="logistics_info">
		<view v-if="status === 1" class="send_all">
			您的快递包裹已全部发货完毕，请注意查收!
		</view>
		<view>
			<view v-for="item in logisticsList" :key="item.id" v-show="logisticsList.length > 0" @click="logisticsDetail(item)" class="logistics_info">
				<view class="top">
					<view>
						<view style="color:#333333;">物流单号：{{ item.express_number }}</view>
						<view class="status">
							<text class="state" :class="[item.status == 0 ? 'state0' : item.status == 1 ? 'state1' : 'state2']"></text>
							<text style="margin-left:10rpx" :class="[item.status == 0 ? 'color0' : item.status == 1 ? 'color1' : 'color2']">
								{{ item.status == 0 ? '运输中' : item.status == 1 ? '已签收' : '物流异常' }}
							</text>
						</view>
					</view>
				</view>
				<view class="center">
					<view class="logistics_name">{{ item.express_com }}</view>
					<view class="info">
						<view>
							<view>郑州市</view>
							<view class="small">管城区</view>
						</view>
						<view class="flow">
							<view class="query">查询物流</view>
							<image src="../../static/icon/arrows.png" mode=""></image>
						</view>
						<view>
							<view>{{ item.city }}</view>
							<view class="small">{{ item.area }}</view>
						</view>
					</view>
				</view>
				<view class="bottom">
					<view class="commodity">
						<view class="detail">商品详情：</view>
						<view style="color:#999999;display: flex;flex-wrap: wrap;">{{item.note}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { _API_GetLogistics } from '../../apis/order.js';
export default {
	data() {
		return {
			logisticsList: [], //物流信息列表
			id: '',
			status: 0
		};
	},
	onLoad(options) {
		console.log(options,'options')
		if (options.order_no) {
			this.getLogistics(options.order_no);
		}
		if(options.status) {
			this.status = Number(options.status)
		}
		// if (options.order_id) {
		// 	this.getExpressTrack(options.order_id);
		// }
	},
	methods: {
		getLogistics(order_no) {
			
			uni.showLoading({
				title: '加载中'
			});
			_API_GetLogistics({
				order_num: order_no
			}).then(res => {
				uni.hideLoading();
				if (res.code === 200) {
					if(res.data.length > 0) {
						this.logisticsList = res.data;
					} else {
						uni.showModal({
							content: res.data.message || '物流信息不存在',
							showCancel: false,
							success() {
								uni.navigateBack()
							}
						});
						return false;
					}
					
					console.log(res.data, '物流信息');
				}
			}).catch(() => {
				uni.showModal({
					content: '服务器发生错误',
					showCancel: false
				});
			});
		},
		logisticsDetail(item) {
			console.log(item.express_number);
			uni.navigateTo({
				url: '../logistics-details/logistics-details?id=' + item.id + '&express_com=' + item.express_com + '&express_number=' + item.express_number
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.logistics_info {
	min-height: 100%;
	background: $app-base-bg;
	.send_all {
		height: 72rpx;
		line-height: 72rpx;
		width: 100%;
		padding: 0 31rpx;
		box-sizing: border-box;
		color: #FFFFFF;
		font-size: 28rpx;
		background-color: #F76353;
	}
	.logistics_info {
		width: 100%;
		background: #fff;
		margin-bottom: 20rpx;
		.top {
			width: 100%;
			border-bottom: 1rpx solid #f2f2f2;
			.status {
				display: flex;
				align-items: center;
				.state {
					display: inline-block;
					height: 12rpx;
					width: 12rpx;
					border-radius: 50%;
				}
				.state0 {
					background-color: #f76454;
				}
				.state1 {
					background-color: #999999;
				}
				.state2 {
					background-color: #f00;
				}
				.color0 {
					color: #333333;
				}
				.color1 {
					color: #999999;
				}
				.color2 {
					color: #f00;
				}
			}
		}
		.top > view {
			margin: 0 30rpx;
			height: 72rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
		.center {
			height: 160rpx;
			font-size: 36rpx;
			font-weight: bold;
			color: #181818;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 30rpx;
			.logistics_name {
				font-size: 32rpx;
				width: 30%;
			}
			.info {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 70%;
				view {
					text-align: center;
				}
				.small {
					font-size: 28rpx;
					font-weight: noraml;
					margin-top: 12rpx;
				}
				.flow {
					display: flex;
					flex-direction: column;
					align-items: center;
					position: relative;
					view {
						height: 48rpx;
						width: 128rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						font-size: 24rpx;
						color: #fff;
						background-color: #f76454;
						border-radius: 24rpx;
						font-weight: normal;
					}
					.query {
						position: absolute;
						top: -45rpx;
						left: 15rpx;
					}
					image {
						margin-top: 12rpx;
						height: 12rpx;
						width: 160rpx;
					}
				}
			}
		}
		.bottom {
			border-top: 1rpx solid #f2f2f2;
			.commodity {
				padding: 20rpx 30rpx;
				display: flex;
				font-size: 28rpx;
				.detail {
					color: #333333;
					width: 150rpx;
					flex-shrink: 0;
				}
			}
		}
	}
}
</style>
