mainStatistics.vue 33 KB

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