mainStatistics.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  1. <template>
  2. <view>
  3. <view class="head">
  4. <view class="">
  5. <image class="userFlagimg" src="../../static/img/userFlag.png" mode=""></image>
  6. </view>
  7. <view class="pname">
  8. <font class="wenzi" style="color: #BDD6F3;font-size:28upx"> {{$t('mainStatistics.name')}}: {{pnameData}}
  9. </font>
  10. </view>
  11. <view class="company">
  12. <font style="color: #BDD6F3;font-size:28upx">{{$t('mainStatistics.company')}}</font>
  13. </view>
  14. </view>
  15. <view class="ri">
  16. <view class="riShell">
  17. <view class="riImg">
  18. <image style="width: 64upx;height: 64upx;padding-top: 20upx;" :src="$t('mainStatistics.dayImg')">
  19. </image>
  20. </view>
  21. <view class="riTitle">
  22. <view style="text-align:left;font-size:28upx;font-family:PingFang-SC-Medium">
  23. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.dayTotalMoney')}}:</font>
  24. <font style="color: #ED341F;">{{dayTotalMoney}}</font>
  25. </view>
  26. <view style="text-align:left;font-size:28upx;font-family:PingFang-SC-Medium">
  27. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.dayTotalNum')}}:</font>
  28. <font style="color: #ED341F;">{{dayTotalNum}}</font>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="riqi">
  33. <view style="text-align:right" class="tody">
  34. <font style="color: #596D83;">{{today}}</font>
  35. </view>
  36. <view style="text-align:right" class="xingqi">
  37. <font style="color: #596D83;">{{week}}</font>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="fourTitle">
  42. <view class="four">
  43. <view class="fourImg">
  44. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.weekImg')"
  45. mode=""></image>
  46. </view>
  47. <view class="fourShell">
  48. <view class="one">
  49. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.weekTotalMoney')}}:</font>
  50. <font style="color: #ED341F;">{{weekTotalMoney}}</font>
  51. </view>
  52. <view class="two">
  53. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.weekTotalNum')}}:</font>
  54. <font style="color: #ED341F;">{{weekTotalNum}}</font>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="four">
  59. <view class="fourImg">
  60. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.monthImg')"
  61. mode=""></image>
  62. </view>
  63. <view class="fourShell">
  64. <view class="one">
  65. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.monthTotalMoney')}}:</font>
  66. <font style="color: #ED341F;">{{monthTotalMoney}}</font>
  67. </view>
  68. <view class="two">
  69. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.monthTotalNum')}}:</font>
  70. <font style="color: #ED341F;">{{monthTotalNum}}</font>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="four">
  75. <view class="fourImg">
  76. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.yearImg')"
  77. mode=""></image>
  78. </view>
  79. <view class="fourShell">
  80. <view class="one">
  81. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.yearTotalMoney')}}:</font>
  82. <font style="color: #ED341F;">{{yearTotalMoney}}</font>
  83. </view>
  84. <view class="two">
  85. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.yearTotalNum')}}:</font>
  86. <font style="color: #ED341F;">{{yearTotalNum}}</font>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="four">
  91. <view class="fourImg">
  92. <image style="width: 54upx;height: 54upx;padding-top: 20upx;" :src="$t('mainStatistics.allImg')"
  93. mode=""></image>
  94. </view>
  95. <view class="fourShell">
  96. <view class="one">
  97. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.machineTotalNum')}}:</font>
  98. <font style="color: #ED341F;">{{machineTotalNum}}</font>
  99. </view>
  100. <view class="two">
  101. <font class="fontLeft" style="color: #596D83;">{{$t('mainStatistics.machineUseNum')}}:</font>
  102. <font style="color: #ED341F;">{{machineUseNum}}</font>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. <view class="riShell">
  108. <!-- 选择框 -->
  109. <view style="width: 80%;">
  110. <!-- 商家选择 -->
  111. <view v-if="id!=1&&type<4&&length>0&&ifForeign=='0'" class="td-right">
  112. <view class="uni-list">
  113. <view class="uni-list-cell">
  114. <view class="uni-list-cell-left">
  115. 当前商家:
  116. </view>
  117. <view class="uni-list-cell-db" style="overflow: hidden;text-overflow: ellipsis;">
  118. <picker @change="changeAdmin" :value="index" :range="adminList">
  119. <view class="uni-input">{{adminList[index]}}</view>
  120. </picker>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. <!-- 支付方式选择 -->
  126. <view v-if="ifForeign!=''&&ifForeign=='1'" class="td-right">
  127. <view class="uni-list">
  128. <view class="uni-list-cell">
  129. <view class="uni-list-cell-left">
  130. PayType:
  131. </view>
  132. <view class="uni-list-cell-db" style="overflow: hidden;text-overflow: ellipsis;">
  133. <picker @change="changePayType" :value="index1" :range="payTypeList">
  134. <view class="uni-input">{{payTypeList[index1]}}</view>
  135. </picker>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. <!-- 刷新按钮 -->
  142. <view class="search-button">
  143. <button type="primary" class="" :disabled="langAbbrs" @click="refresh()">
  144. <p class="">{{$t('mainStatistics.refresh')}}</P>
  145. </button>
  146. </view>
  147. </view>
  148. <view class="qiun-columns">
  149. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  150. <view class="qiun-title-dot-light">
  151. <view class="dis">{{$t('mainStatistics.day')}}</view>
  152. </view>
  153. <view class="shijian" style="text-align: center;position: relative;">
  154. <image @click="pre('day')" class="preImg" src="/static/img/leftTriangle.png"></image>
  155. <span>{{startDate1}}</span>
  156. <image @click="next('day')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  157. </view>
  158. </view>
  159. <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
  160. <canvas canvas-id="canvaColumn1" id="canvaColumn1" class="charts" disable-scroll=true
  161. @touchstart="touchLine1" @touchmove="moveLine1" @touchend="touchEndLine1"
  162. style="background-color: #FFFFFF;"></canvas>
  163. </view>
  164. </view>
  165. <view class="line"></view>
  166. <view class="qiun-columns">
  167. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  168. <view class="qiun-title-dot-light">
  169. <view class="dis">{{$t('mainStatistics.week')}}</view>
  170. </view>
  171. <view class="shijian" style="text-align: center;position: relative;">
  172. <image @click="pre('week')" class="preImg" src="/static/img/leftTriangle.png"></image>
  173. <span>{{startDate2}} -- {{endDate2}}</span>
  174. <image @click="next('week')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  175. </view>
  176. </view>
  177. <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
  178. <canvas canvas-id="canvaColumn2" id="canvaColumn2" class="charts" disable-scroll=true
  179. @touchstart="touchLine2" @touchmove="moveLine2" @touchend="touchEndLine2"
  180. style="background-color: #FFFFFF;"></canvas>
  181. </view>
  182. </view>
  183. <view class="line"></view>
  184. <view class="qiun-columns">
  185. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  186. <view class="qiun-title-dot-light">
  187. <view class="dis">{{$t('mainStatistics.month')}}</view>
  188. </view>
  189. <view class="shijian" style="text-align: center;position: relative;">
  190. <image @click="pre('month')" class="preImg" src="/static/img/leftTriangle.png"></image>
  191. <span>{{startDate3}} -- {{endDate3}}</span>
  192. <image @click="next('month')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  193. </view>
  194. </view>
  195. <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
  196. <canvas canvas-id="canvaColumn3" id="canvaColumn3" class="charts" disable-scroll=true
  197. @touchstart="touchLine3" @touchmove="moveLine3" @touchend="touchEndLine3"
  198. style="background-color: #FFFFFF;"></canvas>
  199. </view>
  200. </view>
  201. <view class="line"></view>
  202. <view class="qiun-columns">
  203. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  204. <view class="qiun-title-dot-light">
  205. <view class="dis">{{$t('mainStatistics.year')}}</view>
  206. </view>
  207. <view class="shijian" style="text-align: center;position: relative;">
  208. <image @click="pre('year')" class="preImg" src="/static/img/leftTriangle.png"></image>
  209. <span>{{startDate4}} -- {{endDate4}}</span>
  210. <image @click="next('year')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  211. </view>
  212. </view>
  213. <view v-show="noticeTRUE" class="qiun-charts" style="background-color: #FFFFFF;">
  214. <canvas canvas-id="canvaColumn4" id="canvaColumn4" class="charts" disable-scroll=true
  215. @touchstart="touchLine4" @touchmove="moveLine4" @touchend="touchEndLine4"
  216. style="background-color: #FFFFFF;"></canvas>
  217. </view>
  218. </view>
  219. <view v-show="noticeShow">
  220. <uni-popup id="popupDialog" ref="popupDialog" type="dialog">
  221. <uni-popup-dialog :type="msgType" title="通知" content="欢迎使用 unisdfdd-popup!" :before-close="true"
  222. @confirm="dialogConfirm(noticeId)" @close="dialogClose">
  223. <scroll-view scroll-y="true" class="scroll-Y" :style="{height:scrollHeight*0.8+'px'}">
  224. <view class="scroll-view-item ">
  225. {{noticeTitle}}<br />
  226. <p v-html="noticeNote">{{noticeNote}}</p>
  227. </view>
  228. </scroll-view>
  229. </uni-popup-dialog>
  230. </uni-popup>
  231. </view>
  232. </view>
  233. </template>
  234. <script>
  235. import {
  236. mapState,
  237. mapActions,
  238. mapMutations
  239. } from 'vuex';
  240. import uCharts from '@/components/u-charts/u-charts.js';
  241. import {
  242. dateUtils
  243. } from '@/common/util.js';
  244. var _self;
  245. var canvaColumn1 = null;
  246. var canvaColumn2 = null;
  247. var canvaColumn3 = null;
  248. var canvaColumn4 = null;
  249. export default {
  250. name: 'mainStatistics',
  251. props: {
  252. equipmentId: '',
  253. adminId: '',
  254. pname: '',
  255. isForeign: 0,
  256. },
  257. data() {
  258. return {
  259. machineTotalNum: 0,
  260. machineUseNum: 0,
  261. dayTotalMoney: 0,
  262. dayTotalNum: 0,
  263. weekTotalMoney: 0,
  264. weekTotalNum: 0,
  265. monthTotalMoney: 0,
  266. monthTotalNum: 0,
  267. yearTotalMoney: 0,
  268. yearTotalNum: 0,
  269. cWidth: '',
  270. cHeight: '',
  271. pixelRatio: 1,
  272. startDate1: '',
  273. startDate2: '',
  274. endDate2: '',
  275. startDate3: '',
  276. endDate3: '',
  277. startDate4: '',
  278. endDate4: '',
  279. today: '',
  280. week: '',
  281. adminList: [],
  282. payTypeList: ["All","non-pay","coin","notes","coin+notes","credit-card","E-PAYMENT"],
  283. payType:'All',
  284. admins: [],
  285. index: 0,
  286. index1: 0,
  287. id: 0,
  288. length: 0,
  289. type: null,
  290. noticeShow: false,
  291. noticeTRUE: true,
  292. noticeTitle: '',
  293. noticeNote: '',
  294. noticeId: '',
  295. msgType: 'success',
  296. scrollHeight: uni.getSystemInfoSync().windowHeight - 130,
  297. ifForeign: this.isForeign,
  298. langAbbrs:false,
  299. localPname: this.pname,
  300. }
  301. },
  302. computed: {
  303. ...mapState(['loginUser']),
  304. pnameData: {
  305. get() {
  306. return this.localPname;
  307. }
  308. },
  309. },
  310. onShow() {
  311. uni.setNavigationBarTitle({
  312. title: this.$t('mainStatistics.title')
  313. });
  314. uni.setTabBarItem({
  315. index: 0,
  316. text: this.$t('tabs.tab1')
  317. });
  318. // uni.setStorageSync('test',1);
  319. this.id = 0;
  320. this.index = 0;
  321. var test = uni.getStorageSync('test');
  322. var globalUser = uni.getStorageSync("globalUser");
  323. this.ifForeign = globalUser.ifForeign;
  324. //test 判断是不是初次登陆
  325. if (globalUser.id != 1 && test == 1) {
  326. setTimeout(() => {
  327. this.getNOtice();
  328. }, 5000);
  329. }
  330. var token = uni.getStorageSync("token");
  331. if (token.toString().length > 1) {
  332. this.init();
  333. } else {
  334. uni.reLaunch({
  335. url: '../Login/Login',
  336. });
  337. }
  338. if (globalUser.toString().length > 1) {
  339. if (globalUser.type > 0 && globalUser.type < 4) {
  340. this.getAdmin();
  341. }
  342. this.id = globalUser.id;
  343. this.type = globalUser.type;
  344. }
  345. this.day();
  346. },
  347. mounted() {
  348. var token = uni.getStorageSync("token");
  349. if (token.toString().length > 1) {
  350. var test = uni.getStorageSync('test');
  351. if (test > 1||test==0) {
  352. this.init();
  353. }
  354. } else {
  355. uni.reLaunch({
  356. url: '../Login/Login',
  357. });
  358. }
  359. // this.day();
  360. this.equipmentStatus();
  361. },
  362. methods: {
  363. // open() {
  364. // this.show = true;
  365. // },
  366. ...mapActions('chart', ['getStatistics', 'getMachineNum']),
  367. async init() {
  368. if (!this.localPname) {
  369. this.localPname = this.loginUser.name;
  370. }
  371. _self = this;
  372. //图表中图
  373. this.cWidth = uni.upx2px(690);
  374. this.cHeight = uni.upx2px(370);
  375. this.getMainStatisticsData();
  376. var test = uni.getStorageSync('test');
  377. await this.initDateRang(new Date(), 'day', 0);
  378. if (test == null || test < 2) {
  379. await this.initDateRang(new Date(), 'week', 0);
  380. await this.initDateRang(new Date(), 'month', 0);
  381. await this.initDateRang(new Date(), 'year', 0);
  382. }
  383. var test = uni.getStorageSync('test');
  384. var globalUser = uni.getStorageSync("globalUser");
  385. //初次登陆跳转后,把test变成2
  386. uni.setStorageSync('test', '2');
  387. },
  388. getNOtice() {
  389. // console.log("notice")
  390. var globalUser = uni.getStorageSync("globalUser");
  391. var token = uni.getStorageSync("token");
  392. uni.request({
  393. url: this.serverurl + '/TNotice/getNotice?id=' + globalUser.id,
  394. // data: {
  395. // "id": globalUser.id
  396. // },
  397. header: {
  398. 'token': token
  399. },
  400. method: "POST",
  401. success: (res) => {
  402. if (res.data.code) {
  403. if (res.data.message == '1') {
  404. var notice = res.data.data;
  405. this.noticeTitle = notice.title,
  406. this.noticeNote = notice.note,
  407. this.noticeId = notice.id,
  408. this.noticeTRUE = false,
  409. this.noticeShow = true,
  410. this.$refs.popupDialog.open()
  411. }
  412. }
  413. },
  414. });
  415. },
  416. day() {
  417. var date = new Date();
  418. // var daystr = dateUtils.formateDate(date, 'yyyy年MM月dd日');
  419. var daystr = dateUtils.formateDate(date, 'yyyy-MM-dd');
  420. this.today = daystr;
  421. // var str= '星期'+'日一二三四五六'.charAt(date.getDay());
  422. this.week = this.$t('mainStatistics.week' + date.getDay());
  423. },
  424. //查询下级用户
  425. getAdmin() {
  426. var param = {};
  427. var token = uni.getStorageSync("token");
  428. var globalUser = uni.getStorageSync("globalUser");
  429. param['id'] = globalUser.id;
  430. uni.request({
  431. url: this.serverurl + '/TAdmin/selectLowAdmin',
  432. data: param,
  433. header: {
  434. 'token': token
  435. },
  436. method: "POST",
  437. success: (res) => {
  438. if (res.data.code) {
  439. var admins = res.data.data;
  440. // this.admins = admins;
  441. var adminss = [];
  442. var adminList = [];
  443. adminList.push('本商户');
  444. if (admins.length > 0) {
  445. this.length = admins.length;
  446. adminList.push('所有下级');
  447. for (var i = 0; i < admins.length; i++) {
  448. // console.log(admins[i].name)
  449. if (i == 0) {
  450. var globalUser = uni.getStorageSync("globalUser");
  451. var id = admins[i].id;
  452. if (id == globalUser.id) {
  453. continue;
  454. }
  455. }
  456. if (admins[i].name != null || admins[i].name != '') {
  457. adminss.push(admins[i]);
  458. adminList.push(admins[i].name);
  459. } else {
  460. adminList.push(admins[i].username);
  461. adminss.push(admins[i]);
  462. }
  463. }
  464. }
  465. this.adminList = adminList;
  466. this.admins = adminss;
  467. } else {
  468. uni.showToast({
  469. title: `获取信息失败:` + res.data.message,
  470. icon: 'none'
  471. })
  472. }
  473. },
  474. });
  475. },
  476. // 改变商家
  477. changeAdmin: function(e) {
  478. this.index = e.target.value;
  479. var id = '';
  480. if (e.target.value > 1) {
  481. id = this.admins[e.target.value - 2].id;
  482. }
  483. if (e.target.value == 1) {
  484. id = 'all';
  485. }
  486. if (e.target.value == 0) {
  487. id = 0;
  488. }
  489. // console.log("adminID="+id);
  490. this.id = id;
  491. uni.setStorageSync('test', 1);
  492. this.init();
  493. },
  494. // 改变支付方式
  495. changePayType: function(e) {
  496. this.index1 = e.target.value;
  497. if(this.index1!=0){
  498. this.payType = this.index1-1;
  499. }else{
  500. this.payType = 'All'
  501. }
  502. uni.setStorageSync('test', 1);
  503. this.init();
  504. },
  505. // 刷新
  506. refresh(){
  507. uni.setStorageSync('test', 1);
  508. this.init();
  509. this.langAbbrs = true;
  510. setTimeout(() => {
  511. // 方法区
  512. this.langAbbrs = false;
  513. }, 5000);
  514. },
  515. equipmentStatus() {
  516. var that = this;
  517. var id = uni.getStorageSync("globalUser").id;
  518. var token = uni.getStorageSync("token");
  519. uni.request({
  520. url: this.serverurl + '/TEquipment/equipmentStatus',
  521. data: {
  522. "adminId": id
  523. },
  524. header: {
  525. 'token': token
  526. },
  527. method: "POST",
  528. success: (res) => {
  529. setTimeout(function() {
  530. that.checkEquipmentStatus(id);
  531. }, 5000);
  532. },
  533. });
  534. },
  535. checkEquipmentStatus(id) {
  536. var token = uni.getStorageSync("token");
  537. uni.request({
  538. url: this.serverurl + '/TEquipment/checkEquipmentStatus',
  539. data: {
  540. "adminId": id
  541. },
  542. header: {
  543. 'token': token
  544. },
  545. method: "POST",
  546. success: (res) => {
  547. },
  548. });
  549. },
  550. initDateRang(day, chartType, type) {
  551. const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
  552. if (chartType === 'day') {
  553. this.startDate1 = dateUtils.formateDate(day, 'yyyy/MM/dd');
  554. }
  555. if (chartType === 'week') {
  556. this.startDate2 = dateUtils.formateDate(dateUtils.getFirstDayOfWeek(day), 'yyyy/MM/dd');
  557. this.endDate2 = dateUtils.formateDate(dateUtils.getLastDayOfWeek(day), 'yyyy/MM/dd');
  558. }
  559. if (chartType === 'month') {
  560. this.startDate3 = dateUtils.formateDate(dateUtils.getCurrentMonFirstDate(day), 'yyyy/MM/dd');
  561. this.endDate3 = dateUtils.formateDate(dateUtils.getCurrentMonLastDate(day), 'yyyy/MM/dd');
  562. }
  563. if (chartType === 'year') {
  564. this.startDate4 = dateUtils.formateDate(dateUtils.getCurrentYearFirstDate(day), 'yyyy/MM/dd');
  565. this.endDate4 = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
  566. }
  567. return this.getStatisticsData(chartType, type);
  568. },
  569. /**上一个 */
  570. pre(chartType) {
  571. let day;
  572. if (chartType === 'day') { // 日
  573. day = new Date(this.startDate1);
  574. day.setDate(day.getDate() - 1);
  575. }
  576. if (chartType === 'week') { // 周
  577. day = new Date(this.startDate2);
  578. day.setDate(day.getDate() - 7);
  579. }
  580. if (chartType === 'month') { // 月
  581. day = new Date(this.startDate3);
  582. day.setMonth(day.getMonth() - 1);
  583. }
  584. if (chartType === 'year') { // 年
  585. day = new Date(this.startDate4);
  586. day.setFullYear(day.getFullYear() - 1);
  587. }
  588. this.initDateRang(day, chartType, 1);
  589. },
  590. /**下一个 */
  591. next(chartType) {
  592. let day;
  593. if (chartType === 'day') { // 日
  594. day = new Date(this.startDate1);
  595. day.setDate(day.getDate() + 1);
  596. }
  597. if (chartType === 'week') { // 周
  598. day = new Date(this.startDate2);
  599. day.setDate(day.getDate() + 7);
  600. }
  601. if (chartType === 'month') { // 月
  602. day = new Date(this.startDate3);
  603. day.setMonth(day.getMonth() + 1);
  604. }
  605. if (chartType === 'year') { // 年
  606. day = new Date(this.startDate4);
  607. day.setFullYear(day.getFullYear() + 1);
  608. }
  609. this.initDateRang(day, chartType, 1);
  610. },
  611. getStatisticsData(chartType, type) {
  612. //type=0 头顶统计数字变,type=1 头顶统计数字不变
  613. const param = {
  614. 'chartType': chartType
  615. };
  616. if (chartType == 'day') {
  617. param['startDate'] = this.startDate1;
  618. param['endDate'] = this.startDate1;
  619. }
  620. if (chartType == 'week') {
  621. param['startDate'] = this.startDate2;
  622. param['endDate'] = this.endDate2;
  623. }
  624. if (chartType == 'month') {
  625. param['startDate'] = this.startDate3;
  626. param['endDate'] = this.endDate3;
  627. }
  628. if (chartType == 'year') {
  629. param['startDate'] = this.startDate4;
  630. param['endDate'] = this.endDate4;
  631. }
  632. if (this.adminId) { // 子组件,则拿传过来的参
  633. param['adminId'] = this.adminId;
  634. } else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
  635. param['adminId'] = this.loginUser['id'];
  636. }
  637. var globalUser = uni.getStorageSync("globalUser");
  638. if (globalUser.id != 1) {
  639. if (param.adminId == null || param.adminId == undefined) {
  640. param['adminId'] = globalUser.id;
  641. }
  642. }
  643. if (this.equipmentId) {
  644. param['equipmentId'] = this.equipmentId;
  645. }
  646. if (this.id != 1) {
  647. var id = this.id;
  648. } else {
  649. var id = 0;
  650. }
  651. if (id == 'all') {
  652. param['adminId'] = null;
  653. if (this.type == 1) {
  654. param['agencyId'] = globalUser.id;
  655. }
  656. if (this.type == 2) {
  657. param['merchantId'] = globalUser.id;
  658. }
  659. } else if (id == 0) {
  660. } else {
  661. param['adminId'] = id;
  662. }
  663. if(this.ifForeign == '1'){
  664. param['payType'] = this.payType;
  665. }
  666. var type = type;
  667. return this.getStatistics(param)
  668. .then(data => {
  669. uni.stopPullDownRefresh();
  670. var date = new Date();
  671. var num = date.getDay(); //'日一二三四五六'0123456
  672. var categories = data.categories;
  673. var series = data.series;
  674. if (param['chartType'] == 'day') {
  675. canvaColumn1 = this.initChart('canvaColumn1', data);
  676. if (type == 0) {
  677. var dayTotalMoney = 0;
  678. var dayTotalNum = 0;
  679. for (var i = 0; i < series[0].data.length; i++) {
  680. dayTotalMoney = dayTotalMoney + series[1].data[i];
  681. dayTotalNum = dayTotalNum + series[0].data[i]
  682. }
  683. this.dayTotalNum = dayTotalNum.toFixed(0);
  684. this.dayTotalMoney = dayTotalMoney.toFixed(2);
  685. }
  686. }
  687. if (param['chartType'] == 'week') {
  688. canvaColumn2 = this.initChart('canvaColumn2', data);
  689. if (type == 0) {
  690. var weekTotalMoney = 0;
  691. var weekTotalNum = 0;
  692. for (var i = 0; i < series[0].data.length; i++) {
  693. weekTotalMoney = weekTotalMoney + series[1].data[i];
  694. weekTotalNum = weekTotalNum + series[0].data[i]
  695. }
  696. this.weekTotalMoney = weekTotalMoney.toFixed(2);
  697. this.weekTotalNum = weekTotalNum.toFixed(0);
  698. }
  699. }
  700. if (param['chartType'] == 'month') {
  701. canvaColumn3 = this.initChart('canvaColumn3', data);
  702. if (type == 0) {
  703. var monthTotalMoney = 0;
  704. var monthTotalNum = 0;
  705. for (var i = 0; i < series[0].data.length; i++) {
  706. monthTotalMoney = monthTotalMoney + series[1].data[i];
  707. monthTotalNum = monthTotalNum + series[0].data[i]
  708. }
  709. this.monthTotalMoney = monthTotalMoney.toFixed(2);
  710. this.monthTotalNum = monthTotalNum.toFixed(0);
  711. }
  712. }
  713. if (param['chartType'] == 'year') {
  714. canvaColumn4 = this.initChart('canvaColumn4', data);
  715. if (type == 0) {
  716. var yearTotalMoney = 0;
  717. var yearTotalNum = 0;
  718. for (var i = 0; i < series[0].data.length; i++) {
  719. yearTotalMoney = yearTotalMoney + series[1].data[i];
  720. yearTotalNum = yearTotalNum + series[0].data[i]
  721. }
  722. this.yearTotalMoney = yearTotalMoney.toFixed(2);
  723. this.yearTotalNum = yearTotalNum.toFixed(0);
  724. }
  725. }
  726. }, _ => {
  727. uni.stopPullDownRefresh();
  728. if (param['chartType'] == 'day') {
  729. canvaColumn1 = this.initChart('canvaColumn1', {
  730. categories: ['暂无数据'],
  731. series: [{
  732. name: '销售个数',
  733. data: [0]
  734. }]
  735. });
  736. }
  737. if (param['chartType'] == 'week') {
  738. canvaColumn2 = this.initChart('canvaColumn2', {
  739. categories: ['暂无数据'],
  740. series: [{
  741. name: '销售个数',
  742. data: [0]
  743. }]
  744. });
  745. }
  746. if (param['chartType'] == 'month') {
  747. canvaColumn3 = this.initChart('canvaColumn3', {
  748. categories: ['暂无数据'],
  749. series: [{
  750. name: '销售个数',
  751. data: [0]
  752. }]
  753. });
  754. }
  755. if (param['chartType'] == 'year') {
  756. canvaColumn4 = this.initChart('canvaColumn4', {
  757. categories: ['暂无数据'],
  758. series: [{
  759. name: '销售个数',
  760. data: [0]
  761. }]
  762. });
  763. }
  764. });
  765. },
  766. initChart(canvasId, chartData) {
  767. if (this.$t('lang') != null && this.$t('lang') != '') {
  768. if (this.$t('lang') != 'zh') {
  769. chartData.categories = chartData.categories.map(e => {
  770. if (e.indexOf('点') >= 0) {
  771. return e.replace('点', this.$t('mainStatistics.oclock'));
  772. }
  773. if (e.indexOf('周') >= 0) {
  774. const weekNum = e.substring(e.length - 1) == '日' ? '0' : e.substring(e.length - 1);
  775. return this.$t('mainStatistics.week' + weekNum);
  776. }
  777. if (e.indexOf('月') >= 0) {
  778. var res = e.toString();
  779. if (res.length > 3) {
  780. return e.replace('月', this.$t('mainStatistics.mon'));
  781. } else {
  782. return e.replace('月', this.$t('mainStatistics.y'));
  783. }
  784. }
  785. return e;
  786. });
  787. chartData.series = chartData.series.map(e => {
  788. if (e['name'] == '销售个数') {
  789. e['name'] = this.$t('mainStatistics.saleNum');
  790. }
  791. if (e['name'] == '销售额') {
  792. e['name'] = this.$t('mainStatistics.saleroom');
  793. }
  794. return e;
  795. });
  796. }
  797. }
  798. return new uCharts({
  799. $this: _self,
  800. canvasId: canvasId,
  801. enableScroll: true,
  802. type: 'column',
  803. legend: true,
  804. fontSize: 10,
  805. background: '#FFFFFF', //y轴颜色
  806. pixelRatio: 1,
  807. animation: true,
  808. categories: chartData.categories,
  809. series: chartData.series,
  810. xAxis: {
  811. type: 'grid',
  812. gridType: 'dash',
  813. itemCount: 5, //x轴单屏显示数据的数量,默认为5个
  814. scrollShow: true, //新增是否显示滚动条,默认false
  815. scrollAlign: 'left', //滚动条初始位置
  816. scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF 滚动条颜色底色
  817. scrollColor: '#DEE7F7', //默认为 #A6A6A6 滚动条颜色
  818. disableGrid: true,
  819. },
  820. yAxis: {
  821. type: 'grid',
  822. gridType: 'soild',
  823. // disabled:true
  824. // disableGrid:true,
  825. },
  826. dataLabel: true,
  827. width: _self.cWidth * _self.pixelRatio,
  828. height: _self.cHeight * _self.pixelRatio,
  829. extra: {
  830. column: {
  831. // width: _self.cWidth*_self.pixelRatio*0.45/chartData.categories.length
  832. width: 18
  833. }
  834. }
  835. });
  836. },
  837. getMainStatisticsData() {
  838. const param = {};
  839. if (this.adminId) { // 子组件,则拿传过来的参
  840. param['adminId'] = this.adminId;
  841. } else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
  842. param['adminId'] = this.loginUser['id'];
  843. }
  844. var globalUser = uni.getStorageSync("globalUser");
  845. if (globalUser.id != 1) {
  846. if (param.adminId == null || param.adminId == undefined) {
  847. param['adminId'] = globalUser.id;
  848. }
  849. }
  850. if (this.equipmentId) {
  851. param['equipmentId'] = this.equipmentId;
  852. }
  853. if (this.id != 1) {
  854. var id = this.id;
  855. } else {
  856. var id = 0;
  857. }
  858. var aid = param.adminId;
  859. if (id == 'all') {
  860. param['adminId'] = null;
  861. if (this.type == 1) {
  862. param['agencyId'] = globalUser.id;
  863. }
  864. if (this.type == 2) {
  865. param['merchantId'] = globalUser.id;
  866. }
  867. } else if (id == 0) {
  868. } else {
  869. param['adminId'] = id;
  870. aid = id;
  871. }
  872. // console.log('getMainStatisticsData:{}', param);
  873. var adminId = param.adminId;
  874. var equipmentId = this.equipmentId;
  875. var serverurl = this.serverurl;
  876. var token = uni.getStorageSync("token");
  877. var test = uni.getStorageSync("test");
  878. param['test'] = test;
  879. uni.request({
  880. url: serverurl + '/TEquipment/getMachineNum',
  881. data: {
  882. "adminId": aid,
  883. "equipmentId": equipmentId
  884. },
  885. method: "POST",
  886. header: {
  887. 'token': token
  888. },
  889. success: (res) => {
  890. var list = res.data.data;
  891. this.machineTotalNum = list[0];
  892. this.machineUseNum = list[1];
  893. }
  894. });
  895. // uni.request({
  896. // url: serverurl + '/TOrder/getMainStatistics',
  897. // data: param,
  898. // method: "POST",
  899. // header: {
  900. // 'token': token
  901. // },
  902. // success: (res) => {
  903. // var list = res.data.data;
  904. // for (let bean of list) {
  905. // if (bean['categorie'] === 'day') {
  906. // this.dayTotalMoney = bean['salePrice'];
  907. // this.dayTotalNum = bean['saleNum'];
  908. // }
  909. // if (bean['categorie'] === 'week') {
  910. // this.weekTotalMoney = bean['salePrice'];
  911. // this.weekTotalNum = bean['saleNum'];
  912. // }
  913. // if (bean['categorie'] === 'month') {
  914. // this.monthTotalMoney = bean['salePrice'];
  915. // this.monthTotalNum = bean['saleNum'];
  916. // }
  917. // if (bean['categorie'] === 'year') {
  918. // this.yearTotalMoney = bean['salePrice'];
  919. // this.yearTotalNum = bean['saleNum'];
  920. // }
  921. // }
  922. // }
  923. // });
  924. },
  925. touchLine1(e) {
  926. if (canvaColumn1) {
  927. canvaColumn1.scrollStart(e);
  928. }
  929. },
  930. moveLine1(e) {
  931. if (canvaColumn1) {
  932. canvaColumn1.scroll(e);
  933. }
  934. },
  935. touchEndLine1(e) {
  936. if (canvaColumn1) {
  937. canvaColumn1.scrollEnd(e);
  938. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  939. canvaColumn1.showToolTip(e, {
  940. format: function(item, category) {
  941. return category + ' ' + item.name + ':' + item.data
  942. }
  943. });
  944. }
  945. },
  946. touchLine2(e) {
  947. if (canvaColumn2) {
  948. canvaColumn2.scrollStart(e);
  949. }
  950. },
  951. moveLine2(e) {
  952. if (canvaColumn2) {
  953. canvaColumn2.scroll(e);
  954. }
  955. },
  956. touchEndLine2(e) {
  957. if (canvaColumn2) {
  958. canvaColumn2.scrollEnd(e);
  959. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  960. canvaColumn2.showToolTip(e, {
  961. format: function(item, category) {
  962. return category + ' ' + item.name + ':' + item.data
  963. }
  964. });
  965. }
  966. },
  967. touchLine3(e) {
  968. if (canvaColumn3) {
  969. canvaColumn3.scrollStart(e);
  970. }
  971. },
  972. moveLine3(e) {
  973. if (canvaColumn3) {
  974. canvaColumn3.scroll(e);
  975. }
  976. },
  977. touchEndLine3(e) {
  978. if (canvaColumn3) {
  979. canvaColumn3.scrollEnd(e);
  980. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  981. canvaColumn3.showToolTip(e, {
  982. format: function(item, category) {
  983. return category + ' ' + item.name + ':' + item.data
  984. }
  985. });
  986. }
  987. },
  988. touchLine4(e) {
  989. if (canvaColumn4) {
  990. canvaColumn4.scrollStart(e);
  991. }
  992. },
  993. moveLine4(e) {
  994. if (canvaColumn4) {
  995. canvaColumn4.scroll(e);
  996. }
  997. },
  998. touchEndLine4(e) {
  999. if (canvaColumn4) {
  1000. canvaColumn4.scrollEnd(e);
  1001. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  1002. canvaColumn4.showToolTip(e, {
  1003. format: function(item, category) {
  1004. return category + ' ' + item.name + ':' + item.data
  1005. }
  1006. });
  1007. }
  1008. },
  1009. // 点击确定
  1010. dialogConfirm(id) {
  1011. this.noticeTRUE = true;
  1012. var adminId = uni.getStorageSync("globalUser").id;
  1013. var token = uni.getStorageSync("token");
  1014. uni.request({
  1015. url: this.serverurl + '/TNotice/updateNotice?adminId=' + adminId + '&noticeId=' + id,
  1016. header: {
  1017. 'token': token
  1018. },
  1019. method: "POST",
  1020. success: (res) => {
  1021. uni.showModal({
  1022. title: "提示",
  1023. content: res.data.message,
  1024. success: (res) => {
  1025. }
  1026. })
  1027. },
  1028. });
  1029. this.$refs.popupDialog.close()
  1030. },
  1031. //点击取消
  1032. dialogClose(done) {
  1033. this.noticeTRUE = true,
  1034. // this.msgType = 'success'
  1035. // 需要执行 done 才能关闭对话框
  1036. this.$refs.popupDialog.close()
  1037. }
  1038. }
  1039. }
  1040. </script>
  1041. <style>
  1042. page {
  1043. /* background: #F2F2F2; */
  1044. background: #FFFFFF;
  1045. width: 750upx;
  1046. overflow-x: hidden;
  1047. }
  1048. .head {
  1049. display: flex;
  1050. flex-direction: row;
  1051. background: #206DC3;
  1052. width: 750upx;
  1053. height: 180upx;
  1054. }
  1055. .company {
  1056. width: 48%;
  1057. text-align: right;
  1058. }
  1059. .pname {
  1060. display: flex;
  1061. flex-direction: row;
  1062. width: 40%;
  1063. }
  1064. .userFlagimg {
  1065. padding-left: 30upx;
  1066. padding-top: 10upx;
  1067. width: 26upx;
  1068. height: 28upx;
  1069. }
  1070. .wenzi {
  1071. padding-left: 5upx;
  1072. /* text-align:right; */
  1073. white-space: nowrap;
  1074. overflow: hidden;
  1075. /* text-overflow: ellipsis; */
  1076. }
  1077. .ri {
  1078. width: 690upx;
  1079. height: 180upx;
  1080. background: #FFFFFF;
  1081. border-radius: 15upx;
  1082. /* 上移 */
  1083. transform: translateY(-90upx);
  1084. text-align: center;
  1085. margin: auto;
  1086. display: flex;
  1087. flex-direction: row;
  1088. /* 阴影 */
  1089. box-shadow: 0upx -1upx 20upx #D3D3D3;
  1090. /* box-shadow:0px 0px 10px 5px #aaa; */
  1091. }
  1092. .riShell {
  1093. display: flex;
  1094. flex-direction: row;
  1095. margin: auto;
  1096. }
  1097. .riTitle {
  1098. display: flex;
  1099. flex-direction: column;
  1100. margin: auto;
  1101. }
  1102. .riqi {
  1103. display: flex;
  1104. flex-direction: column;
  1105. margin: auto;
  1106. }
  1107. .fourTitle {
  1108. width: 690upx;
  1109. height: 294upx;
  1110. display: flex;
  1111. flex-direction: row;
  1112. flex-wrap: wrap;
  1113. background: #FFFFFF;
  1114. box-shadow: 0upx 0upx 20upx #D3D3D3;
  1115. margin: auto;
  1116. border-radius: 15upx;
  1117. transform: translateY(-60upx);
  1118. }
  1119. .four {
  1120. display: flex;
  1121. flex-direction: row;
  1122. margin: auto;
  1123. width: 48%;
  1124. }
  1125. .fourImg {
  1126. width: 54upx;
  1127. height: 54upx;
  1128. }
  1129. .qiun-padding {
  1130. padding: 2%;
  1131. width: 96%;
  1132. }
  1133. .qiun-wrap {
  1134. display: flex;
  1135. flex-wrap: wrap;
  1136. }
  1137. .qiun-rows {
  1138. display: flex;
  1139. flex-direction: row !important;
  1140. }
  1141. .qiun-columns {
  1142. display: flex;
  1143. flex-direction: column !important;
  1144. }
  1145. .qiun-common-mt {
  1146. margin-top: 0upx;
  1147. height: 160upx;
  1148. }
  1149. .qiun-bg-white {
  1150. background: #FFFFFF;
  1151. }
  1152. .qiun-title-bar {
  1153. width: 100%;
  1154. /* padding: 10upx 2%; */
  1155. flex-wrap: nowrap;
  1156. border-radius: 15upx;
  1157. }
  1158. .qiun-title-dot-light {
  1159. width: 92%;
  1160. border-left: 20upx;
  1161. border-left: 10upx solid #206DC3;
  1162. padding-left: 10upx;
  1163. height: 32upx;
  1164. /* padding-bottom: 40upx; */
  1165. font-family: "PingFang-SC-Bold";
  1166. font-weight: bold;
  1167. margin: auto;
  1168. font-size: 32upx;
  1169. color: #363D44;
  1170. transform: translateY(20upx);
  1171. }
  1172. .dis {
  1173. transform: translateY(-13upx);
  1174. font-size: 32upx;
  1175. font-family: "PingFang-SC-Bold";
  1176. color: #363D44;
  1177. }
  1178. .shijian {
  1179. transform: translateY(40upx);
  1180. padding-top: 30upx;
  1181. height: 80upx;
  1182. width: 690upx;
  1183. margin: auto;
  1184. box-shadow: 0upx 0upx 10upx #D3D3D3;
  1185. }
  1186. .line {
  1187. background: #ECECEC;
  1188. height: 20upx;
  1189. }
  1190. .qiun-charts {
  1191. width: 690upx;
  1192. height: 370upx;
  1193. padding-top: 50upx;
  1194. background-color: #FFFFFF;
  1195. margin: auto;
  1196. }
  1197. .charts {
  1198. width: 690upx;
  1199. height: 370upx;
  1200. background-color: #FFFFFF;
  1201. margin: auto;
  1202. }
  1203. .preImg {
  1204. position: absolute;
  1205. left: 30upx;
  1206. width: 71upx;
  1207. height: 57upx;
  1208. }
  1209. .nextImg {
  1210. position: absolute;
  1211. right: 30upx;
  1212. width: 71upx;
  1213. height: 57upx;
  1214. }
  1215. .fontLeft {
  1216. margin-right: 6upx;
  1217. }
  1218. .tr {
  1219. padding-top: 15upx;
  1220. display: flex;
  1221. flex-direction: row;
  1222. justify-content: flex-start;
  1223. font-size: 26upx;
  1224. font-family: "PingFang-SC-Bold";
  1225. }
  1226. .td-left {
  1227. font-family: "PingFang-SC-Bold";
  1228. margin: auto;
  1229. font-size: 26upx;
  1230. width: 30%;
  1231. text-align: right;
  1232. }
  1233. .td-right {
  1234. font-family: "PingFang-SC-Bold";
  1235. /* font-weight: bold; */
  1236. margin: auto;
  1237. /* font-size: 26upx; */
  1238. width: 70%;
  1239. text-align: left;
  1240. }
  1241. .search-button{
  1242. width: 20%;
  1243. padding-left: 7upx;
  1244. text-align: center;
  1245. }
  1246. </style>