You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB
JavaScript

6 years ago
/**
* 公共的JS类
* @author dexiang.jiang
* @date 2019/04/18 11:15
* @company kiisoo
*/
5 years ago
import roter from '../router'
6 years ago
// import store from '../store'
/**
* 跳转到登录页面
* @author dexiang.jiang
* @date 2019/04/18 11:19
*/
5 years ago
export function goToLogin() {
6 years ago
// store.commit("LOGOUT");
5 years ago
roter.push('/login')
6 years ago
}
5 years ago
export function formatDate(dt) {
5 years ago
dt = new Date(dt)
let year = dt.getFullYear()
let month = dt.getMonth() + 1
let day = dt.getDate()
month = month < 10 ? '0' + month : month
day = day < 10 ? '0' + day : day
return year + '-' + month + '-' + day
6 years ago
}
5 years ago
5 years ago
export function isURL(str_url) {
// 验证url
var strRegex =
'^((https|http)?://)' +
"?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" + // ftp的user@
'(([0-9]{1,3}.){3}[0-9]{1,3}' + // IP形式的URL- 199.194.52.184
'|' + // 允许IP和DOMAIN域名
"([0-9a-z_!~*'()-]+.)*" + // 域名- www.
'([0-9a-z][0-9a-z-]{0,61})?[0-9a-z].' + // 二级域名
'[a-z]{2,6})' + // first level domain- .com or .museum
'(:[0-9]{1,4})?' + // 端口- :80
'((/?)|' + // a slash isn't required if there is no file name
"(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"
var re = new RegExp(strRegex)
return re.test(str_url)
}
5 years ago
export default {
goToLogin,
5 years ago
formatDate,
5 years ago
isURL,
5 years ago
}