<template>
    <div v-if="pageLoading">
		<el-main>
			<el-card shadow="never">
				<el-skeleton :rows="5"></el-skeleton>
			</el-card>
			<el-card shadow="never" style="margin-top: 15px;">
				<el-skeleton></el-skeleton>
			</el-card>
		</el-main>
	</div>
    <el-main>
        <div class="card-news mt0">
            <div class="news-title">经营数据</div>
            <div class="total-panel">
                <div :class="this.$store.state.global.ismobile?'panel-item m':'panel-item'" style="background-color: rgb(235, 241, 255);">
                    <div class="item-warp">
                        <div class="left">
                            <div class="title">今日营业额(元)</div>
                            <div class="number">{{ todayData.order_money ? todayData.order_money:'0' }}</div>
                            <div class="desc">来客订单金额</div>
                        </div>
                        <div class="right"><img src="@/assets/image/wave-1-icon.png" /></div>
                    </div>
                    <div class="item-wave"><img src="@/assets/image/wave-1.png" /></div>
                </div>
                <div :class="this.$store.state.global.ismobile?'panel-item m':'panel-item'" style="background-color: rgb(240, 235, 255);">
                    <div class="item-warp">
                        <div class="left">
                            <div class="title">今日订单数(单)</div>
                            <div class="number">{{ todayData.order_num ? todayData.order_num:'0' }}</div>
                            <div class="desc">来客订单</div>
                        </div>
                        <div class="right"><img src="@/assets/image/wave-2-icon.png" /></div>
                    </div>
                    <div class="item-wave"><img src="@/assets/image/wave-2.png" /></div>
                </div>
                <div :class="this.$store.state.global.ismobile?'panel-item m':'panel-item'" style="background-color: rgb(255, 241, 214);">
                    <div class="item-warp">
                        <div class="left">
                            <div class="title">今日核销(单)</div>
                            <div class="number">{{ todayData.order_done ? todayData.order_done:'0' }}</div>
                            <div class="desc">已完成核销</div>
                        </div>
                        <div class="right"><img src="@/assets/image/wave-3-icon.png" /></div>
                    </div>
                    <div class="item-wave"><img src="@/assets/image/wave-3.png" /></div>
                </div>
                <div :class="this.$store.state.global.ismobile?'panel-item m':'panel-item'" style="background-color: rgb(250, 230, 244);">
                    <div class="item-warp">
                        <div class="left">
                            <div class="title">今日待发货(单)</div>
                            <div class="number">{{ todayData.order_send ? todayData.order_send:'0' }}</div>
                            <div class="desc">待发快递</div>
                        </div>
                        <div class="right"><img src="@/assets/image/wave-4-icon.png" /></div>
                    </div>
                    <div class="item-wave"><img src="@/assets/image/wave-4.png" /></div>
                </div>
                <div :class="this.$store.state.global.ismobile?'panel-item m':'panel-item'" style="background-color: rgb(235, 255, 248);">
                    <div class="item-warp">
                        <div class="left">
                            <div class="title">店铺数量</div>
                            <div class="number">{{ todayData.store_num ? todayData.store_num:'0' }}</div>
                            <div class="desc">开通绑定店铺数量</div>
                        </div>
                        <div class="right"><img src="@/assets/image/wave-5-icon.png" /></div>
                    </div>
                    <div class="item-wave"><img src="@/assets/image/wave-5.png" /></div>
                </div>
            </div>
        </div>
        <el-row :gutter="20">
            <el-col :span="this.$store.state.global.ismobile?24:12" :xs="24">
                <div class="card-news mt10">
                    <scEcharts height="500px" :option="option2"></scEcharts>
                </div>
            </el-col>
            <el-col :span="this.$store.state.global.ismobile?24:12" :xs="24">
                <div class="card-news mt10">
                    <scEcharts height="500px" :option="option"></scEcharts>
                </div>
            </el-col>
        </el-row>
    </el-main>
</template>

