<template>
  <div class="el-resource_statistics_pc_2">
    <div class="resource_statistics_pc_2">
   <div class="container">
      <div class="row">
         <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="resource-title clearfix">
               <span class="sp1">贡献榜</span>
               <!--<span class="sp2"><a href="">查看更多~</a></span>-->
            </div>
            <div class="resource-gongxian">
               <div class="row">

                  <div v-for="(list,i) in sites" :key="i" class="col-lg-4 col-md-4 col-sm-6 col-xs-12"><!--循环-->
                     <div class="gongxian-part">
                        <span class="sp1">
                           <img class="sp1-logo" src="../../theme-chalk/src/images/zyk-gx-logo.png" alt="">
                           <span class="sp1-info">
                              <a href="" class="a1">{{list.siteName}}</a>
                              <span class="sp1-list-a">
                                 <a href="javascript:void(0)" class="a2">{{list.resNum | $num }}个资源</a>
                                 <a href="javascript:void(0)" class="a2">{{list.csNum  | $num }}个课程</a>
                              </span>
                           </span>
                        </span>
                        <ul class="ul1">
                           <li v-for="(item,j) in list.resource" :key="j"><a href="javascript:void(0)">{{item.resName}}</a></li>
                        </ul>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </div>
</div>
  </div>
</template>

<script>
   import $ from 'fy-kit';
  import formMixin from '../../../src/mixins/formMixin';
  import lenye_base from 'lenye_base';
  import msg from '../../message';
export default {
  name: 'ElResourceStatisticsPc2',
  mixins: [formMixin],
  model: {},
  data(){
    return {
      sites:[]
    }
   },
   mounted() {
     this.init();
   },
  components:{
    msg
   },
   filters:{
     $num(val){
       if(val){
         return Number(val)
       }else{
         return 0;
       }
     }
   },
   computed: {},
   methods: {
     async resource(sites){
        let res =  await  $.util
        .ajax(
          lenye_base.base_data.getapiUrl() +
            "/resource-service/api/resResource/queryShowPage.do",
          lenye_base.base_data.getformatting({
            rows: 3,
            page:1,
            sites,
            resType:1,  //课程
            orderType:2,  //上传时间倒叙
          })
        )
        if (res.success == "1") {
           return res.data;
          } else {
            msg.error(res.message);
          }
      },
     async init(){
       let res=  await $.util
        .ajax(
          lenye_base.base_data.getapiUrl() +
            "/lucene-service/common/pageQuery.do",
          lenye_base.base_data.getformatting({
            indexName:'resourcecount',
            queryType: 1,
            page:1,
            rows:3,
            sorts:'totalNum=1'
          })
        )
       if (res.success == "1") {
            res.data.forEach((list)=>{
              list['resource'] = this.resource(list.siteId);
            })
            this.sites = res.data;
          } else {
            msg.error(res.message);
          }
     }
   },
};
</script>
