1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309 |
- <template>
- <view>
- <view class="head">
- <view class="">
- <image class="userFlagimg" src="../../static/img/userFlag.png" mode=""></image>
- </view>
- <view class="pname">
- <font class="wenzi" style="color: #BDD6F3;font-size:28upx"> {{$t('mainStatistics.name')}}: {{pnameData}}
- </font>
- </view>
- <view class="company">
- <font style="color: #BDD6F3;font-size:28upx">{{$t('mainStatistics.company')}}</font>
- </view>
- </view>
- <view class="ri">
- <view class="riShell">
- <view class="riImg">
- <image style="width: 64upx;height: 64upx;padding-top: 20upx;" :src="$t('mainStatistics.dayImg')">
- </image>
- </view>
- <view class="riTitle">
- <view style="text-align:left;font-size:28upx;font-family:PingFang-SC-Medium">
- <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.dayTotalMoney')}}:</font>
- <font style="color: #ED341F;">{{dayTotalMoney}}</font>
- </view>
- <view style="text-align:left;font-size:28upx;font-family:PingFang-SC-Medium">
- <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.dayTotalNum')}}:</font>
- <font style="color: #ED341F;">{{dayTotalNum}}</font>
- </view>
- </view>
- </view>
- <view class="riqi">
- <view style="text-align:right" class="tody">
- <font style="color: #596D83;">{{today}}</font>
- </view>
- <view style="text-align:right" class="xingqi">
- <font style="color: #596D83;">{{week}}</font>
- </view>
- </view>
- </view>
- <view class="fourTitle">
- <view class="four">
- <view class="fourImg">
- <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.weekImg')"
- mode=""></image>
- </view>
- <view class="fourShell">
- <view class="one">
- <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.weekTotalMoney')}}:</font>
- <font style="color: #ED341F;">{{weekTotalMoney}}</font>
- </view>
- <view class="two">
- <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.weekTotalNum')}}:</font>
- <font style="color: #ED341F;">{{weekTotalNum}}</font>
- </view>
- </view>
- </view>
- <view class="four">
- <view class="fourImg">
- <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.monthImg')"
- mode=""></image>
- </view>
- <view class="fourShell">
- <view class="one">
- <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.monthTotalMoney')}}:</font>
- <font style="color: #ED341F;">{{monthTotalMoney}}</font>
- </view>
- <view class="two">
- <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.monthTotalNum')}}:</font>
- <font style="color: #ED341F;">{{monthTotalNum}}</font>
- </view>
- </view>
- </view>
- <view class="four">
- <view class="fourImg">
- <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.yearImg')"
- mode=""></image>
- </view>
- <view class="fourShell">
- <view class="one">
- <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.yearTotalMoney')}}:</font>
- <font style="color: #ED341F;">{{yearTotalMoney}}</font>
- </view>
- <view class="two">
- <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.yearTotalNum')}}:</font>
- <font style="color: #ED341F;">{{yearTotalNum}}</font>
- </view>
- </view>
- </view>
- <view class="four">
- <view class="fourImg">
- <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.allImg')"
- mode=""></image>
- </view>
- <view class="fourShell">
- <view class="one">
- <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.machineTotalNum')}}:</font>
- <font style="color: #ED341F;">{{machineTotalNum}}</font>
- </view>
- <view class="two">
- <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.machineUseNum')}}:</font>
- <font style="color: #ED341F;">{{machineUseNum}}</font>
- </view>
- </view>
- </view>
- </view>
- <view class="riShell">
- <!-- 选择框 -->
- <view style="width: 80%;">
- <!-- 商家选择 -->
- <view v-if="id!=1&&type<4&&length>0&&ifForeign=='0'" class="td-right">
- <view class="uni-list">
- <view class="uni-list-cell">
- <view class="uni-list-cell-left">
- 当前商家:
- </view>
- <view class="uni-list-cell-db" style="overflow: hidden;text-overflow: ellipsis;">
- <picker @change="changeAdmin" :value="index" :range="adminList">
- <view class="uni-input">{{adminList[index]}}</view>
- </picker>
- </view>
- </view>
- </view>
- </view>
- <!-- 支付方式选择 -->
- <view v-if="ifForeign!=''&&ifForeign=='1'" class="td-right">
- <view class="uni-list">
- <view class="uni-list-cell">
- <view class="uni-list-cell-left">
- PayType:
- </view>
- <view class="uni-list-cell-db" style="overflow: hidden;text-overflow: ellipsis;">
- <picker @change="changePayType" :value="index1" :range="payTypeList">
- <view class="uni-input">{{payTypeList[index1]}}</view>
- </picker>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 刷新按钮 -->
- <view class="search-button">
- <button type="primary" class="" :disabled="langAbbrs" @click="refresh()">
- <p class="">{{$t('mainStatistics.refresh')}}</P>
- </button>
- </view>
- </view>
- <view class="qiun-columns">
- <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
- <view class="qiun-title-dot-light">
- <view class="dis">{{$t('mainStatistics.day')}}</view>
- </view>
- <view class="shijian" style="text-align: center;position: relative;">
- <image @click="pre('day')" class="preImg" src="/static/img/leftTriangle.png"></image>
- <span>{{startDate1}}</span>
- <image @click="next('day')" class="nextImg" src="/static/img/rightTriangle.png"></image>
- </view>
- </view>
- <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
- <canvas canvas-id="canvaColumn1" id="canvaColumn1" class="charts" disable-scroll=true
- @touchstart="touchLine1" @touchmove="moveLine1" @touchend="touchEndLine1"
- style="background-color: #FFFFFF;"></canvas>
- </view>
- </view>
- <view class="line"></view>
- <view class="qiun-columns">
- <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
- <view class="qiun-title-dot-light">
- <view class="dis">{{$t('mainStatistics.week')}}</view>
- </view>
- <view class="shijian" style="text-align: center;position: relative;">
- <image @click="pre('week')" class="preImg" src="/static/img/leftTriangle.png"></image>
- <span>{{startDate2}} -- {{endDate2}}</span>
- <image @click="next('week')" class="nextImg" src="/static/img/rightTriangle.png"></image>
- </view>
- </view>
- <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
- <canvas canvas-id="canvaColumn2" id="canvaColumn2" class="charts" disable-scroll=true
- @touchstart="touchLine2" @touchmove="moveLine2" @touchend="touchEndLine2"
- style="background-color: #FFFFFF;"></canvas>
- </view>
- </view>
- <view class="line"></view>
- <view class="qiun-columns">
- <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
- <view class="qiun-title-dot-light">
- <view class="dis">{{$t('mainStatistics.month')}}</view>
- </view>
- <view class="shijian" style="text-align: center;position: relative;">
- <image @click="pre('month')" class="preImg" src="/static/img/leftTriangle.png"></image>
- <span>{{startDate3}} -- {{endDate3}}</span>
- <image @click="next('month')" class="nextImg" src="/static/img/rightTriangle.png"></image>
- </view>
- </view>
- <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
- <canvas canvas-id="canvaColumn3" id="canvaColumn3" class="charts" disable-scroll=true
- @touchstart="touchLine3" @touchmove="moveLine3" @touchend="touchEndLine3"
- style="background-color: #FFFFFF;"></canvas>
- </view>
- </view>
- <view class="line"></view>
- <view class="qiun-columns">
- <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
- <view class="qiun-title-dot-light">
- <view class="dis">{{$t('mainStatistics.year')}}</view>
- </view>
- <view class="shijian" style="text-align: center;position: relative;">
- <image @click="pre('year')" class="preImg" src="/static/img/leftTriangle.png"></image>
- <span>{{startDate4}} -- {{endDate4}}</span>
- <image @click="next('year')" class="nextImg" src="/static/img/rightTriangle.png"></image>
- </view>
- </view>
- <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
- <canvas canvas-id="canvaColumn4" id="canvaColumn4" class="charts" disable-scroll=true
- @touchstart="touchLine4" @touchmove="moveLine4" @touchend="touchEndLine4"
- style="background-color: #FFFFFF;"></canvas>
- </view>
- </view>
- <view v-show="noticeShow">
- <uni-popup id="popupDialog" ref="popupDialog" type="dialog">
- <uni-popup-dialog :type="msgType" title="通知" content="欢迎使用 unisdfdd-popup!" :before-close="true"
- @confirm="dialogConfirm(noticeId)" @close="dialogClose">
- <scroll-view scroll-y="true" class="scroll-Y" :style="{height:scrollHeight*0.8+'px'}">
- <view class="scroll-view-item ">
- {{noticeTitle}}<br />
- <p v-html="noticeNote">{{noticeNote}}</p>
- </view>
- </scroll-view>
- </uni-popup-dialog>
- </uni-popup>
- </view>
- </view>
- </template>
- <script>
- import {
- mapState,
- mapActions,
- mapMutations
- } from 'vuex';
- import uCharts from '@/components/u-charts/u-charts.js';
- import {
- dateUtils
- } from '@/common/util.js';
- var _self;
- var canvaColumn1 = null;
- var canvaColumn2 = null;
- var canvaColumn3 = null;
- var canvaColumn4 = null;
- export default {
- name: 'mainStatistics',
- props: {
- equipmentId: '',
- adminId: '',
- pname: '',
- isForeign: 0,
- },
- data() {
- return {
- machineTotalNum: 0,
- machineUseNum: 0,
- dayTotalMoney: 0,
- dayTotalNum: 0,
- weekTotalMoney: 0,
- weekTotalNum: 0,
- monthTotalMoney: 0,
- monthTotalNum: 0,
- yearTotalMoney: 0,
- yearTotalNum: 0,
- cWidth: '',
- cHeight: '',
- pixelRatio: 1,
- startDate1: '',
- startDate2: '',
- endDate2: '',
- startDate3: '',
- endDate3: '',
- startDate4: '',
- endDate4: '',
- today: '',
- week: '',
- adminList: [],
- payTypeList: ["All","non-pay","coin","notes","coin+notes","credit-card","E-PAYMENT"],
- payType:'All',
- admins: [],
- index: 0,
- index1: 0,
- id: 0,
- length: 0,
- type: null,
- noticeShow: false,
- noticeTRUE: true,
- noticeTitle: '',
- noticeNote: '',
- noticeId: '',
- msgType: 'success',
- scrollHeight: uni.getSystemInfoSync().windowHeight - 130,
- ifForeign: this.isForeign,
- langAbbrs:false,
- localPname: this.pname,
- }
- },
- computed: {
- ...mapState(['loginUser']),
- pnameData: {
- get() {
- return this.localPname;
- }
- },
- },
- onShow() {
- uni.setNavigationBarTitle({
- title: this.$t('mainStatistics.title')
- });
- uni.setTabBarItem({
- index: 0,
- text: this.$t('tabs.tab1')
- });
- // uni.setStorageSync('test',1);
- this.id = 0;
- this.index = 0;
- var test = uni.getStorageSync('test');
- var globalUser = uni.getStorageSync("globalUser");
- this.ifForeign = globalUser.ifForeign;
- //test 判断是不是初次登陆
- if (globalUser.id != 1 && test == 1) {
- setTimeout(() => {
- this.getNOtice();
- }, 5000);
- }
- var token = uni.getStorageSync("token");
- if (token.toString().length > 1) {
- this.init();
- } else {
- uni.reLaunch({
- url: '../Login/Login',
- });
- }
- if (globalUser.toString().length > 1) {
- if (globalUser.type > 0 && globalUser.type < 4) {
- this.getAdmin();
- }
- this.id = globalUser.id;
- this.type = globalUser.type;
- }
- this.day();
- },
- mounted() {
- var token = uni.getStorageSync("token");
- if (token.toString().length > 1) {
- var test = uni.getStorageSync('test');
- if (test > 1||test==0) {
- this.init();
- }
- } else {
- uni.reLaunch({
- url: '../Login/Login',
- });
- }
- // this.day();
- this.equipmentStatus();
- },
- methods: {
- // open() {
- // this.show = true;
- // },
- ...mapActions('chart', ['getStatistics', 'getMachineNum']),
- async init() {
- if (!this.localPname) {
- this.localPname = this.loginUser.name;
- }
- _self = this;
- //图表中图
- this.cWidth = uni.upx2px(690);
- this.cHeight = uni.upx2px(370);
- this.getMainStatisticsData();
- var test = uni.getStorageSync('test');
- await this.initDateRang(new Date(), 'day', 0);
- if (test == null || test < 2) {
- await this.initDateRang(new Date(), 'week', 0);
- await this.initDateRang(new Date(), 'month', 0);
- await this.initDateRang(new Date(), 'year', 0);
- }
- var test = uni.getStorageSync('test');
- var globalUser = uni.getStorageSync("globalUser");
- //初次登陆跳转后,把test变成2
- uni.setStorageSync('test', '2');
- },
- getNOtice() {
- // console.log("notice")
- var globalUser = uni.getStorageSync("globalUser");
- var token = uni.getStorageSync("token");
- uni.request({
- url: this.serverurl + '/TNotice/getNotice?id=' + globalUser.id,
- // data: {
- // "id": globalUser.id
- // },
- header: {
- 'token': token
- },
- method: "POST",
- success: (res) => {
- if (res.data.code) {
- if (res.data.message == '1') {
- var notice = res.data.data;
- this.noticeTitle = notice.title,
- this.noticeNote = notice.note,
- this.noticeId = notice.id,
- this.noticeTRUE = false,
- this.noticeShow = true,
- this.$refs.popupDialog.open()
- }
- }
- },
- });
- },
- day() {
- var date = new Date();
- // var daystr = dateUtils.formateDate(date, 'yyyy年MM月dd日');
- var daystr = dateUtils.formateDate(date, 'yyyy-MM-dd');
- this.today = daystr;
- // var str= '星期'+'日一二三四五六'.charAt(date.getDay());
- this.week = this.$t('mainStatistics.week' + date.getDay());
- },
- //查询下级用户
- getAdmin() {
- var param = {};
- var token = uni.getStorageSync("token");
- var globalUser = uni.getStorageSync("globalUser");
- param['id'] = globalUser.id;
- uni.request({
- url: this.serverurl + '/TAdmin/selectLowAdmin',
- data: param,
- header: {
- 'token': token
- },
- method: "POST",
- success: (res) => {
- if (res.data.code) {
- var admins = res.data.data;
- // this.admins = admins;
- var adminss = [];
- var adminList = [];
- adminList.push('本商户');
- if (admins.length > 0) {
- this.length = admins.length;
- adminList.push('所有下级');
- for (var i = 0; i < admins.length; i++) {
- // console.log(admins[i].name)
- if (i == 0) {
- var globalUser = uni.getStorageSync("globalUser");
- var id = admins[i].id;
- if (id == globalUser.id) {
- continue;
- }
- }
- if (admins[i].name != null || admins[i].name != '') {
- adminss.push(admins[i]);
- adminList.push(admins[i].name);
- } else {
- adminList.push(admins[i].username);
- adminss.push(admins[i]);
- }
- }
- }
- this.adminList = adminList;
- this.admins = adminss;
- } else {
- uni.showToast({
- title: `获取信息失败:` + res.data.message,
- icon: 'none'
- })
- }
- },
- });
- },
- // 改变商家
- changeAdmin: function(e) {
- this.index = e.target.value;
- var id = '';
- if (e.target.value > 1) {
- id = this.admins[e.target.value - 2].id;
- }
- if (e.target.value == 1) {
- id = 'all';
- }
- if (e.target.value == 0) {
- id = 0;
- }
- // console.log("adminID="+id);
- this.id = id;
- uni.setStorageSync('test', 1);
- this.init();
- },
- // 改变支付方式
- changePayType: function(e) {
- this.index1 = e.target.value;
- if(this.index1!=0){
- this.payType = this.index1-1;
- }else{
- this.payType = 'All'
- }
- uni.setStorageSync('test', 1);
- this.init();
-
- },
- // 刷新
- refresh(){
- uni.setStorageSync('test', 1);
- this.init();
- this.langAbbrs = true;
- setTimeout(() => {
- // 方法区
- this.langAbbrs = false;
- }, 5000);
- },
- equipmentStatus() {
- var that = this;
- var id = uni.getStorageSync("globalUser").id;
- var token = uni.getStorageSync("token");
- uni.request({
- url: this.serverurl + '/TEquipment/equipmentStatus',
- data: {
- "adminId": id
- },
- header: {
- 'token': token
- },
- method: "POST",
- success: (res) => {
- setTimeout(function() {
- that.checkEquipmentStatus(id);
- }, 5000);
- },
- });
- },
- checkEquipmentStatus(id) {
- var token = uni.getStorageSync("token");
- uni.request({
- url: this.serverurl + '/TEquipment/checkEquipmentStatus',
- data: {
- "adminId": id
- },
- header: {
- 'token': token
- },
- method: "POST",
- success: (res) => {
- },
- });
- },
- initDateRang(day, chartType, type) {
- const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
- if (chartType === 'day') {
- this.startDate1 = dateUtils.formateDate(day, 'yyyy/MM/dd');
- }
- if (chartType === 'week') {
- this.startDate2 = dateUtils.formateDate(dateUtils.getFirstDayOfWeek(day), 'yyyy/MM/dd');
- this.endDate2 = dateUtils.formateDate(dateUtils.getLastDayOfWeek(day), 'yyyy/MM/dd');
- }
- if (chartType === 'month') {
- this.startDate3 = dateUtils.formateDate(dateUtils.getCurrentMonFirstDate(day), 'yyyy/MM/dd');
- this.endDate3 = dateUtils.formateDate(dateUtils.getCurrentMonLastDate(day), 'yyyy/MM/dd');
- }
- if (chartType === 'year') {
- this.startDate4 = dateUtils.formateDate(dateUtils.getCurrentYearFirstDate(day), 'yyyy/MM/dd');
- this.endDate4 = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
- }
- return this.getStatisticsData(chartType, type);
- },
- /**上一个 */
- pre(chartType) {
- let day;
- if (chartType === 'day') { // 日
- day = new Date(this.startDate1);
- day.setDate(day.getDate() - 1);
- }
- if (chartType === 'week') { // 周
- day = new Date(this.startDate2);
- day.setDate(day.getDate() - 7);
- }
- if (chartType === 'month') { // 月
- day = new Date(this.startDate3);
- day.setMonth(day.getMonth() - 1);
- }
- if (chartType === 'year') { // 年
- day = new Date(this.startDate4);
- day.setFullYear(day.getFullYear() - 1);
- }
- this.initDateRang(day, chartType, 1);
- },
- /**下一个 */
- next(chartType) {
- let day;
- if (chartType === 'day') { // 日
- day = new Date(this.startDate1);
- day.setDate(day.getDate() + 1);
- }
- if (chartType === 'week') { // 周
- day = new Date(this.startDate2);
- day.setDate(day.getDate() + 7);
- }
- if (chartType === 'month') { // 月
- day = new Date(this.startDate3);
- day.setMonth(day.getMonth() + 1);
- }
- if (chartType === 'year') { // 年
- day = new Date(this.startDate4);
- day.setFullYear(day.getFullYear() + 1);
- }
- this.initDateRang(day, chartType, 1);
- },
- getStatisticsData(chartType, type) {
- //type=0 头顶统计数字变,type=1 头顶统计数字不变
- const param = {
- 'chartType': chartType
- };
- if (chartType == 'day') {
- param['startDate'] = this.startDate1;
- param['endDate'] = this.startDate1;
- }
- if (chartType == 'week') {
- param['startDate'] = this.startDate2;
- param['endDate'] = this.endDate2;
- }
- if (chartType == 'month') {
- param['startDate'] = this.startDate3;
- param['endDate'] = this.endDate3;
- }
- if (chartType == 'year') {
- param['startDate'] = this.startDate4;
- param['endDate'] = this.endDate4;
- }
- if (this.adminId) { // 子组件,则拿传过来的参
- param['adminId'] = this.adminId;
- } else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
- param['adminId'] = this.loginUser['id'];
- }
- var globalUser = uni.getStorageSync("globalUser");
- if (globalUser.id != 1) {
- if (param.adminId == null || param.adminId == undefined) {
- param['adminId'] = globalUser.id;
- }
- }
- if (this.equipmentId) {
- param['equipmentId'] = this.equipmentId;
- }
- if (this.id != 1) {
- var id = this.id;
- } else {
- var id = 0;
- }
- if (id == 'all') {
- param['adminId'] = null;
- if (this.type == 1) {
- param['agencyId'] = globalUser.id;
- }
- if (this.type == 2) {
- param['merchantId'] = globalUser.id;
- }
- } else if (id == 0) {
- } else {
- param['adminId'] = id;
- }
- if(this.ifForeign == '1'){
- param['payType'] = this.payType;
- }
- var type = type;
- return this.getStatistics(param)
- .then(data => {
- uni.stopPullDownRefresh();
- var date = new Date();
- var num = date.getDay(); //'日一二三四五六'0123456
- var categories = data.categories;
- var series = data.series;
- if (param['chartType'] == 'day') {
- canvaColumn1 = this.initChart('canvaColumn1', data);
- if (type == 0) {
- var dayTotalMoney = 0;
- var dayTotalNum = 0;
- for (var i = 0; i < series[0].data.length; i++) {
- dayTotalMoney = dayTotalMoney + series[1].data[i];
- dayTotalNum = dayTotalNum + series[0].data[i]
- }
- this.dayTotalNum = dayTotalNum.toFixed(0);
- this.dayTotalMoney = dayTotalMoney.toFixed(2);
- }
- }
- if (param['chartType'] == 'week') {
- canvaColumn2 = this.initChart('canvaColumn2', data);
- if (type == 0) {
- var weekTotalMoney = 0;
- var weekTotalNum = 0;
- for (var i = 0; i < series[0].data.length; i++) {
- weekTotalMoney = weekTotalMoney + series[1].data[i];
- weekTotalNum = weekTotalNum + series[0].data[i]
- }
- this.weekTotalMoney = weekTotalMoney.toFixed(2);
- this.weekTotalNum = weekTotalNum.toFixed(0);
- }
- }
- if (param['chartType'] == 'month') {
- canvaColumn3 = this.initChart('canvaColumn3', data);
- if (type == 0) {
- var monthTotalMoney = 0;
- var monthTotalNum = 0;
- for (var i = 0; i < series[0].data.length; i++) {
- monthTotalMoney = monthTotalMoney + series[1].data[i];
- monthTotalNum = monthTotalNum + series[0].data[i]
- }
- this.monthTotalMoney = monthTotalMoney.toFixed(2);
- this.monthTotalNum = monthTotalNum.toFixed(0);
- }
- }
- if (param['chartType'] == 'year') {
- canvaColumn4 = this.initChart('canvaColumn4', data);
- if (type == 0) {
- var yearTotalMoney = 0;
- var yearTotalNum = 0;
- for (var i = 0; i < series[0].data.length; i++) {
- yearTotalMoney = yearTotalMoney + series[1].data[i];
- yearTotalNum = yearTotalNum + series[0].data[i]
- }
- this.yearTotalMoney = yearTotalMoney.toFixed(2);
- this.yearTotalNum = yearTotalNum.toFixed(0);
- }
- }
- }, _ => {
- uni.stopPullDownRefresh();
- if (param['chartType'] == 'day') {
- canvaColumn1 = this.initChart('canvaColumn1', {
- categories: ['暂无数据'],
- series: [{
- name: '销售个数',
- data: [0]
- }]
- });
- }
- if (param['chartType'] == 'week') {
- canvaColumn2 = this.initChart('canvaColumn2', {
- categories: ['暂无数据'],
- series: [{
- name: '销售个数',
- data: [0]
- }]
- });
- }
- if (param['chartType'] == 'month') {
- canvaColumn3 = this.initChart('canvaColumn3', {
- categories: ['暂无数据'],
- series: [{
- name: '销售个数',
- data: [0]
- }]
- });
- }
- if (param['chartType'] == 'year') {
- canvaColumn4 = this.initChart('canvaColumn4', {
- categories: ['暂无数据'],
- series: [{
- name: '销售个数',
- data: [0]
- }]
- });
- }
- });
- },
- initChart(canvasId, chartData) {
- if (this.$t('lang') != null && this.$t('lang') != '') {
- if (this.$t('lang') != 'zh') {
- chartData.categories = chartData.categories.map(e => {
- if (e.indexOf('点') >= 0) {
- return e.replace('点', this.$t('mainStatistics.oclock'));
- }
- if (e.indexOf('周') >= 0) {
- const weekNum = e.substring(e.length - 1) == '日' ? '0' : e.substring(e.length - 1);
- return this.$t('mainStatistics.week' + weekNum);
- }
- if (e.indexOf('月') >= 0) {
- var res = e.toString();
- if (res.length > 3) {
- return e.replace('月', this.$t('mainStatistics.mon'));
- } else {
- return e.replace('月', this.$t('mainStatistics.y'));
- }
- }
- return e;
- });
- chartData.series = chartData.series.map(e => {
- if (e['name'] == '销售个数') {
- e['name'] = this.$t('mainStatistics.saleNum');
- }
- if (e['name'] == '销售额') {
- e['name'] = this.$t('mainStatistics.saleroom');
- }
- return e;
- });
- }
- }
- return new uCharts({
- $this: _self,
- canvasId: canvasId,
- enableScroll: true,
- type: 'column',
- legend: true,
- fontSize: 10,
- background: '#FFFFFF', //y轴颜色
- pixelRatio: 1,
- animation: true,
- categories: chartData.categories,
- series: chartData.series,
- xAxis: {
- type: 'grid',
- gridType: 'dash',
- itemCount: 5, //x轴单屏显示数据的数量,默认为5个
- scrollShow: true, //新增是否显示滚动条,默认false
- scrollAlign: 'left', //滚动条初始位置
- scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF 滚动条颜色底色
- scrollColor: '#DEE7F7', //默认为 #A6A6A6 滚动条颜色
- disableGrid: true,
- },
- yAxis: {
- type: 'grid',
- gridType: 'soild',
- // disabled:true
- // disableGrid:true,
- },
- dataLabel: true,
- width: _self.cWidth * _self.pixelRatio,
- height: _self.cHeight * _self.pixelRatio,
- extra: {
- column: {
- // width: _self.cWidth*_self.pixelRatio*0.45/chartData.categories.length
- width: 18
- }
- }
- });
- },
- getMainStatisticsData() {
- const param = {};
- if (this.adminId) { // 子组件,则拿传过来的参
- param['adminId'] = this.adminId;
- } else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
- param['adminId'] = this.loginUser['id'];
- }
- var globalUser = uni.getStorageSync("globalUser");
- if (globalUser.id != 1) {
- if (param.adminId == null || param.adminId == undefined) {
- param['adminId'] = globalUser.id;
- }
- }
- if (this.equipmentId) {
- param['equipmentId'] = this.equipmentId;
- }
- if (this.id != 1) {
- var id = this.id;
- } else {
- var id = 0;
- }
- var aid = param.adminId;
- if (id == 'all') {
- param['adminId'] = null;
- if (this.type == 1) {
- param['agencyId'] = globalUser.id;
- }
- if (this.type == 2) {
- param['merchantId'] = globalUser.id;
- }
- } else if (id == 0) {
- } else {
- param['adminId'] = id;
- aid = id;
- }
- // console.log('getMainStatisticsData:{}', param);
- var adminId = param.adminId;
- var equipmentId = this.equipmentId;
- var serverurl = this.serverurl;
- var token = uni.getStorageSync("token");
- var test = uni.getStorageSync("test");
- param['test'] = test;
- uni.request({
- url: serverurl + '/TEquipment/getMachineNum',
- data: {
- "adminId": aid,
- "equipmentId": equipmentId
- },
- method: "POST",
- header: {
- 'token': token
- },
- success: (res) => {
- var list = res.data.data;
- this.machineTotalNum = list[0];
- this.machineUseNum = list[1];
- }
- });
- // uni.request({
- // url: serverurl + '/TOrder/getMainStatistics',
- // data: param,
- // method: "POST",
- // header: {
- // 'token': token
- // },
- // success: (res) => {
- // var list = res.data.data;
- // for (let bean of list) {
- // if (bean['categorie'] === 'day') {
- // this.dayTotalMoney = bean['salePrice'];
- // this.dayTotalNum = bean['saleNum'];
- // }
- // if (bean['categorie'] === 'week') {
- // this.weekTotalMoney = bean['salePrice'];
- // this.weekTotalNum = bean['saleNum'];
- // }
- // if (bean['categorie'] === 'month') {
- // this.monthTotalMoney = bean['salePrice'];
- // this.monthTotalNum = bean['saleNum'];
- // }
- // if (bean['categorie'] === 'year') {
- // this.yearTotalMoney = bean['salePrice'];
- // this.yearTotalNum = bean['saleNum'];
- // }
- // }
- // }
- // });
- },
- touchLine1(e) {
- if (canvaColumn1) {
- canvaColumn1.scrollStart(e);
- }
- },
- moveLine1(e) {
- if (canvaColumn1) {
- canvaColumn1.scroll(e);
- }
- },
- touchEndLine1(e) {
- if (canvaColumn1) {
- canvaColumn1.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvaColumn1.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- }
- },
- touchLine2(e) {
- if (canvaColumn2) {
- canvaColumn2.scrollStart(e);
- }
- },
- moveLine2(e) {
- if (canvaColumn2) {
- canvaColumn2.scroll(e);
- }
- },
- touchEndLine2(e) {
- if (canvaColumn2) {
- canvaColumn2.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvaColumn2.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- }
- },
- touchLine3(e) {
- if (canvaColumn3) {
- canvaColumn3.scrollStart(e);
- }
- },
- moveLine3(e) {
- if (canvaColumn3) {
- canvaColumn3.scroll(e);
- }
- },
- touchEndLine3(e) {
- if (canvaColumn3) {
- canvaColumn3.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvaColumn3.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- }
- },
- touchLine4(e) {
- if (canvaColumn4) {
- canvaColumn4.scrollStart(e);
- }
- },
- moveLine4(e) {
- if (canvaColumn4) {
- canvaColumn4.scroll(e);
- }
- },
- touchEndLine4(e) {
- if (canvaColumn4) {
- canvaColumn4.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvaColumn4.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- }
- },
- // 点击确定
- dialogConfirm(id) {
- this.noticeTRUE = true;
- var adminId = uni.getStorageSync("globalUser").id;
- var token = uni.getStorageSync("token");
- uni.request({
- url: this.serverurl + '/TNotice/updateNotice?adminId=' + adminId + '¬iceId=' + id,
- header: {
- 'token': token
- },
- method: "POST",
- success: (res) => {
- uni.showModal({
- title: "提示",
- content: res.data.message,
- success: (res) => {
- }
- })
- },
- });
- this.$refs.popupDialog.close()
- },
- //点击取消
- dialogClose(done) {
- this.noticeTRUE = true,
- // this.msgType = 'success'
- // 需要执行 done 才能关闭对话框
- this.$refs.popupDialog.close()
- }
- }
- }
- </script>
- <style>
- page {
- /* background: #F2F2F2; */
- background: #FFFFFF;
- width: 750upx;
- overflow-x: hidden;
- }
- .head {
- display: flex;
- flex-direction: row;
- background: #206DC3;
- width: 750upx;
- height: 180upx;
- }
- .company {
- width: 48%;
- text-align: right;
- }
- .pname {
- display: flex;
- flex-direction: row;
- width: 40%;
- }
- .userFlagimg {
- padding-left: 30upx;
- padding-top: 10upx;
- width: 26upx;
- height: 28upx;
- }
- .wenzi {
- padding-left: 5upx;
- /* text-align:right; */
- white-space: nowrap;
- overflow: hidden;
- /* text-overflow: ellipsis; */
- }
- .ri {
- width: 690upx;
- height: 180upx;
- background: #FFFFFF;
- border-radius: 15upx;
- /* 上移 */
- transform: translateY(-90upx);
- text-align: center;
- margin: auto;
- display: flex;
- flex-direction: row;
- /* 阴影 */
- box-shadow: 0upx -1upx 20upx #D3D3D3;
- /* box-shadow:0px 0px 10px 5px #aaa; */
- }
- .riShell {
- display: flex;
- flex-direction: row;
- margin: auto;
- }
- .riTitle {
- display: flex;
- flex-direction: column;
- margin: auto;
- }
- .riqi {
- display: flex;
- flex-direction: column;
- margin: auto;
- }
- .fourTitle {
- width: 690upx;
- height: 294upx;
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- background: #FFFFFF;
- box-shadow: 0upx 0upx 20upx #D3D3D3;
- margin: auto;
- border-radius: 15upx;
- transform: translateY(-60upx);
- }
- .four {
- display: flex;
- flex-direction: row;
- margin: auto;
- width: 48%;
- }
- .fourImg {
- width: 54upx;
- height: 54upx;
- }
- .qiun-padding {
- padding: 2%;
- width: 96%;
- }
- .qiun-wrap {
- display: flex;
- flex-wrap: wrap;
- }
- .qiun-rows {
- display: flex;
- flex-direction: row !important;
- }
- .qiun-columns {
- display: flex;
- flex-direction: column !important;
- }
- .qiun-common-mt {
- margin-top: 0upx;
- height: 160upx;
- }
- .qiun-bg-white {
- background: #FFFFFF;
- }
- .qiun-title-bar {
- width: 100%;
- /* padding: 10upx 2%; */
- flex-wrap: nowrap;
- border-radius: 15upx;
- }
- .qiun-title-dot-light {
- width: 92%;
- border-left: 20upx;
- border-left: 10upx solid #206DC3;
- padding-left: 10upx;
- height: 32upx;
- /* padding-bottom: 40upx; */
- font-family: "PingFang-SC-Bold";
- font-weight: bold;
- margin: auto;
- font-size: 32upx;
- color: #363D44;
- transform: translateY(20upx);
- }
- .dis {
- transform: translateY(-13upx);
- font-size: 32upx;
- font-family: "PingFang-SC-Bold";
- color: #363D44;
- }
- .shijian {
- transform: translateY(40upx);
- padding-top: 30upx;
- height: 80upx;
- width: 690upx;
- margin: auto;
- box-shadow: 0upx 0upx 10upx #D3D3D3;
- }
- .line {
- background: #ECECEC;
- height: 20upx;
- }
- .qiun-charts {
- width: 690upx;
- height: 370upx;
- padding-top: 50upx;
- background-color: #FFFFFF;
- margin: auto;
- }
- .charts {
- width: 690upx;
- height: 370upx;
- background-color: #FFFFFF;
- margin: auto;
- }
- .preImg {
- position: absolute;
- left: 30upx;
- width: 71upx;
- height: 57upx;
- }
- .nextImg {
- position: absolute;
- right: 30upx;
- width: 71upx;
- height: 57upx;
- }
- .fontLeft {
- margin-right: 6upx;
- }
- .tr {
- padding-top: 15upx;
- display: flex;
- flex-direction: row;
- justify-content: flex-start;
- font-size: 26upx;
- font-family: "PingFang-SC-Bold";
- }
- .td-left {
- font-family: "PingFang-SC-Bold";
- margin: auto;
- font-size: 26upx;
- width: 30%;
- text-align: right;
- }
- .td-right {
- font-family: "PingFang-SC-Bold";
- /* font-weight: bold; */
- margin: auto;
- /* font-size: 26upx; */
- width: 70%;
- text-align: left;
- }
- .search-button{
- width: 20%;
- padding-left: 7upx;
- text-align: center;
- }
- </style>
|