Browse Source

修改注册

zs 10 months ago
parent
commit
e7f5d3f09e
3 changed files with 497 additions and 63 deletions
  1. 239 0
      src/views/register/index copy.vue
  2. 30 63
      src/views/register/index.vue
  3. 228 0
      src/views/register/parts/userCode.vue

+ 239 - 0
src/views/register/index copy.vue

@@ -0,0 +1,239 @@
+<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">
+          <div class="loginform">
+            <el-col :span="24" class="content_1">
+              <div class="type-list">
+                <el-tooltip
+                  v-for="(item, index) in typeList"
+                  :key="index"
+                  effect="dark"
+                  :content="item.remark"
+                  placement="top"
+                >
+                  <span
+                    class="span"
+                    :class="[item.value === type ? 'active' : '']"
+                    @click="toSelect(item.value)"
+                    >{{ item.label }}</span
+                  >
+                </el-tooltip>
+              </div>
+            </el-col>
+            <el-col :span="24" class="content_2">
+              <user v-if="type == '0'"></user>
+              <expert v-if="type == '1'"></expert>
+              <company v-if="type == '2'"></company>
+              <incubator v-if="type == '3'"></incubator>
+              <competition v-if="type == '4'"></competition>
+              <investment v-if="type == '5'"></investment>
+              <association v-if="type == '6'"></association>
+              <state v-if="type == '7'"></state>
+              <unit v-if="type == '8'"></unit>
+            </el-col>
+          </div>
+        </el-col>
+      </el-col>
+    </el-row>
+    <el-dialog v-model="dialog" title="使用协议">
+      <div v-html="configInfo.agreement"></div>
+    </el-dialog>
+  </div>
+</template>
+<script setup>
+// API 引用
+import { getCity } from '@/utils/city'
+import { siteInfo } from '@/layout/site'
+const $checkRes = inject('$checkRes')
+import { get, cloneDeep } from 'lodash-es'
+// 接口
+import { DictDataStore } from '@/store/api/system/dictData'
+import { DesignStore } from '@/store/api/platform/design'
+const dictDataStore = DictDataStore()
+const designStore = DesignStore()
+// 组件
+import user from './parts/user.vue'
+import association from './parts/association.vue'
+import company from './parts/company.vue'
+import competition from './parts/competition.vue'
+import expert from './parts/expert.vue'
+import incubator from './parts/incubator.vue'
+import state from './parts/state.vue'
+import unit from './parts/unit.vue'
+import investment from './parts/investment.vue'
+// 路由
+const router = useRouter()
+// 加载中
+const loading = ref(false)
+// 表单验证
+const ruleFormRef = ref()
+// 弹框
+const dialog = ref(false)
+// 基本设置
+const configInfo = ref({})
+// 字典
+const typeList = ref([])
+const genderList = ref([])
+const fieldList = ref([])
+const educationList = ref([])
+const cityList = ref([])
+const isUseList = ref([])
+const patternList = ref([])
+const scaleList = ref([])
+const IndustryList = ref([])
+const cardTypeList = ref([])
+const contributionList = ref([])
+const companyList = ref([])
+// 用户类型
+const type = ref('0')
+// 用户协议
+const isAgree = ref(false)
+// 请求
+onMounted(async () => {
+  loading.value = true
+  await searchOther()
+  loading.value = false
+})
+const searchOther = async () => {
+  let result
+  // 性别
+  result = await dictDataStore.query({ code: 'gender', is_use: '0' })
+  if ($checkRes(result)) genderList.value = result.data
+  // 用户类型
+  result = await dictDataStore.query({ code: 'userType', is_use: '0' })
+  if ($checkRes(result)) typeList.value = result.data
+  // 专家领域
+  result = await dictDataStore.query({ code: 'field', is_use: '0' })
+  if ($checkRes(result)) fieldList.value = result.data
+  // 企业类型
+  result = await dictDataStore.query({ code: 'companyType', is_use: '0' })
+  if ($checkRes(result)) patternList.value = result.data
+  // 企业规模
+  result = await dictDataStore.query({ code: 'companyScale', is_use: '0' })
+  if ($checkRes(result)) scaleList.value = result.data
+  // 企业所属行业
+  result = await dictDataStore.query({ code: 'companyIndustry', is_use: '0' })
+  if ($checkRes(result)) IndustryList.value = result.data
+  // 学历
+  result = await dictDataStore.query({ code: 'education', is_use: '0' })
+  if ($checkRes(result)) educationList.value = result.data
+  // 证件类型
+  result = await dictDataStore.query({ code: 'cardType', is_use: '0' })
+  if ($checkRes(result)) cardTypeList.value = result.data
+  // 出资方式
+  result = await dictDataStore.query({ code: 'contribution', is_use: '0' })
+  if ($checkRes(result)) contributionList.value = result.data
+  // 是否使用
+  result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
+  if ($checkRes(result)) isUseList.value = result.data
+  // 公司状态
+  result = await dictDataStore.query({ code: 'companyStatus', is_use: '0' })
+  if ($checkRes(result)) companyList.value = result.data
+  // 基础设置
+  result = await designStore.query({})
+  if ($checkRes(result)) configInfo.value = result.data[0] || {}
+  // 城市
+  getCity().then((response) => (cityList.value = response.address))
+}
+// 选择用户类型
+const toSelect = async (data) => {
+  type.value = data
+}
+// 去登录
+const toLogin = () => {
+  router.push({ path: '/login' })
+}
+// 返回
+const toBack = () => {
+  router.push({ path: '/home' })
+}
+// provide
+provide('cloneDeep', cloneDeep)
+provide('get', get)
+provide('siteInfo', siteInfo)
+provide('dialog', dialog)
+provide('isAgree', isAgree)
+provide('ruleFormRef ', ruleFormRef)
+provide('router', router)
+// 字典
+provide('genderList', genderList)
+provide('fieldList', fieldList)
+provide('educationList', educationList)
+provide('cityList', cityList)
+provide('isUseList', isUseList)
+provide('patternList', patternList)
+provide('scaleList', scaleList)
+provide('IndustryList', IndustryList)
+provide('cardTypeList', cardTypeList)
+provide('contributionList', contributionList)
+provide('companyList', companyList)
+// 方法
+provide('toLogin', toLogin)
+provide('toBack', toBack)
+</script>
+<style scoped lang="scss">
+.main {
+  .one {
+    background-image: url(/images/loginbg.jpeg);
+    background-position: center center;
+    background-repeat: no-repeat;
+    height: calc(100vh - 23vh);
+    width: 100%;
+    background-size: cover;
+    display: flex;
+    justify-content: space-evenly;
+
+    .loginform {
+      width: 800px;
+      position: absolute;
+      top: 50%;
+      left: 50%;
+      min-height: 400px;
+      background: hsla(0, 0%, 100%, 0.6);
+      box-shadow: 0 0 30px 0 rgba(51, 51, 51, 0.2);
+      -webkit-transform: translate(-50%, -50%);
+      transform: translate(-50%, -50%);
+      border-top: 10px solid #1492ff;
+
+      .content_1 {
+        text-align: center;
+        padding: 10px;
+        .type-list {
+          margin: 10px 0 0 0;
+          .span {
+            padding: 0 10px;
+            margin-left: 5px;
+            height: 26px;
+            line-height: 24px;
+            border: 1px solid #ddd;
+            border-radius: 3px;
+            background-color: #f4f4f4;
+          }
+          .span:hover {
+            border-color: #3497fc;
+            background-color: #d2f1fe;
+          }
+          .active {
+            border-color: #3497fc;
+            background-color: #d2f1fe;
+            background-image: url(/images/icon_2.png);
+            background-position: top right;
+            background-repeat: no-repeat;
+          }
+        }
+      }
+
+      .content_2 {
+        margin: 0 20px;
+        overflow-y: auto;
+      }
+
+      .content_2::-webkit-scrollbar {
+        display: none;
+      }
+    }
+  }
+}
+</style>

