|
@@ -4,38 +4,9 @@
|
|
|
<el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
|
<el-col :span="24" class="one">
|
|
|
<div class="loginform">
|
|
|
- <el-col :span="24" class="tab">
|
|
|
- <el-col
|
|
|
- :span="5"
|
|
|
- class="title"
|
|
|
- @click="toTab(0)"
|
|
|
- :class="[activeName == '0' ? 'tab0' : 'tab1']"
|
|
|
- >平台用户</el-col
|
|
|
- >
|
|
|
- <el-col
|
|
|
- :span="5"
|
|
|
- class="title"
|
|
|
- @click="toTab(1)"
|
|
|
- :class="[activeName == '1' ? 'tab0' : 'tab1']"
|
|
|
- >企业用户</el-col
|
|
|
- >
|
|
|
- <el-col
|
|
|
- :span="5"
|
|
|
- class="title"
|
|
|
- @click="toTab(2)"
|
|
|
- :class="[activeName == '2' ? 'tab0' : 'tab1']"
|
|
|
- >科研单位</el-col
|
|
|
- >
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="content" v-show="activeName == '0'">
|
|
|
+ <el-col :span="24" class="content">
|
|
|
<User></User>
|
|
|
</el-col>
|
|
|
- <el-col :span="24" class="content" v-show="activeName == '1'">
|
|
|
- <Company></Company>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="content" v-show="activeName == '2'">
|
|
|
- <Unit></Unit>
|
|
|
- </el-col>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
@@ -45,44 +16,92 @@
|
|
|
</template>
|
|
|
<script setup>
|
|
|
import { siteInfo } from '@/layout/site'
|
|
|
+const $checkRes = inject('$checkRes')
|
|
|
+import { cloneDeep } from 'lodash-es'
|
|
|
+// 接口
|
|
|
+import { UserStore } from '@/store/api/user/user'
|
|
|
+import { DictDataStore } from '@/store/api/system/dictData'
|
|
|
+const store = UserStore()
|
|
|
+const dictDataStore = DictDataStore()
|
|
|
// 组件
|
|
|
import User from './parts/user.vue'
|
|
|
-import Unit from './parts/unit.vue'
|
|
|
-import Company from './parts/company.vue'
|
|
|
// 路由
|
|
|
const router = useRouter()
|
|
|
// 加载中
|
|
|
const loading = ref(false)
|
|
|
-const form = ref({})
|
|
|
+const form = ref({ role: ['user'] })
|
|
|
const dialog = ref(false)
|
|
|
+const validatePhoneNumber = (rule, value, callback) => {
|
|
|
+ const reg = /^1[3-9]\d{9}$/
|
|
|
+ if (!value) {
|
|
|
+ return callback(new Error('手机号不能为空'))
|
|
|
+ }
|
|
|
+ if (!reg.test(value)) {
|
|
|
+ return callback(new Error('请输入正确的手机号'))
|
|
|
+ }
|
|
|
+ callback()
|
|
|
+}
|
|
|
+const validatePassword = (rule, value, callback) => {
|
|
|
+ if (!value) {
|
|
|
+ return callback(new Error('请输入确认密码'))
|
|
|
+ }
|
|
|
+ if (form.value.password !== value) {
|
|
|
+ callback(new Error('两次输入的密码不一致'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+}
|
|
|
const rules = reactive({
|
|
|
+ nick_name: [{ required: true, message: '请输入昵称', trigger: 'blur' }],
|
|
|
+ gender: [{ required: true, message: '请选择性别', trigger: 'blur' }],
|
|
|
+ phone: [{ required: true, validator: validatePhoneNumber, trigger: 'blur' }],
|
|
|
account: [{ required: true, message: '请输入账号', trigger: 'blur' }],
|
|
|
- password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
|
|
|
+ password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
|
|
+ refpassword: [{ required: true, validator: validatePassword, trigger: 'blur' }]
|
|
|
})
|
|
|
-const activeName = ref(0)
|
|
|
const isAgree = ref(false)
|
|
|
+const genderList = ref(false)
|
|
|
// 请求
|
|
|
onMounted(async () => {
|
|
|
loading.value = true
|
|
|
- search()
|
|
|
+ await searchOther()
|
|
|
+ await search()
|
|
|
loading.value = false
|
|
|
})
|
|
|
+const searchOther = async () => {
|
|
|
+ let result
|
|
|
+ // 性别
|
|
|
+ result = await dictDataStore.query({ code: 'gender', is_use: '0' })
|
|
|
+ if ($checkRes(result)) genderList.value = result.data
|
|
|
+}
|
|
|
const search = async () => {
|
|
|
// let res: IQueryResult = await toolsAxios.dataCount();
|
|
|
// if (res.errcode == '0') {
|
|
|
// info.value = res.data;
|
|
|
// }
|
|
|
}
|
|
|
-// 选择
|
|
|
-const toTab = async (active) => {
|
|
|
- activeName.value = active
|
|
|
-}
|
|
|
// 注册
|
|
|
const submitForm = async (formEl) => {
|
|
|
+ if (!isAgree.value) {
|
|
|
+ ElMessage({
|
|
|
+ message: '请阅读并同意用户协议和隐私政策',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
if (!formEl) return
|
|
|
- await formEl.validate((valid, fields) => {
|
|
|
+ await formEl.validate(async (valid, fields) => {
|
|
|
if (valid) {
|
|
|
- console.log('submit!')
|
|
|
+ const data = cloneDeep(form.value)
|
|
|
+ delete data.refpassword
|
|
|
+ const res = await store.create(data)
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ ElMessage({
|
|
|
+ message: '注册用户成功,审核中请稍后登录',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ router.push({ path: '/login' })
|
|
|
+ }
|
|
|
} else {
|
|
|
console.log('error submit!', fields)
|
|
|
}
|
|
@@ -90,7 +109,7 @@ const submitForm = async (formEl) => {
|
|
|
}
|
|
|
// 去登录
|
|
|
const toLogin = () => {
|
|
|
- router.push({ path: '/login', query: { status: '0' } })
|
|
|
+ router.push({ path: '/login' })
|
|
|
}
|
|
|
// 返回
|
|
|
const toBack = () => {
|
|
@@ -101,6 +120,7 @@ provide('siteInfo', siteInfo)
|
|
|
provide('form', form)
|
|
|
provide('rules', rules)
|
|
|
provide('isAgree', isAgree)
|
|
|
+provide('genderList', genderList)
|
|
|
provide('submitForm', submitForm)
|
|
|
provide('toLogin', toLogin)
|
|
|
provide('toBack', toBack)
|
|
@@ -111,18 +131,18 @@ provide('toBack', toBack)
|
|
|
background-image: url(@/assets/loginbg.jpeg);
|
|
|
background-position: center center;
|
|
|
background-repeat: no-repeat;
|
|
|
- height: calc(100vh - 20vh);
|
|
|
+ height: calc(100vh - 22.6vh);
|
|
|
width: 100%;
|
|
|
background-size: cover;
|
|
|
display: flex;
|
|
|
justify-content: space-evenly;
|
|
|
|
|
|
.loginform {
|
|
|
+ width: 800px;
|
|
|
position: absolute;
|
|
|
top: 50%;
|
|
|
left: 50%;
|
|
|
min-height: 460px;
|
|
|
- padding: 20px 85px;
|
|
|
background: hsla(0, 0%, 100%, 0.6);
|
|
|
box-shadow: 0 0 30px 0 rgba(51, 51, 51, 0.2);
|
|
|
-webkit-transform: translate(-50%, -50%);
|
|
@@ -159,7 +179,6 @@ provide('toBack', toBack)
|
|
|
|
|
|
.content {
|
|
|
margin: 30px 30px 0 30px;
|
|
|
- height: 340px;
|
|
|
overflow-y: auto;
|
|
|
|
|
|
.remark {
|