wangzhibo
6 天以前 7bd866831780abcf5a59c4cbb7d1be456eea7c99
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
<template>
    <div class="order-goods">
        <div class="list">
            <div class="goods" v-for="goods in list" :key="goods.id">
                <p class="name">{{ goods.name }}</p>
 
                <div class="specs">
                    <div class="item" v-for="item in goods.children" :key="item.id">
                        <cl-image :src="item.cover" :size="60" />
 
                        <div class="det">
                            <p class="name">{{ item.spec.name }}</p>
                            <p class="flex1"></p>
                            <p class="price">
                                <span>¥{{ item.spec.price }}</span>
                                <span>x{{ item.count }}</span>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
 
<script setup lang="ts" name="order-goods">
import { isEmpty } from "lodash-es";
import { PropType, computed } from "vue";
 
interface Item {
    id: number;
    name: string;
    children: Eps.GoodsInfoEntity[];
}
 
const props = defineProps({
    scope: {
        type: Object as PropType<Eps.OrderInfoEntity & { goodsList?: any[] }>,
        default: () => ({})
    }
});
 
const list = computed(() => {
    const arr: Item[] = [];
 
    props.scope.goodsList
        ?.filter((e) => !!e)
        .forEach((e) => {
            // 封面图
            let pics = e.spec.images || [];
            if (isEmpty(pics)) {
                pics = [e.goodsInfo.mainPic];
            }
            e.cover = pics[0];
 
            const d = arr.find((a) => a.id == e.goodsInfo.id);
 
            if (d) {
                d.children?.push(e);
            } else {
                arr.push({
                    id: e.goodsInfo.id!,
                    name: e.goodsInfo.title!,
                    children: [e]
                });
            }
        });
 
    return arr;
});
</script>
 
<style lang="scss" scoped>
.order-goods {
    .list {
        display: flex;
        flex-wrap: wrap;
 
        .goods {
            margin-left: 10px;
 
            & > .name {
                font-size: 14px;
                margin-bottom: 5px;
                padding: 0 2px;
                height: 20px;
                max-width: 200px;
                box-sizing: border-box;
                overflow: hidden;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 1;
            }
 
            .specs {
                display: flex;
            }
 
            .item {
                display: flex;
                align-items: center;
                font-size: 12px;
                position: relative;
                border: 1px solid var(--el-bg-color-page);
                border-radius: 6px;
                padding: 10px;
                height: 80px;
                width: 250px;
                margin-right: 10px;
 
                .cl-image {
                    margin-right: 10px;
                    border-radius: 6px;
                    overflow: hidden;
                }
 
                .det {
                    display: flex;
                    flex-direction: column;
                    flex: 1;
                    height: 100%;
                    padding: 2px 0;
 
                    .name {
                        overflow: hidden;
                        display: -webkit-box;
                        -webkit-box-orient: vertical;
                        -webkit-line-clamp: 2;
                    }
 
                    .flex1 {
                        flex: 1;
                    }
 
                    .price {
                        display: flex;
                        align-items: center;
                        justify-content: space-between;
                    }
                }
            }
        }
    }
}
</style>