<template>
    <el-dialog v-if="deliverOrder" title="物流详情" :close-on-click-modal="false" :visible.sync="visible"
        :before-close="beforeCloseDialog" width="80%">
        <!-- <div class="content" >
            <el-button type="primary" size="small" onclick="">确定</el-button>            
        </div> -->
        
        <div class="deliverInfo" style="width: 300px; margin: 10px auto;" v-if="activities != []">
            <!-- <div style="margin-bottom: 5px;"><i class="el-icon-location-outline"></i><span
                    style="  margin-left:10px;">收货地址</span>：天津市河东区天津站</div> -->
            <div style=""><icon-svg name="ren"></icon-svg><span
                    style=" margin-left:10px;">收货人</span>：{{ deliverOrder.userName }}</div>
            <div style="margin-bottom: 5px;"><icon-svg name="dianhua"></icon-svg><span style="  margin-left:10px;">电 话</span>：{{ deliverOrder.userPhone }}</div>

        </div>
        <el-row :gutter="10" class="flexbox">
            <div v-if="activities.length == 0" class="noinfo">-暂无物流信息-</div>
            <el-col v-else :lg="8" :md="12" :xs="24" v-for="(item, index) in activities" :key="index"
                :class="item.length == 1 ? 'onlyOne' : 'notOone'" >
                <div class="scroll">
                    <div style="margin-bottom: 5px;"><icon-svg name="truck"></icon-svg><span
                            style=" margin-left: 10px;">快递</span>:
                        {{ activities[0].ShipperName }}{{ activities[0].LogisticCode }}</div>
                    <el-timeline v-if="item.Traces != []">
                        <el-timeline-item :reverse="reverse" v-for="(activity, index2) in item.Traces" :key="index2"
                            :icon="activity.icon" :type="activity.Action" :color="activity.color" :size="activity.size"
                            :timestamp="activity.AcceptTime">
                            {{ activity.AcceptStation }}
                        </el-timeline-item>
                    </el-timeline>
                    
                    
                </div>
            </el-col>
            
        </el-row>
    </el-dialog>
</template>

<script>

export default {
    name: 'printOrderDialog',
    props: {
        visible: {
            type: Boolean,
            value: false
        },
        deliverOrder: {
            type: Object,
            value: {}
        }
    },
    data() {
        return {
            reverse: true,
            DeliverList: [],
            activities: [
            ]
        }
    },
    created() {
        
    },
    methods: {
        // 根据订单ID查询物流信息
        getDeliverList(deliverOrder) {
            // this.DeliverList = data.list
            // console.log('根据订单ID查询物流信息')
            // console.log(this.deliverOrder)
            let loading = this.$loading({
                lock: true,
                text: '正在获取物流信息，请稍后...',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });
            console.log(deliverOrder.orderId, '收到的deliverOrder')            
            this.$http({
                url: this.$http.adornUrl('/book/buyOrder/queryFMS'),
                method: 'post',
                params: this.$http.adornParams({
                    'orderId': deliverOrder.orderId
                })
            }).then(({ data }) => {
                loading.close()
                if (data && data.code === 0) {
                    console.log(data,'data')
                    if (data.msg.indexOf('暂未查到物流信息') != -1) {   
                        this.activities = []                                                                    
                    } else {
                        this.activities = data.rntStr                      
                    }  
                    this.visible = true  
                    console.log(this.activities,4545)
                } else {
                    loading.close()
                    return this.$message.error('获取失败，请重新尝试') 
                }
            }).catch(() => {
                return this.$message.error('获取失败，请重新尝试') 
            })
        },
        beforeCloseDialog() {
            this.$emit('closeDeliverDetailDialog', false)
        }
    }
}

</script>
<style scoped>
/* @import '../../../assets/css/time-line.css'; */
</style>
<style lang="less" scoped>
.noinfo {
    color: #ddd;
    text-align: center;
    padding: 20px;
}

.flexbox {
    display: flex;
    justify-content: center;
}



.content {
    text-align: center;
    margin-top: 15px;
}</style>