<template>
    <view v-if="pageShow">
        <!-- 使用标题栏 -->
        <status-nav class="statush" :statusBackw="true" :statusTitle="true" :title-val="'查看物流'" :tabcolor="'#ffffff'"></status-nav>
        <view class="bacb padding-zy20 padding-sx30" :style="{paddingTop:statusHNH+'px'}">
            <view class="disba margin-s30 margin-x20">
                <view class="fon30 bold">包裹已{{orderStatus}}</view>
                <view class="fon26 color9">{{orderTime}}</view>
            </view>
            <view class="dis">
                <image class="flexs goodsImg radius10" :src="orderImg" mode="aspectFill"></image>
                <view class="margin-z20 margin-s10">
                    <view class="clips1 fon28">{{orderInfo.skus[0].spu_name}}</view>
                    <view class="fon24 margin-sx20">订单号：{{orderInfo.order_id}}</view>
                    <view class="fon28 color9 padding20 width100" style="background-color: #f8f8f8;border-radius: 2rpx;">
                        <view>您的包裹已成功{{orderResult}}</view>
						<view class="clips1 margin-s20">物流公司：{{orderInfo.express_name}}</view>
                        <view class="disba">
                            <view class="clips1">运单编号：{{orderInfo.express_number}}</view>
                            <view class="flexs" @tap="copy" style="width: 94rpx;height: 60rpx;line-height: 60rpx;text-align: center;border-radius: 30.5rpx;border: 1rpx solid #999999;color: #000000;">复制</view>
                        </view>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
				orderInfo:{},//订单详情
				orderImg:'',//订单图片
				orderStatus:'',//当前状态
				orderResult:'',//当前状态结果
				orderTime:'',//当前状态时间
				statusHNH:uni.getStorageSync('statusHNH'),
				pageShow:false
            }
        },
		onShow() {
			this.$toolAll.tools.guoq()
		},
        onLoad(options) {
            this.checkWl(options.orderId)
        },
        methods: {
			checkWl(orderId){//查看物流事件
				this.$requst.post('order/logistics',{order_id:orderId}).then(res=>{
					// console.log(res);
					if(res.code==0){
						this.pageShow = true
						this.orderInfo = res.data
						this.orderImg = this.$http + res.data.skus[0].sku_cover
						if(res.data.status=='shipped') {
							this.orderStatus = this.orderResult = '发货'
						}
						if(res.data.status=='completed') {
							this.orderStatus = '领取'
							this.orderResult = '取出'
						}
						if(res.data.express_info.status==500){
							let zdtime = res.data.skus[0].created_at//获取物流最新时间
							let jtime = zdtime.slice(0,10)//去除时分秒
							let ftime = jtime.split('-')//去除-
							this.orderTime = ftime[0].slice(2,4)+'/'+ftime[1]+'/'+ftime[2]
						} else {
							if(res.data.express_info.data.length!=0){
								let zdtime = res.data.express_info.data[0].time//获取物流最新时间
								let jtime = zdtime.slice(0,10)//去除时分秒
								let ftime = jtime.split('-')//去除-
								this.orderTime = ftime[0].slice(2,4)+'/'+ftime[1]+'/'+ftime[2]
							}
						}
					}
				},error=>{})
			},
            copy(){
                uni.setClipboardData({
                    data: this.orderInfo.express_number,
                    success: function() {
                        uni.showToast({
                            title: '复制成功',
                            duration: 2000,
                            icon: 'none'
                        });
                    }
                });
            }
        }
    }
</script>

<style>

</style>
