<template>
    <div class="active_show_detail_pc_2">
        <!--弹出-->
        <upload v-show="bool==true" ref="upload" :isUpload="oolean" :type="type" :wksId="wksId"></upload>
        <div class="container">
            <div class="row">
                <div class="col-lg-6 col-md-5 col-xs-12 col-sm-12">
                    <span class="class-detail-pic"><img :src="actDetail.actPhoto" alt=""></span>
                </div>
                <div class="col-lg-6 col-md-7 col-xs-12 col-sm-12">
                    <div class="class-detail-info">
               <span class="title">{{actDetail.actTitle}}
                  <span class="twobtn">

                      <a  @click="delcill()" v-if="collId==1" class="share-icon"><img src="../../theme-chalk/src/images/class-detail-faving.png" alt=""></a>
                      <a  @click="addcill()" v-else class="share-icon"><img src="../../theme-chalk/src/images/class-detail-fav.png" alt=""></a>
                     <!--<a  class="share-icon"><img src="../../theme-chalk/src/images/class-detail-share.png" alt=""></a>-->
                  </span>
               </span>
                        <ul class="detail-ul clearfix">
                            <li><span>活动时间：</span>{{actDetail.actStartDate}}-{{actDetail.actEndDate}}</li>
                            <li><span>创建人：</span>{{actDetail.createByName}}</li>
                            <li><span>活动类型：</span><span v-if="actDetail.actType==1">宣传活动</span><span
                                    v-else-if="actDetail.actType==2">评比类活动</span></li>
                        </ul>
                        <div class="detail-tongji">
                            <span class="sp1" v-if="actDetail.actSignupNum==''">参加人次：0人次</span>
                            <span class="sp1" v-else>参加人次：{{actDetail.actSignupNum}}人次</span>
                            <span class="sp3" v-show="actDetail.actType!=1">投票票数：{{actDetail.actVoteLimitNum}}票</span>
                        </div>
                        <span class="detail-btn" v-show="actDetail.actType!=1" v-if="selectboolId==1 && actDetail.isEnd==0"
                              @click="upload(actDetail.actId,bool)">
                  <a>上传作品</a>
               </span>
                        <span class="detail-btn" v-else>
                  <a v-show="actDetail.actType!=1" @click="baoming()">立即报名</a>
               </span>

                        <!-- <span class="detail-btn" >
                           <a >上传作品</a>
                        </span> -->
                    </div>
                </div>
            </div>
        </div>
        <!--tab页-->
        <div class="et4-class">
            <div class="container">
                <div class="row">
                    <div class="col-lg-9 col-md-8 col-sm-12 col-xs-12">
                        <div class="et4-class-body">
                            <div class="et4-class-body-hd">
                                <ul>
                                    <li @click="clvClick(0)" :class="{active:cslShow===0}">活动简介</li>
                                    <li @click="clvClick(1)" :class="{active:cslShow===1}">活动内容</li>
                                    <li @click="clvClick(2)" :class="{active:cslShow===2}"><p
                                            v-if="actDetail.actType==1">成果({{actList.totalCount}})</p>
                                        <p v-else-if="actDetail.actType==2">活动作品({{actList.totalCount}})</p></li>
                                </ul>
                            </div>
                            <div class="et4-class-body-bd">
                                <div class="et4-class-cont" v-show="cslShow===0">
                                    <p v-html="actDetail.actInfo"></p>
                                </div>
                                <div class="et4-class-cont" v-show="cslShow===1">
                                    <p v-html="actDetail.actContent"></p>
                                </div>
                                <div class="et4-active-works" v-show="cslShow===2">
                                    <div class="row">
                                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                            <div class="activeworks-search">
                                                <!-- <ul class="activeworks-search-ul">
                                                   <li class="active"><a href="">最新<span class="iconfont icon-shunxu"></span></a></li>
                                                   <li><a href="">票数<span class="iconfont icon-shunxu"></span></a></li>
                                                </ul> -->
                                                <span class="search-body clearfix" >
                                         <input type="text" class="inp1" placeholder="输入作品编号或作者姓名" v-model="number">
                                         <input type="button" class="btn1" value="搜索" v-show="actDetail.actType==2" @click="selectActid()">
                                      </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12"
                                             v-for="(item,index) in actList.data" :key="index"><!--循环-->
                                            <div class="activeworks-list" v-if="actDetail.actType==2">
                                       <span class="sp1" @click="zpDetail(item.wksId)">
                                          <img  :src="item.wksPhoto" alt="">
                                          <span class="class-pic-hover" >作者：{{item.wksAuthor}}<br>票数：{{item.wksVoteNum}}</span>
                                       </span>
                                                <span class="sp2" ><i>编号：</i>{{item.wksCode}}</span>
                                                <span class="sp2"><i>名称：</i><a >{{item.wksName}}</a></span>
                                                <span class="sp3"><i>作者：</i>{{item.wksAuthor}}</span>
                                                <span class="sp3"><i>票数：</i>{{item.wksVoteNum}}</span>
                                                <span class="sp4" >
