12345678910111213141516171819202122232425262728293031323334353637 |
- import { dayjs } from "element-plus"
- //验证密码的正则 产品定的规则是:8位及以上,包含数字、大写字母、小写字母、特殊字符中的三个类型
- export const patternPassWord = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/
- export function checkPassWord(pwd){
- let num = 0
- const patternArr = [
- /^(?=.*[0-9])/,
- /^(?=.*[a-z])/,
- /^(?=.*[A-Z])/,
- /^(?=.*[@#$%^&+=.])/,
- ]
- patternArr.forEach(pattern=>{
- if(pattern.test(pwd)){
- num++
- }
- })
- if(pwd.length<8){
- num = 0
- }
- return num>=3
- }
- //验证手机号的正则 仅支持国内大陆的
- export const patternPhone = /0?(13|14|15|18|17)[0-9]{9}/
- export function isMobileNo(account) {
- //改成和后端一样的正则
- const phonePatter = new RegExp("(^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|(17[0-9])|(16[0-9])|(19[0-9]))\\d{8}$)")
- return phonePatter.test(account)
- }
- //验证邮箱的正则
- export const patternEmail = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/
- // 格式话时间 t时间字符串 f要格式化的样式
- export function formatTime(t,f='YYYY-MM-DD HH:mm:ss'){
- if(!t) return ''
- return dayjs(t).format(f)
- }
|