js 通用的 utils

// 验证手机号码
export function isMobile(s) {
    return /^1[0-9]{10}$/.test(s)
}
验证手机号码
// 验证邮箱
export function isEmail(email) {
    return /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test(email)
}
验证邮箱
export function returnTime(e) {
    var thisTime = Date.parse(new Date()); //当前的时间戳
    var startTime = Date.parse(e); //发布的时间戳
    let past = parseInt(parseInt(parseInt((thisTime - startTime) / 1000) / 60) / 60); //过去了多久
    return past < 1 ? '刚刚' : past < 24 ? past + "小时前" : e.substring(0, 11)
}
时间转换:过去了多久
//万位数转换
export function returnWan(e) {
    if (e > 10000) {
        return Math.floor(e / 10000 * 100) / 100 + "万" + "+"
    }
    return e
}
万位数转换

猜你喜欢

转载自www.cnblogs.com/caitangbutian/p/12938031.html
今日推荐