<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 class="title-open">
                    <div class="name">显示数据</div>
                    <el-switch
                        v-model="hideState"
                        :active-value="1"
                        :inactive-value="0"
                        size="large"
                        @change="getHide"
                    />
                </div>
            </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.userNum ? todayData.userNum:'0.00' }}</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.rechargeNum ? todayData.rechargeNum:'0.00' }}</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.rechargeMoney ? todayData.rechargeMoney:'0.00' }}</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>
        </div>
        <el-row :gutter="20">
            <el-col :span="this.$store.state.global.ismobile?24:24" :xs="24">
                <div class="card-news mt10">
                    <div class="date-check">
                        <el-radio-group v-model="moneyDate" size="large" @change="getmoneyDate">
                            <el-radio-button v-for="(city,indx) in dateData" :key="indx" :label="city.key">
                                {{ city.name }}
                            </el-radio-button>
                        </el-radio-group>
                    </div>
                    <scEcharts height="500px" :option="option2"></scEcharts>
                </div>
            </el-col>
            <el-col :span="this.$store.state.global.ismobile?24:24" :xs="24">
                <div class="card-news mt10">
                    <div class="date-check">
                        <el-radio-group v-model="orderDate" size="large" @change="getorderDate">
                            <el-radio-button v-for="(city,indx) in dateData" :key="indx" :label="city.key">
                                {{ city.name }}
                            </el-radio-button>
                        </el-radio-group>
                    </div>
                    <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 {
            dateData:[{"name":"近7天","key":7},{"name":"近14天","key":14},{"name":"近30天","key":30}],
            orderDate:7,
            moneyDate:7,
            hideState:0,
            pageLoading: false,
            dashboard: '0',
            todayData:{},
            blueBg,
            baseData:{},
            option2: {},
            option: {},
        }
    },
    created(){
        var baseData = this.$TOOL.data.get("SERVICE");
        this.baseData = baseData;
        this.getData()
    },
    methods: {
        getmoneyDate(data){
            this.moneyDate = data;
            this.getData()
        },
        getorderDate(data){
            this.orderDate = data;
            this.getData()
        },
        getHide(data){
            this.hideState = (data==1?1:0)
            this.getData()
        },
        async getData(){
            var loading = this.$loading();
            var resp = await this.$API.dash.shop.get({"hide":this.hideState,"money":this.moneyDate,"order":this.orderDate});
            loading.close();
            this.todayData = resp.data.data;
            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;
}
.card-news .date-check{
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 99;
}
.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(33.333333% - 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;
    top: 0;
}
.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;
    position: relative;
}
.news-title{
    font-size: 16px;
    color: #000;
    font-weight: bold;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}
.news-title .title-open{
    margin-left: auto;
    margin-right: 0;
    font-size: 12px;
    font-weight: normal;
    color: #666;
    display: flex;
    align-items: center;
}
.news-title .title-open .name{
    margin-right: 10px;
}
.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>
