<template>
  <div class="dashboard-container">
    <div class="dashboard-editor-container">
      <panel-group @handleSetLineChartData="handleSetLineChartData" />
      <jrcp ref="jrcp" />
      <div class="mclz-card">
        <h5 style="padding: 10px 15px; text-align: left">名厨亮灶</h5>
        <el-carousel :interval="5000" indicator-position="none" type="card" class="carousel_mclz">
          <el-carousel-item v-for="(arr,index) in data" :key="index" class="carousel_mclz">
            <easy-player live muted autoplay :video-url="arr.path" class="carousel_mclz medium" />
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
  </div>
</template>

<script>
import PanelGroup from './dashboard/PanelGroup'
import jrcp from './dashboard/jrcp'
import EasyPlayer from '@easydarwin/easyplayer'
import { getVideo } from '@/api/home'
const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}

export default {
  name: 'Dashboard',
  components: {
    PanelGroup,
    jrcp,
    EasyPlayer
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      data: []
    }
  },
  created() {
    this.getPanelGroup()
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    },
    getPanelGroup() {
      getVideo().then(res => {
        // const array = []
        // for (let i = 0; i < res.length; i++) {
        //   array.push(res.slice(i, (i + 1)))
        // }
        // this.data = array
        this.data = res
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .dashboard-editor-container {
    padding: 32px;
    background-color: rgb(240, 242, 245);
    position: relative;

    .github-corner {
      position: absolute;
      top: 0;
      border: 0;
      right: 0;
    }

    .chart-wrapper {
      background: #fff;
      padding: 16px 16px 0;
      margin-bottom: 32px;
    }
  }

  @media (max-width:1024px) {
    .chart-wrapper {
      padding: 8px;
    }
  }
  .el-carousel__item easy-player {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 200px;
    margin: 0;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }

  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
  .mclz-card{
    background: white;
    /* margin-bottom: 10px; */
    text-align: center;
    height: 460px;
  }
  .mclz-video{
    width: 31%;
    margin: 20px auto;
  }

  .carousel_mclz{
    height: 340px;
  }
</style>
