wangzhibo
4 天以前 10595d8632f959d0954d1939243196f4eed02372
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
<template>
    <view class="banner">
        <cl-banner :list="list" type="card" :height="300" @select="toPath">
            <template #item="{ item }">
                <cl-skeleton
                    height="100%"
                    :loading="!item.pic"
                    :loading-style="{
                        borderRadius: '24rpx',
                    }"
                >
                    <image mode="aspectFill" :src="item.pic" />
                </cl-skeleton>
            </template>
        </cl-banner>
    </view>
</template>
 
<script lang="ts" setup>
import { onShow } from "@dcloudio/uni-app";
import { ref } from "vue";
import { useCool } from "/@/cool";
 
const { service, router } = useCool();
 
const list = ref<Eps.InfoBannerEntity[]>([{}, {}, {}]);
 
function refresh() {
    service.info.banner.list({ order: "sortNum", sort: "desc" }).then((res) => {
        list.value = res;
    });
}
 
function toPath(index: number) {
    const { path } = list.value[index];
 
    if (path) {
        router.push(path);
    }
}
 
onShow(() => {
    refresh();
});
</script>
 
<style lang="scss" scoped>
.banner {
    margin: 32rpx 0;
 
    image {
        height: 100%;
        width: 100%;
        border-radius: 24rpx;
    }
}
</style>