<template>
    <div class="page">
        <div class="express-info" v-if="data">
            <div class="name">{{ data.name }}</div>
            <div class="nu">
                快递号：{{ data.nu }}
                <div class="copy" @click="copyExpressNu()">复制</div>
            </div>
            <div class="nu">更新时间：{{ data.lastSyncTime }}</div>
        </div>

        <div class="time-line" v-if="data">
            <ul>
                <li class="item on" v-for="item of data.data" :key="item.id">
                    <div class="head">
                        <!-- <span class="status">{{ item.context }}</span> -->
                        <div class="time">
                            {{ item.time | dateFormat("MM-dd hh:mm") }}
                        </div>
                    </div>
                    <div class="des">{{ item.context }}</div>
                </li>
            </ul>
            <p class="empty-text" v-if="dataList.length === 0 && !dataLoading">
                无订单跟踪数据
            </p>
        </div>
    </div>
</template>

<script>
import MyImage from "../../components/image/index";

export default {
    name: "",
    components: { MyImage },

    // 数据
    data() {
        return {
            orderItemId: null,
            data: null,
            dataLoading: true,
        };
    },

    async onShow() {
        const self = this;
        await self.fn.init();
        self.orderItemId = self.$mp.query.orderItemId;
        self.getData();
    },

    // 函数
    methods: {
        getData() {
            uni.showLoading({
                title: "加载中...",
            });
            this.dataLoading = true;
            this.api
                .get("/Order/GetLogisticsInfo", {
                    id: this.orderItemId,
                })
                .then((res) => {
                    uni.hideLoading();
                    this.data = res.data;
                    this.data = this.data.sort((x, y) =>
                        x.time < y.time ? 1 : -1
                    );
                });
        },

        // 复制订单号
        copyExpressNu() {
            const self = this;

            uni.setClipboardData({
                data: self.data.nu,
                success: () => {
                    self.fn.showToast("复制成功");
                },
            });
        },
    },

    // 数据计算
    computed: {},

    // 数据监听
    watch: {},
};
</script>

<style lang="scss" scoped>
.express-info {
    background-color: #fff;
    padding: px(30);
    margin-bottom: px(30);
    .name {
        font-size: px(44);
        margin-bottom: px(20);
    }
    .nu {
        font-size: px(40);
        color: #666;
    }
    .copy {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        width: px(140);
        height: px(70);
        font-size: px(36);
        color: #666;
        margin-left: px(30);
        border: solid px(3) #ddd;
    }
}
.time-line {
    width: 100%;
    background-color: #fff;
    padding: px(30);
    padding-top: px(60);
    .item {
        color: #666;
        padding-left: px(80);
        position: relative;
        padding-bottom: px(40);
        &::after {
            content: "";
            position: absolute;
            top: 0;
            left: px(40);
            z-index: 1;
            width: px(5);
            height: 100%;
            background-color: rgb(249, 196, 166);
        }
        &::before {
            content: "";
            position: absolute;
            left: px(40);
            z-index: 2;
            transform: translate(-49%, 0);
            top: px(20);
            width: px(25);
            height: px(25);
            border-radius: 50%;
            background-color: rgb(249, 196, 166);
        }
        &:first-child {
            &::before {
                top: 0;
                width: px(50);
                height: px(50);
                background: url("/static/icon/select2.png") no-repeat center;
                background-size: 100%;
            }
        }
        &.on {
            .des {
                color: #333;
            }
            .status {
                color: #f7672b;
            }
        }
    }
    .head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        .status {
            font-size: px(40);
        }
        .date {
            font-size: px(34);
        }
        .time {
            flex-shrink: 0;
            margin-left: px(20);
        }
    }
    .des {
        margin-top: px(20);
        font-size: px(36);
    }
}
.empty-text {
    padding: px(50) px(30);
    font-size: px(36);
    color: #888;
    text-align: center;
}
</style>