<template>
  <div class="page">
    <el-row>
      <el-col :span="24">
        <el-card class="box-card">
          <div slot="header">
            <span class="card-title">订单数据</span>
          </div>
          <div class="flex">
            <div class="orderData flex ac">
              <div class="orderData-left flex ac fs">
                <i style="font-size: 40px; color:#1ABC9C" class="el-icon-tickets"></i>
                <div>
                  <div>今日订单总数</div>
                  <div>200</div>
                </div>
              </div>
              <div class="orderData-right oneflex flex jw ae">
                <div class="orderData-right-item">
                  <span>待核销订单</span>
                  <span>(10)</span>
                </div>
                <div class="orderData-right-item">
                  <span>已核销订单</span>
                  <span>(10)</span>
                </div>
                <div class="orderData-right-item mt">
                  <span>已完成订单</span>
                  <span>(10)</span>
                </div>
                <div class="orderData-right-item mt">
                  <span>待退款订单</span>
                  <span>(10)</span>
                </div>
              </div>
            </div>
          </div>
        </el-card></el-col
      >
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-card class="box-card">
          <div slot="header">
            <span class="card-title">商品总览</span>
          </div>
          <div class="product-card flex js ac">
            <div class="product-card-item">
              <div class="number">100</div>
              <div>已下架</div>
            </div>
            <div class="product-card-item">
              <div class="number">100</div>
              <div>已下架</div>
            </div>

            <div class="product-card-item">
              <div class="number">100</div>
              <div>已下架</div>
            </div>

            <div class="product-card-item">
              <div class="number">100</div>
              <div>已下架</div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card class="box-card">
          <div slot="header">
            <span class="card-title">用户总览</span>
          </div>
          <div class="product-card flex js ac">
            <div class="product-card-item">
              <div class="number">100</div>
              <div>今日新增</div>
            </div>
            <div class="product-card-item">
              <div class="number">100</div>
              <div>昨日新增</div>
            </div>

            <div class="product-card-item">
              <div class="number">100</div>
              <div>本月新增</div>
            </div>

            <div class="product-card-item">
              <div class="number">100</div>
              <div>会员总数</div>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-card class="box-card">
          <div slot="header">
            <span class="card-title">订单统计</span>
          </div>
          <div class="orderStatistics-card flex">
            <div class="orderStatistics-card-left flex column jc">
              <div class="orderStatistics-card-left-item">
                <div class="orderStatistics-card-left-item-title">本月订单总数</div>
                <div class="orderStatistics-card-left-item-number">10000</div>
                <div class="orderStatistics-card-left-item-title">10% 同比上周</div>
              </div>
              <div class="orderStatistics-card-left-item mt">
                <div class="orderStatistics-card-left-item-title">本周订单数量</div>
                <div class="orderStatistics-card-left-item-number">10000</div>
                <div class="orderStatistics-card-left-item-title">10% 同比上周</div>
              </div>
            </div>
            <div class="orderStatistics-card-right oneflex">
              <div class="flex ac">
                <div style="width: 100%;">近一周订单统计</div>
                <el-date-picker
                  v-model="createTime"
                  type="daterange"
                  align="right"
                  unlink-panels
                  value-format="yyyy-MM-dd"
                  range-separator="~"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions"
                >
                </el-date-picker>
                 <el-button type="primary" @click="userSearchs" style="margin-left:10px">查询</el-button>
              </div>

              <div style="width: 100%; height:500px;margin-top:20px" id="chart"></div>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import echarts from 'echarts'

export default {
  filters: {},
  data() {
    return {
      myChart: null,
      createTime: '',
      pickerOptions: {
        shortcuts: [
          {
            text: '今天',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '最近一周',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
              picker.$emit('pick', [start, end])
            }
          }
        ]
      }
    }
  },
  created() {
    this.init()
  },
  mounted() {
    this.initChart('chart')
  },
  methods: {
    initChart(id = 'chart') {
      this.myChart = echarts.init(document.getElementById(id))
      this.myChart.setOption({
        color: ['#4370da'],
        grid: {
          x: 50,
          y: 25,
          x2: 30,
          y2: 35
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['07-01周六', '07-02周日', '07-03周一', '07-04周二', '07-05周三', '07-06周四', '07-07周五']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: [820, 932, 901, 934, 1290, 1330, 1320],
            type: 'line',
            smooth: true,
            areaStyle: {}
          }
        ]
      })
    },
    init() {}
  }
}
</script>

<style scoped lang="scss">
@import './index.scss';
</style>
