Skip to content

Commit 06cef9e

Browse files
authored
Merge branch 'master' into fix-CI-static-site-tom
2 parents 4dd6851 + cd10306 commit 06cef9e

File tree

2 files changed

+26
-70
lines changed

2 files changed

+26
-70
lines changed

src/components/user/login.vue

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
type="primary"
2929
v-on:click="onSubmit();"
3030
:loading="buttonLoading"
31-
:disabled="!(legal_1 && legal_2)"
3231
>
3332
Login
3433
</el-button>
@@ -48,19 +47,15 @@ export default {
4847
data() {
4948
let validateUsername = (rule, value, callback) => {
5049
if (value === '') {
51-
this.legal_1 = false;
5250
callback(new Error('Input your username'));
5351
} else {
54-
this.legal_1 = true;
5552
callback();
5653
}
5754
};
5855
let validatePasswd = (rule, value, callback) => {
5956
if (value === '') {
60-
this.legal_2 = false;
6157
callback(new Error('Input your password'));
6258
} else {
63-
this.legal_2 = true;
6459
callback();
6560
}
6661
};
@@ -77,9 +72,7 @@ export default {
7772
{ validator: validatePasswd, trigger: 'blur' }
7873
]
7974
},
80-
buttonLoading: false,
81-
legal_1: false,
82-
legal_2: false
75+
buttonLoading: false
8376
};
8477
},
8578
methods: {
@@ -133,8 +126,6 @@ export default {
133126
});
134127
},
135128
reset() {
136-
this.legal_1 = false;
137-
this.legal_2 = false;
138129
this.$refs['loginForm'].resetFields();
139130
}
140131
}

src/components/user/register.vue

Lines changed: 25 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
type="primary"
5252
v-on:click="onSubmit();"
5353
:loading="buttonLoading"
54-
:disabled="! (legal_1 && legal_2 && legal_3 && legal_4)"
5554
>
5655
Register
5756
</el-button>
@@ -70,69 +69,38 @@ import captcha from './../lib/captcha.vue';
7069
export default {
7170
name: 'UserRegister',
7271
data() {
72+
let validatePasswd = (rule, value, callback) => {
73+
if (value === '' || value === this.ldata.password) {
74+
callback();
75+
} else {
76+
callback(new Error('Password mismatch'));
77+
}
78+
};
79+
let validateEmail = (rule, value, callback) => {
80+
let regular = new RegExp('^(\\w-*\\.*)+@(\\w-?)+(\\.\\w{2,})+$');
81+
if (regular.test(value) || value === '') {
82+
callback();
83+
} else {
84+
callback(new Error('Email format error'));
85+
}
86+
};
7387
let validateUsername = (rule, value, callback) => {
7488
if(value === '') {
75-
this.legal_1 = false;
76-
callback(new Error('Input your username'));
77-
}
78-
if(value.length > 150) {
79-
this.legal_1 = false;
80-
callback(new Error('No more than 150 characters'));
89+
callback();
8190
}
8291
this.$axios
8392
.get(apiurl('account/username/accessibility/' + value))
8493
.then(() => {
85-
this.legal_1 = true;
8694
callback();
8795
})
8896
.catch(err => {
8997
if (err.request.status === 409) {
90-
this.legal_1 = false;
9198
callback(new Error('The user name is already in use'));
9299
} else {
93-
this.legal_1 = false;
94100
callback(new Error('Unkown Error'));
95101
}
96102
});
97103
};
98-
let validatePasswd = (rule, value, callback) => {
99-
if(value === '') {
100-
this.legal_2 = false;
101-
callback(new Error('Input your username'));
102-
} else if(value.length < 6) {
103-
this.legal_2 = false;
104-
callback(new Error('No less than 6 characters'));
105-
} else {
106-
this.legal_2 = true;
107-
callback();
108-
}
109-
};
110-
let validatePasswdRp = (rule, value, callback) => {
111-
if(value === '') {
112-
this.legal_3 = false;
113-
callback(new Error('Repeat your password'));
114-
} else if(value !== this.ldata.password) {
115-
this.legal_3 = false;
116-
callback(new Error('Password mismatch'));
117-
} else {
118-
this.legal_3 = true;
119-
callback();
120-
}
121-
};
122-
let validateEmail = (rule, value, callback) => {
123-
if(value === '') {
124-
this.legal_4 = false;
125-
callback(new Error('Input your email'));
126-
}
127-
let regular = new RegExp('^(\\w-*\\.*)+@(\\w-?)+(\\.\\w{2,})+$');
128-
if (regular.test(value)) {
129-
this.legal_4 = true;
130-
callback();
131-
} else {
132-
this.legal_4 = false;
133-
callback(new Error('Email format error'));
134-
}
135-
};
136104
return {
137105
ldata: {
138106
username: '',
@@ -142,23 +110,24 @@ export default {
142110
},
143111
rules: {
144112
username: [
113+
{ required: true, message: 'Input your username', trigger: 'blur' },
114+
{ max: 150, message: 'No more than 150 characters', trigger: 'blur' },
145115
{ validator: validateUsername, trigger: 'blur'}
146116
],
147117
password: [
148-
{ validator: validatePasswd, trigger: 'blur'}
118+
{ required: true, message: 'Input your password', trigger: 'blur' },
119+
{ min: 6, message: 'No less than 6 characters', trigger: 'blur' }
149120
],
150121
passwdrepeat: [
151-
{ validator: validatePasswdRp, trigger: 'blur' },
122+
{ required: true, message: 'Repeat your password', trigger: 'blur' },
123+
{ validator: validatePasswd, trigger: 'blur' },
152124
],
153125
email: [
126+
{ required: true, message: 'Input your email', trigger: 'blur' },
154127
{ validator: validateEmail, trigger: 'blur'}
155128
]
156129
},
157-
buttonLoading: false,
158-
legal_1: false,
159-
legal_2: false,
160-
legal_3: false,
161-
legal_4: false
130+
buttonLoading: false
162131
};
163132
},
164133
methods: {
@@ -213,10 +182,6 @@ export default {
213182
});
214183
},
215184
reset() {
216-
this.legal_1 = false;
217-
this.legal_2 = false;
218-
this.legal_3 = false;
219-
this.legal_4 = false;
220185
this.$refs['registerForm'].resetFields();
221186
}
222187
},
@@ -234,4 +199,4 @@ export default {
234199
.margin-bottom {
235200
margin-bottom: 20px;
236201
}
237-
</style>
202+
</style>

0 commit comments

Comments
 (0)