257 lines
6.3 KiB
Vue
257 lines
6.3 KiB
Vue
<template>
|
|
<div class="content">
|
|
<el-header>
|
|
<h3 class="title">河北省计量业务应用平台</h3>
|
|
</el-header>
|
|
<div class="stude">学生注册</div>
|
|
<div class="user-from">
|
|
<el-form
|
|
:model="userForm"
|
|
:rules="rules"
|
|
ref="userForm"
|
|
label-width="120px"
|
|
class="demo-userForm"
|
|
>
|
|
<el-form-item label="学生学号" prop="userName">
|
|
<el-input
|
|
v-model="userForm.userName"
|
|
placeholder="请输入学号"
|
|
></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="姓名" prop="name">
|
|
<el-input v-model="userForm.name" placeholder="请输入姓名"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="密码" prop="password">
|
|
<paddwordinput
|
|
v-model="userForm.password"
|
|
placeholder="请输入密码"
|
|
:pastips="true"
|
|
:maxlength="10"
|
|
></paddwordinput>
|
|
<el-button class="Tips" type="text"
|
|
>密码必须为8至10位大小写字母和数字组合</el-button
|
|
>
|
|
</el-form-item>
|
|
<el-form-item label="确认密码" prop="confirmPassword">
|
|
<paddwordinput
|
|
v-model="userForm.confirmPassword"
|
|
placeholder="请再次输入密码"
|
|
:maxlength="10"
|
|
></paddwordinput>
|
|
</el-form-item>
|
|
<el-form-item label="昵称" prop="nickName">
|
|
<el-input v-model="userForm.nickName" placeholder="请输入昵称"></el-input>
|
|
</el-form-item>
|
|
<el-form-item style="text-align: center">
|
|
<el-button
|
|
type="primary"
|
|
@click="submitForm('userForm')"
|
|
:disabled="btnDisabled"
|
|
>注册</el-button
|
|
>
|
|
<el-button @click="resetForm()">关闭</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {registUser} from '@/api/user.js'
|
|
import qs from "qs";
|
|
import paddwordinput from "@/components/passwordSafe/index.vue";
|
|
export default {
|
|
components: { paddwordinput },
|
|
data() {
|
|
var validatorPhone = function (rule, value, callback) {
|
|
if (value === "") {
|
|
callback(new Error("学号不能为空"));
|
|
} else {
|
|
callback();
|
|
}
|
|
};
|
|
var validatePass2 = (rule, value, callback) => {
|
|
if (value === "") {
|
|
callback(new Error("请再次输入密码"));
|
|
// password 是表单上绑定的字段
|
|
} else if (value !== this.userForm.password) {
|
|
callback(new Error("两次输入密码不一致!"));
|
|
} else {
|
|
callback();
|
|
}
|
|
};
|
|
return {
|
|
downTime: "",
|
|
isDisabled: false,
|
|
userForm: {
|
|
name: "",//姓名
|
|
userName: "", //学号
|
|
password: "",
|
|
confirmPassword: "",
|
|
nickName: "", //昵称
|
|
},
|
|
btnDisabled: false,
|
|
rule: [{ required: true, message: "不能为空", trigger: "blur" }],
|
|
rules: {
|
|
userName: [
|
|
{ required: true, validator: validatorPhone, trigger: "blur" },
|
|
],
|
|
password: [
|
|
{ required: true, message: "请输入密码", trigger: "blur" },
|
|
{
|
|
min: 8,
|
|
max: 10,
|
|
message: "长度在 8 到 10 个字符大小写字母和数字组合",
|
|
trigger: "blur",
|
|
},
|
|
],
|
|
confirmPassword: [
|
|
{ required: true, validator: validatePass2, trigger: 'blur' }
|
|
],
|
|
},
|
|
};
|
|
},
|
|
methods: {
|
|
FrontPhotoUrl(url) {
|
|
this.userForm.idFrontPhoto = url.filePath;
|
|
},
|
|
BackPhotoUrl(url) {
|
|
this.userForm.idBackPhoto = url.filePath;
|
|
},
|
|
submitForm(formName) {
|
|
this.btnDisabled = true;
|
|
this.$refs[formName].validate((valid) => {
|
|
if (valid) {
|
|
registUser(this.userForm)
|
|
.then((res) => {
|
|
console.log(res);
|
|
this.btnDisabled = false;
|
|
this.$confirm("注册成功, 是否关闭页面?", "提示", {
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
type: "success",
|
|
}).then(() => {
|
|
this.$router.push('/login');
|
|
});
|
|
})
|
|
.catch(() => {
|
|
this.btnDisabled = false;
|
|
});
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
},
|
|
resetForm() {
|
|
this.$router.push('/login');
|
|
},
|
|
onInputBlur() {
|
|
// 用户名密码
|
|
this.userForm.userName = this.userForm.idNo;
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import "~@/styles/variables.scss";
|
|
h3 {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
.el-header {
|
|
width: 100%;
|
|
background-color: #0294d7;
|
|
color: #fff;
|
|
line-height: 60px;
|
|
overflow: hidden;
|
|
position: fixed;
|
|
z-index: 99;
|
|
top: 0;
|
|
.title {
|
|
float: left;
|
|
font-size: 26px;
|
|
margin-left: 35px;
|
|
}
|
|
}
|
|
.content {
|
|
padding: 50px 0;
|
|
background-color: #f7f9fc;
|
|
}
|
|
</style>
|
|
|
|
<style lang="scss">
|
|
@import "~@/styles/variables.scss";
|
|
.opcity {
|
|
opacity: 1 !important;
|
|
}
|
|
.stude{
|
|
margin-left: 735px;
|
|
margin-top: 20px;
|
|
font-size: 26px;
|
|
}
|
|
.user-from {
|
|
width: 860px;
|
|
padding-top: 20px;
|
|
margin: 0 auto;
|
|
.el-input__inner:focus {
|
|
border: 1px solid $border-color;
|
|
}
|
|
.Tips {
|
|
padding-left: 10px;
|
|
position: absolute;
|
|
left: 100%;
|
|
top: 0;
|
|
}
|
|
|
|
.pasTips {
|
|
display: flex;
|
|
justify-content: center;
|
|
|
|
span {
|
|
display: inline-block;
|
|
margin: 15px 10px 0 10px;
|
|
padding: 0 30px;
|
|
line-height: 30px;
|
|
border-top: 3px solid red;
|
|
opacity: 0.3;
|
|
}
|
|
|
|
span:nth-child(2) {
|
|
border-color: blue;
|
|
}
|
|
|
|
span:nth-child(3) {
|
|
border-color: green;
|
|
}
|
|
}
|
|
|
|
.avatar-uploader .el-upload {
|
|
border: 1px dashed #d9d9d9;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.avatar-uploader .el-upload:hover {
|
|
border-color: #409eff;
|
|
}
|
|
|
|
.avatar-uploader-icon {
|
|
font-size: 28px;
|
|
color: #8c939d;
|
|
width: 200px;
|
|
height: 178px;
|
|
line-height: 178px;
|
|
text-align: center;
|
|
}
|
|
|
|
.avatar {
|
|
width: 178px;
|
|
height: 178px;
|
|
display: block;
|
|
}
|
|
}
|
|
</style>
|