<!--
此模块为c端投票页
channelId 引用id
userId 用户id
type 投票来源(用于统计每一票的来源)
  -->
<template>
    <div class="vote-container">
        <vote-item v-for="item in voteData" :key="item" :id="item" :include_id="channelId" :type="type" :user_id="userId"></vote-item>
    </div>
</template>

<script>
    import {getConfigVote} from '@/plugins/API/apiVote'
    import voteItem from './voteItem'

    export default {
        components: {
            voteItem,
        },
        props: {
            channelId: {},
            userId: {},
            type: {},
        },
        data () {
            return {
                voteData: []
            }
        },
        mounted(){
            this.$Bus.$on('bus-voteList', this._changeVoteList)
            this.getConfigVote()
        },
        methods: {
            async getConfigVote() {
                const res = await getConfigVote({include_id: this.channelId, type: this.type});
                if(res.code == 200 && res.errorCode == 0){
                    this.voteData = res.data || [];
                }
            },
            _changeVoteList(data){
                this.voteData = data.voteIds;
            },
        },
        beforeDestroy(){
            this.$Bus.$off('bus-voteList', this._changeVoteList)
        },
    }
</script>
<style lang="less" scoped>
.vote-container{
    background-color: #F0F1F3;
    height: 100%;
    overflow: auto;
}
</style>
