opsCharginglog.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. // pages/ucenter/charginglog/charginglog.js
  2. let Util = require("../../../utils/util");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. charginglogs: [],
  9. pagesize:10,
  10. pagenum:1,
  11. total:-1,
  12. loadTotal: 0,
  13. finishedLoadTap: 0,
  14. finishedLoadShowTimes: 0,
  15. chargPileId: ''
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function(options) {
  21. let userInfo = wx.getStorageSync('userInfo');
  22. let isLogin = wx.getStorageSync('isLogin');
  23. let that = this;
  24. let {
  25. chargPileId
  26. } = options;
  27. console.info(chargPileId)
  28. this.setData({
  29. chargPileId
  30. })
  31. // 页面显示
  32. this.getPage();
  33. },
  34. getPage(){
  35. wx.showLoading({
  36. title: '数据加载中....',
  37. })
  38. let that = this;
  39. wx.request({
  40. url: getApp().globalData.postHeadAgreement +'/restapi/pileLog/wechatchargpilelog',
  41. data: {
  42. chargPileId:that.data.chargPileId
  43. },
  44. method: 'POST',
  45. success(res) {
  46. console.log(res);
  47. if (res.data.result) {
  48. that.formatCharginglogs(res.data.result);
  49. wx.hideLoading()
  50. that.setData({
  51. charginglogs: res.data.result,
  52. });
  53. }
  54. }
  55. });
  56. },
  57. formatCharginglogs(charginglogs) {
  58. charginglogs.forEach((item, index) => {
  59. try {
  60. item.platenumber = item.platenumber?item.platenumber:'';
  61. item.userPlateNumber = item.userPlateNumber?item.userPlateNumber:'';
  62. item.vinno = item.vinno?item.vinno:'';
  63. // 坑爹的上报有问题用正则过滤一下
  64. item.vinno = /^[0-9a-zA-Z]*$/.test(item.vinno)?item.vinno:'';
  65. item.socstart = item.socstart?item.socstart:'';
  66. item.socend = item.socend?item.socend:'';
  67. // var startDate = Util.parseDate(item.chargstarttime);
  68. // var endDate = Util.parseDate(item.chargendtime)
  69. // var totalTime = Math.round((endDate.getTime() - startDate.getTime()) / 60000);
  70. // var totalTimeHour = Math.floor(totalTime / 60);
  71. // var totalTimeMinute = totalTime % 60;
  72. // var startTime = startDate.getFullYear() + "年" + Util.formatNumber(startDate.getMonth() + 1) + '月' + Util.formatNumber(startDate.getDate()) + '日 ' + Util.formatNumber(startDate.getHours()) + ':' + Util.formatNumber(startDate.getMinutes()) + ':' + Util.formatNumber(startDate.getSeconds());
  73. // var endTime = endDate.getFullYear() + "年" + Util.formatNumber(endDate.getMonth() + 1) + '月' + Util.formatNumber(endDate.getDate()) + '日 ' + Util.formatNumber(endDate.getHours()) + ':' + Util.formatNumber(endDate.getMinutes()) + ':' + Util.formatNumber(endDate.getSeconds());
  74. // totalTime = Util.formatNumber(totalTimeHour) + "时" + Util.formatNumber(totalTimeMinute) + "分";
  75. // item.startTime = startTime;
  76. // item.endTime = endTime;
  77. // item.totalTime = totalTime;
  78. // item.chargallmoney = item.chargallmoney.toFixed(2);
  79. // item.chargservice = item.chargservice.toFixed(2);
  80. // item.chargmoney = item.chargmoney.toFixed(2);
  81. //console.log(item.chargPile);
  82. } catch (err) {
  83. //在这里处理错误
  84. }
  85. });
  86. },
  87. startTimeOrder(charginglogs) {
  88. if (charginglogs && 0 != charginglogs.length) {
  89. charginglogs.sort(function(ma, mb) {
  90. return mb.chargstarttime.localeCompare(ma.chargstarttime);
  91. });
  92. }
  93. },
  94. /**
  95. * 生命周期函数--监听页面初次渲染完成
  96. */
  97. onReady: function() {
  98. },
  99. /**
  100. * 生命周期函数--监听页面显示
  101. */
  102. onShow: function() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面隐藏
  106. */
  107. onHide: function() {
  108. },
  109. /**
  110. * 生命周期函数--监听页面卸载
  111. */
  112. onUnload: function() {
  113. },
  114. /**
  115. * 页面相关事件处理函数--监听用户下拉动作
  116. */
  117. onPullDownRefresh: function() {
  118. },
  119. /**
  120. * 页面上拉触底事件的处理函数
  121. */
  122. onReachBottom: function() {
  123. },
  124. bindScrollTolowerEvent: function(){
  125. this.getPage();
  126. },
  127. /**
  128. * 用户点击右上角分享
  129. */
  130. onShareAppMessage: function() {
  131. }
  132. })