| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <template>
- <div class="app-content" @click="dropdownShow = false">
- <!-- sel -wrap -->
- <div class="sel-wrap">
- <dropdown-list :show="dropdownShow" :top="80" :width="750" :height="400">
- <template v-slot:selectionbox>
- <div class="sel-open-btn" @click.stop="dropdownShow = dropdownShow ? false : true">
- <span>{{ typeName }}</span>
- <i class="iconfont iconsanjiao_xia"></i>
- </div>
- </template>
- <template v-slot:dropdownbox>
- <div class="sel-list-wrap">
- <scroll-view scroll-y class="tui-dropdown-scroll">
- <div class="sel-list" v-for="(item, index) in typeData" :key="index" @click.stop="selCategory(item)">{{ item.name }}</div>
- </scroll-view>
- </div>
- </template>
- </dropdown-list>
- </div>
- <!-- 收入统计 -->
- <div class="module-com">
- <div class="module-tit"></div>
- <div class="module-det">
- <echart-trend ref="echartIncome" :chartData="incomeStat" color="#FC243A" yName="金额(¥)" serviceName="收入统计"></echart-trend>
- </div>
- </div>
- <!-- 访问统计 -->
- <div class="module-com">
- <div class="module-tit"></div>
- <div class="module-det">
- <echart-trend ref="echartVisit" :chartData="visitStat" color="#3385FF" yName="数量(人)" serviceName="访问统计"></echart-trend>
- </div>
- </div>
- <!-- 客户数统计 -->
- <div class="module-com">
- <div class="module-tit"></div>
- <div class="module-det">
- <echart-trend ref="echartUser" :chartData="userStat" color="#28C57D" yName="数量(人)" serviceName="客户数统计"></echart-trend>
- </div>
- </div>
- <!-- 收入来源统计 -->
- <div class="module-com">
- <div class="module-tit">收入来源统计</div>
- <div class="module-det">
- <echart-circle ref="echartCircle" :chartData="incomeSourceStat"></echart-circle>
- </div>
- </div>
- <!-- 分类统计 -->
- <div class="module-com">
- <div class="module-tit">分类统计</div>
- <div class="module-det">
- <div class="category-list-wrap">
- <div class="category-list" v-for="(item, index) in categoryStat.list" :key="index">
- <div class="list-tit">{{ `${index + 1} ${item.name}` }}</div>
- <div class="list-det">
- <div class="progress-wrap">
- <div class="progress" :style="{ width: item.percentage + '%' }"></div>
- </div>
- <div class="progress-num">{{ item.num }}</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- 用途统计 -->
- <div class="module-com">
- <div class="module-tit">用途统计</div>
- <div class="module-det">
- <echart-columnar ref="echartColumnar" :chartData="useStat"></echart-columnar>
- </div>
- </div>
- </div>
- </template>
- <script>
- import EchartTrend from './components/echart-trend'
- import EchartCircle from './components/echart-circle'
- import EchartColumnar from './components/echart-columnar'
- import DropdownList from '@/components/plugin/dropdown-list'
- // api
- import { getStatList } from '@/api/stat'
- export default {
- name: 'statistics',
- components: {
- EchartTrend,
- EchartCircle,
- EchartColumnar,
- DropdownList
- },
- data() {
- return {
- dropdownShow: false,
- typeData: [
- {
- name: '最近7天',
- value: 1
- },
- {
- name: '最近30天',
- value: 2
- },
- {
- name: '本月',
- value: 3
- },
- {
- name: '上月',
- value: 4
- },
- {
- name: '最近3月',
- value: 30
- },
- {
- name: '最近半年',
- value: 31
- },
- {
- name: '最近一年',
- value: 32
- },
- {
- name: '今年',
- value: 33
- }
- ],
- typeName: '最近7天',
- type: 1,
- // 收入统计
- incomeStat: {},
- // 访问量统计
- visitStat: {},
- // 客户数统计
- userStat: {},
- // 粉丝数统计
- fansStat: {},
- // 收入来源统计
- incomeSourceStat: {},
- // 分类统计
- categoryStat: {},
- // 用途统计
- useStat: {}
- }
- },
- onLoad() {},
- mounted() {
- this.mInit()
- },
- methods: {
- mInit() {
- this._getData()
- },
- _getData() {
- getStatList({ type: this.type }).then(res => {
- if (!this.$util.isEmpty(res.data)) {
- let data = res.data
- data.categoryStat.list = data.categoryStat.list.map(e => {
- e.percentage = ((e.num / data.categoryStat.total) * 100).toFixed(2)
- return e
- })
- data.incomeSourceStat.list = data.incomeSourceStat.list.map(e => {
- e.name = `${e.name} ${((e.num / data.incomeSourceStat.total) * 100).toFixed(2)}% ${e.num}`
- e.value = e.num
- return e
- })
- Object.keys(data).forEach((i, index) => {
- if (i != 'categoryStat') {
- data[i].nameArr = data[i].list.map(e => e.name)
- data[i].numArr = data[i].list.map(e => e.num)
- }
- })
- this.incomeStat = data.incomeStat
- this.visitStat = data.visitStat
- this.userStat = data.userStat
- this.fansStat = data.fansStat
- this.incomeSourceStat = data.incomeSourceStat
- this.categoryStat = data.categoryStat
- this.useStat = data.useStat
- console.log(data)
- setTimeout(() => {
- this.initChart()
- }, 100)
- }
- })
- },
- initChart() {
- this.$refs.echartIncome.initChart()
- this.$refs.echartVisit.initChart()
- this.$refs.echartUser.initChart()
- this.$refs.echartCircle.initChart()
- this.$refs.echartColumnar.initChart()
- },
- selCategory(item) {
- this.typeName = item.name
- this.type = item.value
- this.dropdownShow = false
- this._getData()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .sel-wrap {
- width: 100%;
- height: 80upx;
- // background-color: ;
- // 下拉框
- .sel-open-btn {
- width: 30%;
- height: 80upx;
- line-height: 80upx;
- padding-left: 30upx;
- }
- .iconfont {
- color: $fontColor2;
- }
- .iconsanjiao_xia {
- font-size: 24upx;
- margin-left: 10upx;
- }
- .sel-list-wrap {
- background-color: #fff;
- box-shadow: 6upx 6upx 10upx #cccccc;
- .sel-list {
- padding: 20upx 30upx;
- // border-top: 1px solid $borderColor;
- }
- }
- .tui-dropdown-scroll {
- height: 400upx;
- }
- }
- .module-com {
- background-color: #fff;
- padding: 20upx 16upx 20upx 14upx;
- margin-bottom: 20upx;
- .module-tit {
- font-size: 28upx;
- margin-bottom: 26upx;
- padding-left: 16upx;
- }
- }
- .category-list-wrap {
- padding: 0 20upx;
- .category-list {
- margin-bottom: 20upx;
- .list-tit {
- color: $fontColor2;
- margin-bottom: 10upx;
- }
- .list-det {
- height: 30upx;
- @include disFlex(center, space-between);
- .progress-wrap {
- width: 84%;
- height: 100%;
- background-color: #f0f2f6;
- border-radius: 6upx;
- .progress {
- height: 100%;
- background-color: $mainColor;
- border-radius: 6upx;
- }
- .progress-num {
- color: $fontColor2;
- }
- }
- }
- }
- }
- </style>
|