<template>
    <view class="timeline-container">
        <view class="timeBox">
            <view
                v-for="(item, index) in freQuenceList"
                :key="index"
                class="timeline-item"
            >
                <view class="timeline-content">
                    <!-- 左侧：目标离开 -->
                    <view class="timeline-time timeline-time-left">
                        <text class="time-text">{{
                            formatTime(item.enterTime)
                        }}</text>
                        <text class="event-text">目标进入</text>
                    </view>

                    <!-- 中间：时间轴 -->
                    <view class="timeline-line">
                        <view class="node-circle"></view>
                        <view
                            class="node-line"
                            v-if="index !== freQuenceList.length - 1"
                        ></view>
                    </view>

                    <!-- 右侧：目标进入 -->
                    <view class="timeline-time timeline-time-right">
                        <text class="time-text">{{
                            formatTime(item.leaveTime)
                        }}</text>
                        <text class="event-text">目标离开</text>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            freQuenceList: "",
        };
    },
    methods: {
        formatTime(time) {
            return time ? time.slice(11, 19) : "暂无";
        },
    },
    onLoad(options) {
        this.freQuenceList = JSON.parse(options.freQuenceList);
    },
};
</script>

<style scoped>
.timeline-container {
    padding: 30rpx;
    background: linear-gradient(180deg, #f6f6f6 0%, #ffffff 100%);
    box-sizing: border-box;
}

.timeBox {
    overflow-y: auto;
    height: 100vh;
}

.timeline-item {
    display: flex;
    justify-content: center;
    padding-bottom: 40rpx;
    position: relative;
}

.timeline-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
}

.timeline-time {
    font-size: 24rpx;
    color: #99715f;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.timeline-time-left {
    margin-right: 30rpx;
    align-items: flex-end;
    text-align: right;
}

.timeline-time-right {
    margin-left: 30rpx;
    align-items: flex-start;
    text-align: left;
}

.time-text {
    font-size: 30rpx;
    color: #99715f;
    font-weight: bold;
    margin-bottom: 6rpx;
}

.event-text {
    font-size: 24rpx;
    color: #999;
}

.timeline-line {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 4rpx;
    min-height: 120rpx;
    background-color: #7e5648;
    position: relative;
}

.node-circle {
    width: 16rpx;
    height: 16rpx;
    border-radius: 50%;
    background-color: #7e5648;
    border: 4rpx solid #fff;
    z-index: 2;
    margin: 10rpx 0;
}
.node-line {
    flex: 1;
    width: 4rpx;
    background-color: #7e5648;
}
</style>
