const base = { reg: { idCard: /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|[xX])$/, phone: /^1(?:3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\d|9\d)\d{8}$/, email: /^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/ }, isImg: function (url) { var temp = [] temp = url.toString().split('.') if (temp[temp.length - 1].toLowerCase() === 'png' || temp[temp.length - 1].toLowerCase() === 'jpg') { return true } else { return false } }, isTypeBySend: function (fileName, typeArr) { if (typeof fileName !== 'string') return let name = fileName.toLowerCase() let boo = false typeArr.forEach(item => { console.log(name.endsWith(item)) if (name.endsWith(item)) { boo = true } }) return boo }, timestampToTime: function (timestamp) { var date = new Date(Number(timestamp))// 时间戳为10位需*1000,时间戳为13位的话不需乘1000 var Y = date.getFullYear() + '-' var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-' var D = date.getDate() + ' ' // var h = date.getHours() + ':' // var m = date.getMinutes() + ':' // var s = date.getSeconds() return Y + M + D }, dateFormat: function (fmt, that) { var o = { 'M+': that.getMonth() + 1, // 月份 'd+': that.getDate(), // 日 'h+': that.getHours(), // 小时 'm+': that.getMinutes(), // 分 's+': that.getSeconds(), // 秒 'q+': Math.floor((that.getMonth() + 3) / 3), // 季度 S: that.getMilliseconds() // 毫秒 } if (/(y+)/.test(fmt)) { fmt = fmt.replace( RegExp.$1, (that.getFullYear() + '').substr(4 - RegExp.$1.length) ) } for (var k in o) { if (new RegExp('(' + k + ')').test(fmt)) { fmt = fmt.replace( RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length) ) } } return fmt } } export { base }