function isEmpty(val) { return typeof val === 'undefined' || val === '' || val === null } function formateDate(datetime) { if (isEmpty(datetime)) { return '' } var date = getDate(datetime.trim()) var today = getDate() var week = '' if (date.toString().substring(0, 15) === today.toString().substring(0, 15)) { week = '(今天)' } else if (date.getTime() > today.getTime()) { week = '(明天)' } return week + datetime } function formateText(text, length) { if (!text) { return '' } if (text.length <= length) { return text } return text.substring(0, length) } function colorText(price) { if(!price || price == 0){ return 'text-gray' } if(price > 0){ return 'text-red' } if(price < 0){ return 'text-green' } } function floatImage(price) { if(!price || price == 0){ return 'text-gray' } if(price > 0){ return '/assets/image/icon-up.png' } if(price < 0){ return '/assets/image/icon-down.png' } } module.exports = { formateDate: formateDate, formateText: formateText, colorText: colorText, floatImage: floatImage }