| | |
| | | return y + '-' + m + '-' + d; |
| | | } |
| | | |
| | | export { gsdate } |
| | | /*** |
| | | * |
| | | * @param time 日期 年月日时分秒 |
| | | * @param Sign 间隔 |
| | | */ |
| | | function setTime (time, Sign) { |
| | | let year = time.getFullYear(); |
| | | let month = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : `0${time.getMonth() + 1}`; |
| | | let day = time.getDate() >= 10 ? time.getDate() : `0${time.getDate()}`; |
| | | let hour = time.getHours() >= 10 ? time.getHours() : `0${time.getHours()}`; |
| | | let minute = time.getMinutes() >= 10 ? time.getMinutes() : `0${time.getMinutes()}`; |
| | | let second = time.getSeconds() >= 10 ? time.getSeconds() : `0${time.getSeconds()}`; |
| | | return [year, Sign, month , Sign, day, ' ', hour , ':', minute, ':', second ].join(''); |
| | | } |
| | | |
| | | /*** |
| | | * |
| | | * @param time 日期 年月日时分秒 |
| | | * @param Sign 间隔 |
| | | */ |
| | | function setTimeO (time, Sign) { |
| | | let year = time.getFullYear(); |
| | | let month = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : `0${time.getMonth() + 1}`; |
| | | let day = time.getDate() >= 10 ? time.getDate() : `0${time.getDate()}`; |
| | | let hour = time.getHours() >= 10 ? time.getHours() : `0${time.getHours()}`; |
| | | let minute = time.getMinutes() >= 10 ? time.getMinutes() : `0${time.getMinutes()}`; |
| | | let second = time.getSeconds() >= 10 ? time.getSeconds() : `0${time.getSeconds()}`; |
| | | return [year, Sign, month , Sign, day, ' ', hour , ':', minute, ':', '00' ].join(''); |
| | | } |
| | | |
| | | /*** |
| | | * phoneRegular: 手机号验证 |
| | | * mailboxRegular: 邮箱验证 |
| | | * positiveInteger: 正整数 |
| | | * decimal: 小数(只支持四位小数) |
| | | * positiveIntegerDecimal: 正整数小数(最多四位小数) |
| | | * number:数字最多保留四位小数 |
| | | */ |
| | | const REGULAR = { |
| | | phoneRegular: /^1[3456789]\d{9}$/, |
| | | mailboxRegular: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, |
| | | positiveInteger: /^[0-9]*[1-9][0-9]*$/, |
| | | decimal: /^0$|^[1-9]\d{0,15}$|^[1-9]\d{0,15}\.{1}\d{1,4}$|^0\.{1}\d{1,4}$/g, |
| | | positiveIntegerDecimal: /^([1-9][0-9]*|0)(\.[0-9]?[1-9][1-9][1-9])?$/, |
| | | number: /^\d+(?:\.\d{1,4})?$/ |
| | | } |
| | | |
| | | /*** |
| | | * |
| | | * @param type 文件类型 |
| | | */ |
| | | function judgmentType (type) { |
| | | let arr = ['jpg', 'jpeg', 'png'] |
| | | // arr.includes(type) |
| | | let open = false |
| | | arr.forEach(item => { |
| | | if (type === item) { |
| | | open = true |
| | | } |
| | | }) |
| | | return open; |
| | | } |
| | | |
| | | export { gsdate, setTime, setTimeO, REGULAR, judgmentType } |