<template>
    <div>
        <div class="flex flex-mean" style="background-color: #FFFFFF;">
            <van-search class=".flex flex-1" v-model="searchValue" left-icon="" shape="round" placeholder="请输入搜索关键词" />
            <van-button round type="info" class="custom-button font-size13 m-top10 m-right12 ">查询</van-button>
        </div>
        <div class='container'>
            <van-list  class="card" :offset="50">
               
                <div class="activity_content " v-for="(item, index) in discussionList" :key="index"      >
          
                    <div class="van-multi-ellipsis--l2 m-bottom10"     @click="$router.push({ path: `/discusionDetail` })">
                        {{ item.eventContent }}
                    </div>
                    <div class="flex flex-end">
                        <div class=""><img src="@/assets/images/icons/resi.png" class="img_17"> 参加{{ item.total }}
                        </div>
                        <div><img src="@/assets/images/icons/support.png" class="img_17" @click="handelClicsupport(item.eventId)">支持{{ item.supportNum }}</div>
                        <div><img src="@/assets/images/icons/oppose.png" class="img_17" @click="handelClicopposeNum(item.eventId)">反对{{ item.opposeNum }}</div>
                    </div>
                </div>
            </van-list>
            <register-dialog v-if="showRegister" @close="showRegister = false"></register-dialog>

        </div>
    </div>


</template>

<script>
import { communityActivity,icEventOldDiscuss,handelClicsupport } from '@/api/home';
import registerDialog from '@/components/registerDialog';

export default {
    data() {
        return {
            discussionList: [
            ],
            pageSize: 5,
            pageNo: 1,
            agencyId: null,
            finished: false,
            loading: false,
            showRegister: false,
            searchValue: "",
            userId:""
        };
    },
    created() {
        this.agencyId = this.$store.state.app.agencyId;
        this.userId = this.$store.state.app.appId;
        this.icEventOldDiscuss();
    },
    methods: {
        async handelClicsupport(data){
            let parm = {
                eventId:data,
                agencyId: this.agencyId,
                userId: this.userId,
                opinionFlag:0
            }
            console.log(parm);
            let res = await handelClicsupport(parm)
            this.icEventOldDiscuss()
        
        },
        async handelClicopposeNum(data){
            let parm = {
                eventId:data,
                agencyId: this.agencyId,
                userId: this.userId,
                opinionFlag:1
            }
            console.log(parm);
            let res = await handelClicsupport(parm)
            this.icEventOldDiscuss()
        
        },
        async icEventOldDiscuss(){
            let parm = {
                pageSize: 10,
                pageNo: 1,
                agencyId: null,
                icEventId:null
            }
           
            let res = await icEventOldDiscuss(parm)

            if (res) {
                
              console.log(res);
              this.discussionList = res.list
            }
           
           
        },
   
        handelClickJump(path) {
            if (path === 'activityDetail') {
                if (this.$store.state.app.userInfo.mobile) {
                    this.$router.push({ path: `/${path}` });
                } else {
                    this.showRegister = true;
                }
            }

        }
    },
    components: { registerDialog },
    computed: {},
    watch: {},
}
</script>

<style lang='less' scoped>
.custom-button {
    width: 60px;
    height: 33px;
}

.activity_content {
    padding-bottom: 10px;
    box-sizing: border-box;
    width: 100%;
    border-bottom: 1px solid #EAEAEA;
    margin-top: 14px;
    min-height: 50px;

    .img {
        width: 231px;
        height: 33px;
        margin: 5px 3px 0 3px;
    }

    &:last-child {
        border-bottom: none;
    }


    .content {

        width: 325px;
        height: 40px;
        font-family: PingFang SC;
        font-weight: 500;
        font-size: 16px;
        color: #333333;
        line-height: 23px;
    }

    .dianzan {
        width: 325px;
        height: 20px;
        display: flex;
        font-size: 13px;
        color: #AAAAAA;
        flex-direction: row;
        justify-content: space-evenly;
        align-items: center;

        .img {
            width: 14.5px;
            height: 15px;
        }
    }


}

.header {}

.header .input_search {
    width: 279px;
    height: 33px;
    background: rgba(193, 193, 193, 0.16);
    border-radius: 17px;
    // flex: 1;
    color: #333333;
    border: none;
    /* 取消边框 */
    margin-left: 10px;
}

.header .btn_search {
    width: 60px;
    height: 33px;
    background: #3974F6;
    border-radius: 17px;
    font-family: PingFang SC;
    font-weight: 500;
    font-size: 14px;
    color: #FFFFFF;
    line-height: 23px;
    border: none;
    /* 取消边框 */
    margin-right: 10px;
}
</style>
