mainStatistics.vue 34 KB

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