username@email.com
2024-03-25 99e2324eea7af7dd8da898277abd6f2cbb32e3f2
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
<template>
    <view>
        <!--提示框组件-->
        <u-toast ref="uToast" />
        <view v-if="position && advert">
            <view v-if="position.type==1">
                <view v-for="(item, index) in advert" :key="index">
                    <u--image :showLoading="true" :src="item.imageUrl" mode="widthFix" width="100%" height="auto" @click="showSliderInfo(item.type, item.val)"></u--image>
                </view>
            </view>
            <view v-else>
                <u-swiper :list="advert" indicator indicatorMode="line" circular keyName="imageUrl" :showTitle="showTitle" @click="clickSwiper"></u-swiper>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        props: {
            code: {
                type: String,
                required: true,
                default: 'tpl1_class_banner1'
            },
            showTitle: {
                type: Boolean,
                required: false,
                default: false
            },
        },
        data() {
            return {
                position: {},
                advert: [],
            }
        },
        created() {
            this.getData();
        },
        methods: {
            getData() {
                this.$u.api.advert({
                    code: this.code,
                    platform: 3
                }).then(res => {
                    if (res.status) {
                        this.advert = res.data.childs;
                        this.position = res.data.position;
                        if (this.advert) {
                            for (var i = 0; i < this.advert.length; i++) {
                                this.advert[i].title = this.advert[i].name;
                            }
                        }
                    }
                });
            },
            clickSwiper(index) {
                console.log(index);
                this.showSliderInfo(this.advert[index].type, this.advert[index].val)
            }
        },
    }
</script>
<style scoped lang="scss">
</style>