<script>
import blueBg from "@/assets/image/blue_bg.png";
import scEcharts from '@/components/scEcharts';
export default {
    name: "dashboard",
    components: {
        scEcharts
    },
    data(){
        return {
            pageLoading: false,
            dashboard: '0',
            todayData:{},
            blueBg,
            baseData:{},
            option2: {},
            option: {
                // title: {
                //     left: 'left', 
                //     text: '订单数据',
                // },
                // grid: {
                //     top: '80px'
                // },
                // tooltip: {
                //     trigger: 'axis'
                // },
                // legend: {
                //     x: 'right',
                //     data: ['呼出总数量', '接听总数量', '短信发送总数量', '添加微信总数量']
                // },
                // calculable: true,
                // xAxis: {
                //     type: 'category',
                //     data: ['06-25', '06-26', '06-27', '06-28', '06-29', '06-30', '07-01', '07-02', '07-03', '07-04']
                // },
                // yAxis: [{
                //     type: 'value'
                // }],
                // // yAxis: [{type: 'value', splitLine: {show: true}, gridIndex: 0, axisLabel: {formatter: '{value} 单'}}],
                // series: [{
                //     name: '呼出总数量',
                //     data: [120, 200, 50, 80, 170, 210, 130,450,244,168],
                //     smooth: true, showBackground: false,
                //     areaStyle: {color: 'rgba(64, 158, 254, 0.6)'},
                //     type: 'line', showSymbol: true, xAxisIndex: 0, yAxisIndex: 0,
                //     emphasis:{focus: 'series'},
                //     label: {position: 'top', formatter: '{c}', show: true},
                // },{
                //     name: '接听总数量',
                //     data: [20, 210, 10, 180, 110, 100, 130,450,244,168],
                //     smooth: true, showBackground: false,
                //     areaStyle: {color: 'rgba(54, 206, 159, 0.6)'},
                //     type: 'line', showSymbol: true, xAxisIndex: 0, yAxisIndex: 0,
                //     emphasis:{focus: 'series'},
                //     label: {position: 'top', formatter: '{c}', show: true},
                // },{
                //     name: '短信发送总数量',
                //     data: [20, 210, 10, 80, 110, 100, 130,450,244,168],
                //     smooth: true, showBackground: false,
                //     areaStyle: {color: 'rgba(245, 110, 106, 0.6)'},
                //     type: 'line', showSymbol: true, xAxisIndex: 0, yAxisIndex: 0,
                //     emphasis:{focus: 'series'},
                //     label: {position: 'top', formatter: '{c}', show: true},
                // },{
                //     name: '添加微信总数量',
                //     data: [20, 210, 110, 180, 110, 100, 130,450,244,268],
                //     smooth: true, showBackground: false,
                //     areaStyle: {color: 'rgba(98, 108, 144, 0.6)'},
                //     type: 'line', showSymbol: true, xAxisIndex: 0, yAxisIndex: 0,
                //     emphasis:{focus: 'series'},
                //     label: {position: 'top', formatter: '{c}', show: true},
                // }]
            },
        }
    },
    created(){
        var baseData = this.$TOOL.data.get("SERVICE");
        this.baseData = baseData;
        // this.getData()
    },
    methods: {
        async getData(){
            var loading = this.$loading();
            var resp = await this.$API.dash.store.get();
            loading.close();
            this.todayData = resp.data.today;
            let data = resp.data.moneys;
            let moneyDay = data.map(function (item) {
                return item['当天日期'];
            });
            let data2 = resp.data.orders;
            let orderDay = data2.map(function (item) {
                return item['当天日期'];
            });
            this.option = {
                title: {
                    left: 'left', 
                    text: '近15天订单数据',
                },
                grid: {
                    top: '80px'
                },
                tooltip: {trigger: 'axis', show: true, axisPointer: {type: 'cross', label: {}}},
                xAxis: [{data: orderDay, gridIndex: 0}],
                yAxis: [
                    {
                        splitLine: {show: true}, gridIndex: 0, type: 'value', axisLabel: {
                            formatter: '{value} 单'
                        }
                    }
                ],
                grid: [{left: '5%', right: '3%', top: '15%', bottom: '5%'}],
                series: [
                    {
                        smooth: true, showBackground: true,
                        areaStyle: {color: 'rgba(180, 180, 180, 0.5)'},
                        type: 'bar', showSymbol: true, xAxisIndex: 0, yAxisIndex: 0,
                        label: {normal: {position: 'top', formatter: '{c} 单', show: true}},
                        data: data2.map(function (item) {
                            return item['订单数量'];
                        }),
                    }
                ]
            };
            this.option2 = {
                title: {
                    left: 'left', 
                    text: '近15天订单金额',
                },
                grid: {
                    top: '80px'
                },
                tooltip: {trigger: 'axis', show: true, axisPointer: {type: 'cross', label: {}}},
                xAxis: [{data: moneyDay, gridIndex: 0}],
                yAxis: [
                    {
                        splitLine: {show: true}, gridIndex: 0, type: 'value', axisLabel: {
                            formatter: '{value} 元'
                        }
                    }
                ],
                grid: [{left: '5%', right: '3%', top: '15%', bottom: '5%'}],
                series: [
                    {
                        smooth: true, showBackground: true,
                        areaStyle: {color: 'rgba(180, 180, 180, 0.5)'},
                        type: 'line', showSymbol: true, xAxisIndex: 0, yAxisIndex: 0,
                        label: {normal: {position: 'top', formatter: '{c} 元', show: true}},
                        data: data.map(function (item) {
                            return item['订单金额'];
                        }),
                    }
                ]
            };
        }
    }
}
</script>

