Commit ba13ee4f by 张立顺

修复手机好检验

1 parent 5016268a
...@@ -10,7 +10,7 @@ class WxValidate { ...@@ -10,7 +10,7 @@ class WxValidate {
Object.assign(this, { Object.assign(this, {
data: {}, data: {},
rules, rules,
messages, messages
}) })
this.__init() this.__init()
} }
...@@ -54,7 +54,7 @@ class WxValidate { ...@@ -54,7 +54,7 @@ class WxValidate {
rangelength: this.formatTpl('请输入长度在 {0} 到 {1} 之间的字符。'), rangelength: this.formatTpl('请输入长度在 {0} 到 {1} 之间的字符。'),
min: this.formatTpl('请输入不小于 {0} 的数值。'), min: this.formatTpl('请输入不小于 {0} 的数值。'),
max: this.formatTpl('请输入不大于 {0} 的数值。'), max: this.formatTpl('请输入不大于 {0} 的数值。'),
range: this.formatTpl('请输入范围在 {0} 到 {1} 之间的数值。'), range: this.formatTpl('请输入范围在 {0} 到 {1} 之间的数值。')
} }
} }
} }
...@@ -89,13 +89,18 @@ class WxValidate { ...@@ -89,13 +89,18 @@ class WxValidate {
* 验证手机格式 * 验证手机格式
*/ */
tel(value) { tel(value) {
return that.optional(value) || /^1[34578]\d{9}$/.test(value) return that.optional(value) || /^1[3456789]\d{9}$/.test(value)
}, },
/** /**
* 验证URL格式 * 验证URL格式
*/ */
url(value) { url(value) {
return that.optional(value) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(value) return (
that.optional(value) ||
/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(
value
)
)
}, },
/** /**
* 验证日期格式 * 验证日期格式
...@@ -174,7 +179,7 @@ class WxValidate { ...@@ -174,7 +179,7 @@ class WxValidate {
*/ */
range(value, param) { range(value, param) {
return that.optional(value) || (value >= param[0] && value <= param[1]) return that.optional(value) || (value >= param[0] && value <= param[1])
}, }
} }
} }
...@@ -208,7 +213,7 @@ class WxValidate { ...@@ -208,7 +213,7 @@ class WxValidate {
formatTpl(source, params) { formatTpl(source, params) {
const that = this const that = this
if (arguments.length === 1) { if (arguments.length === 1) {
return function() { return function () {
let args = Array.from(arguments) let args = Array.from(arguments)
args.unshift(source) args.unshift(source)
return that.formatTpl.apply(this, args) return that.formatTpl.apply(this, args)
...@@ -223,8 +228,8 @@ class WxValidate { ...@@ -223,8 +228,8 @@ class WxValidate {
if (params.constructor !== Array) { if (params.constructor !== Array) {
params = [params] params = [params]
} }
params.forEach(function(n, i) { params.forEach(function (n, i) {
source = source.replace(new RegExp("\\{" + i + "\\}", "g"), function() { source = source.replace(new RegExp('\\{' + i + '\\}', 'g'), function () {
return n return n
}) })
}) })
...@@ -298,7 +303,7 @@ class WxValidate { ...@@ -298,7 +303,7 @@ class WxValidate {
this.errorList.push({ this.errorList.push({
param: param, param: param,
msg: msg, msg: msg,
value: value, value: value
}) })
} }
...@@ -309,7 +314,6 @@ class WxValidate { ...@@ -309,7 +314,6 @@ class WxValidate {
* @param {Object} data 需要验证的数据对象 * @param {Object} data 需要验证的数据对象
*/ */
checkParam(param, rules, data) { checkParam(param, rules, data) {
// 缓存数据对象 // 缓存数据对象
this.data = data this.data = data
...@@ -318,10 +322,8 @@ class WxValidate { ...@@ -318,10 +322,8 @@ class WxValidate {
// 遍历某个指定字段的所有规则,依次验证规则,否则缓存错误信息 // 遍历某个指定字段的所有规则,依次验证规则,否则缓存错误信息
for (let method in rules) { for (let method in rules) {
// 判断验证方法是否存在 // 判断验证方法是否存在
if (this.isValidMethod(method)) { if (this.isValidMethod(method)) {
// 缓存规则的属性及值 // 缓存规则的属性及值
const rule = { const rule = {
method: method, method: method,
...@@ -358,7 +360,7 @@ class WxValidate { ...@@ -358,7 +360,7 @@ class WxValidate {
$invalid: false, $invalid: false,
$error: {}, $error: {},
$success: {}, $success: {},
$viewValue: ``, $viewValue: ``
} }
} }
......
...@@ -69,8 +69,8 @@ const domain = { ...@@ -69,8 +69,8 @@ const domain = {
/**登录: 192.168.2.3:8315 /**登录: 192.168.2.3:8315
商城: 192.168.2.3:8558 */ 商城: 192.168.2.3:8558 */
dev: 'https://scrm.dev.glsx.com.cn', dev: 'https://scrm.dev.glsx.com.cn',
uat: 'https://scrm.test.glsx.com.cn', // uat: 'https://scrm.test.glsx.com.cn',
// uat: 'https://scrm.beta.glsx.com.cn', uat: 'https://scrm.beta.glsx.com.cn',
prod: 'https://scrm.cgacar.com' prod: 'https://scrm.cgacar.com'
}[target[index]] }[target[index]]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!