index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="box">
  3. <div class="content">
  4. <div class="login-content">
  5. <v-card height="392px" class="carousel mr-3" style="width: 792px; border-radius: 8px;">
  6. <v-carousel show-arrows="hover" cycle>
  7. <v-carousel-item v-for="(item, i) in carouselList" :key="i">
  8. <div style="height: 392px; overflow: hidden;">
  9. <v-img :src="item.src" cover style="height: 100%; overflow: hidden;"></v-img>
  10. </div>
  11. </v-carousel-item>
  12. </v-carousel>
  13. </v-card>
  14. <div class="login-card">
  15. <div class="login-change" @click="handleChangeLogin">{{ isEnterpriseLogin ? '切换个人登录' : '切换企业登录' }}</div>
  16. <!-- 企业邮箱登录 -->
  17. <div v-show="isEnterpriseLogin" class="login-tab">
  18. <v-tabs v-model="tab1" align-tabs="center" color="primary" class="mb-10">
  19. <v-tab :value="1">企业邮箱登录</v-tab>
  20. </v-tabs>
  21. <passwordFrom ref="passRef" placeholder="请输入企业邮箱" :validEmail="true" @handleEnter="handleLogin"></passwordFrom>
  22. </div>
  23. <!-- 个人登录 -->
  24. <div v-show="!isEnterpriseLogin" class="login-tab">
  25. <v-tabs v-model="tab" align-tabs="center" color="primary" class="mb-10" @update:modelValue="tabChange">
  26. <v-tab :value="1">验证码</v-tab>
  27. <v-tab :value="2">账号</v-tab>
  28. <!-- <v-tab :value="3">微信</v-tab> -->
  29. </v-tabs>
  30. <v-window v-model="tab">
  31. <!-- 验证码登录 -->
  32. <v-window-item :value="1">
  33. <phoneFrom ref="phoneRef" @handleEnter="handleLogin"></phoneFrom>
  34. </v-window-item>
  35. <!-- 账号密码登录 -->
  36. <v-window-item :value="2">
  37. <passwordFrom ref="passRef" @handleEnter="handleLogin"></passwordFrom>
  38. </v-window-item>
  39. <!-- <v-window-item :value="3">
  40. <div v-if="showQrCode" class="d-flex align-center flex-column">
  41. <span class="text-decoration-underline">微信扫描二维码进行登录</span>
  42. <v-img src="https://minio.citupro.com/dev/menduner/login-qrCode.png" width="150" height="150"></v-img>
  43. </div>
  44. <div v-else style="height: 150px; line-height: 150px; text-align: center;">
  45. 加载中 . . .
  46. </div>
  47. </v-window-item> -->
  48. </v-window>
  49. </div>
  50. <div class="font-size-14 tips">
  51. <span class="float-left color-666 cursor-pointer" v-if="tab === 2 && !isEnterpriseLogin" @click="router.push('/forgotPassword')">忘记密码</span>
  52. <span class="float-right color-error cursor-pointer text-decoration-underline" @click="router.push('/register/selected')">还没有登录账户?去注册</span>
  53. </div>
  54. <v-btn :loading="loginLoading" color="primary" class="white--text mt-5" min-width="350" @click="handleLogin">
  55. {{ $t('login.login') }}
  56. </v-btn>
  57. <div class="login-tips mt-3">
  58. {{ $t('login.agreeLogin') }}
  59. <span class="color" style="cursor: pointer;" @click="router.push('/userAgreement')"> [{{ $t('login.userAgreement') }}] </span>和
  60. <span class="color" style="cursor: pointer;" @click="router.push('/privacyPolicy')">[{{ $t('login.privacyPolicy') }}]</span>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="aboutBox">
  65. <about></about>
  66. </div>
  67. </div>
  68. <navBar :showLoginBtn="false" class="navBar"></navBar>
  69. </div>
  70. </template>
  71. <script setup>
  72. defineOptions({ name: 'login-index' })
  73. import { nextTick, ref } from 'vue'
  74. import passwordFrom from './components/passwordPage.vue'
  75. import phoneFrom from '@/components/VerificationCode'
  76. import { useUserStore } from '@/store/user'
  77. import { useRouter } from 'vue-router'
  78. import { useI18n } from '@/hooks/web/useI18n'
  79. import {
  80. getEnterpriseRegisterApply,
  81. // socialAuthRedirect,
  82. } from '@/api/common'
  83. import Snackbar from '@/plugins/snackbar'
  84. import Confirm from '@/plugins/confirm'
  85. import navBar from '@/layout/personal/navBar.vue'
  86. import about from '@/views/about/index.vue'
  87. const { t } = useI18n()
  88. const router = useRouter()
  89. const tab = ref(1)
  90. const tab1 = ref(1)
  91. const isEnterpriseLogin = ref(false)
  92. const handleChangeLogin = () => {
  93. isEnterpriseLogin.value = !isEnterpriseLogin.value
  94. nextTick(() => {
  95. tab.value = isEnterpriseLogin.value ? 2 : 1 // 为了验证邮箱validate
  96. })
  97. }
  98. // 验证码登录
  99. const phoneRef = ref()
  100. const passRef = ref()
  101. const loginLoading = ref(false)
  102. const userStore = useUserStore()
  103. const handleCheckEnterprise = async () => {
  104. const data = await getEnterpriseRegisterApply(passRef.value.loginData.phone)
  105. if (data && Object.keys(data).length) {
  106. // 查看申请状态
  107. localStorage.setItem('entRegisterData', JSON.stringify(data))
  108. localStorage.setItem('loginAccount', data.phone)
  109. router.push({ path: '/recruit/entRegister/inReview', query: { type: 'noLoginToRegister', noLogin: true } })
  110. }
  111. }
  112. const handleLogin = async () => {
  113. const { valid } = tab.value === 1 ? await phoneRef.value.phoneForm.validate() : await passRef.value.passwordForm.validate()
  114. if (!valid) return
  115. loginLoading.value = true
  116. try {
  117. let params, api = {}
  118. if (tab.value === 1) { params = { ...phoneRef.value.loginData }; api = 'handleSmsLogin'}
  119. else { params = { ...passRef.value.loginData }; api = 'handlePasswordLogin'}
  120. // 邮箱为企业招聘, 手机号为个人求职
  121. if (isEnterpriseLogin.value) {
  122. const pattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
  123. const isEnterprise = pattern.test(params.phone)
  124. if (!isEnterprise) return // 选中企业登录但输入内容非邮箱
  125. params.isEnterprise = isEnterprise
  126. }
  127. await userStore[api](params)
  128. // 跳转
  129. if (params.isEnterprise) return // 企业邮箱登录
  130. else localStorage.setItem('simpleCompleteDialogHaveBeenShow', true) // 个人登录简易基本信息填写弹窗open-status
  131. Snackbar.success(t('login.loginSuccess'))
  132. router.push({ path: '/recruitHome' })
  133. } catch (err) {
  134. if (!err.code) return
  135. // 企业注册申请中
  136. if (err.code === 1100021016) {
  137. handleCheckEnterprise()
  138. return
  139. }
  140. // 登录未注册过的账号跳转注册
  141. const text = err.code === 1100016002 ? '您的手机号还未注册过' : '您的邮箱还未注册过'
  142. Confirm('系统提示', `${text},去注册?`, {
  143. cancelCallback: true
  144. }).then(() => {
  145. localStorage.setItem('loginAccount', tab.value === 1 ? phoneRef.value.loginData.phone : passRef.value.loginData.phone)
  146. router.push(err.code === 1100016002 ? '/register/person?type=noLoginToRegister' : '/register/company?type=noLoginToRegister')
  147. })
  148. } finally {
  149. loginLoading.value = false
  150. }
  151. }
  152. // const getSocialAuthRedirect = async () => {
  153. // const params = {
  154. // type: '34',
  155. // redirectUri: 'https://www.baidu.com'
  156. // }
  157. // const res = await socialAuthRedirect(params)
  158. // const otherUrl = res?.url
  159. // if (otherUrl) window.open(otherUrl)
  160. // }
  161. // const showQrCode = ref(false)
  162. const tabChange = (val) => {
  163. if (val === 3) {
  164. // getSocialAuthRedirect()
  165. }
  166. }
  167. // 轮播广告 // 轮播图片
  168. const carouselList = ref([
  169. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/IHG-banner-new.gif' },
  170. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/Hilton.jpg'},
  171. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/SWISS-HOTEL-MANAGEMENT-SCHOOL-MBA.jpg'},
  172. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/Hong-Kong-Polytechnic-University-banner.jpg' }
  173. ])
  174. </script>
  175. <style lang="scss" scoped>
  176. .box {
  177. position: relative;
  178. width: 100%;
  179. height: 100vh;
  180. background-image: url('https://www.mendunerhr.com/images/userfiles/92d7e4a755e2428b94aab3636d5047f3/images/recruitment/adImages/2018/11/1920x940.jpg');
  181. background-size: cover;
  182. overflow: hidden;
  183. .navBar {
  184. position: absolute;
  185. top: 0;
  186. }
  187. }
  188. .content {
  189. width: 100%;
  190. height: 100%;
  191. overflow-y: auto;
  192. }
  193. .login-content {
  194. display: flex;
  195. align-items: center;
  196. justify-content: center;
  197. width: 100%;
  198. height: 84vh;
  199. margin-top: 50px;
  200. }
  201. .login-change {
  202. position: absolute;
  203. top: 0;
  204. right: 0;
  205. padding: 15px 44px;
  206. text-decoration: underline;
  207. color: orange;
  208. cursor: pointer;
  209. font-weight: 400;
  210. &:hover {
  211. text-decoration: underline;
  212. color: #fbb93e;
  213. }
  214. }
  215. .login-card {
  216. position: relative;
  217. width: 450px;
  218. background-color: #fff;
  219. border-radius: 8px;
  220. padding: 36px 50px;
  221. // margin-right: 12px;
  222. }
  223. .left {
  224. display: flex;
  225. }
  226. .login-tips {
  227. width: 100%;
  228. font-size: 12px;
  229. text-align: center;
  230. }
  231. .tips {
  232. span:hover {
  233. text-decoration: underline;
  234. }
  235. }
  236. .color {
  237. color: var(--v-primary-base);
  238. }
  239. .aboutBox {
  240. width: 100%;
  241. background-color: #fff;
  242. // overflow-x: auto;
  243. }
  244. .carousel {
  245. :deep(.v-window) {
  246. height: 392px !important;
  247. }
  248. }
  249. </style>