<style>
.myMods {list-style:none;margin:-10px;}
.myMods li {display: inline-block;width: 11.5%;height:100px;vertical-align: top;transition:all 0.3s ease;margin:10px;border-radius:5px;color: #333;}
.myMods li:hover {opacity: 0.8;}
.myMods li a {width: 100%;height: 100%;padding:10px;display: flex;flex-direction: column;align-items: center;justify-content: center;text-align: center;color: #333;}
.myMods li i {font-size: 26px;color: #333;}
.myMods li p {font-size: 12px;color: #333;margin-top: 10px;width: 100%;white-space:nowrap;text-overflow:ellipsis;overflow: hidden;}
.mt0 {
    margin-top: 0;
}
.service-item {
    border: 1px solid #EAE9F0;
    padding: 12px 14px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    flex: 1;
}
.service-item .item-sub{
    width: 40%;
}
.service-item .right-btn {
    margin-left: auto;
}
.service-item img {
    width: 44px;
    height: 54px;
    margin-right: 20px;
}
.service-item h3 {
    font-size: 14px;
    color: #000000d9;
    margin-bottom: 8px;
}
.service-item p {
    font-size: 13px;
    color: #333333d9;
}
.service-item .value{
    font-size: 18px;
    color: #f64945;
    font-weight: 700;
    margin-left: auto;
}
.service-item .value span {
    font-weight: normal;
    color: #666;
    font-size: 12px;
}
.service-tel {
    display: flex;
    align-items: center;
    margin-top: 20px;
}
.service-tel img{
    width: 32px;
    height: 32px;
    margin-right: 12px;
}
.service-tel span{
    font-size: 20px;
    font-weight: 500;
    color: #35f;
}
.total-panel .panel-item.bg-gray .item-warp .left{
    padding: 12px 24px;
}
.total-panel .panel-item.bg-gray {
    background-color: #F7F9FC;
    height: 104px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: #fff;
}
.total-panel .panel-item.bg-gray .item-warp.img .title {color: #fff;}
.total-panel .panel-item.bg-gray .item-warp.img .number{color: #fff;}
.total-panel .panel-item.bg-gray .item-warp.img .desc{color: #fff;}
.total-panel .panel-item.bg-gray .number{
    font-size: 24px;
}
.total-panel .panel-item.bg-gray .number span{
    font-size: 14px;
    margin-left: 10px;
}
.total-panel .panel-item.bg-gray .title{
    margin-bottom: 7px;
}
.total-panel-sub .sub-card {
    border: 1px solid #EAE9F0;
}
.total-panel-sub .sub-card .title{
    font-size: 14px;
    color: #000000;
    font-weight: bold;
    margin: 22px 0 12px 22px;
}
.total-panel-sub .sub-card .title.red{
    display: flex;
    align-items: center;
}
.total-panel-sub .sub-card .title.red::before{
    content: "";
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 4px;
    background-color: #f64945;
    margin-right: 6px;
}
.total-panel-sub .sub-card .sub-content{
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    padding: 0px 22px 22px 22px;
}
.sub-box {
    width: calc((100% - 24px) / 3);
    padding: 12px 16px 12px 16px;
    background: #FFFFFF;
    box-shadow: 0px 0px 10px 0px rgba(203, 203, 203, 0.25);
    border-radius: 6px;
    box-sizing: border-box;
}
.sub-box .row1 {
    display: flex;
    align-items: center;
    line-height: 1;
    margin-bottom: 10px;
}
.sub-box .row2 {
    font-size: 24px;
    color: #333333;
    font-weight: bold;
    margin-bottom: 10px;
}
.sub-box .row2.red{
    color: #f00;
}
.sub-box .row2 span {
    margin-left: 10px;
    font-size: 14px;
}
.sub-box .row3 {
    font-size: 14px;
    color: #666666;
}
.sub-box .row1 img{
    width: 15px;
    height: auto;
    margin-right: 8px;
}
.sub-box .row1 span{
    font-size: 14px;
    color: #333333;
}
.total-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-top: 16px;
}
.total-panel .panel-item.m{
    width: calc(100% - 9.6px);
    margin-bottom: 10px;
}
.total-panel .panel-item{
    width: calc(20% - 9.6px);
    height: 130px;
    box-shadow: rgba(0, 0, 0, 0.05) 0px 0px 8px;
    position: relative;
    border-radius: 6px;
}
.total-panel .panel-item .item-warp .left {
    padding:16px 0px 0px 23px;
}
.total-panel .panel-item .item-warp .right {
    width: 32px;
    height: 32px;
    margin: 13px 14px 0px 0px;
}
.total-panel .panel-item .item-warp .right img{
    width:100%;
    height:100%;
    display:block;
}
.total-panel .panel-item .item-warp{
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
}
.total-panel .panel-item .item-wave {
    position: absolute;
    left: 0px;
    right: 0px;
    bottom: 0px;
    width: 100%;
    height: auto;
    z-index: 9;
}
.total-panel .panel-item .item-wave img {
    width: 100%;
    height: 100%;
}
.total-panel .panel-item .title{
    font-size: 14px;
    color: rgb(51, 51, 51);
    margin-bottom: 18px;
    font-weight: 500;
}
.total-panel .panel-item .number{
    font-size: 26px;
    margin-bottom: 7px;
    font-weight: 700;
    color: rgb(51, 51, 51);
}
.total-panel .panel-item .desc{
    font-size: 13px;
    color: rgb(102, 102, 102);
}
.total-panel .panel-item .number span{
    font-size: 16px;
    font-weight: normal;
}
.panel-line{
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}
.panel-line span{
    width: 1px;
    background-color: #f0f0f0;
    height: 60%;
    display: block;
}
.card-news{
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
}
.news-title{
    font-size: 16px;
    color: #000;
    font-weight: bold;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}
.news-title::before{
    content: "";
    width: 4px;
    height: 16px;
    display: block;
    background-color: var(--el-color-primary);;
    margin-right: 8px;
}
.date-title{display:flex; align-items:center;line-height:40px;position: relative;}
.date-title .dot{
    width: 5px;
    height: 5px;
    background: var(--el-color-primary);
    border-radius: 100%;
    margin-right: 10px;
}
.date-time{
    font-size: 12px;
    color: #666;
    margin-left: auto;
    margin-right: 0;
}
</style>
