123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- /**
- * @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.href
- let returnUrl = ''
- if (/online/.test(url)) { //线上
- returnUrl = 'https://mstuonline.dayaedu.com'
- } else if (/dev/.test(url)) { // dev 环境
- returnUrl = 'https://mstudev.dayaedu.com'
- } else if (/test/.test(url)) { // dev 环境
- returnUrl = 'http://mstutest.dayaedu.com'
- } else { // 默认dev环境
- returnUrl = 'https://mstutest.dayaedu.com'
- }
- return returnUrl
- }
- // 老师地址
- export function vaildTeacherUrl() {
- let url = window.location.href
- let returnUrl = ''
- if (/online/.test(url)) { //线上
- returnUrl = 'https://mteaonline.dayaedu.com'
- } else if (/dev/.test(url)) { // dev 环境
- returnUrl = 'http://mteadev.dayaedu.com'
- } else if (/test/.test(url)) { // dev 环境
- returnUrl = 'http://mteatest.dayaedu.com'
- } else { // 默认dev环境
- returnUrl = 'https://mteatest.dayaedu.com'
- }
- return returnUrl
- }
- // 教务地址
- export function vaildTeachingUrl() {
- let url = window.location.href
- let returnUrl = ''
- if (/online/.test(url)) { //线上
- returnUrl = 'https://manonline.dayaedu.com'
- } else if (/dev/.test(url)) { // dev 环境
- returnUrl = 'http://mandev.dayaedu.com'
- } else if (/test/.test(url)) { // dev 环境
- returnUrl = 'http://mantest.dayaedu.com'
- } else { // 默认dev环境
- returnUrl = 'https://mantest.dayaedu.com'
- }
- return returnUrl
- }
- // 教务地址
- export function validOaUrl() {
- let url = window.location.href
- let returnUrl = ''
- if (/online/.test(url)) { //线上
- returnUrl = 'https://oaonline.dayaedu.com'
- } else if (/dev/.test(url)) { // dev 环境
- returnUrl = 'http://oadev.dayaedu.com'
- } else if (/test/.test(url)) { // dev 环境
- returnUrl = 'https://oatest.dayaedu.com'
- } else { // 默认dev环境
- returnUrl = 'http://oadev.dayaedu.com'
- }
- 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);
- }
|