123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- <template>
- <view class="pagebox">
- <!-- #ifdef MP || APP-PLUS -->
- <NavBar titleText="数据统计" :iconColor="iconColor" :textColor="iconColor" :isScrolling="isScrolling" showBack></NavBar>
- <!-- #endif -->
- <view class="headerBg">
- <view :style="{ height: `${getHeight.barTop}px` }"></view>
- <view :style="{ height: `${getHeight.barHeight}px` }"></view>
- <view class="inner"></view>
- </view>
- <view class="order-index" ref="container">
- <view class="wrapper">
- <view class="header acea-row row-between-wrapper">
- <view class="title">数据统计</view>
- <view class="tab">
- <view class="box" :class="item.id== current ? 'on':''" v-for="item in dataList" @click="detailtab(item.id)">{{item.name}}</view>
- </view>
- </view>
- <view class="list acea-row">
- <view class="item" :class="orderType == item.type?'on':''" v-if="item.isManager" @click="orderNum(item.type)" v-for="item in statistics">
- <view>{{item.name}}</view>
- <view class="num">{{ item.price }}</view>
- </view>
- </view>
- <view class="canvas">
- <canvas canvas-id="canvasMix" id="canvasMix" class="charts" disable-scroll @touchstart="touchMix" @touchmove="moveMix" @touchend="touchEndMix">
- </canvas>
- </view>
- </view>
- <view class="public-wrapper">
- <view class="title">
- 详细数据
- </view>
- <view class="nav acea-row row-between-wrapper">
- <view class="num">日期</view>
- <view class="num" :class="[3,9,10].indexOf(orderType) == -1?'on':''">数量</view>
- <view class="num price" v-if="[3,9,10].indexOf(orderType) == -1">金额</view>
- </view>
- <view class="conter">
- <view class="item acea-row row-between-wrapper" v-for="(item, index) in list" :key="index">
- <view class="num">{{item.day}}</view>
- <view class="num" :class="[3,9,10].indexOf(orderType) == -1?'on':''">{{item.count}}</view>
- <view class="num price" v-if="[3,9,10].indexOf(orderType) == -1">{{item.price}}</view>
- </view>
- </view>
- </view>
- </view>
- <view class="safe-area-inset-bottom"></view>
- </view>
- </template>
- <script>
- let _self;
- let canvaMix = null;
- import {
- statisticsMenuApi,
- getStoreChart,
- getStatisticsListApi
- } from "@/api/admin";
- import uCharts from '../components/ucharts/ucharts'
- // #ifdef MP || APP-PLUS
- import NavBar from '@/components/NavBar.vue';
- // #endif
- export default {
- name: 'adminOrder',
- components: {
- // #ifdef MP ||APP-PLUS
- NavBar,
- // #endif
- },
- data() {
- return {
- iconColor: '#FFFFFF',
- isScrolling: false,
- getHeight: this.$util.getWXStatusHeight(),
- dataList:[
- {id:'today',name:'今日'},
- {id:'yesterday',name:'昨日'},
- {id:'month',name:'本月'}
- ],
- current:'today',
- statistics:[],
- isManager:0,
- orderType:1,
- cWidth: '',
- cHeight: '',
- list: [],
- pixelRatio: 1
- }
- },
- onLoad(options) {
- this.isManager = parseInt(options.isManager);
- this.getstatisticsMenu();
- this.getOrderChart();
- this.cWidth = uni.upx2px(710);
- this.cHeight = uni.upx2px(500);
- this.getList();
- },
- onPageScroll(e) {
- // #ifdef MP
- if (e.scrollTop > 50) {
- this.isScrolling = true;
- this.iconColor = '#333333';
- } else if (e.scrollTop < 50) {
- this.isScrolling = false;
- this.iconColor = '#FFFFFF';
- }
- // #endif
- },
- beforeMount() {
- canvaMix = null
- },
- methods: {
- orderNum(num){
- this.orderType = num;
- this.getOrderChart();
- this.getList();
- },
- getstatisticsMenu(){
- let data = {
- is_manager:this.isManager,
- data:this.current
- }
- statisticsMenuApi(data).then(res=>{
- let data = res.data;
- this.statistics = [
- {name:'销售额',price:data.price,type:1,isManager:1},
- {name:'配送订单额',price:data.send_price,type:2,isManager:this.isManager},
- {name:'收银订单额',price:data.cashier_price,type:5,isManager:1},
- {name:'核销订单额',price:data.writeoff_price,type:6,isManager:1},
- {name:'配送订单数',price:data.send_count,type:3,isManager:this.isManager},
- {name:'付费会员额',price:data.svip_price,type:7,isManager:1},
- {name:'充值订单额',price:data.recharge_price,type:8,isManager:1},
- {name:'退款订单额',price:data.refund_price,type:4,isManager:this.isManager},
- {name:'推广用户数',price:data.spread_count,type:9,isManager:1},
- {name:'激活会员卡',price:data.card_count,type:10,isManager:1}
- ]
- }).catch(err=>{
- this.$util.Tips({
- title: err
- });
- })
- },
- getOrderChart() {
- let data = {
- is_manager:this.isManager,
- time:this.current
- }
- getStoreChart(this.orderType,data).then(res => {
- const data = res.data;
- let Mix = {
- categories: [],
- series: []
- };
- let series = [{
- "name": '销售额',
- "type": "line",
- "data": [],
- }];
- data.forEach(({
- num,
- number,
- time
- }) => {
- series[0].data.push(number);
- Mix.categories.push(time);
- });
- Mix.series = series;
- this.chartData = data;
- if (canvaMix) {
- canvaMix.updateData(Mix);
- } else {
- this.showLineA("canvasMix", Mix);
- }
- });
- },
- // 创建charts
- showLineA(canvasId, chartData) {
- let _self = this
- canvaMix = new uCharts({
- $this: _self,
- canvasId: canvasId,
- type: 'line',
- fontSize: 11,
- padding: [5, 5, 0, 5],
- legend: {
- show: true,
- position: 'bottom',
- float: 'center',
- padding: 5,
- lineHeight: 11,
- margin: 6,
- },
- background: '#FFFFFF',
- pixelRatio: _self.pixelRatio,
- categories: chartData.categories,
- series: chartData.series,
- animation: true,
- enableScroll: true, //开启图表拖拽功能
- xAxis: {
- disableGrid: false,
- type: 'grid',
- gridType: 'dash',
- itemCount: 6,
- scrollShow: true,
- scrollAlign: 'left',
- },
- yAxis: {
- data: [{
- calibration: true,
- position: 'left',
- title: '销售额(元)',
- titleFontSize: 12,
- format: (val) => {
- return val.toFixed(0)
- }
- }, ],
- showTitle: true,
- gridType: 'dash',
- dashLength: 4,
- splitNumber: 7,
- },
- width: _self.cWidth * _self.pixelRatio,
- height: _self.cHeight * _self.pixelRatio,
- dataLabel: true,
- dataPointShape: true,
- });
- },
- touchMix(e) {
- canvaMix.scrollStart(e);
- },
- moveMix(e) {
- canvaMix.scroll(e);
- },
- touchEndMix(e) {
- var index = canvaMix.getCurrentDataIndex(e);
- canvaMix.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvaMix.touchLegend(e);
- canvaMix.showToolTip(e, {
- textList: [{
- text: this.chartData[index].time,
- color: null
- },
- {
- text: "销售额:" + this.chartData[index].price,
- color: "#1890FF"
- },
- {
- text: "订单量:" + this.chartData[index].num,
- color: "#91CB74"
- }
- ]
-
- });
- },
- // 统计菜单
- detailtab: function(type) {
- this.current = type
- this.getstatisticsMenu();
- this.getOrderChart();
- this.getList()
- },
- getList: function() {
- let data = {
- is_manager:this.isManager,
- time:this.current
- }
- getStatisticsListApi(this.orderType,data).then(res=>{
- this.list = res.data;
- }).catch(err=>{
- this.$util.Tips({
- title: err
- })
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .pagebox {
- position: relative;
- overflow: hidden;
- }
- .safe-area-inset-bottom {
- height: 0;
- height: constant(safe-area-inset-bottom);
- height: env(safe-area-inset-bottom);
- }
- .headerBg {
- position: absolute;
- top: 0;
- left: -25%;
- width: 150%;
- border-bottom-right-radius: 100%;
- border-bottom-left-radius: 100%;
- background: linear-gradient(270deg, #01ABF8 0%, #2A7EFB 100%);
- .inner {
- height: 356rpx;
- }
- }
- /*订单首页*/
- .order-index {
- position: relative;
- padding: 0 20rpx;
- }
-
- .order-index .wrapper {
- background-color: #fff;
- border-radius: 24rpx;
- padding-top: 30rpx;
- margin-top: 40rpx;
-
- .canvas{
- padding: 0 40rpx;
- margin-top: 26rpx;
- }
-
- .header{
- padding: 0 24rpx;
- .title{
- font-size: 30rpx;
- font-weight: 500;
- }
- .tab{
- width: 288rpx;
- height: 48rpx;
- background: #F5F5F5;
- border-radius: 24rpx;
- display: flex;
- justify-content: space-between;
- font-weight: 400;
- color: #999999;
- font-size: 24rpx;
- .box{
- width: 96rpx;
- height: 100%;
- border-radius: 24rpx;
- text-align: center;
- line-height: 48rpx;
- }
- .on{
- background: #1890FF;
- color: #FFFFFF;
- }
- }
- }
- .chart-title {
- padding: 40rpx 0 6rpx 42rpx;
- font-size: 22rpx;
- line-height: 26rpx;
- color: #999999;
- }
-
- .charts {
- width: 100%;
- height: 514rpx;
- }
- }
-
- .order-index .wrapper .list{
- margin-top: 16rpx;
- padding: 0 40rpx;
- }
- .order-index .wrapper .list .item {
- padding: 24rpx 0;
- text-align: left;
- font-size: 24rpx;
- line-height: 34rpx;
- color: #999;
- width: 150rpx;
- margin-right: 90rpx;
- &:nth-of-type(3n){
- margin-right: 0;
- }
- &.on{
- color: #2A7EFB;
- .num{
- color: #2A7EFB;
- }
- }
- }
- .order-index .wrapper .list .item .num {
- margin-top: 12rpx;
- font-family: SemiBold;
- font-size: 36rpx;
- color: #333;
- }
- .public-wrapper .title {
- font-weight: 500;
- font-size: 30rpx;
- line-height: 42rpx;
- color: #333333;
- padding: 32rpx 0 40rpx 24rpx;
- }
- .public-wrapper {
- background-color: #fff;
- border-radius: 24rpx;
- margin-top: 20rpx;
- }
- .public-wrapper .nav {
- padding: 0 40rpx;
- line-height: 34rpx;
- font-size: 24rpx;
- color: #999;
- }
- .public-wrapper .conter {
- padding: 0 40rpx;
- }
- .public-wrapper .conter .item,.public-wrapper .nav {
- border-bottom: 1px solid #F1F1F1;
- height: 74rpx;
- font-size: 24rpx;
- .num {
- flex: 1;
- word-break: break-all;
-
- &.price{
- text-align: right;
- }
-
- &.on{
- text-align: center;
- }
- }
- }
- .cover-view {
- position: fixed;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- </style>
|