<template>
	<!-- 订单详情 -->
	<view>
		<u-navbar title="" autoBack placeholder></u-navbar>
		<view class="card_order_detail">
			<view class="orderNumber">
				<view class="card_order_title">
					<span>运单号:</span>{{orderList.waybillNo}}
				</view>
				<span class="card_state"
					:style="{color:getState(orderList.status)}">{{orderStatus(orderList.status)}}</span>
			</view>
			<view class="title_delivery">寄件人:</view>
			<x-orderCard :list="senderList"></x-orderCard>
			<view class="title_delivery">收件人:</view>
			<x-orderCard :list="consigneeList"></x-orderCard>
			<view class="card_humiture">
				<view class="title_claim">
					<span>温度需求:</span>
					<view style="width: auto;">
						<u-tag :text="orderList.temperatureInterval" plain size="mini" type="success"></u-tag>
					</view>
				</view>
				<view class="title_claim">
					<span>配送要求:</span>
					<view style="width: auto;">
						<u-tag :text="orderList.deliveryCondition" plain size="mini" type="primary"></u-tag>
					</view>
				</view>
				<view class="title_claim">
					<span>货物类型:</span>
					<view style="width: auto;">
						<u-tag :text="orderList.cargoType" plain size="mini" type="warning"></u-tag>
					</view>
				</view>
				<view class="title_claim">
					<span>数量:</span>
					<view style="width: auto;font-size: 28rpx;">
						{{orderList.quantity}}
					</view>
				</view>
				<view class="title_claim"><span>备注:</span>{{orderList.remark}}</view>
			</view>
			<view class="card_humiture1" v-if="orderList.status == 8">
				<view class="order_iamge_item" v-for="(item,index) in srcList" :key="index">
					<u-image :showLoading="true" :src="item.url" width="80px" height="80px" radius="2"></u-image>
					<view class="order_item_title">{{item.title}}</view>
				</view>
			</view>
			<view v-if="orderList.status != 1">
				<view class="line_back" style="margin-top: 40rpx;" @click="logistics">查看物流详情</view>
				<view class="line_back" @click="goHumiture">查看温湿度</view>
			</view>
			<view style="width: 100%;height: 80rpx;"></view>
		</view>
		<!-- <view class="btn_print" v-if="type == 'details' && orderList.status == 2 || orderList.status == 3">
			<u-button type="primary" text="打印条码"></u-button>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 'details',
				senderList: {
					name: '',
					phone: '',
					address: '',
				},
				consigneeList: {
					name: '',
					phone: '',
					address: '',
				},
				orderList: {},
				srcList: [{
					title: '运单签收图片',
					url: '',
				}, {
					title: '随货通行单图片',
					url: '',
				}, {
					title: '冷链交接单图片',
					url: '',
				}],
				userInfo: {},
			}
		},
		onLoad(value) {
			var userInfo = this.$cache.getCache('userInfo')
			this.userInfo = userInfo
			this.type = value.type
		},
		onShow() {
			var orderList = this.$cache.getCache('orderDetails')
			this.orderList = orderList
			this.senderList.name = orderList.senderAddressName
			this.senderList.phone = orderList.senderAddressPhone
			this.senderList.address = orderList.senderAddressDetails
			this.consigneeList.name = orderList.consigneeAddressName
			this.consigneeList.phone = orderList.consigneeAddressPhone
			this.consigneeList.address = orderList.consigneeAddressDetails
			if (orderList.status == 8) {
				const arr = orderList.ReceiptImg.split(',')
				this.srcList[0].url = arr[0]
				this.srcList[1].url = arr[1]
				this.srcList[2].url = arr[2]
			}
		},
		methods: {
			// 物流详情
			logistics() {
				uni.navigateTo({
					url: '/pages/order/logisticsDetails'
				});
			},
			// 温湿度记录
			goHumiture() {
				uni.navigateTo({
					url: '/pages/order/humiture'
				});
			},
			// 订单状态
			orderStatus(value) {
				if (this.userInfo.userType == 'sys') {
					if (this.userInfo.type == 2) {
						// 仓管
						if (value == 3) {
							return '未入库'
						} else if (value == 5) {
							return '已入库'
						} else {
							return '已出库'
						}
					} else if (this.userInfo.type == 3) {
						// 司机
						if (value == 2) {
							return '未装车'
						} else if (value == 4) {
							return '已装车'
						} else if (value == 6) {
							return '已下车'
						} else {
							return '已签收'
						}
					}
				} else {
					if (value == 1 || value == 2 || value == 3) {
						return '未发货'
					} else if (value == 4 || value == 5 || value == 6 || value == 7) {
						return '已发货'
					} else {
						return '已签收'
					}
				}
			},
			// 订单文字颜色
			getState(value) {
				if (this.userInfo.userType == 'sys') {
					if (this.userInfo.type == 2) {
						// 仓管
						if (value == 3) {
							return '#ff9900'
						} else if (value == 5) {
							return '#19be6b'
						} else {
							return '#606266'
						}
					} else if (this.userInfo.type == 3) {
						// 司机
						if (value == 2) {
							return '#ff9900'
						} else if (value == 4) {
							return '#19be6b'
						} else if (value == 6) {
							return '#19be6b'
						} else {
							return '#606266'
						}
					}
				} else {
					if (value == 1 || value == 2 || value == 3) {
						return '#ff9900'
					} else if (value == 4 || value == 5 || value == 6 || value == 7) {
						return '#19be6b'
					} else {
						return '#606266'
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.card_order_detail {
		margin: 20rpx;
	}

	.orderNumber {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #fff;
		border-radius: 20rpx;
		padding: 15rpx;
	}

	.card_order_title {
		span {
			font-size: 28rpx;
			color: #909399;
			margin-right: 10rpx;
		}
	}

	.card_state {
		color: #606266;
		font-size: 30rpx;
	}
	.title_delivery {
		font-size: 30rpx;
		font-weight: 600;
		margin: 20rpx 0rpx 10rpx 10rpx;
	}

	.card_humiture {
		margin-top: 30rpx;
		border-radius: 20rpx;
		padding: 1rpx 20rpx;
		background-color: #fff;
	}

	.card_humiture1 {
		display: flex;
		justify-content: space-around;
		align-items: center;
		flex-wrap: wrap;
		margin-top: 10rpx;
		border-radius: 20rpx;
		padding: 20rpx;
		background-color: #fff;
	}

	.order_iamge_item {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.order_item_title {
		font-weight: 600;
		margin-top: 10rpx;
		font-size: 26rpx;
	}

	.title_claim {
		display: flex;
		margin: 20rpx 0rpx;

		span {
			font-size: 28rpx;
			color: #909399;
			margin-right: 10rpx;
		}
	}

	.line_back {
		font-size: 30rpx;
		margin: 20rpx 0rpx;
		color: #3c9cff;
	}
</style>