+ 30 - 63
src/views/register/index.vue

@@ -4,34 +4,8 @@
       <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="content_1">
-              <div class="type-list">
-                <el-tooltip
-                  v-for="(item, index) in typeList"
-                  :key="index"
-                  effect="dark"
-                  :content="item.remark"
-                  placement="top"
-                >
-                  <span
-                    class="span"
-                    :class="[item.value === type ? 'active' : '']"
-                    @click="toSelect(item.value)"
-                    >{{ item.label }}</span
-                  >
-                </el-tooltip>
-              </div>
-            </el-col>
             <el-col :span="24" class="content_2">
-              <user v-if="type == '0'"></user>
-              <expert v-if="type == '1'"></expert>
-              <company v-if="type == '2'"></company>
-              <incubator v-if="type == '3'"></incubator>
-              <competition v-if="type == '4'"></competition>
-              <investment v-if="type == '5'"></investment>
-              <association v-if="type == '6'"></association>
-              <state v-if="type == '7'"></state>
-              <unit v-if="type == '8'"></unit>
+              <userCode></userCode>
             </el-col>
           </div>
         </el-col>
@@ -54,15 +28,7 @@ import { DesignStore } from '@/store/api/platform/design'
 const dictDataStore = DictDataStore()
 const designStore = DesignStore()
 // 组件
