Browse Source

用户注册

guhongwei 1 year ago
parent
commit
f671d19d53

+ 3 - 3
src/router/module/common.ts

@@ -5,8 +5,8 @@ export default [
     component: () => import('@/views/login/index.vue')
   },
   {
-    path: '/test',
-    meta: { title: '测试' },
-    component: () => import('@/views/testIndex.vue')
+    path: '/register',
+    meta: { title: '账号注册' },
+    component: () => import('@/views/register/index.vue')
   }
 ];

+ 5 - 1
src/views/login/index.vue

@@ -66,6 +66,7 @@ import { siteInfo } from '@common/src/layout/site';
 import validcode from '@common/src/components/ValidCode.vue';
 import type { Ref } from 'vue';
 import { onMounted, ref, reactive } from 'vue';
+import { useRouter } from 'vue-router';
 import type { FormInstance, FormRules } from 'element-plus';
 import { ElMessage } from 'element-plus';
 // 接口
@@ -81,6 +82,9 @@ const companyAxios = CompanyStore();
 const expertAxiso = ExpertStore();
 const tokenAxiso = TokenStore();
 
+// 路由
+const router = useRouter();
+
 // 登录类型
 const login_type: Ref<any> = ref('1');
 // 表单
@@ -164,7 +168,7 @@ const tokenView = async () => {
 };
 // 账号注册
 const toRegister = () => {
-  console.log('账号注册');
+  router.push({ path: '/register' });
 };
 </script>
 <style scoped lang="scss">

+ 145 - 0
src/views/register/index.vue

@@ -0,0 +1,145 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
+        <el-col :span="24" class="one">
+          <el-col :span="24" class="one_1 w_1200">
+            <el-image class="image" :src="siteInfo.logo_url"></el-image>
+            <span>{{ siteInfo.zhTitle }}--{{ router_title }}</span>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="two">
+          <el-col :span="24" class="two_1 w_1200">
+            <el-col :span="17" class="l">
+              <component :is="cForm"></component>
+            </el-col>
+            <el-col :span="6" class="r">
+              <el-col :span="24" class="title">常见问题</el-col>
+              <el-col :span="24" class="r_1">
+                <el-col :span="24" class="list" v-for="(item, index) in questionList" :key="index">
+                  <p>{{ index + 1 + '.' }}{{ item.title }}</p>
+                  <p>{{ item.content }}</p>
+                  <p>{{ item.other }}</p>
+                </el-col>
+              </el-col>
+            </el-col>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <el-col :span="24" class="thr_1 w_1200">
+            <p v-html="footInfo.content"></p>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script setup lang="ts">
+// 基础
+import { siteInfo, footInfo, questionList } from '@common/src/layout/site';
+import cForm from './parts/c-form.vue';
+import type { Ref } from 'vue';
+import { useRoute } from 'vue-router';
+import { onMounted, ref } from 'vue';
+
+// 路由
+const route = useRoute();
+// 加载中
+const loading: Ref<any> = ref(false);
+// 路由地址名称
+const router_title: Ref<any> = ref('');
+// 请求
+onMounted(async () => {
+  loading.value = true;
+  router_title.value = route.meta.title;
+  loading.value = false;
+});
+</script>
+<style scoped lang="scss">
+.main {
+  background-color: #f1f1f1;
+  .one {
+    height: 100px;
+    overflow: hidden;
+    border-bottom: 4px solid #44b549;
+    background-color: #ffffff;
+    .one_1 {
+      padding: 10px 0;
+      .image {
+        width: 66px;
+        height: 66px;
+        overflow: hidden;
+      }
+      span {
+        position: absolute;
+        top: 30px;
+        font-size: 25px;
+        padding: 0 20px;
+        font-family: cursive;
+        color: #2d64b3;
+      }
+    }
+  }
+  .two {
+    padding: 10px 0;
+    .two_1 {
+      display: flex;
+      .l {
+        background-color: #ffffff;
+        margin: 0 15px 0 0;
+        padding: 10px;
+      }
+      .r {
+        background-color: #ffffff;
+        padding: 10px;
+        .title {
+          padding: 0 0 10px 0;
+          margin: 0 0 5px 0;
+          border-bottom: 1px dashed #cccccc;
+        }
+        .r_1 {
+          .list {
+            border-bottom: 1px dashed #ccc;
+            padding: 10px 0;
+            p {
+              font-size: 14px;
+            }
+            p:nth-child(1) {
+              font-weight: bold;
+              padding: 5px 0 0 0;
+            }
+            p:nth-child(2) {
+              color: #ff0000;
+              padding: 5px 0 0 0;
+            }
+            p:nth-child(3) {
+              font-weight: bold;
+              padding: 5px 0 0 0;
+              span {
+                color: #ff0000;
+              }
+            }
+          }
+          .list:last-child {
+            border-bottom: none;
+          }
+        }
+      }
+    }
+  }
+  .thr {
+    height: 120px;
+    background-color: #3a3637;
+    .thr_1 {
+      padding: 10px 0;
+      color: #999999;
+      :deep(p) {
+        p {
+          margin: 0 0 5px 0;
+        }
+      }
+    }
+  }
+}
+</style>

