Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
When the work used records about the future continue to update
1, partially hidden identity
idnumfilter (value) { // 身份证星号
if (value) {
let val = value.replace(/(.{6}).*(.{4})/,"$1******$2")
return val
} else {
return ''
}
}
2, partially hidden phone number
phonefilter (value) { // 号码星号
if (value) {
let val = value.replace(/(.{3}).*(.{4})/,"$1****$2")
return val
} else {
return ''
}
}
3, partially hidden names
namefiletr (value) { // 名字星号
if (value.length === 2) {
let val = value.replace(/(.{1}).*(.{0})/,"$1*$2")
return val
} else if (value.length > 2) {
let val = value.replace(/(.{1}).*(.{1})/,"$1*$2")
return val
}
}
4, the string to a space
blankfiletr (value) { // 去空格
let val = value.replace(/\s/g,'')
return val
}
5, and the second transfer time format ms
formatSeconds (value) {
var offset = parseInt(value);// 单位为秒
var offset = parseInt(value/1000);// 单位为毫秒
var secLeft = offset%60;
var minLeft = Math.floor(offset/60)%60;
var hourLeft = Math.floor(offset/60/60)%24;
var dayLeft = Math.floor(offset/60/60/24);
var min = minLeft
var hour = hourLeft
var day = dayLeft
// 补0操作
secLeft = (secLeft<10 ? '0' : '') + secLeft;
minLeft = (minLeft<10 ? '0' : '') + minLeft;
hourLeft = (hourLeft<10 ? '0' : '') + hourLeft;
// )拼接时间格式,返回值
let result
if (min <= 0 && hour <= 0 && day <= 0) {
result = '00' + ':' + secLeft ;
} else if (min > 0 && hour <= 0 && day <= 0) {
result = minLeft + ':' + secLeft ;
} else if (min > 0 && hour > 0 && day <= 0) {
result = hourLeft + ':' + minLeft + ':' + secLeft ;
} else {
result = dayLeft + ':' + hourLeft + ':' + minLeft + ':' + secLeft;
}
return result;
}