Ver código fonte

企业忘记密码

lifanagju_citu 6 meses atrás
pai
commit
f16bd8a1ba

+ 15 - 0
src/api/common/index.js

@@ -106,6 +106,21 @@ export const resetPassword = async (data) => {
   })
 }
 
+// 企业重置密码
+export const entResetPassword = async (data) => {
+  return await request.put({
+    url: '/app-api/menduner/system/recruit/enterprise/auth/reset-password',
+    data
+  })
+}
+
+// 发送邮箱验证码
+export const getEmailCode = async (email) => {
+  return await request.post({
+    url: `/app-api/menduner/system/recruit/enterprise/auth/send-email-code?email=${email}`
+  })
+}
+
 // 字典
 export const getDictData = async (params) => {
   return await request.get({

+ 1 - 0
src/components/VerificationCode/index.vue

@@ -93,6 +93,7 @@ const handleCode = () => {
   setTime()
   getSmsCode()
 }
+// 短信验证码scene参数: 30-手机号登陆  31-修改手机  32-修改密码  33-忘记密码
 const getSmsCode = async () => {
   const query = {
     phone: loginData.phone,

+ 44 - 21
src/views/login/components/editPasswordEnt.vue

@@ -9,20 +9,21 @@
         density="compact"
         color="primary"
         prepend-inner-icon="mdi-email" 
-        :rules="[v=> !!v || '请输入企业邮箱', v=> checkEmail(v)]"
+        :rules="[v=> !!v || '请输入企业邮箱', v=> checkEmail(v) || '邮箱格式不正确']"
       ></v-text-field>
-      <div class="d-flex">
-        <v-text-field
-          v-model="query.code"
-          label="验证码"
-          placeholder="请输入邮箱收到的验证码" 
-          variant="outlined" 
-          density="compact"
-          color="primary"
-          :rules="[v=> !!v || '请输入邮箱收到的验证码']"
-        ></v-text-field>
-        <v-btn color="primary" class="ml-2" style="margin-top: 2px;" @click="emit('getCode')">获取验证码</v-btn>
-      </div>
+      <v-text-field
+        v-model="query.code"
+        label="验证码"
+        placeholder="请输入邮箱收到的验证码" 
+        variant="outlined" 
+        density="compact"
+        color="primary"
+        :rules="[v=> !!v || '请输入邮箱收到的验证码']"
+      >
+        <template #append-inner>
+          <span class="login-code" @click="handleCode">{{ $t('login.getSmsCode') }}</span>
+        </template>
+      </v-text-field>
     </v-form>
     <v-form ref="passwordRef" style="width: 100%;">
       <v-text-field
@@ -60,9 +61,10 @@
 <script setup>
 defineOptions({ name: 'editPasswordEnt'})
 import { ref, reactive, computed } from 'vue'
-import { resetPassword } from '@/api/common/index'
+import { entResetPassword, getEmailCode } from '@/api/common/index'
 import Snackbar from '@/plugins/snackbar'
 import { checkEmail } from '@/utils/validate'
+import { useRouter } from 'vue-router'; const router = useRouter()
 
 const emit = defineEmits(['cancel', 'getCode'])
 const props = defineProps({
@@ -70,9 +72,9 @@ const props = defineProps({
     type: String,
     default: ''
   },
-  verifySuccess: {
-    type: Boolean,
-    default: false
+  captchaVerification: {
+    type: String,
+    default: ''
   },
   showCancelBtn: {
     type: Boolean,
@@ -119,23 +121,37 @@ const confirmPassword = computed(() => {
 //   emit('cancel')
 // }
 
+const handleCode = async () => {
+  if (!query.email || !checkEmail(query.email)) {
+    Snackbar.warning('请输入企业邮箱')
+    return
+  }
+  emit('getCode')
+  await getEmailCode(query.email)
+  Snackbar.success('已发送验证码,请注意查看!')
+}
+
 // 修改
 const handleSubmit = async () => {
   const emailValid = await emailRef.value.validate()
   const passwordValid = await passwordRef.value.validate()
   if (!emailValid.valid || !passwordValid.valid) return
-  if (!props.verifySuccess) {
+  if (!props.captchaVerification) {
     emit('getCode')
     return
   }
   const data = {
-    password: query.password,
+    ...query,
+    captchaVerification: props.captchaVerification,
   }
   loading.value = true
   // const api = props.isReset ? resetPassword : updatePassword
   try {
-    await resetPassword(data)
-    Snackbar.success('修改成功')
+    await entResetPassword(data)
+    Snackbar.success('修改成功,即将为您跳转到登录页面')
+    setTimeout(() => {
+      router.push({ path: '/login', query: { entLogin: true } })
+    }, 1000);
   } finally {
     loading.value = false
     // handleClose()
@@ -145,4 +161,11 @@ const handleSubmit = async () => {
 </script>
 
 <style scoped lang="scss">
+.login-code {
+  width: 97px;
+  color: var(--v-primary-base);
+  text-align: end; 
+  font-size: 12px; 
+  cursor: pointer;
+}
 </style>

+ 7 - 3
src/views/login/forgotPasswordEnt.vue

@@ -5,7 +5,7 @@
       <div class="resume-header">
         <div class="resume-title">企业修改密码</div>
       </div>
-      <editPasswordPage class="mt-5" :showCancelBtn="false" :verifySuccess="verifySuccess" @getCode="getCode"  @cancel="router.push('/login')"></editPasswordPage>
+      <editPasswordPage class="mt-5" :showCancelBtn="false" :captchaVerification="captchaVerification" @getCode="getCode"  @cancel="router.push('/login')"></editPasswordPage>
     </div>
   </div>
   <Verify
@@ -13,7 +13,7 @@
     :captchaType="captchaType"
     :imgSize="{ width: '400px', height: '200px' }"
     mode="pop"
-    @success="verifySuccess = true"
+    @success="verifySuccess"
   />
 </template>
 
@@ -32,12 +32,16 @@ const router = useRouter()
 const verify = ref()
 const captchaType = ref('blockPuzzle') // blockPuzzle 滑块 clickWord 点击文字
 
-const verifySuccess = ref(false)
 // 获取验证码
 const getCode = async () => {
   // 弹出验证码 // 已开启:则展示验证码;只有完成验证码的情况,才进行登录
   verify.value.show()
 }
+
+const captchaVerification = ref(false)
+const verifySuccess = (params) => {
+  captchaVerification.value = params.captchaVerification
+}
 </script>
 
 <style scoped lang="scss">

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

@@ -85,12 +85,14 @@ import Snackbar from '@/plugins/snackbar'
 import Confirm from '@/plugins/confirm'
 import navBar from '@/layout/personal/navBar.vue'
 import about from '@/views/about/index.vue'
+import { useRoute } from 'vue-router'; const route = useRoute()
 
 const { t } = useI18n()
 const router = useRouter()
 const tab = ref(1)
 const tab1 = ref(1)
-const isEnterpriseLogin = ref(false)
+const isEnterpriseLogin = ref(route.query?.entLogin || false)
+debugger
 
 const handleChangeLogin = () => {
   isEnterpriseLogin.value = !isEnterpriseLogin.value