+ 207 - 0
src/views/register/parts/c-form.vue

@@ -0,0 +1,207 @@
+<template>
+  <div id="c-form">
+    <el-row>
+      <el-col :span="24" class="main" v-loading="loading">
+        <el-col :span="24" class="one">
+          <el-steps :active="steps_active" align-center>
+            <el-step title="基本信息" />
+            <el-step title="详细信息" />
+          </el-steps>
+        </el-col>
+        <el-col :span="24" class="two">
+          <template v-if="steps_active == 1">
+            <cForm :span="24" :fields="fields" :form="form" :rules="rules" :isSave="false" label-width="auto">
+              <template #code>
+                <el-option v-for="i in codeList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+              </template>
+              <template #type>
+                <el-option v-for="i in typeList" :key="i.label" :label="i.label" :value="i.value"></el-option>
+              </template>
+              <template #area>
+                <el-option v-for="i in areaList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+              </template>
+              <template v-slot:submit>
+                <el-button>提交</el-button>
+              </template>
+            </cForm>
+            <el-col :span="24" class="btn">
+              <el-button type="primary" @click="toSteps(2)">下一步</el-button>
+              <el-button type="danger" @click="toLogin">返回登录</el-button>
+            </el-col>
+          </template>
+          <template v-else-if="steps_active == 2">
+            <cForm :span="24" :fields="otherfields" :form="otherform" :rules="rules" label-width="auto">
+              <template v-slot:submit>
+                <el-button type="primary" @click="toSteps(1)">上一步</el-button>
+                <el-button type="success" @click="toSave">提交注册</el-button>
+                <el-button type="danger" @click="toLogin">返回登录</el-button>
+              </template>
+            </cForm>
+          </template>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script setup lang="ts">
+// 基础
+import type { Ref } from 'vue';
+// reactive,
+import { onMounted, ref, reactive } from 'vue';
+import { ElMessage } from 'element-plus';
+import type { FormRules } from 'element-plus';
+// 接口
+import { PersonalStore } from '@common/src/stores/admins/personal'; // 个人
+import { CompanyStore } from '@common/src/stores/admins/company'; // 企业
+import { DictDataStore } from '@common/src/stores/system/dictData';
+import type { IQueryResult } from '@/util/types.util';
+import router from '@/router';
+const personalAxios = PersonalStore();
+const companyAxios = CompanyStore();
+const dictAxios = DictDataStore();
+
+// 加载中
+const loading: Ref<any> = ref(false);
+// 进度
+const steps_active: Ref<any> = ref(1);
+// 表单
+let form: Ref<any> = ref({});
+let fields: Ref<any[]> = ref([
+  { label: '用户类型', model: 'type', type: 'select' },
+  { label: '邀请码', model: 'code', type: 'select' },
+  { label: '登录账号', model: 'account' },
+  { label: '登录密码', model: 'password', type: 'password' },
+  { label: '用户名', model: 'name' },
+  { label: '手机号', model: 'phone' },
+  { label: '电子邮箱', model: 'email' },
+  { label: '联系地址', model: 'address' },
+  { label: '办公电话', model: 'work_phone' },
+  { label: '所属行业', model: 'industry' },
+  { label: '所属辖区', model: 'area', type: 'select' }
+]);
+let otherform: Ref<any> = ref({});
+let otherfields: Ref<any[]> = ref([]);
+const rules = reactive<FormRules>({
+  type: [{ required: true, message: '请选择用户类型', trigger: 'change' }],
+  code: [{ required: true, message: '请选择邀请码', trigger: 'change' }],
+  account: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
+  password: [{ required: true, message: '请输入登录密码', trigger: 'blur' }],
+  name: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
+  phone: [{ required: false, message: '请输入手机号', trigger: 'blur' }],
+  email: [{ required: false, message: '请输入电子邮箱', trigger: 'blur' }],
+  address: [{ required: false, message: '请输入联系地址', trigger: 'blur' }],
+  work_phone: [{ required: false, message: '请输入办公电话', trigger: 'blur' }],
+  profindustryession: [{ required: false, message: '请输入所属行业', trigger: 'blur' }],
+  juris: [{ required: false, message: '请选择所属辖区', trigger: 'change' }]
+});
+
+// 字典表
+const typeList: Ref<any> = ref([
+  { label: '个人用户', value: '4' },
+  { label: '企业用户', value: '5' }
+]);
+const areaList: Ref<any> = ref([]);
+const codeList: Ref<any> = ref([]);
+// 请求
+onMounted(async () => {
+  loading.value = true;
+  await searchOther();
+  loading.value = false;
+});
+// 下一步
+const toSteps = async (e) => {
+  if (e == 2) {
+    if (!form.value.type) {
+      ElMessage({ message: '请选择用户类型', type: 'error' });
+      return;
+    }
+    if (!form.value.code) {
+      ElMessage({ message: '请选择邀请码', type: 'error' });
+      return;
+    }
+    if (!form.value.account) {
+      ElMessage({ message: '请输入账号', type: 'error' });
+      return;
+    }
+    if (!form.value.password) {
+      ElMessage({ message: '请输入账号', type: 'error' });
+      return;
+    }
+    if (!form.value.name) {
+      ElMessage({ message: '请输入用户名', type: 'error' });
+      return;
+    }
+    // 下一步,根据用户类型不同,赋值不同的otherFields
+    let list: any = [];
+    if (form.value.type == '4') {
+      list = [
+        { label: '身份证号', model: 'card' },
+        { label: '职务职称', model: 'zwzc' },
+        { label: '所在院系', model: 'school' },
+        { label: '所学专业', model: 'major' }
+      ];
+    } else if (form.value.type == '5') {
+      list = [
+        { label: '机构代码', model: 'institution_code' },
+        { label: '注册类型', model: 'companytype' },
+        { label: '注册时间', model: 'companydate', type: 'date' },
+        { label: '注册资金', model: 'companycapital' },
+        { label: '企业法人', model: 'companyperson' },
+        { label: '上年度企业总收入', model: 'sndqyzsr' },
+        { label: '上年度研发费用', model: 'sndyffy' },
+        { label: '企业总人数', model: 'companytotal' },
+        { label: '专&兼职研发人数', model: 'zjzyfrs' },
+        { label: '企业简介', model: 'companybrief', type: 'textarea' },
+        { label: '主要产品', model: 'mainproduct', type: 'textarea' },
+        { label: '企业资质&荣誉', model: 'qualifications', type: 'textarea' }
+      ];
+    }
+    otherfields.value = list;
+  }
+  steps_active.value = e;
+};
+// 提交保存
+const toSave = async () => {
+  let object = { ...form.value, ...otherform.value };
+  let res: IQueryResult;
+  if (object.type == '4') res = await personalAxios.create(object);
+  else if (object.type == '5') res = await companyAxios.create(object);
+  if (res.errcode == '0') {
+    ElMessage({ message: '注册成功', type: 'success' });
+    toLogin();
+  } else {
+    ElMessage({ message: `${res.errmsg}`, type: 'error' });
+  }
+};
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 辖区
+  res = await dictAxios.query({ type: 'jl_area' });
+  if (res.errcode == '0') areaList.value = res.data;
+  // 邀请码
+  res = await dictAxios.query({ type: 'account_code' });
+  if (res.errcode == '0') {
+    let list = res.data as any;
+    list = list.filter((i) => i.value != 'CJGLY');
+    codeList.value = list;
+  }
+};
+// 返回登录
+const toLogin = () => {
+  router.push({ path: '/login' });
+};
+</script>
+<style scoped lang="scss">
+.main {
+  .one {
+    margin: 10px 0;
+  }
+  .two {
+    .btn {
+      text-align: center;
+    }
+  }
+}
+</style>

