<template>
	<view class="content">
		<view v-if='showLoading'>
			<u-loading-page :loading="showLoading"></u-loading-page>
		</view>
		<view v-else>
			<view class="order">
				<p>订单号:{{goodsDetil.logistics.order_sn}}</p>
				<view class='phone'> </view>
				<!-- 已送达 -->
				<view class="left" v-if="goodsDetil.logistics.status==2">
					<view class="list">
						<text>
							收货时间
						</text>
						<view>
							{{goodsDetil.record[2].create_time}}
						</view>
					</view>
					<view class="list">
						<text>
							收获详情
						</text>
						<view>
							<view>
								{{goodsDetil.logistics.user_address}}
							</view>
							<view>
								{{goodsDetil.logistics.user_name||"顾客电话"}} :{{goodsDetil.logistics.user_phone||"顾客电话"}}
							</view>
							<view>
								{{goodsDetil.record[2].create_time}}
							</view>
						</view>

					</view>
					<view class="list">
						<text>
							取货详情
						</text>
						<view>
							<view>
								{{goodsDetil.logistics.shop_address||"商家地址"}}
							</view>
							<view>
								{{goodsDetil.logistics.shop_name||"商家电话"}} :{{goodsDetil.logistics.shop_phone||"商家电话"}}
							</view>
							<view>
								{{goodsDetil.record[1].create_time}}
							</view>
						</view>
					</view>
					<view class="list">
						<text>
							订单详情
						</text>
						<view>
							<u-steps :current="record.length" direction="column">
								<u-steps-item :title="item.content" :desc="item.create_time"
									v-for="(item,index) in goodsDetil.record">
								</u-steps-item>
								<!-- <u-steps-item title="已出库" desc="10:35">
								</u-steps-item>
								<u-steps-item title="运输中" desc="11:40">
								</u-steps-item> -->
							</u-steps>
						</view>
					</view>
					<view class="pro_list">
						<text style="color: #999;width: 15vw;">
							商品信息
						</text>
						<view>
							<view class="goods_tit" v-for="(item,index) in goodsDetil.product">
								<text style="width: 60vw;margin: 0;padding: 0;">{{item.goods_name}}</text>
								<text>X{{item.product_num}}{{item.goods_unit}}</text>
							</view>
						</view>
					</view>
				</view>

				<!-- 已取货 -->
				<view class="left" v-else>
					<view class="list">
						<text>
							用户名称
						</text>
						<view>
							{{goodsDetil.logistics.user_name}}
						</view>
					</view>
					<view class="list">
						<text>
							联系方式
						</text>
						<view>
							{{goodsDetil.logistics.user_phone}}
						</view>
					</view>
					<view class="list" style="margin: 10rpx 0;">
						<text style="width: 16vw;">
							收货地址
						</text>
						<view>
							<view>
								{{goodsDetil.logistics.user_address}}
							</view>
						</view>
					</view>
					<view class="list">
						<text>
							物流信息
						</text>
						<!-- <view>
							<view v-for="(item,index) in goodsDetil.record">
								{{item.content}}
								<view>
									{{item.create_time}}
								</view>
							</view>
						</view> -->
						<u-steps :current="record.length-1" direction="column">
							<u-steps-item :title="item.content" :desc="item.create_time"
								v-for="(item,index) in (record)">
							</u-steps-item>
						</u-steps>
					</view>
					<view class="pro_list">
						<text style="color: #999;width: 15vw;">
							商品信息
						</text>
						<view>
							<view class="goods_tit" v-for="(item,index) in goodsDetil.product">
								<text style="width: 60vw;margin: 0;padding: 0;">{{item.goods_name}}</text>
								<text>X{{item.product_num}}{{item.goods_unit}}</text>
							</view>
						</view>
					</view>
				</view>



				<view class="total">
					<text>共计{{goodsDetil.product_count}}件商品 </text>
				</view>
				<u-button v-if='goodsDetil.logistics.status==1' @click="showPop=true" type="primary"
					style="background-color: #34A853;border: none;">已送达</u-button>
			</view>
			<view class="cil_left">
			</view>
			<view class="cil_right">
			</view>
			<!-- 	<u-modal :show="showPop" @confirm="confirm" content="请确认货物已送达" @close="showPop=false"
				:closeOnClickOverlay="true"></u-modal> -->

			<u-modal :show="showPop" @close="showPop=false" title="请输入收件码" @confirm="confirm"
				:closeOnClickOverlay="true">
				<view class="slot-content">
					<u--input placeholder="请输入收件码" type="number" border="surround" v-model="take_code"></u--input>
				</view>
			</u-modal>




			<u-toast ref="uToast"></u-toast>
		</view>

	</view>


	</view>

</template>

<script>
	import {
		doneDelivery
	} from "@/api/logistics.js"
	import {
		getDetil
	} from "@/api/logistics.js"
	export default {
		data() {
			return {
				showPop: false,
				showLoading: true,
				goodsDetil: undefined,
				flag: 0,
				take_code: ""
			}
		},
		computed: {
			// rereverse()
			record() {
				return this.goodsDetil.record.reverse()
			}
		},
		methods: {
			confirm() {
				if (!this.take_code) return
				doneDelivery({
					take_code: this.take_code,
					logistics_id: this.goodsDetil.logistics.id
				}).then(res => {
					this.showToast()
					setTimeout(() => {
						uni.navigateBack()
					}, 2000)
				})
				this.showPop = false

			},
			showToast() {
				this.$refs.uToast.show({
					type: 'success',
					title: '成功主题(带图标)',
					message: "操作成功",
					iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
				})
			},
		},
		onLoad(options) {

			getDetil({
				logistics_id: options.id
			}).then(res => {
				this.showLoading = false
				this.goodsDetil = res.data
				console.log(this.goodsDetil)
			})

		},
	}
</script>

<style lang='scss' scoped>
	.content {
		background-color: #F5F5F5;
		padding: 2vh 2vw;
	}

	.order {
		position: relative;
		background-color: white;
		margin: 20rpx 0;
		border-radius: 15rpx;
		height: auto;
		padding: 2vh 3vw;
		box-sizing: border-box;



		p {
			font-family: "PingFang SC-Medium";
			font-size: 32rpx;
			font-weight: bold;
		}

		.phone {
			color: #999999;
			padding: 10rpx 0;
			border-bottom: 1px dashed blue;
			font-size: 20rpx;
		}

		.left {
			.list {
				display: flex;

				view {
					flex: 8;

					view {
						margin-bottom: 10rpx;
					}
				}

				text {
					flex: 2;
				}

			}
		}

		.pro_list {
			display: flex;

			text {
				margin-right: 20rpx;
			}
		}

		.total {
			/* font-family: "宋体"; */
			margin: 20rpx 0;
			color: #3274F9;
			font-weight: bold;
			font-size: 32rpx;
			text-align: right;
		}

		.cil_left {
			width: 30rpx;
			height: 30rpx;
			background-color: #F5F5F5;
			border-radius: 30rpx;
			position: absolute;
			top: 110rpx;
			left: -15rpx;

		}

		.cil_right {
			width: 30rpx;
			height: 30rpx;
			background-color: #F5F5F5;
			border-radius: 30rpx;
			position: absolute;
			top: 110rpx;
			right: -15rpx;

		}

		.goods_tit {
			display: flex;
			justify-content: space-between;
		}

		.tost_tit {
			text-align: center;
		}

	}
</style>