county_seat/xz_dingjie/utils/utils.wxs

42 lines
949 B
Plaintext
Raw Permalink Normal View History

2024-02-22 10:58:38 +08:00
function indexOf(str, val) {
if (str.indexOf(val) != -1) {
return true;
} else {
return false;
}
}
function formatCount(count){
var counter = parseInt(count)
if(counter > 100000000){
return (counter / 100000000).toFixed(1) + '亿'
}else if(counter > 10000){
return (counter / 10000).toFixed(1) + '万'
}else{
return counter
}
}
// 12->12 5->05
function padLeftZero(str){
str = str + ''
return ("00" + str).slice(str.length)
}
function formatDuration(duration, isMilliseconds) {
isMilliseconds = isMilliseconds === undefined
if (isMilliseconds) {
duration = duration / 1000
}
var minute = Math.floor(duration / 60)
var second = Math.floor(duration) % 60
return padLeftZero(minute) + ":" + padLeftZero(second)
}
module.exports = {
indexOf: indexOf,
formatCount:formatCount,
formatDuration:formatDuration
}