mainStatistics.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  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. <!-- 商家选择 -->
  108. <view v-if="id!=1&&type<4&&length>0" class="td-right">
  109. <view class="uni-list">
  110. <view class="uni-list-cell">
  111. <view class="uni-list-cell-left">
  112. 当前商家:
  113. </view>
  114. <view class="uni-list-cell-db" style="overflow: hidden;text-overflow: ellipsis;">
  115. <picker @change="changeAdmin" :value="index" :range="adminList">
  116. <view class="uni-input">{{adminList[index]}}</view>
  117. </picker>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <view class="qiun-columns">
  123. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  124. <view class="qiun-title-dot-light">
  125. <view class="dis">{{$t('mainStatistics.day')}}</view>
  126. </view>
  127. <view class="shijian" style="text-align: center;position: relative;">
  128. <image @click="pre('day')" class="preImg" src="/static/img/leftTriangle.png"></image>
  129. <span>{{startDate1}}</span>
  130. <image @click="next('day')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  131. </view>
  132. </view>
  133. <view class="qiun-charts" style="background-color: #FFFFFF;">
  134. <canvas canvas-id="canvaColumn1" id="canvaColumn1" class="charts" disable-scroll=true
  135. @touchstart="touchLine1" @touchmove="moveLine1" @touchend="touchEndLine1"
  136. style="background-color: #FFFFFF;"></canvas>
  137. </view>
  138. </view>
  139. <view class="line"></view>
  140. <view class="qiun-columns">
  141. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  142. <view class="qiun-title-dot-light">
  143. <view class="dis">{{$t('mainStatistics.week')}}</view>
  144. </view>
  145. <view class="shijian" style="text-align: center;position: relative;">
  146. <image @click="pre('week')" class="preImg" src="/static/img/leftTriangle.png"></image>
  147. <span>{{startDate2}} -- {{endDate2}}</span>
  148. <image @click="next('week')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  149. </view>
  150. </view>
  151. <view class="qiun-charts" style="background-color: #FFFFFF;">
  152. <canvas canvas-id="canvaColumn2" id="canvaColumn2" class="charts" disable-scroll=true
  153. @touchstart="touchLine2" @touchmove="moveLine2" @touchend="touchEndLine2"
  154. style="background-color: #FFFFFF;"></canvas>
  155. </view>
  156. </view>
  157. <view class="line"></view>
  158. <view class="qiun-columns">
  159. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  160. <view class="qiun-title-dot-light">
  161. <view class="dis">{{$t('mainStatistics.month')}}</view>
  162. </view>
  163. <view class="shijian" style="text-align: center;position: relative;">
  164. <image @click="pre('month')" class="preImg" src="/static/img/leftTriangle.png"></image>
  165. <span>{{startDate3}} -- {{endDate3}}</span>
  166. <image @click="next('month')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  167. </view>
  168. </view>
  169. <view class="qiun-charts" style="background-color: #FFFFFF;">
  170. <canvas canvas-id="canvaColumn3" id="canvaColumn3" class="charts" disable-scroll=true
  171. @touchstart="touchLine3" @touchmove="moveLine3" @touchend="touchEndLine3"
  172. style="background-color: #FFFFFF;"></canvas>
  173. </view>
  174. </view>
  175. <view class="line"></view>
  176. <view class="qiun-columns">
  177. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  178. <view class="qiun-title-dot-light">
  179. <view class="dis">{{$t('mainStatistics.year')}}</view>
  180. </view>
  181. <view class="shijian" style="text-align: center;position: relative;">
  182. <image @click="pre('year')" class="preImg" src="/static/img/leftTriangle.png"></image>
  183. <span>{{startDate4}} -- {{endDate4}}</span>
  184. <image @click="next('year')" class="nextImg" src="/static/img/rightTriangle.png"></image>
  185. </view>
  186. </view>
  187. <view class="qiun-charts" style="background-color: #FFFFFF;">
  188. <canvas canvas-id="canvaColumn4" id="canvaColumn4" class="charts" disable-scroll=true
  189. @touchstart="touchLine4" @touchmove="moveLine4" @touchend="touchEndLine4"
  190. style="background-color: #FFFFFF;"></canvas>
  191. </view>
  192. </view>
  193. <view>
  194. <uni-popup id="popupDialog" ref="popupDialog" type="dialog">
  195. <uni-popup-dialog :type="msgType" title="通知" content="欢迎使用 unisdfdd-popup!"
  196. :before-close="true" @confirm="dialogConfirm" @close="dialogClose">
  197. <scroll-view scroll-y="true" class="scroll-Y" :style="{height:scrollHeight*0.8+'px'}">
  198. <view class="scroll-view-item ">
  199. 投诉处理通知书 <br/>
  200. 背景:消费者投诉是指消费者在买糖之后,在微信或者支付宝平台对该笔订单发起投诉。该功能是微信及支付宝所拥有的功能。
  201. 消费者投诉后,支付宝或者微信会通知到我们公司,我们公司再通知到商家。商家接到消费者投诉后需要进行处理。
  202. 如果商家在收到短信24小时后还不处理,我们将会进行退款处理。<br/>
  203. 处理需知:我们申泽会以短信的信息通知到商家,通知的内容里我们会加上消费者的联系方式,以供商家去核实情况,如果没有消费者的联系方式,可以在微信群联系我们,然后把商家的联系方式发送到我们这边,我们公司会把商家的联系方式发送到消费者的微信上,让消费者自己去联系商家。
  204. 以下是处理方式:<br/>
  205. 1,退款<br/>
  206. 退款一般是在消费者离开机器现场后,在微信或者支付平台上投诉的情况。<br/>
  207. 1.1在小程序“申泽智能物联”上退款<br/>
  208. 我们推荐使用这种方式,因为在我们申泽的平台上退款后,我们会有已退款的记录凭证,以免后续不必要的纠纷。
  209. 如果商家在我们公司的账户里没钱,可推荐红包或转账的方式<br/>
  210. 1.2用红包或转账的方式<br/>
  211. 商家可用红包或转账的方式给消费者退款,但是需要收集3个资料:消费者的支付凭证,截图红包或者转账的界面(红包最好写上备注),
  212. 聊天界面-消费者同意用红包或转账的方式退款。商家收集这3个资料给到我们公司,由我们公司反馈上去。<br/>
  213. 2,不退款<br/>
  214. 不退款一般发生在消费者还在机器的情况下,商家和消费者取得了联系,用其他方式补偿。<br/>
  215. 2.1重新做糖<br/>
  216. 商家可以用重新做糖给消费者的形式补偿,但是商家也需要收集证据。
  217. 需要收集:1消费者的支付凭证;2聊天界面-消费者同意截图;商家需要把这些收集好。
  218. 如果消费者投诉了这个有重新做糖的订单,可以把这些信息发送到我们申泽这边,这样就可以不用退款。<br/>
  219. 2.2消费者提供不了证据<br/>
  220. 这个情况是在商家与消费者取得联系后,消费者无法提供证据说明商品有问题。
  221. 商家可以把聊天记录--确认消费者提供不了证据的界面的截图提供到我们这边。由我们把情况反馈上去。<br/>
  222. </view>
  223. </scroll-view>
  224. </uni-popup-dialog>
  225. </uni-popup>
  226. </view>
  227. </view>
  228. </template>
  229. <script>
  230. import {
  231. mapState,
  232. mapActions,
  233. mapMutations
  234. } from 'vuex';
  235. import uCharts from '@/components/u-charts/u-charts.js';
  236. import {
  237. dateUtils
  238. } from '@/common/util.js';
  239. var _self;
  240. var canvaColumn1 = null;
  241. var canvaColumn2 = null;
  242. var canvaColumn3 = null;
  243. var canvaColumn4 = null;
  244. export default {
  245. name: 'mainStatistics',
  246. props: {
  247. equipmentId: '',
  248. adminId: '',
  249. pname: '',
  250. },
  251. data() {
  252. return {
  253. machineTotalNum: 0,
  254. machineUseNum: 0,
  255. dayTotalMoney: 0,
  256. dayTotalNum: 0,
  257. weekTotalMoney: 0,
  258. weekTotalNum: 0,
  259. monthTotalMoney: 0,
  260. monthTotalNum: 0,
  261. yearTotalMoney: 0,
  262. yearTotalNum: 0,
  263. cWidth: '',
  264. cHeight: '',
  265. pixelRatio: 1,
  266. startDate1: '',
  267. startDate2: '',
  268. endDate2: '',
  269. startDate3: '',
  270. endDate3: '',
  271. startDate4: '',
  272. endDate4: '',
  273. today: '',
  274. week: '',
  275. adminList: [],
  276. admins: [],
  277. index: 0,
  278. id: 0,
  279. length:0,
  280. // type:null,
  281. type: 'top',
  282. msgType: 'success',
  283. value: '默认输入的内容',
  284. scrollHeight:uni.getSystemInfoSync().windowHeight - 130,
  285. }
  286. },
  287. onReady() {
  288. // 页面打开自动打开对话框
  289. setTimeout(() => {
  290. // this.msgType = 'success'
  291. this.$refs.popupDialog.open()
  292. }, 500)
  293. },
  294. computed: {
  295. ...mapState(['loginUser']),
  296. pnameData: {
  297. get() {
  298. return this.pname;
  299. }
  300. },
  301. },
  302. onShow() {
  303. uni.setNavigationBarTitle({
  304. title: this.$t('mainStatistics.title')
  305. });
  306. uni.setTabBarItem({
  307. index: 0,
  308. text: this.$t('tabs.tab1')
  309. });
  310. this.id = 0;
  311. this.index = 0;
  312. var token = uni.getStorageSync("token");
  313. if (token.toString().length > 1) {
  314. this.init();
  315. } else {
  316. uni.reLaunch({
  317. url: '../Login/Login',
  318. });
  319. }
  320. // console.log("onShow");
  321. var test = uni.getStorageSync('test');
  322. var globalUser = uni.getStorageSync("globalUser");
  323. if (globalUser.toString().length > 1) {
  324. //判断是不是初次登陆
  325. // if (test == 2) {
  326. // this.init();
  327. // }
  328. if (globalUser.type > 0&&globalUser.type<4) {
  329. this.getAdmin();
  330. }
  331. this.id = globalUser.id;
  332. this.type = globalUser.type;
  333. }
  334. // var id = this.adminId;
  335. this.day();
  336. // this.equipmentStatus();
  337. },
  338. mounted() {
  339. var token = uni.getStorageSync("token");
  340. if (token.toString().length > 1) {
  341. this.init();
  342. } else {
  343. uni.reLaunch({
  344. url: '../Login/Login',
  345. });
  346. }
  347. // this.day();
  348. this.equipmentStatus();
  349. },
  350. methods: {
  351. // open() {
  352. // this.show = true;
  353. // },
  354. ...mapActions('chart', ['getStatistics', 'getMachineNum']),
  355. async init() {
  356. if (!this.pname) {
  357. this.pname = this.loginUser.name;
  358. }
  359. _self = this;
  360. //图表中图
  361. this.cWidth = uni.upx2px(690);
  362. this.cHeight = uni.upx2px(370);
  363. await this.getMainStatisticsData();
  364. await this.initDateRang(new Date(), 'day');
  365. await this.initDateRang(new Date(), 'week');
  366. await this.initDateRang(new Date(), 'month');
  367. await this.initDateRang(new Date(), 'year');
  368. //初次登陆跳转后,把test变成2
  369. uni.setStorageSync('test', '2');
  370. },
  371. day() {
  372. var date = new Date();
  373. // var daystr = dateUtils.formateDate(date, 'yyyy年MM月dd日');
  374. var daystr = dateUtils.formateDate(date, 'yyyy-MM-dd');
  375. this.today = daystr;
  376. // var str= '星期'+'日一二三四五六'.charAt(date.getDay());
  377. this.week = this.$t('mainStatistics.week' + date.getDay());
  378. },
  379. //查询下级用户
  380. getAdmin() {
  381. var param = {};
  382. var token = uni.getStorageSync("token");
  383. var globalUser = uni.getStorageSync("globalUser");
  384. param['id'] = globalUser.id;
  385. uni.request({
  386. url: this.serverurl + '/TAdmin/selectLowAdmin',
  387. data: param,
  388. header: {
  389. 'token': token
  390. },
  391. method: "POST",
  392. success: (res) => {
  393. if (res.data.code) {
  394. var admins = res.data.data;
  395. this.admins = admins;
  396. var adminList = [];
  397. adminList.push('本商户');
  398. if (admins.length > 0) {
  399. this.length = admins.length;
  400. adminList.push('所有下级');
  401. for (var i = 1; i < admins.length; i++) {
  402. // console.log(admins[i].name)
  403. if (admins[i].name != null || admins[i].name != '') {
  404. adminList.push(admins[i].name);
  405. } else {
  406. adminList.push(admins[i].username);
  407. }
  408. }
  409. }
  410. this.adminList = adminList;
  411. } else {
  412. uni.showToast({
  413. title: `获取信息失败:` + res.data.message,
  414. icon: 'none'
  415. })
  416. }
  417. },
  418. });
  419. // this.selectLowAdmin(param)
  420. // .then(res => {
  421. // if (res.code) {
  422. // var admins = res.data;
  423. // this.admins = admins;
  424. // var adminList = [];
  425. // adminList.push('本商户');
  426. // if (admins.length > 0) {
  427. // this.length = admins.length;
  428. // adminList.push('所有下级');
  429. // for (var i = 1; i < admins.length; i++) {
  430. // // console.log(admins[i].name)
  431. // if (admins[i].name != null || admins[i].name != '') {
  432. // adminList.push(admins[i].name);
  433. // } else {
  434. // adminList.push(admins[i].username);
  435. // }
  436. // }
  437. // }
  438. // this.adminList = adminList;
  439. // } else {
  440. // uni.showToast({
  441. // title: `获取信息失败:` + res.message,
  442. // icon: 'none'
  443. // })
  444. // }
  445. // });
  446. },
  447. // 改变商家
  448. changeAdmin: function(e){
  449. this.index = e.target.value;
  450. var id = '';
  451. if(e.target.value>1){
  452. id = this.admins[e.target.value-1].id;
  453. }
  454. if(e.target.value==1){
  455. id = 'all';
  456. }
  457. if(e.target.value==0){
  458. id = 0;
  459. }
  460. // console.log("adminID="+id);
  461. this.id = id;
  462. this.init();
  463. },
  464. equipmentStatus() {
  465. var that = this;
  466. var id = uni.getStorageSync("globalUser").id;
  467. var token = uni.getStorageSync("token");
  468. uni.request({
  469. url: this.serverurl + '/TEquipment/equipmentStatus',
  470. data: {
  471. "adminId": id
  472. },
  473. header: {
  474. 'token': token
  475. },
  476. method: "POST",
  477. success: (res) => {
  478. setTimeout(function() {
  479. that.checkEquipmentStatus(id);
  480. }, 5000);
  481. },
  482. });
  483. },
  484. checkEquipmentStatus(id) {
  485. var token = uni.getStorageSync("token");
  486. uni.request({
  487. url: this.serverurl + '/TEquipment/checkEquipmentStatus',
  488. data: {
  489. "adminId": id
  490. },
  491. header: {
  492. 'token': token
  493. },
  494. method: "POST",
  495. success: (res) => {
  496. },
  497. });
  498. },
  499. initDateRang(day, chartType) {
  500. const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
  501. if (chartType === 'day') {
  502. this.startDate1 = dateUtils.formateDate(day, 'yyyy/MM/dd');
  503. }
  504. if (chartType === 'week') {
  505. this.startDate2 = dateUtils.formateDate(dateUtils.getFirstDayOfWeek(day), 'yyyy/MM/dd');
  506. this.endDate2 = dateUtils.formateDate(dateUtils.getLastDayOfWeek(day), 'yyyy/MM/dd');
  507. }
  508. if (chartType === 'month') {
  509. this.startDate3 = dateUtils.formateDate(dateUtils.getCurrentMonFirstDate(day), 'yyyy/MM/dd');
  510. this.endDate3 = dateUtils.formateDate(dateUtils.getCurrentMonLastDate(day), 'yyyy/MM/dd');
  511. }
  512. if (chartType === 'year') {
  513. this.startDate4 = dateUtils.formateDate(dateUtils.getCurrentYearFirstDate(day), 'yyyy/MM/dd');
  514. this.endDate4 = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
  515. }
  516. return this.getStatisticsData(chartType);
  517. },
  518. /**上一个 */
  519. pre(chartType) {
  520. let day;
  521. if (chartType === 'day') { // 日
  522. day = new Date(this.startDate1);
  523. day.setDate(day.getDate() - 1);
  524. }
  525. if (chartType === 'week') { // 周
  526. day = new Date(this.startDate2);
  527. day.setDate(day.getDate() - 7);
  528. }
  529. if (chartType === 'month') { // 月
  530. day = new Date(this.startDate3);
  531. day.setMonth(day.getMonth() - 1);
  532. }
  533. if (chartType === 'year') { // 年
  534. day = new Date(this.startDate4);
  535. day.setFullYear(day.getFullYear() - 1);
  536. }
  537. this.initDateRang(day, chartType);
  538. },
  539. /**下一个 */
  540. next(chartType) {
  541. let day;
  542. if (chartType === 'day') { // 日
  543. day = new Date(this.startDate1);
  544. day.setDate(day.getDate() + 1);
  545. }
  546. if (chartType === 'week') { // 周
  547. day = new Date(this.startDate2);
  548. day.setDate(day.getDate() + 7);
  549. }
  550. if (chartType === 'month') { // 月
  551. day = new Date(this.startDate3);
  552. day.setMonth(day.getMonth() + 1);
  553. }
  554. if (chartType === 'year') { // 年
  555. day = new Date(this.startDate4);
  556. day.setFullYear(day.getFullYear() + 1);
  557. }
  558. this.initDateRang(day, chartType);
  559. },
  560. getStatisticsData(chartType) {
  561. const param = {
  562. 'chartType': chartType
  563. };
  564. if (chartType == 'day') {
  565. param['startDate'] = this.startDate1;
  566. param['endDate'] = this.startDate1;
  567. }
  568. if (chartType == 'week') {
  569. param['startDate'] = this.startDate2;
  570. param['endDate'] = this.endDate2;
  571. }
  572. if (chartType == 'month') {
  573. param['startDate'] = this.startDate3;
  574. param['endDate'] = this.endDate3;
  575. }
  576. if (chartType == 'year') {
  577. param['startDate'] = this.startDate4;
  578. param['endDate'] = this.endDate4;
  579. }
  580. if (this.adminId) { // 子组件,则拿传过来的参
  581. param['adminId'] = this.adminId;
  582. } else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
  583. param['adminId'] = this.loginUser['id'];
  584. }
  585. var globalUser = uni.getStorageSync("globalUser");
  586. if (globalUser.id != 1) {
  587. if (param.adminId == null || param.adminId == undefined) {
  588. param['adminId'] = globalUser.id;
  589. }
  590. }
  591. if (this.equipmentId) {
  592. param['equipmentId'] = this.equipmentId;
  593. }
  594. if (this.id!=1) {
  595. var id = this.id;
  596. }else{
  597. var id = 0;
  598. }
  599. if(id=='all'){
  600. param['adminId'] = null;
  601. if(this.type==1){
  602. param['agencyId'] = globalUser.id;
  603. }
  604. if(this.type==2){
  605. param['merchantId'] = globalUser.id;
  606. }
  607. }else if(id==0){
  608. }else{
  609. param['adminId'] = id;
  610. }
  611. return this.getStatistics(param)
  612. .then(data => {
  613. uni.stopPullDownRefresh();
  614. if (param['chartType'] == 'day') {
  615. canvaColumn1 = this.initChart('canvaColumn1', data);
  616. }
  617. if (param['chartType'] == 'week') {
  618. canvaColumn2 = this.initChart('canvaColumn2', data);
  619. }
  620. if (param['chartType'] == 'month') {
  621. canvaColumn3 = this.initChart('canvaColumn3', data);
  622. }
  623. if (param['chartType'] == 'year') {
  624. canvaColumn4 = this.initChart('canvaColumn4', data);
  625. }
  626. }, _ => {
  627. uni.stopPullDownRefresh();
  628. if (param['chartType'] == 'day') {
  629. canvaColumn1 = this.initChart('canvaColumn1', {
  630. categories: ['暂无数据'],
  631. series: [{
  632. name: '销售个数',
  633. data: [0]
  634. }]
  635. });
  636. }
  637. if (param['chartType'] == 'week') {
  638. canvaColumn2 = this.initChart('canvaColumn2', {
  639. categories: ['暂无数据'],
  640. series: [{
  641. name: '销售个数',
  642. data: [0]
  643. }]
  644. });
  645. }
  646. if (param['chartType'] == 'month') {
  647. canvaColumn3 = this.initChart('canvaColumn3', {
  648. categories: ['暂无数据'],
  649. series: [{
  650. name: '销售个数',
  651. data: [0]
  652. }]
  653. });
  654. }
  655. if (param['chartType'] == 'year') {
  656. canvaColumn4 = this.initChart('canvaColumn4', {
  657. categories: ['暂无数据'],
  658. series: [{
  659. name: '销售个数',
  660. data: [0]
  661. }]
  662. });
  663. }
  664. });
  665. },
  666. initChart(canvasId, chartData) {
  667. if (this.$t('lang') != null && this.$t('lang') != '') {
  668. if (this.$t('lang') != 'zh') {
  669. chartData.categories = chartData.categories.map(e => {
  670. if (e.indexOf('点') >= 0) {
  671. return e.replace('点', this.$t('mainStatistics.oclock'));
  672. }
  673. if (e.indexOf('周') >= 0) {
  674. const weekNum = e.substring(e.length - 1) == '日' ? '0' : e.substring(e.length - 1);
  675. return this.$t('mainStatistics.week' + weekNum);
  676. }
  677. if (e.indexOf('月') >= 0) {
  678. var res = e.toString();
  679. if (res.length > 3) {
  680. return e.replace('月', this.$t('mainStatistics.mon'));
  681. } else {
  682. return e.replace('月', this.$t('mainStatistics.y'));
  683. }
  684. }
  685. return e;
  686. });
  687. chartData.series = chartData.series.map(e => {
  688. if (e['name'] == '销售个数') {
  689. e['name'] = this.$t('mainStatistics.saleNum');
  690. }
  691. if (e['name'] == '销售额') {
  692. e['name'] = this.$t('mainStatistics.saleroom');
  693. }
  694. return e;
  695. });
  696. }
  697. }
  698. return new uCharts({
  699. $this: _self,
  700. canvasId: canvasId,
  701. enableScroll: true,
  702. type: 'column',
  703. legend: true,
  704. fontSize: 10,
  705. background: '#FFFFFF', //y轴颜色
  706. pixelRatio: 1,
  707. animation: true,
  708. categories: chartData.categories,
  709. series: chartData.series,
  710. xAxis: {
  711. type: 'grid',
  712. gridType: 'dash',
  713. itemCount: 5, //x轴单屏显示数据的数量,默认为5个
  714. scrollShow: true, //新增是否显示滚动条,默认false
  715. scrollAlign: 'left', //滚动条初始位置
  716. scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF 滚动条颜色底色
  717. scrollColor: '#DEE7F7', //默认为 #A6A6A6 滚动条颜色
  718. disableGrid: true,
  719. },
  720. yAxis: {
  721. type: 'grid',
  722. gridType: 'soild',
  723. // disabled:true
  724. // disableGrid:true,
  725. },
  726. dataLabel: true,
  727. width: _self.cWidth * _self.pixelRatio,
  728. height: _self.cHeight * _self.pixelRatio,
  729. extra: {
  730. column: {
  731. // width: _self.cWidth*_self.pixelRatio*0.45/chartData.categories.length
  732. width: 18
  733. }
  734. }
  735. });
  736. },
  737. getMainStatisticsData() {
  738. const param = {};
  739. if (this.adminId) { // 子组件,则拿传过来的参
  740. param['adminId'] = this.adminId;
  741. } else if ('admin' !== this.loginUser['username']) { //否则为主页,拿登录用户
  742. param['adminId'] = this.loginUser['id'];
  743. }
  744. var globalUser = uni.getStorageSync("globalUser");
  745. if (globalUser.id != 1) {
  746. if (param.adminId == null || param.adminId == undefined) {
  747. param['adminId'] = globalUser.id;
  748. }
  749. }
  750. if (this.equipmentId) {
  751. param['equipmentId'] = this.equipmentId;
  752. }
  753. if (this.id!=1) {
  754. var id = this.id;
  755. }else{
  756. var id = 0;
  757. }
  758. var aid = param.adminId;
  759. if(id=='all'){
  760. param['adminId'] = null;
  761. if(this.type==1){
  762. param['agencyId'] = globalUser.id;
  763. }
  764. if(this.type==2){
  765. param['merchantId'] = globalUser.id;
  766. }
  767. }else if(id==0){
  768. }else{
  769. param['adminId'] = id;
  770. aid = id;
  771. }
  772. // console.log('getMainStatisticsData:{}', param);
  773. var adminId = param.adminId;
  774. var equipmentId = this.equipmentId;
  775. var serverurl = this.serverurl;
  776. var token = uni.getStorageSync("token");
  777. uni.request({
  778. url: serverurl + '/TEquipment/getMachineNum',
  779. data: {
  780. "adminId": aid,
  781. "equipmentId": equipmentId
  782. },
  783. method: "POST",
  784. header: {
  785. 'token': token
  786. },
  787. success: (res) => {
  788. var list = res.data.data;
  789. this.machineTotalNum = list[0];
  790. this.machineUseNum = list[1];
  791. }
  792. });
  793. uni.request({
  794. url: serverurl + '/TOrder/getMainStatistics',
  795. data: param,
  796. method: "POST",
  797. header: {
  798. 'token': token
  799. },
  800. success: (res) => {
  801. var list = res.data.data;
  802. for (let bean of list) {
  803. if (bean['categorie'] === 'day') {
  804. this.dayTotalMoney = bean['salePrice'];
  805. this.dayTotalNum = bean['saleNum'];
  806. }
  807. if (bean['categorie'] === 'week') {
  808. this.weekTotalMoney = bean['salePrice'];
  809. this.weekTotalNum = bean['saleNum'];
  810. }
  811. if (bean['categorie'] === 'month') {
  812. this.monthTotalMoney = bean['salePrice'];
  813. this.monthTotalNum = bean['saleNum'];
  814. }
  815. if (bean['categorie'] === 'year') {
  816. this.yearTotalMoney = bean['salePrice'];
  817. this.yearTotalNum = bean['saleNum'];
  818. }
  819. }
  820. }
  821. });
  822. // return this.getMainStatistics(param)
  823. // .then(data => {
  824. // for (let bean of data) {
  825. // if (bean['categorie'] === 'day') {
  826. // this.dayTotalMoney = bean['salePrice'];
  827. // this.dayTotalNum = bean['saleNum'];
  828. // }
  829. // if (bean['categorie'] === 'week') {
  830. // this.weekTotalMoney = bean['salePrice'];
  831. // this.weekTotalNum = bean['saleNum'];
  832. // }
  833. // if (bean['categorie'] === 'month') {
  834. // this.monthTotalMoney = bean['salePrice'];
  835. // this.monthTotalNum = bean['saleNum'];
  836. // }
  837. // if (bean['categorie'] === 'year') {
  838. // this.yearTotalMoney = bean['salePrice'];
  839. // this.yearTotalNum = bean['saleNum'];
  840. // }
  841. // }
  842. // uni.stopPullDownRefresh();
  843. // }, _ => void uni.stopPullDownRefresh());
  844. },
  845. touchLine1(e) {
  846. if (canvaColumn1) {
  847. canvaColumn1.scrollStart(e);
  848. }
  849. },
  850. moveLine1(e) {
  851. if (canvaColumn1) {
  852. canvaColumn1.scroll(e);
  853. }
  854. },
  855. touchEndLine1(e) {
  856. if (canvaColumn1) {
  857. canvaColumn1.scrollEnd(e);
  858. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  859. canvaColumn1.showToolTip(e, {
  860. format: function(item, category) {
  861. return category + ' ' + item.name + ':' + item.data
  862. }
  863. });
  864. }
  865. },
  866. touchLine2(e) {
  867. if (canvaColumn2) {
  868. canvaColumn2.scrollStart(e);
  869. }
  870. },
  871. moveLine2(e) {
  872. if (canvaColumn2) {
  873. canvaColumn2.scroll(e);
  874. }
  875. },
  876. touchEndLine2(e) {
  877. if (canvaColumn2) {
  878. canvaColumn2.scrollEnd(e);
  879. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  880. canvaColumn2.showToolTip(e, {
  881. format: function(item, category) {
  882. return category + ' ' + item.name + ':' + item.data
  883. }
  884. });
  885. }
  886. },
  887. touchLine3(e) {
  888. if (canvaColumn3) {
  889. canvaColumn3.scrollStart(e);
  890. }
  891. },
  892. moveLine3(e) {
  893. if (canvaColumn3) {
  894. canvaColumn3.scroll(e);
  895. }
  896. },
  897. touchEndLine3(e) {
  898. if (canvaColumn3) {
  899. canvaColumn3.scrollEnd(e);
  900. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  901. canvaColumn3.showToolTip(e, {
  902. format: function(item, category) {
  903. return category + ' ' + item.name + ':' + item.data
  904. }
  905. });
  906. }
  907. },
  908. touchLine4(e) {
  909. if (canvaColumn4) {
  910. canvaColumn4.scrollStart(e);
  911. }
  912. },
  913. moveLine4(e) {
  914. if (canvaColumn4) {
  915. canvaColumn4.scroll(e);
  916. }
  917. },
  918. touchEndLine4(e) {
  919. if (canvaColumn4) {
  920. canvaColumn4.scrollEnd(e);
  921. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  922. canvaColumn4.showToolTip(e, {
  923. format: function(item, category) {
  924. return category + ' ' + item.name + ':' + item.data
  925. }
  926. });
  927. }
  928. },
  929. // 点击确定
  930. dialogConfirm(done){
  931. this.$refs.popupDialog.close()
  932. },
  933. //点击取消
  934. dialogClose(done){
  935. // this.msgType = 'success'
  936. // 需要执行 done 才能关闭对话框
  937. this.$refs.popupDialog.close()
  938. }
  939. }
  940. }
  941. </script>
  942. <style>
  943. page {
  944. /* background: #F2F2F2; */
  945. background: #FFFFFF;
  946. width: 750upx;
  947. overflow-x: hidden;
  948. }
  949. .head {
  950. display: flex;
  951. flex-direction: row;
  952. background: #206DC3;
  953. width: 750upx;
  954. height: 180upx;
  955. }
  956. .company {
  957. width: 48%;
  958. text-align: right;
  959. }
  960. .pname {
  961. display: flex;
  962. flex-direction: row;
  963. width: 40%;
  964. }
  965. .userFlagimg {
  966. padding-left: 30upx;
  967. padding-top: 10upx;
  968. width: 26upx;
  969. height: 28upx;
  970. }
  971. .wenzi {
  972. padding-left: 5upx;
  973. /* text-align:right; */
  974. white-space: nowrap;
  975. overflow: hidden;
  976. /* text-overflow: ellipsis; */
  977. }
  978. .ri {
  979. width: 690upx;
  980. height: 180upx;
  981. background: #FFFFFF;
  982. border-radius: 15upx;
  983. /* 上移 */
  984. transform: translateY(-90upx);
  985. text-align: center;
  986. margin: auto;
  987. display: flex;
  988. flex-direction: row;
  989. /* 阴影 */
  990. box-shadow: 0upx -1upx 20upx #D3D3D3;
  991. /* box-shadow:0px 0px 10px 5px #aaa; */
  992. }
  993. .riShell {
  994. display: flex;
  995. flex-direction: row;
  996. margin: auto;
  997. }
  998. .riTitle {
  999. display: flex;
  1000. flex-direction: column;
  1001. margin: auto;
  1002. }
  1003. .riqi {
  1004. display: flex;
  1005. flex-direction: column;
  1006. margin: auto;
  1007. }
  1008. .fourTitle {
  1009. width: 690upx;
  1010. height: 294upx;
  1011. display: flex;
  1012. flex-direction: row;
  1013. flex-wrap: wrap;
  1014. background: #FFFFFF;
  1015. box-shadow: 0upx 0upx 20upx #D3D3D3;
  1016. margin: auto;
  1017. border-radius: 15upx;
  1018. transform: translateY(-60upx);
  1019. }
  1020. .four {
  1021. display: flex;
  1022. flex-direction: row;
  1023. margin: auto;
  1024. width: 48%;
  1025. }
  1026. .fourImg {
  1027. width: 54upx;
  1028. height: 54upx;
  1029. }
  1030. .qiun-padding {
  1031. padding: 2%;
  1032. width: 96%;
  1033. }
  1034. .qiun-wrap {
  1035. display: flex;
  1036. flex-wrap: wrap;
  1037. }
  1038. .qiun-rows {
  1039. display: flex;
  1040. flex-direction: row !important;
  1041. }
  1042. .qiun-columns {
  1043. display: flex;
  1044. flex-direction: column !important;
  1045. }
  1046. .qiun-common-mt {
  1047. margin-top: 0upx;
  1048. height: 160upx;
  1049. }
  1050. .qiun-bg-white {
  1051. background: #FFFFFF;
  1052. }
  1053. .qiun-title-bar {
  1054. width: 100%;
  1055. /* padding: 10upx 2%; */
  1056. flex-wrap: nowrap;
  1057. border-radius: 15upx;
  1058. }
  1059. .qiun-title-dot-light {
  1060. width: 92%;
  1061. border-left: 20upx;
  1062. border-left: 10upx solid #206DC3;
  1063. padding-left: 10upx;
  1064. height: 32upx;
  1065. /* padding-bottom: 40upx; */
  1066. font-family: "PingFang-SC-Bold";
  1067. font-weight: bold;
  1068. margin: auto;
  1069. font-size: 32upx;
  1070. color: #363D44;
  1071. transform: translateY(20upx);
  1072. }
  1073. .dis {
  1074. transform: translateY(-13upx);
  1075. font-size: 32upx;
  1076. font-family: "PingFang-SC-Bold";
  1077. color: #363D44;
  1078. }
  1079. .shijian {
  1080. transform: translateY(40upx);
  1081. padding-top: 30upx;
  1082. height: 80upx;
  1083. width: 690upx;
  1084. margin: auto;
  1085. box-shadow: 0upx 0upx 10upx #D3D3D3;
  1086. }
  1087. .line {
  1088. background: #ECECEC;
  1089. height: 20upx;
  1090. }
  1091. .qiun-charts {
  1092. width: 690upx;
  1093. height: 370upx;
  1094. padding-top: 50upx;
  1095. background-color: #FFFFFF;
  1096. margin: auto;
  1097. }
  1098. .charts {
  1099. width: 690upx;
  1100. height: 370upx;
  1101. background-color: #FFFFFF;
  1102. margin: auto;
  1103. }
  1104. .preImg {
  1105. position: absolute;
  1106. left: 30upx;
  1107. width: 71upx;
  1108. height: 57upx;
  1109. }
  1110. .nextImg {
  1111. position: absolute;
  1112. right: 30upx;
  1113. width: 71upx;
  1114. height: 57upx;
  1115. }
  1116. .fontLeft {
  1117. margin-right: 6upx;
  1118. }
  1119. .tr {
  1120. padding-top: 15upx;
  1121. display: flex;
  1122. flex-direction: row;
  1123. justify-content: flex-start;
  1124. font-size: 26upx;
  1125. font-family: "PingFang-SC-Bold";
  1126. }
  1127. .td-left {
  1128. font-family: "PingFang-SC-Bold";
  1129. margin: auto;
  1130. font-size: 26upx;
  1131. width: 30%;
  1132. text-align: right;
  1133. }
  1134. .td-right {
  1135. font-family: "PingFang-SC-Bold";
  1136. /* font-weight: bold; */
  1137. margin: auto;
  1138. /* font-size: 26upx; */
  1139. width: 70%;
  1140. text-align: left;
  1141. }
  1142. </style>