<!--                                          <a href="">分享</a>-->
                                          <a @click="toupiao(item.wksId)">投票</a>
                                       </span>
                                            </div>
                                            <div class="activeworks-list" v-else>
                                       <span class="sp1" @click="cgDetail(item.rstId)">
                                          <img :src="item.wksPhoto" alt="">
<!--                                          <span class="class-pic-hover" >作者：{{item.wksAuthor}}<br>票数：{{item.wksVoteNum}}</span>-->
                                       </span>
<!--                                                <span class="sp2"><i>编号：</i>{{item.wksCode}}</span>-->
                                                <span class="sp2"><i>名称：</i><a >{{item.rstTitle}}</a></span>
<!--                                                <span class="sp3"><i>作者：</i>{{item.wksAuthor}}</span>-->
<!--                                                <span class="sp3"><i>票数：</i>{{item.wksVoteNum}}</span>-->
<!--                                                <span class="sp4" >-->
<!--                                          <a href="">分享</a>-->
<!--                                          <a href="">投票</a>-->
                                       </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="pingjia-page">
                                        <el-pagination
                                                background
                                                layout="total, prev, pager, next"
                                                @prev-click="prevClick"
                                                @next-click="nextClick"
                                                :page-size="actrows"
                                                @current-change="sizeChange"
                                                :total="actList.totalCount"
                                        >
                                        </el-pagination>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-3 col-md-4 col-sm-12 col-xs-12 et4-class-right-body">
                        <div class="et4-class-right">
                            <div class="et4-class-right-title">最新活动<span><a href="/activelist">更多</a></span></div>
                            <div class="et4-course-part" v-for="item in hotList" :key="item.actId">
                                <a :href="'/activedetail?id='+item.actId"><img :src="item.actPhoto" alt="">
                                    <span>{{item.actTitle}}</span></a>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--活动详情展示组件2结束-->

    </div>
</template>

