From 79e1091fa8885e98c70bbcd40d91f76f4829ae60 Mon Sep 17 00:00:00 2001 From: CTP <630182278@qq.com> Date: Wed, 19 Apr 2023 11:30:13 +0800 Subject: [PATCH] =?UTF-8?q?1=E7=BA=A7=E5=8C=BB=E9=99=A2=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/register.vue | 254 +++++++++++++++++++++++++++-------------- 1 file changed, 166 insertions(+), 88 deletions(-) diff --git a/src/views/register.vue b/src/views/register.vue index 6fc2433..a34d3a8 100644 --- a/src/views/register.vue +++ b/src/views/register.vue @@ -5,7 +5,7 @@ style=" width: 60%; margin-top: 35px; - margin-left:20%; + margin-left: 20%; margin-bottom: 35px; text-align: center; " @@ -24,7 +24,7 @@ :model="inputQuery" :rules="rules" ref="inputQuery" - style="margin-left: 20%;" + style="margin-left: 20%" > @@ -141,7 +141,6 @@ - - @@ -193,8 +191,7 @@ - - + @@ -210,7 +207,6 @@ - - @@ -251,7 +246,6 @@ - @@ -299,11 +293,12 @@ - @@ -441,16 +436,15 @@ icon="search" style="margin-top: 20px; width: 200px" @click="onSubmit('inputQuery')" - >提交 - + >提交 + 厦门高立新鹏软件科技有限公司 13459286066厦门高立新鹏软件科技有限公司 13459286066 @@ -468,7 +462,6 @@ - - 您的注册信息已提交,等待审核,请牢记您的账号密码,方便登录系统。 + 您的注册信息已提交,等待审核,请牢记您的账号密码,方便登录系统。 - - - + {{ this.acoountInfo }} - - - + @@ -526,7 +524,9 @@ import { getCheckcode, register } from "@/api/login"; import { getCompany, modifyCompany, - getRefid, checkCompany, getRegisterConfig, + getRefid, + checkCompany, + getRegisterConfig, } from "@/api/system/company"; import { provinceAndCityData, @@ -536,14 +536,13 @@ import { CodeToText, TextToCode, } from "element-china-area-data"; -import Clipboard from 'clipboard'; -import {BASE_URL} from "@/config/app"; -import {getBasicUnitMaintains} from "@/api/basic/basicUnitMaintain" - - +import Clipboard from "clipboard"; +import { BASE_URL } from "@/config/app"; +import { getBasicUnitMaintains } from "@/api/basic/basicUnitMaintain"; export default { data() { + // 确认密码 let validatePass2 = (rule, value, callback) => { if (value === "") { callback(new Error("请再次输入密码")); @@ -553,6 +552,48 @@ export default { callback(); } }; + // 限制输入中文 + const validateName = (rule, value, callback) => { + if (/^[\u4e00-\u9fa5]+$/.test(value) === false) { + callback(new Error("请输入中文")); + } else { + // 校验通过 + callback(); + } + }; + //限制输入字母数字 + const validatePass = (rule, value, callback) => { + if ( + /^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9]{8,20}$/.test(value) === false + ) { + callback(new Error("密码包含字母和数字且在8-20之间")); + } else { + // 校验通过 + callback(); + } + }; + //输入正确的手机号码格式 + const validatePhone = (rule, value, callback) => { + if (/^1[3-9]\d{9}$/.test(value) === false) { + callback(new Error("请输入正确的电话号码")); + } else { + // 校验通过 + callback(); + } + }; + //限制输入正确的邮箱 + const validateEmail = (rule, value, callback) => { + if ( + /^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test( + value + ) === false + ) { + callback(new Error("请输入正确的邮箱地址")); + } else { + // 校验通过 + callback(); + } + }; return { inputQuery: { nickName: null, @@ -589,42 +630,63 @@ export default { acoountInfo: "账号:" + "------" + "\n密码:" + "-----", rules: { nickName: [ - {required: true, message: "请输入用户名称", trigger: "blur"}, + { required: true, message: "请输入用户名称", trigger: "blur" }, + { min: 2, max: 8, message: "用户名称在2-8个字符", trigger: "blur" }, + { validator: validateName, trigger: "blur" }, + ], + password: [ + { required: true, message: "请输入密码", trigger: "blur" }, + { validator: validatePass, trigger: "blur" }, ], - password: [{required: true, message: "请输入密码", trigger: "blur"}], realName: [ - {required: true, message: "请输入负责人姓名", trigger: "blur"}, + { required: true, message: "请输入负责人姓名", trigger: "blur" }, + { validator: validateName, trigger: "blur" }, ], - tel: [{required: true, message: "请输入联系电话", trigger: "blur"}, + tel: [ + { required: true, message: "请输入联系电话", trigger: "blur" }, + { validator: validatePhone, trigger: "blur" }, // { pattern:/^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/, message: "请输入正确的电话号码", trigger: "blur" } ], - mobile: [{required: true, message: "请输入手机号码", trigger: "blur"}, + mobile: [ + { required: true, message: "请输入手机号码", trigger: "blur" }, // { pattern:/^0{0,1}(13[0-9]|15[7-9]|153|156|18[7-9])[0-9]{8}$/, message: "请输入正确的手机号", trigger: "blur" } + { validator: validatePhone, trigger: "blur" }, ], confirmPassword: [ - {required: true, message: "请确认密码", trigger: "blur"}, - {validator: validatePass2, trigger: "blur"}, + { required: true, message: "请确认密码", trigger: "blur" }, + { validator: validatePass2, trigger: "blur" }, ], checkCode: [ - {required: true, message: "请输入手机验证码", trigger: "blur"}, + { required: true, message: "请输入手机验证码", trigger: "blur" }, + ], + email: [ + { required: true, message: "请输入邮箱", trigger: "blur" }, + { + validator: validateEmail, + trigger: "blur", + }, ], - email: [{required: true, message: "请输入邮箱", trigger: "blur"}], companyName: [ - {required: true, message: "请输入企业名称", trigger: "blur"}, + { required: true, message: "请输入企业名称", trigger: "blur" }, ], udplatCompanyName: [ - {required: this.udplatEnable, message: "请输入阳光采购平台企业名称", trigger: "blur"}, + { + required: this.udplatEnable, + message: "请输入阳光采购平台企业名称", + trigger: "blur", + }, ], creditNum: [ - {required: true, message: "请输入统一社会信用号", trigger: "blur"}, + { required: true, message: "请输入统一社会信用号", trigger: "blur" }, ], - area: [{required: true, message: "请选择所属地区", trigger: "blur"}], + area: [{ required: true, message: "请选择所属地区", trigger: "blur" }], detailAddr: [ - {required: true, message: "请输入详细地址", trigger: "blur"}, + { required: true, message: "请输入详细地址", trigger: "blur" }, + { mix: 1, max: 30, message: "请输入详细地址", trigger: "blur" }, ], bussinessStatus: [ - {required: true, message: "请选择企业类型", trigger: "blur"}, + { required: true, message: "请选择企业类型", trigger: "blur" }, ], }, registerConfigMap: { @@ -635,13 +697,16 @@ export default { formData: { account: "", password: "", - } + }, }; }, created() { this.registerConfig(); - this.uploadUrl = process.env.VUE_APP_BASE_API + "/udiwms/upload/register/file"; - this.fileUrl = process.env.VUE_APP_BASE_API + "/udiwms/image/register/file/getImage?type=image1&name="; + this.uploadUrl = + process.env.VUE_APP_BASE_API + "/udiwms/upload/register/file"; + this.fileUrl = + process.env.VUE_APP_BASE_API + + "/udiwms/image/register/file/getImage?type=image1&name="; // this.getData(); this.headers = { ADMIN_ID: store.getters.adminId, @@ -656,7 +721,7 @@ export default { if (valid) { if (this.registerConfigMap.companyCheckStatus) { if (this.$isBlank(this.inputQuery.companyName)) { - this.$message.error('企业名称不能为空'); + this.$message.error("企业名称不能为空"); return; } } @@ -673,11 +738,14 @@ export default { this.formData = { account: response.data, password: this.inputQuery.password, - } + }; this.formVisible = true; - this.acoountInfo = "账号:" + this.formData.account + "\n密码:" + this.formData.password; - + this.acoountInfo = + "账号:" + + this.formData.account + + "\n密码:" + + this.formData.password; } else { this.$message.error(response.message); } @@ -689,7 +757,7 @@ export default { }, formDefine() { this.formVisible = false; - this.$router.push({path: "../login"}); + this.$router.push({ path: "../login" }); }, getData() { this.loading = true; @@ -714,7 +782,7 @@ export default { }, checkCompanyName() { if (this.$isBlank(this.inputQuery.companyName)) { - this.$message.error('企业名称不能为空'); + this.$message.error("企业名称不能为空"); return; } let tQuery = { @@ -753,40 +821,46 @@ export default { }, handleChange(value) { this.inputQuery.area = CodeToText[value[0]]; - if (CodeToText[value[1]] != null && CodeToText[value[1]] != "" - && CodeToText[value[1]] != "undefined") { + if ( + CodeToText[value[1]] != null && + CodeToText[value[1]] != "" && + CodeToText[value[1]] != "undefined" + ) { this.inputQuery.area += CodeToText[value[1]]; } - if (CodeToText[value[2]] != null && CodeToText[value[2]] != "" - && CodeToText[value[2]] != "undefined") { + if ( + CodeToText[value[2]] != null && + CodeToText[value[2]] != "" && + CodeToText[value[2]] != "undefined" + ) { this.inputQuery.area += CodeToText[value[2]]; } this.inputQuery.areaCode = value.toString(); }, copy() { - let sel = this; - let clipboard = new Clipboard('.tag-read'); + let clipboard = new Clipboard(".tag-read"); - clipboard.on('success', e => { + clipboard.on("success", (e) => { // 释放内存 clipboard.destroy(); }); - clipboard.on('error', e => { + clipboard.on("error", (e) => { // 不支持复制 // 释放内存 - clipboard.destroy() + clipboard.destroy(); }); this.$confirm("账号已复制,请牢记自己的账号密码!是否跳转登录", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", - }).then(() => { - // this.formVisible = false; - // this.$router.push({path: "../login"}); - sel.formDefine(); - }).catch(() => { - }); + }) + .then(() => { + // this.formVisible = false; + // this.$router.push({path: "../login"}); + sel.formDefine(); + }) + .catch(() => {}); }, selectOne(event) { this.inputQuery.companyName = event.name; @@ -802,7 +876,6 @@ export default { this.fromOptions = []; let cQuery = { key: query, - }; getBasicUnitMaintains(cQuery) .then((response) => { @@ -829,23 +902,29 @@ export default { this.loading = false; }); }, - uploadHandleRemove(file, fileList) { - }, - uploadHandlePreview(file) { - }, + uploadHandleRemove(file, fileList) {}, + uploadHandlePreview(file) {}, uploadHandleExceed(files, fileList) { - this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`); + this.$message.warning( + `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${ + files.length + fileList.length + } 个文件` + ); }, uploadOnchange(file, fileList) { let fileName = file.name; - let uid = file.uid + let uid = file.uid; let pos = fileName.lastIndexOf("."); let lastName = fileName.substring(pos, fileName.length); - if (lastName.toLowerCase() !== ".jpg" && lastName.toLowerCase() !== ".png") { + if ( + lastName.toLowerCase() !== ".jpg" && + lastName.toLowerCase() !== ".png" + ) { this.$message.error("上传文件只能是 .jpg,.png 格式"); - for (let i = 0; i < fileList.length; i++) {//从list删除 + for (let i = 0; i < fileList.length; i++) { + //从list删除 if (fileList[i].uid === uid) { - fileList.splice(i, 1) + fileList.splice(i, 1); } } return; @@ -856,7 +935,7 @@ export default { this.$message.error("上传文件大小不能超过 30MB"); for (let i = 0; i < fileList.length; i++) { if (fileList[i].uid === uid) { - fileList.splice(i, 1) + fileList.splice(i, 1); } } } @@ -869,8 +948,7 @@ export default { this.$message.error("文件上传失败:" + response.message); } }, - uploadHandleError() { - }, + uploadHandleError() {}, openFile(path) { window.open(this.fileUrl + path); },