<template>
    <view class="cu-modal" :class="{ show: visible }">
        <view class="rule-mask" @click="close"></view>
        <view class="cu-dialog" style="background-color: transparent; width: 100%">
            <view class="relative wrapper">
                <image :src="ossurl.welfare.toys.rewardBg" class="rule" />

                <view class="prize">
                    <view class="prize_scroll">
                        <view
                            v-for="(item, index) in prizeList"
                            :key="item.spuId"
                            class="prize_item"
                            :class="{ rightMar: (index + 1) % 3 == 0 }"
                        >
                            <view class="prize_img">
                                <image :src="item.cover" class="width100 height100" mode="aspectFit"/>
                            </view>
                            <view class="prize_text line-ellipsis">{{ item.name }}</view>
                        </view>
                    </view>
                </view>
            </view>
            <view class="paddingT30 flex-align-center">
                <view class="close cuIcon-close" @click="close"></view>
            </view>
        </view>
    </view>
</template>

<script>
    import ossurl from '@/utils/ossurl'
    export default {
        props: {
            luckKing: Object
        },
        data() {
            return {
                ossurl,
                visible: false,
                type: 5,
                prizeList: [] // 抽到的奖励
            }
        },
        methods: {
            show(data) {
                this.visible = true
                this.$parent.$parent.$parent.lock = true
                this.prizeList = data
            },
            close() {
                this.visible = false
                this.$parent.$parent.$parent.lock = false
            }
        }
    }
</script>

<style lang="scss" scoped>
    .rule-mask {
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
    }
    .close {
        width: 64rpx;
        height: 64rpx;
        background: #d8d8d8;
        font-size: 32rpx;
        text-align: center;
        line-height: 64rpx;
        color: #444;
        border-radius: 50%;
    }
    .wrapper {
        z-index: 1001;
        width: 652rpx;
        height: 904rpx;
        margin: 0 auto;
        .rule {
            width: 100%;
            height: 100%;
        }

        .prize {
            position: absolute;
            top: 157rpx;
            left: 54rpx;
            right: 54rpx;

            height: 715rpx;
            overflow-y: scroll;
            .prize_scroll {
                width: 100%;
                display: flex;
                flex-direction: row;
                flex-wrap: wrap;
                justify-content: flex-start;
            }
            .prize_item {
                width: 160rpx;
                height: 233rpx;
                margin-right: 20rpx;
                margin-top: 23rpx;
                .prize_img {
                    width: 160rpx;
                    height: 200rpx;
                }
                .prize_text {
                    color: #B58100;
                    margin-top: 12rpx;
                    text-align: center;
                }
            }
            .rightMar {
                margin-right: 0;
            }
        }
    }
</style>
