const formatTime = date => { const year = date.getFullYear() const month = date.getMonth() + 1 const day = date.getDate() const hour = date.getHours() const minute = date.getMinutes() const second = date.getSeconds() return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') } const formatNumber = n => { n = n.toString() return n[1] ? n : '0' + n } //年级显示方法 let gradeArr = ["学前班", "一年级", "二年级", "三年级"] const gradeUpper = grade => { return gradeArr[grade]; } //时间转换秒转天或小时或分 const day = msd => { let time = Math.floor(msd) + "秒"; if( Math.floor(msd )> 60){ let min = Math.floor(msd / 60); time = min + "分"; if( min > 60 ){ min = Math.floor(msd / 60) % 60; let hour = Math.floor( msd / 3600 ); time = hour + "小时" + min + "分"; if( hour > 24 ){ hour = Math.floor( msd / 3600 ) % 24; let day = Math.floor(msd / 3600 / 24 ); time = day + "天" + hour + "小时"; } } } return time; } //获取当前页面传的的值 function getUrl() { var pages = getCurrentPages() //获取加载的页面 var currentPage = pages[pages.length-1] //获取当前页面的对象 var url = currentPage.route //当前页面url var options = currentPage.options //如果要获取url中所带的参数可以查看options return options } module.exports = { formatTime: formatTime, gradeUpper, day, getUrl }