123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- // pages/ucenter/charginglog/charginglog.js
- let Util = require("../../../utils/util");
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- charginglogs: [],
- pagesize:10,
- pagenum:1,
- total:-1,
- loadTotal: 0,
- finishedLoadTap: 0,
- finishedLoadShowTimes: 0,
- chargPileId: ''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- let userInfo = wx.getStorageSync('userInfo');
- let isLogin = wx.getStorageSync('isLogin');
- let that = this;
- let {
- chargPileId
- } = options;
- console.info(chargPileId)
- this.setData({
- chargPileId
- })
- // 页面显示
- this.getPage();
- },
- getPage(){
- wx.showLoading({
- title: '数据加载中....',
- })
- let that = this;
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/pileLog/wechatchargpilelog',
- data: {
- chargPileId:that.data.chargPileId
- },
- method: 'POST',
- success(res) {
- console.log(res);
- if (res.data.result) {
- that.formatCharginglogs(res.data.result);
- wx.hideLoading()
- that.setData({
- charginglogs: res.data.result,
- });
- }
- }
- });
- },
- formatCharginglogs(charginglogs) {
- charginglogs.forEach((item, index) => {
- try {
- item.platenumber = item.platenumber?item.platenumber:'';
- item.userPlateNumber = item.userPlateNumber?item.userPlateNumber:'';
- item.vinno = item.vinno?item.vinno:'';
- // 坑爹的上报有问题用正则过滤一下
- item.vinno = /^[0-9a-zA-Z]*$/.test(item.vinno)?item.vinno:'';
- item.socstart = item.socstart?item.socstart:'';
- item.socend = item.socend?item.socend:'';
-
-
-
- // var startDate = Util.parseDate(item.chargstarttime);
- // var endDate = Util.parseDate(item.chargendtime)
- // var totalTime = Math.round((endDate.getTime() - startDate.getTime()) / 60000);
- // var totalTimeHour = Math.floor(totalTime / 60);
- // var totalTimeMinute = totalTime % 60;
- // 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());
- // 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());
- // totalTime = Util.formatNumber(totalTimeHour) + "时" + Util.formatNumber(totalTimeMinute) + "分";
- // item.startTime = startTime;
- // item.endTime = endTime;
- // item.totalTime = totalTime;
- // item.chargallmoney = item.chargallmoney.toFixed(2);
- // item.chargservice = item.chargservice.toFixed(2);
- // item.chargmoney = item.chargmoney.toFixed(2);
- //console.log(item.chargPile);
- } catch (err) {
- //在这里处理错误
- }
- });
- },
- startTimeOrder(charginglogs) {
- if (charginglogs && 0 != charginglogs.length) {
- charginglogs.sort(function(ma, mb) {
- return mb.chargstarttime.localeCompare(ma.chargstarttime);
- });
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- bindScrollTolowerEvent: function(){
- this.getPage();
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- }
- })
|