Browse Source

add statistics api

organize
刘嘉炜 3 years ago
parent
commit
c521760753
  1. 2
      src/js/server.js
  2. 79
      src/pages/turnover/turnover.vue

2
src/js/server.js

@ -1,6 +1,6 @@
import util from '../utils/util'; import util from '../utils/util';
// import { app as vm } from '../main'; // import { app as vm } from '../main';
const islog = true;
const islog = false;
export class Server { export class Server {

79
src/pages/turnover/turnover.vue

@ -1,22 +1,22 @@
<template> <template>
<view class="turnover-container"> <view class="turnover-container">
<view class="tc-tab" v-if="storeList.length > 1"> <view class="tc-tab" v-if="storeList.length > 1">
<view :class="[tabID == 0?'active':'']" @click="tabChange(0)">品牌统计</view>
<view :class="[tabID == 1?'active':'']" @click="tabChange(1)">门店统计</view>
<view :class="[tabID == 4?'active':'']" @click="tabChange(4)">品牌统计</view>
<view :class="[tabID == 3?'active':'']" @click="tabChange(3)">门店统计</view>
</view> </view>
<view class="tc-total-section"> <view class="tc-total-section">
<!-- 品牌 --> <!-- 品牌 -->
<view class="tts-address" v-if="tabID == 0&&storeList.length > 1">
<image class="ta-logo" :src="pageInfo.logo" mode="aspectFit"></image>
<view>{{pageInfo.name || '-'}}</view>
<view class="tts-address" v-if="tabID == 4&&storeList.length > 1">
<image class="ta-logo" :src="totalData.logo" mode="aspectFit"></image>
<view>{{totalData.brand_or_stadium_name || '-'}}</view>
</view> </view>
<!-- 仅有一家店铺情况下没有品牌查看权限 --> <!-- 仅有一家店铺情况下没有品牌查看权限 -->
<view class="tts-address" v-else-if="tabID == 1&&storeList.length ==1">
<view class="tts-address" v-else-if="tabID == 3&&storeList.length ==1">
<view>{{curSelectStore.name || '-'}}</view> <view>{{curSelectStore.name || '-'}}</view>
<!-- <image mode="aspectFit" src="/static/images/icon/arrow_b2.png"></image> --> <!-- <image mode="aspectFit" src="/static/images/icon/arrow_b2.png"></image> -->
</view> </view>
<picker v-else-if="tabID == 1" :range="storeList" range-key="name" @change="storeChange">
<picker v-else-if="tabID == 3" :range="storeList" range-key="name" @change="storeChange">
<view class="tts-address"> <view class="tts-address">
<view>{{curSelectStore.name || '-'}}</view> <view>{{curSelectStore.name || '-'}}</view>
<image mode="aspectFit" src="/static/images/icon/arrow_b2.png"></image> <image mode="aspectFit" src="/static/images/icon/arrow_b2.png"></image>
@ -24,12 +24,12 @@
</picker> </picker>
<view class="tts-money"> <view class="tts-money">
<view>{{pageInfo.duration || '-'}}</view>
<view>{{totalData.brand_or_stadium_duration || '-'}}</view>
<view> <view>
<text>总收入</text> <text>总收入</text>
<image mode="aspectFit" src="/static/images/icon/question_mark.png" @click="showQuestionModal"></image> <image mode="aspectFit" src="/static/images/icon/question_mark.png" @click="showQuestionModal"></image>
</view> </view>
<view><text>¥</text>{{pageInfo.total || '0'}}</view>
<view><text>¥</text>{{totalData.total || '0'}}</view>
</view> </view>
<view class="tts-preview"> <view class="tts-preview">
<view>线上 ¥0.00</view> <view>线上 ¥0.00</view>
@ -112,9 +112,9 @@ export default {
}, },
data(){ data(){
return { return {
tabID: 0,
tabID: 4,
timeTabIdx: 0, timeTabIdx: 0,
totalData: {},
pageInfo: { pageInfo: {
calc: {} calc: {}
}, },
@ -138,7 +138,7 @@ export default {
this.curTime = _timeObj; this.curTime = _timeObj;
let _storeList = await this.getStoreList(); let _storeList = await this.getStoreList();
if(_storeList.length == 1)this.tabID = 1;
if(_storeList.length == 1)this.tabID = 3;
this.$nextTick(this.refreshPageInfo); this.$nextTick(this.refreshPageInfo);
}catch(err){ }catch(err){
@ -148,13 +148,48 @@ export default {
}, },
methods: { methods: {
getCountType({ tabID, timeTabIdx }){
/*
count_type
3 门店总的统计
4 品牌总的统计
0 统计门店的某一天 (近7天)
1 统计门店的某一月
2 统计门店的某一年
5 统计品牌的某一天 (近7天)
6 统计品牌的某一月
7 统计品牌的某一年
*/
getCountType({ tab_id = -1, time_tab_idx = -1 }){
if(time_tab_idx == -1)return tab_id;
let _type = getType(time_tab_idx) || -1
if(tab_id == 3&&_type != -1)return _type;
if(tab_id == 4&&_type != -1)return _type + 5;
function getType(idx){
switch(idx){
case 0:
return 0
case 1:
return 0
case 2:
return 1
case 3:
return 2
default:
return -1
}
}
}, },
showQuestionModal(){ showQuestionModal(){
let { totalData } = this
util.showModal({ util.showModal({
title: '提示',
content: '总收入为:线上(微信支付)+线下的总收入(退款已删除)',
title: totalData.income_record_tips || '提示',
content: totalData.income_record_name || '总收入为:线上(微信支付)+ 线下的总收入(退款已删除)',
showCancel: true, showCancel: true,
success: mRes => { success: mRes => {
@ -165,7 +200,7 @@ export default {
toTimeSelect(type){ toTimeSelect(type){
let { curTime, tabID, curSelectStore } = this; let { curTime, tabID, curSelectStore } = this;
let storeID = ''; let storeID = '';
if(tabID == 1)storeID = curSelectStore.id;
if(tabID == 3)storeID = curSelectStore.id;
if(type == 0)util.routeTo(`/pages/time_select/date/date?date=${curTime.date || ''}&store_id=${storeID}`,'nT'); if(type == 0)util.routeTo(`/pages/time_select/date/date?date=${curTime.date || ''}&store_id=${storeID}`,'nT');
if(type == 2)util.routeTo(`/pages/time_select/month/month?date=${curTime.month || ''}&store_id=${storeID}`,'nT'); if(type == 2)util.routeTo(`/pages/time_select/month/month?date=${curTime.month || ''}&store_id=${storeID}`,'nT');
if(type == 3)util.routeTo(`/pages/time_select/year/year?date=${curTime.year || ''}&store_id=${storeID}`,'nT'); if(type == 3)util.routeTo(`/pages/time_select/year/year?date=${curTime.year || ''}&store_id=${storeID}`,'nT');
@ -175,7 +210,7 @@ export default {
let { tabID, timeTabIdx, curSelectStore, curTime } = this; let { tabID, timeTabIdx, curSelectStore, curTime } = this;
let _date; let _date;
if(timeTabIdx == 0)_date = curTime.date || '' if(timeTabIdx == 0)_date = curTime.date || ''
if(timeTabIdx == 1)_date = util.formatDate({}).substr(0,10);
// if(timeTabIdx == 1)_date = util.formatDate({}).substr(0,10);
if(timeTabIdx == 2)_date = `${curTime.month}-01` || '' // if(timeTabIdx == 2)_date = `${curTime.month}-01` || '' //
if(timeTabIdx == 3)_date = `${curTime.year}-01-01` || ''// if(timeTabIdx == 3)_date = `${curTime.year}-01-01` || ''//
@ -183,8 +218,12 @@ export default {
type: timeTabIdx + 1, type: timeTabIdx + 1,
date: _date, date: _date,
} }
if(tabID == 1)_query.stadium_id = curSelectStore.id;
if(tabID == 3)_query.stadium_id = curSelectStore.id;
//
this.getCountData({
stadium_id: curSelectStore.id || '',
count_type: this.getCountType({ tab_id: tabID })
})
this.getBrandInfo(_query); this.getBrandInfo(_query);
}, },
// //
@ -265,7 +304,7 @@ export default {
getCountData({ getCountData({
stadium_id, stadium_id,
count_type, count_type,
time_str, // = y-m-d/y-m/y
time_str = '', // = y-m-d/y-m/y
time_str_max = '', // >= y-m-d time_str_max = '', // >= y-m-d
time_str_min = '', // <= y-m-d time_str_min = '', // <= y-m-d
}){ }){

Loading…
Cancel
Save