<!-- * @Description: 收入情况:昨日,今日,本月,全年 * @Author: 王晓颖 * @Date: 2020-10-13 14:31:57 --> <template> <single-layout title="停车场收入情况"> <div class="block-container"> <div class="block" v-for="(value,key,index) in data" :key="index"> <simple-block :data="value" size="small"> <img :src="images[key]"> </simple-block> </div> </div> </single-layout> </template> <script> import {fetchSmartParkData} from '@/api/cityManage' import SimpleBlock from './simpleBlock' import SingleLayout from '@/components/layout/singleLayout' export default { name: 'parkIncomeCount', components: {SingleLayout, SimpleBlock}, data () { return { data: { yesterday: {name: '昨日收入', value: '', unit: '万元'}, today: {name: '今日收入', value: '', unit: '万元'}, month: {name: '本月收入', value: '', unit: '万元'}, year: {name: '全年收入', value: '', unit: '万元'} }, images: { yesterday: require('@/assets/images/city/icon-income-yesterday.png'), today: require('@/assets/images/city/icon-income-today.png'), month: require('@/assets/images/city/icon-income-month.png'), year: require('@/assets/images/city/icon-income-year.png') } } }, created () { // this.getData() const mockData = this.$globalJsons.globalSocialLive this.data = mockData.right.park.incomeCount }, methods: { getData () { this.getIncomeYesterday() this.getIncomeToday() this.getIncomeMonth() this.getIncomeYear() }, getIncomeYesterday () { fetchSmartParkData('incomeYesterday').then(response => { if (response.code === 200) { this.data.yesterday.value = (Number(response.data.total) / 10000).toFixed(2) } }) }, getIncomeToday () { fetchSmartParkData('incomeToday').then(response => { if (response.code === 200) { this.data.today.value = (Number(response.data.total) / 10000).toFixed(2) } }) }, getIncomeMonth () { fetchSmartParkData('incomeMonth').then(response => { if (response.code === 200) { this.data.month.value = (Number(response.data.total) / 10000).toFixed(2) } }) }, getIncomeYear () { fetchSmartParkData('incomeYear').then(response => { if (response.code === 200) { this.data.year.value = (Number(response.data.total) / 10000).toFixed(2) } }) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .block-container{ height: 100%; width: 100%; display: flex; justify-content: space-between; flex-wrap: wrap; margin: 0.04rem; .block{ width: 50%; height: 45%; } } </style>