<script>
    import {httpPost} from "../../../src/utils/utils";
    import lenye_base from 'lenye_base';
    import $ from "fy-kit";
    import msg from '../../message';
    import upload from '../../active-updata-pc/src/main'

    export default {
        components: {upload},
        name: 'ElActiveShowDetailPc2',
        data() {
            return {
                actId: "98c5cdc9a598456987382b7715c21f80",//获取页面传入的idb25e5e170edc4727b6f43be7febd4c19
                bool: false,
                actDetail: {},//详情
                cslShow: 0,//分类显示隐藏

                actList: [],//作品列表
                // docUrl: "", //头像
                // default_img: 'this.src="' + require("../../theme-chalk/src/../../theme-chalk/src/images/jslndx-footer-icon6.png")+ '"',
                //作品分页
                actrows: 3,
                actpage: 1,

                number: '',//检索编号
                selectboolId: '',
                //活动列表
                hotList: {},
                actType:null,
                collId:'',
                type:'',
                wksId:'',
                oolean:true,

            }
        },
        created() {
            this.actId= $.util.urlParams('id')
            if(!this.actId){
                this.actId= $.util.urlParams('actId')
            }

        },
        mounted() {
            this.getDetail();
            if (lenye_base.user_data.getuserData() && lenye_base.user_data.getuserData()!='undefined') {
                this.selectbool();
                this.cillent();
            }
            // this.gethotList();
            // this.getall();
        },
        methods: {
            //获取活动详情
            getDetail() {
                const that = this;
                httpPost(
                    lenye_base.base_data.getapiUrl() +
                    "/activity-service/common/actActivity/queryById.do",
                    lenye_base.base_data.getformatting({
                        actId: that.actId
                    }),
                    function (data) {
                        that.actDetail = data.data
                        if (data.data.actType == 1) {
                            httpPost(
                                lenye_base.base_data.getapiUrl() +
                                "/activity-service/common/actResults/queryPage.do",
                                lenye_base.base_data.getformatting({
                                    actId: that.actId,
                                    rows: that.actrows,
                                    page: that.actpage,
                                }),
                                function (data) {
                                    that.actList = data
                                }
                            )

                        } else if (data.data.actType == 2) {
                            httpPost(
                                lenye_base.base_data.getapiUrl() +
                                "/activity-service/common/actActivityWorks/queryPageByActId.do",
                                lenye_base.base_data.getformatting({
                                    actId: that.actId,
                                    rows: that.actrows,
                                    page: that.actpage,
                                    wksNameOrCode:that.number
                                }),
                                function (data) {
                                    that.actList = data
                                }
                            )
                        }
                    }
                )
            },
            //获取活动作品分页
            // getclapage() {
            //
            //     console.log(this.actType)
            //
            //
            // },
            //判断是否报名
            selectbool() {
                const that = this;
                httpPost(
                    lenye_base.base_data.getapiUrl() +
                    "/activity-service/api2/actActivityMemer/isSignUp.do",
                    lenye_base.base_data.getformatting({
                        list:[
                            {
                                actId: that.actId,
                                custId:lenye_base.user_data.getuserData().custId
                            }
                        ]
                    }),
                    function (data) {
                        that.selectboolId = data.data[0].status
                    }
                )

            },
            //判断是否收藏
            cillent(){
                const that = this;
                httpPost(
                    lenye_base.base_data.getapiUrl() +
                    "/interact-service/api2/itaCollection/isCollect.do",
                    lenye_base.base_data.getformatting({
                        collects:[
                            {type:'act',objId: that.actId,custId:lenye_base.user_data.getuserData().custId},
                            ]
                    }),
                    function (data) {
                        that.collId = data.data[0].status
                    }
                )
            },
            //统计量
            // getall(){
            //     const that = this;
            //     httpPost(
            //         lenye_base.base_data.getapiUrl() +
            //         "/interact-service/common/itaInteractionTimes/queryPageByCritical.do",
            //         lenye_base.base_data.getformatting({
            //            type:'act',
            //             objId: that.actId,
            //         }),
            //         function (data) {
            //             that.collList = data.data[0]
            //         }
            //     )
            // },
            //获取活动列表
            // gethotList() {
            //     const that = this;
            //     httpPost(
            //         lenye_base.base_data.getapiUrl() +
            //         "/activity-service/common/actActivity/queryPageByCriteria.do",
            //         lenye_base.base_data.getformatting({
            //             actId: that.actId,
            //             rows: 3,
            //             sorts: 'actPubDate=1'
            //         }),
            //         function (data) {
            //             that.hotList = data.data
            //         }
            //     )
            // },
            selectActid() {
                this.getDetail();
            },
            clvClick(sId) {
                this.cslShow = sId
            },
            prevClick(page) {
                this.actpage = page
                this.getDetail();
            },
            nextClick(page) {
                this.actpage = page
                this.getDetail();
            },
            sizeChange(page){
                this.actpage = page
                this.getDetail();
            },
            upload(actId, bool) {

                this.actId = actId
                //   console.log(bool)
                //   if(bool == true){
                this.bool = !this.$refs.upload.close(1);
                //   console.log(this.bool)
                //   }else{
                //      this.bool= bool
                //   }
            },
            baoming(){
                if (lenye_base.user_data.getuserData() && lenye_base.user_data.getuserData()!='undefined') {
                     window.location.href='/projectorderpay?id='+this.actId+'&type=4';
                }else {
                    msg.warning("请先登录");
                }
            },
            delcill(){
                const that = this;
                httpPost(
                    lenye_base.base_data.getapiUrl() +
                    "/interact-service/api2/itaCollection/delete.do",
                    lenye_base.base_data.getformatting({
                        objId: that.actId,
                        type:'act',
                    }),
                    function (data) {
                        if(data.success === '1'){
                           that.cillent();
                            // that.getall()
                        }
                    }
                )
            },
            addcill(){
                console.log(lenye_base.user_data.getuserData())
                if (lenye_base.user_data.getuserData() && lenye_base.user_data.getuserData()!='undefined') {
                    const that = this;
                    httpPost(
                        lenye_base.base_data.getapiUrl() +
                        "/interact-service/api2/itaCollection/insert.do",
                        lenye_base.base_data.getformatting({
                            objId: that.actId,
                            type:'act',
                            siteId:lenye_base.user_data.getuserData().siteId
                        }),
                        function (data) {
                            if(data.success === '1'){
                                that.cillent();
                                // that.getall()
                            }
                        }
                    )
                }else {
                    msg.warning("请先登录");
                }
            },
            toupiao(id){
                if (lenye_base.user_data.getuserData() && lenye_base.user_data.getuserData()!='undefined') {
                    const that = this;
                    httpPost(
                        lenye_base.base_data.getapiUrl() +
                        "/activity-service/api2/actActivityWorks/vote.do",
                        lenye_base.base_data.getformatting({
                            wksId: id,
                        }),
                        function (data) {
                            if(data.success === '1'){
                                that.getDetail();
                            }
                        }
                    )
                }else {
                    msg.warning("请先登录");
                }

            },
            // 作品
            zpDetail(id){
                this.wksId = id
                this.bool = !this.$refs.upload.close(1);
                console.log(111)
                this.type='pro'
                this.oolean=false
                this.$refs.upload.detail(id);
            },
            //成果
            cgDetail(id){
                this.wksId = id
                this.bool = !this.$refs.upload.close(1);
                console.log(111)
                this.type='ach'
                this.oolean=false
                this.$refs.upload.detail1(id);
            }
        },
    };
</script>
