zhangnuoyan
2024-08-25 efd620b121f27ba59a265402f2cec0ea0a5a1309
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<template>
    <the-a-date :data="date" />
    <div class="travel-lines">
        <div v-for="(line, key) in newData" :key="key" class="travel-line">
            <div v-for="(item, index) in line" :key="index" :class="`div-${item.type}`">
                <div>{{ item.type }}</div>
                <section>
                    <span></span>
                </section>
                <p>
                    <span>{{ item.title }}</span>
                    <span>{{ item.content }}</span>
                </p>
            </div>
        </div>
    </div>
</template>
<script lang="ts" setup name="TheTravelLine">
const props = withDefaults(
    defineProps<{
        date?: string;
        data?: Array<any>;
    }>(),
    {
        data: () => [],
        date: ""
    }
);
const newData = computed(() => {
    let max = 6;
    let result = [];
    let newArray = [];
    for (let i = 0; i < props.data.length; i += max) {
        result.push(props.data.slice(i, i + max));
    }
    for (let i = 0; i < result.length; i++) {
        if (i % 2 > 0) {
            const reverseArray = result[i].reverse();
            const number = max - reverseArray.length;
            for (let index = 0; index < number; index++) {
                reverseArray.unshift({
                    type: "none"
                });
            }
            newArray.push(reverseArray);
        } else {
            newArray.push(result[i]);
        }
    }
    return newArray;
});
</script>
<style lang="scss" scoped>
.travel-lines {
    margin: 0 100px;
    .travel-line {
        display: flex;
        &:nth-child(even) {
            > div {
                &:last-child {
                    position: relative;
                    &:after {
                        content: "";
                        position: absolute;
                        bottom: 65px;
                        right: 50px;
                        width: 50px;
                        height: 180px;
                        display: block;
                        border-radius: 0 40px 40px 0;
                        box-sizing: border-box;
                        border: 2px solid rgba(204, 214, 214, 0.4);
                        border-left: none;
                    }
                }
            }
        }
        &:nth-child(odd) {
            > div {
                &:first-child {
                    position: relative;
                    &:before {
                        content: "";
                        position: absolute;
                        bottom: 65px;
                        left: -60px;
                        width: 50px;
                        height: 180px;
                        display: block;
                        border-radius: 40px 0 0 40px;
                        box-sizing: border-box;
                        border: 2px solid rgba(204, 214, 214, 0.4);
                        border-right: none;
                    }
                }
            }
        }
        &:first-child {
            > div {
                &:first-child {
                    position: relative;
                    &:before {
                        content: "";
                        display: none;
                    }
                }
            }
        }
        > div {
            flex: 1;
            margin-bottom: 50px;
            padding: 50px 0;
            display: flex;
            align-items: center;
            position: relative;
            section {
                flex: 1;
                margin: 0 20px;
                display: flex;
                align-items: center;
                > span {
                    width: 100%;
                    background: rgba(204, 214, 214, 0.4);
                    display: block;
                    height: 2px;
                }
            }
            &:last-child {
                section {
                    display: none;
                }
            }
            &.div-in {
                > p {
                    bottom: 0;
                }
                > div {
                    background: #0e9cff;
                }
            }
            &.div-none {
                opacity: 0;
            }
            &.div-out {
                > p {
                    top: 0;
                }
                > div {
                    background: #ff9d35;
                }
            }
            > p {
                position: absolute;
                left: 0;
                > span {
                    display: block;
                    &:first-child {
                        font-size: 16px;
                        font-weight: bold;
                        line-height: 22px;
                        margin-bottom: 5px;
                    }
                    &:last-child {
                        font-size: 12px;
                    }
                }
            }
 
            > div {
                width: 32px;
                height: 32px;
                border-radius: 4px;
                line-height: 30px;
                text-align: center;
                font-size: 16px;
                font-weight: bold;
                color: #fff;
            }
        }
    }
}
</style>