<template>
    <view>
        <block v-if="detail.type == 1">
            <image v-for="(item, index) in detail.attinfos_pic" :key="item.attachmentid" class="image"
                :src="item.attinfos[0].url" mode="widthFix" hover-class="navigator-hover" lazy-load="true"
                @click="onClick(item, index)" />
        </block>
        <u-parse v-else-if="detail.type == 3" :content="detail.content" />

        <bottom1 v-if="detail.sharepagecontrol.style_bottom == '默认黑色预约报名样式'" />
        <view v-else style="height: 10px;" />
    </view>
</template>

<script>
import { viewImage } from "../../../utils/settleFiles";
import bottom1 from "../../../components/bottomModules/bottom1.vue";
export default {
    name: "advertisingPage",
    components: { bottom1 },
    data() {
        return {
            detail: {
                type: 1,//1图片 2视频 3图文
                content: ""
            },
        }
    },
    methods: {
        getDetail(id) {
            return new Promise((resolve, reject) => {
                this.$Http.basic({
                    "id": "20240408131902",
                    "content": {
                        "sat_sharematerialid": id
                    }
                }).then(res => {
                    console.log('获取长图文详情', res)
                    if (this.cutoff(res.msg)) return;
                    this.detail = res.data;
                    resolve(res.data)
                    uni.setNavigationBarTitle({
                        title: res.data.title,
                    })
                })
            })

        },
        onClick(item, index) {
            console.log(item, index)
            if (item.jumpurl) {
                uni.navigateTo({
                    url: item.jumpurl,
                    fail: (fail) => {
                        viewImage(item.attinfos[0].url)
                    },
                })
            } else {
                viewImage(item.attinfos[0].url)
            }
        }
    },
}
</script>

<style lang="scss" scoped>
.image {
    width: 100vw;
    margin-top: 10px;
}

.image:first-child {
    margin-top: 0;
}
</style>