<template>
    <section class="homeAdvert" v-if='bannerArr.length'>
       <el-carousel :interval="5000" arrow="always" height="200">
                <el-carousel-item v-for="(item,index) in bannerArr" :key="index">
                <img :src="item.pic" @click="applidetaillink(item)"/>
                </el-carousel-item>
            </el-carousel>
    </section>
</template>
<script>
import { Loading } from 'element-ui';
export default {
    inject: [
     'addTab', 
    ],
    data(){
        return{
          bannerArr:[], //广告
        }
    },
    mounted() {
        this.AppMarketBannerlist()//广告列表
    },
    methods: {
        AppMarketBannerlist(){//广告列表
            // let options={
            //      target:document.querySelector(".homeAdvert"),                 
            //      text: '加载中...',
            //      spinner: 'el-icon-loading',
            // }
            // const loading = Loading.service(options);//开始加载
            this.$api.AppMarketBannerlistApi({},{                
                onSucess: response => {
                //    this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
                //        loading.close();//关闭加载
                //    });
                   console.log("banner______________",response.data.data.data)
                   if(response.data.data.data){
                       let Arry=[]
                       response.data.data.data.forEach(item=>{
                           var obj={}
                               obj.name=item.items['__f1dc2wtiu1VnfSPzQse'].value //标题
                               obj.pic=item.items['__cMLE2QENXQjNp1sWHE6'].value&&JSON.parse(item.items['__cMLE2QENXQjNp1sWHE6'].value)[0].path //图片
                               obj.appid=item.items['__qPv375wKiySlNqrRlEi'].value //应用id-跳转到详情页面
                               obj.imgsort=item.items['__XkErrW7l1lWDQVE29vq'].value //图片排序
                           Arry.push(obj)    
                       })
                       this.bannerArr=Arry
                       console.log(this.bannerArr)
                   }
                }
            })
        },
        applidetaillink(obj){//进入详情
           var param={
            id:"applicationMarket",
            name:'应用市场',
            linkType:'applicationMarket',
            actionContent:"",
            icon:"-1",
            key:""
          }
          this.addTab(param)//监听传递给父元素---重要父子传递         
        },        
    },
}
</script>
<style lang="scss">
.homeAdvert{
    img{height: 115px; width:690px;cursor: pointer; border-radius:8px;}
    .el-carousel__container{height: 115px!important;}    
}
</style>