|
@@ -58,6 +58,26 @@ export default {
|
|
VerificationCode: () => import('@/components/VerificationCode/index.vue')
|
|
VerificationCode: () => import('@/components/VerificationCode/index.vue')
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
|
|
+ const validatePhone = (rule, value, callback) => {
|
|
|
|
+ if (!value) {
|
|
|
|
+ callback(new Error('请输入手机号'))
|
|
|
|
+ } else if (value.length !== 11 || !/^\d{11}$/g.test(value)) {
|
|
|
|
+ callback(new Error('手机号格式有误'))
|
|
|
|
+ } else {
|
|
|
|
+ callback()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const validateName = (rule, value, callback) => {
|
|
|
|
+ if (!value) {
|
|
|
|
+ callback(new Error('请输入会员名称'))
|
|
|
|
+ } else if (value.length < 6 || value.length > 16) {
|
|
|
|
+ callback(new Error('会员名称必须是6-16位数字和字母组合'))
|
|
|
|
+ } else if (/^([a-zA-Z]+\d+$)|(\d+[a-zA-Z]+$)/g.test(value)) {
|
|
|
|
+ callback()
|
|
|
|
+ } else {
|
|
|
|
+ callback(new Error('会员名称必须是6-16位数字和字母组合'))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return {
|
|
return {
|
|
loading: false,
|
|
loading: false,
|
|
ruleForm: {
|
|
ruleForm: {
|
|
@@ -72,10 +92,13 @@ export default {
|
|
// provinceCityIds: []
|
|
// provinceCityIds: []
|
|
},
|
|
},
|
|
rules: {
|
|
rules: {
|
|
- userName: [{ required: true, message: '请输入会员名称', trigger: 'blur' }],
|
|
|
|
|
|
+ userName: [{ required: true, message: '请输入会员名称', trigger: 'blur' },
|
|
|
|
+ { validator: validateName, trigger: 'blur' }],
|
|
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
|
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
|
confirmPassword: [{ required: true, message: '请输入确认密码', trigger: 'blur' }],
|
|
confirmPassword: [{ required: true, message: '请输入确认密码', trigger: 'blur' }],
|
|
- phoneNumber: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
|
|
|
|
|
|
+ phoneNumber: [{ required: true, message: '请输入手机号', trigger: 'blur' },
|
|
|
|
+ { validator: validatePhone, trigger: 'blur' }
|
|
|
|
+ ],
|
|
code: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
|
|
code: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
|
|
},
|
|
},
|
|
regionList: []
|
|
regionList: []
|