You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.1 KiB
59 lines
1.1 KiB
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
|
|
}
|