<template>
	<view class="app">
		<view class="info">
			<image :src="baseurl+list.attributePitureUrl" mode=""></image>
			<view class="title" v-if="expresslist">
				{{expresslist.State==0?'暂无信息':''}}
				{{expresslist.State==1?'已揽收':''}}
				{{expresslist.State==2?'在途中':''}}
				{{expresslist.State==3?'已签收':''}}
				{{expresslist.State==4?'问题件':''}}
			</view>
			<view class="title" v-else>
				未发货
			</view>
			<view class="express" v-if="expresslist">
				{{expresslist.shipperName}}：{{expresslist.LogisticCode}}
			</view>
			<view class="border" style=""></view>
			<view class="address">
				【收货地址】{{list.receiveAddress}}
			</view>
		</view>
		<view class="logisticsinfo" v-if="expresslist">
			<view class="item" v-for="(item,index) in expresslist.Traces">
				<view class="time">
					{{item.AcceptTime}}
				</view>
				<view class="title">
					{{Actioncode(item.Action)}}
				</view>
				<view class="text">
					{{item.AcceptStation}}
				</view>
			</view>
		</view>
		<view class="logisticsinfo" v-else style="height:100vh">
			<view class="item" style="height: 260rpx;">
				<view class="time">
					{{gettime}}
				</view>
				<view class="title">
					暂无物流信息
				</view>
				<view class="text">
					<!-- {{item.AcceptStation}} -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		queryLogistics
	} from '@/api/pagesB/logistics/index.js'
	import baseurl from '../../api/baseurl';
	export default {
		data() {
			return {
				gettime: null,
				baseurl: '', //url
				list: {}, //订单信息
				expresslist: null, //快递信息
			};
		},
		methods: {
			//快递信息
			queryLogisticsInfo(goOrderNo, expressNo) {
				queryLogistics(goOrderNo, expressNo).then(res => {
					this.expresslist = res.data
				})
			},
			//判断状态
			Actioncode(code) {
				var obj = {
					0: '暂无轨迹信息',
					1: '已揽收',
					2: '在途中',
					201: '到达派件城市',
					202: '派件中',
					211: '已放入快递柜或驿站',
					3: '已签收',
					301: '正常签收',
					302: '派件异常后最终签收',
					304: '代收签收',
					311: '快递柜或驿站签收',
					4: '问题件',
					401: '发货无信息',
					402: '超时未签收',
					403: '超时未更新',
					404: '拒收(退件)',
					405: '派件异常',
					406: '退货签收',
					407: '退货未签收',
					412: '快递柜或驿站超时未取',
					10: '待揽件',
				}
				return obj[code]
			},
			getCurrentTime() {
				//获取当前时间并打印
				var that = this;
				let yy = new Date().getFullYear();
				let mm = new Date().getMonth() + 1;
				let dd = new Date().getDate();
				let hh = new Date().getHours();
				let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
				let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
				that.gettime = yy + '/' + mm + '/' + dd + ' ' + hh + ':' + mf + ':' + ss;
			}
		},
		onLoad(options) {
			this.baseurl = baseurl
			this.list = JSON.parse(options.item)
			this.queryLogisticsInfo(this.list.goOrderNo, this.list.expressNo);
			this.getCurrentTime();
		},
	}
</script>

<style lang="scss">
	@import './logistics.scss';
</style>
