export default {
getImg:function(imgurl) {
let url = ""
if (imgurl) {
if (imgurl.indexOf('http') > -1) {
url = imgurl
} else {
url = uni.getStorageSync('IMG_URL') + imgurl
}
} else {
url = '/static/distance-learning/banner.png'
}
return url
},
IsURL(str_url) {
let strRegex =
"^((https|http|ftp|rtsp|mms)?://)" +
"?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" +
"(([0-9]{1,3}.){3}[0-9]{1,3}" +
"|" +
"([0-9a-z_!~*'()-]+.)*" +
"([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]." +
"[a-z]{2,6})" +
"(:[0-9]{1,4})?" +
"((/?)|" +
"(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
let re = new RegExp(strRegex);
if (re.test(str_url)) {
return true;
} else {
return false;
}
},
phone(str) {
return new RegExp(/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/).test(str)
},
specialPlane(str) {
return new RegExp(/^(0[0-9]{2,3}\-)([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/).test(str)
},
isOfficerCard(str) {
return new RegExp(/^[\u4E00-\u9FA5](字第)([0-9a-zA-Z]{4,8})(号)$/).test(str)
},
soldiers(str) {
return new RegExp(/^[\u4E00-\u9FA5](字第)([0-9]{7})(号)$/).test(str)
},
cadreCard(str) {
return new RegExp(/^(军字第)([0-9]{7})(号)$/).test(str)
},
isMacauCard(str) {
let state = false
if (new RegExp(/^[1|5|7][0-9]{6}[(][0-9A-Z][)]$/).test(str)) {
state = true
} else if (new RegExp(/^[1|5|7][0-9]{6}[0-9A-Z]$/).test(str)) {
state = true
}
return state
},
HongkongCard(str) {
let state = false
let str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if (new RegExp(/^[A-Z]{1}[0-9]{6}[(]([0-9]{1}|A)[)]$/).test(str)) {
let index1 = str1.indexOf(str[0]) + 1
let index = index1 * 8 + str[1] * 7 + str[2] * 6 + str[3] * 5 + str[4] * 4 + str[5] * 3 + str[6] * 2
let lastindex = str[8]
let _lastindex = index % 11
let lastindex1 = 11 - _lastindex
if (lastindex == lastindex1) {
state = true
} else if (lastindex == 'A' && lastindex1 == 10) {
state = true
}
}
return state
},
TaiwanCard(str) {
let state = false
let str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
let arrstr1 = [10, 11, 12, 13, 14, 15, 16, 17, 34, 18, 19, 20, 21, 22, 35, 23, 24, 25, 26, 27, 28, 29, 32, 30, 31, 33]
if (new RegExp(/^[A-Z]{1}(1|2)[0-9]{8}$/).test(str)) {
let _index1 = str1.indexOf(str[0])
let index1 = arrstr1[_index1] + ''
let index = index1[0] * 1 + index1[1] * 9 + str[1] * 8 + str[2] * 7 + str[3] * 6 + str[4] * 5 + str[5] * 4 + str[6] *
3 + str[7] * 2 + str[8] * 1 + ''
indexlength = index.length - 1
if (10 - index[indexlength] == str[9]) {
state = true
}
}
return state
},
isHKCard(str) {
let state = ''
if (new RegExp(/^(H|M)[0-9]{6}$/).test(str)) {
state = true
} else if (new RegExp(/^(H|M)[0-9]{10}$/).test(str)) {
state = true
} else {
state = false
}
return state
},
isTWCard(str) {
let state = ''
if (new RegExp(/^[0-9]{8}$/).test(str)) {
state = true
} else if (new RegExp(/^([0-9]{10})[A-Z]$/).test(str)) {
state = true
} else if (new RegExp(/^[0-9]{18}$/).test(str)) {
state = true
} else {
state = false
}
return state
},
foreignIdNum(str) {
return new RegExp(/^[A-Z]{3}\d{12}$/).test(str)
},
username(str) {
return new RegExp(/^[a-zA-Z0-9_-]{4,16}$/).test(str)
},
passwprd(str) {
return new RegExp(/^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*? ]).*$/).test(str)
},
posInt(str) {
return new RegExp(/^\d+$/).test(str)
},
negInt(str) {
return new RegExp(/^-\d+$/).test(str)
},
int(str) {
return new RegExp(/^-?\d+$/).test(str)
},
posNum(str) {
return new RegExp(/^\d*\.?\d+$/).test(str)
},
negNum(str) {
return new RegExp(/^-\d*\.?\d+$/).test(str)
},
number(str) {
return new RegExp(/^-?\d*\.?\d+$/).test(str)
},
email(str) {
return new RegExp(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/).test(str)
},
idNum(str) {
return new RegExp(
/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/).test(
str)
},
date(str) {
return new RegExp(
/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/
).test(str)
},
qqNum(str) {
return new RegExp(/^[1-9][0-9]{4,10}$/).test(str)
},
qqNum(str) {
return new RegExp(/^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/).test(str)
},
licensePlate(str) {
return new RegExp(/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/).test(str)
},
onlyChinese(str) {
return new RegExp(/^[\u4e00-\u9fa5]{0,}$/).test(str)
},
taxId(str) {
return new RegExp(/^[A-Z0-9]{15}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/).test(str)
},
bankAccount(str) {
return new RegExp(/^([1-9]{1})([0-9]{13,19})$/).test(str)
},
}