+ 0 - 41
src/views/testIndex.vue

@@ -1,41 +0,0 @@
-<template>
-  <div id="testIndex">
-    <el-row>
-      <el-col :span="24" class="main animate__animated animate__backInRight">
-        <el-col :span="12" class="one">
-          <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="onSubmit"></cForm>
-        </el-col>
-      </el-col>
-    </el-row>
-  </div>
-</template>
-<script setup lang="ts">
-import type { FormRules } from 'element-plus';
-import type { Ref } from 'vue';
-import { ref, reactive, onMounted } from 'vue';
-import { ElMessage } from 'element-plus';
-import { AdminStore } from '@common/src/stores/admins/admin'; // 角色
-import type { IQueryResult } from '@/util/types.util';
-const admin = AdminStore();
-let form: Ref<any> = ref({});
-// 表单
-let formFields: Ref<any[]> = ref([
-  { label: '账号', model: 'account' },
-  { label: '密码', model: 'password' }
-]);
-const rules = reactive<FormRules>({});
-onMounted(async () => {
-  await search();
-});
-const search = async () => {};
-// 提交
-const onSubmit = async (data) => {
-  let res: IQueryResult = await admin.login(data);
-  if (res.errcode == 0) {
-    ElMessage({ type: `success`, message: `登陆成功` });
-    localStorage.setItem('token', `${res.data}`);
-    console.log(res.data);
-  }
-};
-</script>
-<style scoped lang="scss"></style>