const dayjs = require('./dayjs.min.js'); import { getCurrentPageUrl} from "./getUrl.js" const formatDate = function (value) { return dayjs(value).format('YYYY-MM-DD HH:mm'); } const formatDateText = function (value) { return dayjs(value).format('YYYY年MM月DD日'); } const throttle=function(fn,wait=1500){ var flag = true; var timer = null; return function(){ if(flag) { fn.apply(this,arguments); flag = false; timer = setTimeout(() => { flag = true },wait) } } } function setBarData(total){ let currentUrl = getCurrentPageUrl(); if(currentUrl=='pages/index/index' || currentUrl=='pages/message/message' || currentUrl=='pages/my/my' ){ if(total>0){ if(total<=99){ wx.setTabBarBadge({ index:1, text: total.toString() }) }else{ wx.setTabBarBadge({ index:1, text:"99+" }) } }else{ wx.removeTabBarBadge({ index:1 }) } } } // function formatDate(date) { // var year = date.getFullYear() // var month = date.getMonth() + 1 // var day = date.getDate() // var hour = date.getHours() // var minute = date.getMinutes() // var second = date.getSeconds() // return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') // } module.exports = { formatDate, formatDateText, throttle, setBarData }