// 主要正对校验 const mixin = { data() { return { // 验证码 iscFocusCode: false, // 是否正在输入 isCodeError: false, // 判断是否正确 // 手机号 iscFocusMobile: false, isMobileError: false, // 图片验证码 iscFocusImgCode: false, isImgCodeError: false, // 密码 iscFocusPsw: false, isPswError: false, // 新密码 iscFocusRePsw: false, isRePswError: false } }, methods: { inputFocus(type) { if (type === 'code') { this.isCodeError = false this.iscFocusCode = true } else if (type === 'mobile') { this.isMobileError = false this.iscFocusMobile = true } else if (type === 'imgCode') { this.isImgCodeError = false this.iscFocusImgCode = true } else if (type === 'psw') { this.isPswError = false this.iscFocusPsw = true } else if (type === 'repsw') { this.isRePswError = false this.iscFocusRePsw = true } }, // 失去焦点事件 inputBlur(type) { if (type === 'code') { this.iscFocusCode = false if (this.form.code.length > 5) { this.$u.toast('验证码错误'); this.isCodeError = true } } else if (type === 'mobile') { if (!this.$u.test.mobile(this.form.mobile)) { this.$u.toast('手机号有误'); this.isMobileError = true } this.iscFocusMobile = false } else if (type === 'imgCode') { this.iscFocusImgCode = false } else if (type === 'psw') { if (this.form.password.length <= 5) { this.$u.toast('密码长度最少6位'); this.isPswError = true } this.iscFocusPsw = false } else if (type === 'repsw') { if (this.form.rePassword.length <= 5) { this.$u.toast('密码长度最少6位'); this.isRePswError = true } this.iscFocusRePsw = false } }, } } export default mixin