mainStatistics.vue 34 KB

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