/** * @param {string} path * @returns {Boolean} */ export function isExternal(path) { return /^(https?:|mailto:|tel:)/.test(path); } /** * @param {string} str * @returns {Boolean} */ export function validUsername(str) { const valid_map = ["admin", "editor"]; return valid_map.indexOf(str.trim()) >= 0; } // 手机号验证 export function isvalidPhone(str) { const reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/; return reg.test(str); } // 学生地址 export function vaildStudentUrl() { let url = window.location.hostname; let returnUrl = ""; if (/dev/.test(url)) { // dev 环境 returnUrl = "https://dev.gym.lexiaoya.cn/mdaya"; } else if (/test/.test(url)) { // dev 环境 returnUrl = "https://test.gym.lexiaoya.cn/mdaya"; } else { returnUrl = "https://gym.lexiaoya.cn/mdaya"; } return returnUrl; } // 老师地址 export function vaildTeacherUrl() { let url = window.location.hostname; let returnUrl = ""; if (/dev/.test(url)) { // dev 环境 returnUrl = "https://dev.gym.lexiaoya.cn/mteacher"; } else if (/test/.test(url)) { // dev 环境 returnUrl = "https://test.gym.lexiaoya.cn/mteacher"; } else { // 线上环境 returnUrl = "https://gym.lexiaoya.cn/mteacher"; } return returnUrl; } // 教务地址 export function vaildTeachingUrl() { let url = window.location.hostname; let returnUrl = ""; if (/dev/.test(url)) { // dev 环境 returnUrl = "https://dev.gym.lexiaoya.cn/manager"; } else if (/test/.test(url)) { // dev 环境 returnUrl = "https://test.gym.lexiaoya.cn/manager"; } else { // 线上环境 returnUrl = "https://gym.lexiaoya.cn/manager"; } return returnUrl; } // 学校地址 export function vaildSchoolUrl() { let url = window.location.hostname; let returnUrl = ""; if (/dev/.test(url)) { // dev 环境 returnUrl = "https://dev.gym.lexiaoya.cn/school"; } else if (/test/.test(url)) { // dev 环境 returnUrl = "https://test.gym.lexiaoya.cn/school"; } else { // 线上环境 returnUrl = "https://gym.lexiaoya.cn/school"; } return returnUrl; } // OA地址 export function validOaUrl() { let url = window.location.hostname; let returnUrl = ""; if (/dev/.test(url)) { // dev 环境 returnUrl = "https://dev.gym.lexiaoya.cn/oa"; } else if (/test/.test(url)) { // dev 环境 returnUrl = "https://test.gym.lexiaoya.cn/oa"; } else { // 线上环境 returnUrl = "https://gym.lexiaoya.cn/oa"; } return returnUrl; } // 商城地址 export function validMallUrl() { let url = window.location.hostname; let returnUrl = ""; if (/dev/.test(url)) { // dev 环境 returnUrl = "https://dev.gym.lexiaoya.cn/mall/"; } else if (/test/.test(url)) { // dev 环境 returnUrl = "https://test.gym.lexiaoya.cn/mall/"; } else { // 线上环境 returnUrl = "https://gym.lexiaoya.cn/mall/"; } return returnUrl; } export function nextMonthLastDay(year, month) { //日期显示为次月最后一天 // var time = date ? new Date(date) : new Date(); // var year = time.getFullYear(); // //var year = 1900; //用于测试 // var month = time.getMonth() + 2; if (month > 12) { month = month - 12; year = year + 1; } var day = nextMonthDay(year, month); return [year, month, day]; } function nextMonthDay(year, month) { //判断每月多少天 var day31 = [1, 3, 5, 7, 8, 10, 12]; var day30 = [4, 6, 9, 11]; if (day31.indexOf(month) > -1) { return 31; } else if (day30.indexOf(month) > -1) { return 30; } else { if (isLeapYear(year)) { return 29; } else { return 28; } } } function isLeapYear(year) { //判断是否为闰年 return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); }