-import user from './parts/user.vue'
-import association from './parts/association.vue'
-import company from './parts/company.vue'
-import competition from './parts/competition.vue'
-import expert from './parts/expert.vue'
-import incubator from './parts/incubator.vue'
-import state from './parts/state.vue'
-import unit from './parts/unit.vue'
-import investment from './parts/investment.vue'
+import userCode from './parts/userCode.vue'
 // 路由
 const router = useRouter()
 // 加载中
@@ -104,33 +70,33 @@ const searchOther = async () => {
   // 用户类型
   result = await dictDataStore.query({ code: 'userType', is_use: '0' })
   if ($checkRes(result)) typeList.value = result.data
-  // 专家领域
-  result = await dictDataStore.query({ code: 'field', is_use: '0' })
-  if ($checkRes(result)) fieldList.value = result.data
-  // 企业类型
-  result = await dictDataStore.query({ code: 'companyType', is_use: '0' })
-  if ($checkRes(result)) patternList.value = result.data
-  // 企业规模
-  result = await dictDataStore.query({ code: 'companyScale', is_use: '0' })
-  if ($checkRes(result)) scaleList.value = result.data
-  // 企业所属行业
-  result = await dictDataStore.query({ code: 'companyIndustry', is_use: '0' })
-  if ($checkRes(result)) IndustryList.value = result.data
-  // 学历
-  result = await dictDataStore.query({ code: 'education', is_use: '0' })
-  if ($checkRes(result)) educationList.value = result.data
-  // 证件类型
-  result = await dictDataStore.query({ code: 'cardType', is_use: '0' })
-  if ($checkRes(result)) cardTypeList.value = result.data
-  // 出资方式
-  result = await dictDataStore.query({ code: 'contribution', is_use: '0' })
-  if ($checkRes(result)) contributionList.value = result.data
-  // 是否使用
-  result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
-  if ($checkRes(result)) isUseList.value = result.data
-  // 公司状态
-  result = await dictDataStore.query({ code: 'companyStatus', is_use: '0' })
-  if ($checkRes(result)) companyList.value = result.data
+  // // 专家领域
+  // result = await dictDataStore.query({ code: 'field', is_use: '0' })
+  // if ($checkRes(result)) fieldList.value = result.data
+  // // 企业类型
+  // result = await dictDataStore.query({ code: 'companyType', is_use: '0' })
+  // if ($checkRes(result)) patternList.value = result.data
+  // // 企业规模
+  // result = await dictDataStore.query({ code: 'companyScale', is_use: '0' })
+  // if ($checkRes(result)) scaleList.value = result.data
+  // // 企业所属行业
+  // result = await dictDataStore.query({ code: 'companyIndustry', is_use: '0' })
+  // if ($checkRes(result)) IndustryList.value = result.data
+  // // 学历
+  // result = await dictDataStore.query({ code: 'education', is_use: '0' })
+  // if ($checkRes(result)) educationList.value = result.data
+  // // 证件类型
+  // result = await dictDataStore.query({ code: 'cardType', is_use: '0' })
+  // if ($checkRes(result)) cardTypeList.value = result.data
+  // // 出资方式
+  // result = await dictDataStore.query({ code: 'contribution', is_use: '0' })
+  // if ($checkRes(result)) contributionList.value = result.data
+  // // 是否使用
+  // result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
+  // if ($checkRes(result)) isUseList.value = result.data
+  // // 公司状态
+  // result = await dictDataStore.query({ code: 'companyStatus', is_use: '0' })
+  // if ($checkRes(result)) companyList.value = result.data
   // 基础设置
   result = await designStore.query({})
   if ($checkRes(result)) configInfo.value = result.data[0] || {}
@@ -158,6 +124,7 @@ provide('isAgree', isAgree)
 provide('ruleFormRef ', ruleFormRef)
 provide('router', router)
 // 字典
+provide('typeList', typeList)
 provide('genderList', genderList)
 provide('fieldList', fieldList)
 provide('educationList', educationList)

+ 228 - 0
src/views/register/parts/userCode.vue

@@ -0,0 +1,228 @@
+<template>
+  <div class="index">
+    <el-form
+      ref="ruleFormRef"
+      :model="form"
+      :rules="rules"
+      label-width="80px"
+      class="form"
+      label-position="left"
+    >
+      <el-form-item label="注册类型" prop="type">
+        <el-radio-group v-model="form.type">
+          <el-radio label="普通用户"></el-radio>
+          <el-radio label="角色用户"></el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <el-form-item label="角色选择" prop="role">
+        <el-radio-group v-model="form.role">
+          <el-radio v-for="(item, index) in typeList" :key="index" :label="item.label"></el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <el-form-item label="板块选择" prop="plate">
+        <el-radio-group v-model="form.plate">
+          <el-radio v-for="(item, index) in plateList" :key="index" :label="item.label"></el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <el-form-item label="姓名" prop="nick_name">
+        <el-input clearable v-model="form.nick_name" placeholder="请输入姓名/单位名称">
+          <template #prefix>
+            <el-icon>
+              <Avatar />
+            </el-icon>
+          </template>
+        </el-input>
+      </el-form-item>
+      <el-form-item label="手机号" prop="phone">
+        <el-input clearable v-model="form.phone" placeholder="请输入手机号">
+          <template #prefix>
+            <el-icon>
+              <Iphone />
+            </el-icon>
+          </template>
+        </el-input>
+      </el-form-item>
+      <el-form-item label="验证码" prop="checkCode">
+        <el-input class="check-code-box" v-model.number="form.checkCode" placeholder="请输入验证码">
+          <template #prefix>
+            <el-icon>
+              <Message />
+            </el-icon>
+          </template>
+          <template v-slot:append>
+            <el-button :disabled="codeCd" @click="handleCaptcha('form')"
+              >获取验证码
+              <span v-if="codeCd">({{ long }})</span>
+            </el-button>
+          </template>
+        </el-input>
+      </el-form-item>
+      <el-form-item label="密码" prop="password">
+        <el-input
+          v-model="form.password"
+          type="password"
+          show-password
+          placeholder="请输入登录密码"
+        >
+          <template #prefix>
+            <el-icon>
+              <Unlock />
+            </el-icon>
+          </template>
+        </el-input>
+      </el-form-item>
+      <el-col :span="24" class="remark">
+        <span @click="toLogin">已有账号去登录</span>
+        <span @click="toBack">返回首页</span>
+      </el-col>
+      <el-col :span="24" class="button">
+        <el-button type="primary" @click="submitForm(ruleFormRef)">注册</el-button>
+      </el-col>
+      <el-col :span="24" class="agree">
+        <el-checkbox v-model="isAgree"></el-checkbox>
+        <span style="margin: 0 0 0 5px">我已阅读并同意</span>
+        <span @click="dialog = true">《{{ siteInfo.zhTitle }}使用协议》</span>
+      </el-col>
+    </el-form>
+  </div>
+</template>
+<script setup>
+// 基础
+const siteInfo = inject('siteInfo')
+const cloneDeep = inject('cloneDeep')
+const router = inject('router')
+// 弹框
+const dialog = inject('dialog')
+// 用户协议
+const isAgree = inject('isAgree')
+// 表单
+const ruleFormRef = inject('ruleFormRef')
+// 方法
+const toLogin = inject('toLogin')
+const toBack = inject('toBack')
+// 接口
+import { UsersStore } from '@/store/api/user/user'
+const store = UsersStore()
+const form = ref({ role: ['User'] })
+const typeList = inject('typeList')
+const plateList = ref([
+  { label: '汽车电子及新型汽车零部件', value: '0' },
+  { label: '精细化工及天然气化工', value: '1' },
+  { label: '农产品加工及绿色食品', value: '2' },
+  { label: '光电子及智能传感器', value: '3' },
+  { label: '车规级芯片及功率半导体器件', value: '4' },
+  { label: '新能源及动力电池', value: '5' },
+  { label: '生物基新材料', value: '6' },
+  { label: '人工智能及智能机器人', value: '7' },
+  { label: '碳纤维及复合材料', value: '8' },
+  { label: '遥感卫星及航天航空技术', value: '9' },
+  { label: '精密仪器及先进装备', value: '10' },
+  { label: '生物医药及先进医疗器械', value: '11' }
+])
+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 rules = reactive({
+  nick_name: [{ required: true, message: '请输入昵称', trigger: 'blur' }],
+  phone: [{ required: true, validator: validatePhoneNumber, trigger: 'blur' }],
+  account: [{ required: true, message: '请输入账号', trigger: 'blur' }],
+  password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
+  type: [{ required: true, message: '请选择注册类型', trigger: 'blur' }],
+  role: [{ required: true, message: '请选择角色', trigger: 'blur' }],
+  plate: [{ required: true, message: '请选择板块', trigger: 'blur' }],
+  checkCode: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
+})
+// 注册
+const submitForm = async (formEl) => {
+  if (!isAgree.value) {
+    ElMessage({
+      message: '请阅读并同意用户协议和隐私政策',
+      type: 'warning'
+    })
+    return
+  }
+  if (!formEl) return
+  await formEl.validate(async (valid, fields) => {
+    if (valid) {
+      const data = cloneDeep(form.value)
+      delete data.refpassword
+      const res = await store.create(data)
+      if (res.errcode === 0) {
+        ElMessage({
+          message: '注册用户成功,审核中请稍后登录',
+          type: 'success'
+        })
+        router.push({ path: '/login' })
+      }
+    } else {
+      console.log('error submit!', fields)
+    }
+  })
+}
+</script>
+<style scoped lang="scss">
+.index {
+  margin: 10px 30px 0 30px;
+  overflow-y: auto;
+  height: 500px;
+
+  .remark {
+    display: flex;
+    justify-content: space-between;
+
+    span {
+      cursor: pointer;
+      font-family: PingFangSC-Regular;
+      font-size: 14px;
+      color: #333333;
+      letter-spacing: -0.09px;
+      text-align: right;
+      line-height: 32px;
+    }
+
+    span:hover {
+      color: #2374ff;
+    }
+  }
+
+  .button {
+    padding: 10px 0;
+
+    :deep(.el-button) {
+      width: 100% !important;
+      height: 44px !important;
+      border: 0 !important;
+      color: #f8f8f8 !important;
+      font-size: 16px !important;
+      text-align: center !important;
+      line-height: 40px !important;
+      cursor: pointer !important;
+      font-family: PingFangSC-Regular !important;
+      background-color: #1492ff !important;
+    }
+  }
+
+  .agree {
+    display: flex;
+    align-items: center;
+    padding: 0 0 10px 0;
+    color: #999;
+    font-size: 12px;
+
+    span:last-child {
+      color: #2374ff;
+    }
+  }
+}
+
+.index::-webkit-scrollbar {
+  display: none;
+}
+</style>