<template>
  <div class="banner-box">
    <div class="banner space-between">
      <div :class="index+1==list.length ?'banner-item item-end' : 'banner-item'" :key="index" v-for="(item,index) in list" @click="goToPage(item)">
        <img class="banner-img" :src="item.imageUrl"/>
        <span class="banner-text fs24">
          {{item.name}}
         <!--  <i></i> -->
        </span>

      </div>
    </div>
  </div>
</template>

<script>
 import { jumpWebPageUrl } from '@/utils/index'
export default {
  name: 'YqyHomeBanner',
   data(){
    return {
      list:[],
    }
  },
  mounted(){
    
    this.list = this.parmData;
   // this.getData();
  },
  props:{
     
      parmData:{
        type:Array,
        default:[]
      },
      userToken:{
        default:'',
        type:String
      }
  },
  methods: {
    goToPage(itemData){
      let paramList = this.setEventByModuleCode(itemData);
      //console.log(paramList)
      //alert(this.userToken);
      

      if(itemData.appModuleInfo && itemData.appModuleInfo.code == 'M500'){
        //let url = jumpWebPageUrl+'activity?categoryId=1';
        let url = '';
        if(itemData.appModuleInfo.paramList.length>0){
          if(itemData.appModuleInfo.paramList[0].value.indexOf('activity') > -1){
            url = itemData.appModuleInfo.paramList[0].value + '?categoryId=1';
          }
          if(itemData.appModuleInfo.paramList[0].value.indexOf('teachers') > -1){
            url = itemData.appModuleInfo.paramList[0].value+'?userToken='+this.userToken;
          }
          //alert(url);
          
        }
        

        itemData.appModuleInfo.code = 'M300';
        let item = {
            "title":"",
            "imageUrl":"",
            "appModuleInfo":{
                "code":itemData.appModuleInfo.code,
                "type":4,
                "name":"wwww",
                "paramFlag":1,
                "paramList":[
                    {
                        "key":"pageUrl",
                        "value": url,
                        "type":4,
                        "seqNo":1
                    },{
                        "key":"showTitle",
                        "value": false,
                        "type":1,
                        "seqNo":2
                    },{
                        "key":"title",
                        "value": '',
                        "type":1,
                        "seqNo":3
                    }
                ]
            }
        };
        itemData = item;
      }
      //itemData.appModuleInfo.code = 'M300'

     

      
      //alert(JSON.stringify(itemData))

      rocNative.dispatchEventByModuleCode({
          modeCode: itemData.appModuleInfo.code,
          jsonString: itemData.appModuleInfo.paramList
      })
      // let paramList = this.setEventByModuleCode(itemData);
      // console.log(paramList);

      // if(itemData.appModuleInfo.code != 'M400'){
      //   //alert(itemData.appModuleInfo.code);
      //   rocNative.dispatchEventByModuleCode({
      //       modeCode: itemData.appModuleInfo.code,
      //       jsonString: paramList
      //   })
      // }else{

      //     rocNative.gotoNewWebActivity({
      //         pageUrl: jumpWebPageUrl+'activity?categoryId'+paramList[0].query.categoryId
      //     })
      //   // this.$router.push({
      //   //     path: paramList[0].url,
      //   //     query:paramList[0].query
      //   // })
      // }
      this.pageBurialPoin({
        menuLevel:1,
        menuCode:'m_home',
        functionCode:'f_icon',
        actionCode:'c_icon_files',
        labelId:itemData.id,
        labelValue :itemData.name,
      })
      
    
    }
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
@import '../../style/mixin.scss';
@import '../../style/global.scss';
html,body{
  width: px2rem(375px);
  height: px2rem(100%);
  background-color: #F8F8F8;
}
.banner-box{
  position: relative;
  height: px2rem(47px);
  padding:0 px2rem(15px);
}
.banner{
  width: px2rem(345px);
  height: px2rem(74px);
  background-color: #fff;
  position: absolute;
  top:-(px2rem(27px));

  padding: px2rem(15px) px2rem(10px);
  box-shadow: 0 px2rem(1px) px2rem(5px) RGBA(49, 127, 119, 0.1);
  border-radius: px2rem(3px);
  z-index: 2;
}
.banner-item{
  width: px2rem(50px);
  display: inline-block;
  margin-right: px2rem(18px);
  text-align: center;

}
.item-end{
  margin-right: 0
}
.banner-img{
  width: px2rem(22px);
  height: px2rem(22px);
  margin: 0  auto;
  display:block;
  
}
.banner-text{
  margin-top:px2rem(5px);
  display: block;
  position: relative;
  font-size: px2rem(12px);
  text-align: center;
  width: 100%;
}
.banner-text i{
  width: px2rem(4px);
  height: px2rem(4px);
  display: inline-block;
  background: #FB5B52;
  border-radius: 100%;
  position: absolute;
  top:0;
  right: -4px

}
</style>
