45 lines
1.0 KiB
XML
45 lines
1.0 KiB
XML
function indexOf(arr, value) {
|
|
if (arr.indexOf(value) < 0) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
function hasBtnWhiteList(whiteList){
|
|
if(whiteList&&whiteList.split(',').length>0){
|
|
return true
|
|
}else{
|
|
return false
|
|
}
|
|
}
|
|
function toFix(num,decimal){
|
|
if(num===0){
|
|
return 0
|
|
}else{
|
|
return num.toFixed(decimal?decimal:1)
|
|
}
|
|
|
|
}
|
|
function dateFormat(now,timestamp){
|
|
var day = 60*60*24;
|
|
var offset = now-timestamp
|
|
if(offset<day*7){
|
|
return '最近'
|
|
}else if(offset>day*7&&offset<day*30){
|
|
return '一周前'
|
|
}else if(offset>day*30&&offset<day*60){
|
|
return '一个月前'
|
|
}else if(offset>day*60&&offset<day*90){
|
|
return '二个月前'
|
|
}else if(offset>day*90&&offset<day*180){
|
|
return '三个月前'
|
|
}else if(offset>day*180&&offset<day*365){
|
|
return '六个月前'
|
|
}else {
|
|
return '一年前'
|
|
}
|
|
}
|
|
module.exports.indexOf = indexOf;
|
|
module.exports.hasBtnWhiteList= hasBtnWhiteList;
|
|
module.exports.toFix = toFix;
|
|
module.exports.dateFormat= dateFormat |