index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="box">
  3. <div class="content">
  4. <div class="login-content">
  5. <v-card v-if="props.showCarousel" height="392px" class="mr-3" style="width: 792px; border-radius: 0px;">
  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. <navBar :showLoginBtn="false" class="navBar"></navBar>
  68. </div>
  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 props = defineProps({
  88. showCarousel: {
  89. type: Boolean,
  90. default: true
  91. }
  92. })
  93. const { t } = useI18n()
  94. const router = useRouter()
  95. const tab = ref(1)
  96. const tab1 = ref(1)
  97. const isEnterpriseLogin = ref(false)
  98. const handleChangeLogin = () => {
  99. isEnterpriseLogin.value = !isEnterpriseLogin.value
  100. nextTick(() => {
  101. tab.value = isEnterpriseLogin.value ? 2 : 1 // 为了验证邮箱validate
  102. })
  103. }
  104. // 验证码登录
  105. const phoneRef = ref()
  106. const passRef = ref()
  107. const loginLoading = ref(false)
  108. const userStore = useUserStore()
  109. const handleCheckEnterprise = async () => {
  110. const data = await getEnterpriseRegisterApply(passRef.value.loginData.phone)
  111. if (data && Object.keys(data).length) {
  112. // 查看申请状态
  113. localStorage.setItem('entRegisterData', JSON.stringify(data))
  114. localStorage.setItem('loginAccount', data.phone)
  115. router.push({ path: '/recruit/entRegister/inReview', query: { type: 'noLoginToRegister', noLogin: true } })
  116. }
  117. }
  118. const handleLogin = async () => {
  119. const { valid } = tab.value === 1 ? await phoneRef.value.phoneForm.validate() : await passRef.value.passwordForm.validate()
  120. if (!valid) return
  121. loginLoading.value = true
  122. try {
  123. let params, api = {}
  124. if (tab.value === 1) { params = { ...phoneRef.value.loginData }; api = 'handleSmsLogin'}
  125. else { params = { ...passRef.value.loginData }; api = 'handlePasswordLogin'}
  126. // 邮箱为企业招聘, 手机号为个人求职
  127. if (isEnterpriseLogin.value) {
  128. 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,}))$/
  129. const isEnterprise = pattern.test(params.phone)
  130. if (!isEnterprise) return // 选中企业登录但输入内容非邮箱
  131. params.isEnterprise = isEnterprise
  132. }
  133. await userStore[api](params)
  134. // 跳转
  135. if (params.isEnterprise) return // 企业邮箱登录
  136. else localStorage.setItem('simpleCompleteDialogHaveBeenShow', true) // 个人登录简易基本信息填写弹窗open-status
  137. Snackbar.success(t('login.loginSuccess'))
  138. router.push({ path: '/recruitHome' })
  139. } catch (err) {
  140. if (!err.code) return
  141. // 企业注册申请中
  142. if (err.code === 1100021016) {
  143. handleCheckEnterprise()
  144. return
  145. }
  146. // 登录未注册过的账号跳转注册
  147. const text = err.code === 1100016002 ? '您的手机号还未注册过' : '您的邮箱还未注册过'
  148. Confirm('系统提示', `${text},去注册?`, {
  149. cancelCallback: true
  150. }).then(() => {
  151. localStorage.setItem('loginAccount', tab.value === 1 ? phoneRef.value.loginData.phone : passRef.value.loginData.phone)
  152. router.push(err.code === 1100016002 ? '/register/person?type=noLoginToRegister' : '/register/company?type=noLoginToRegister')
  153. })
  154. } finally {
  155. loginLoading.value = false
  156. }
  157. }
  158. // const getSocialAuthRedirect = async () => {
  159. // const params = {
  160. // type: '34',
  161. // redirectUri: 'https://www.baidu.com'
  162. // }
  163. // const res = await socialAuthRedirect(params)
  164. // const otherUrl = res?.url
  165. // if (otherUrl) window.open(otherUrl)
  166. // }
  167. // const showQrCode = ref(false)
  168. const tabChange = (val) => {
  169. if (val === 3) {
  170. // getSocialAuthRedirect()
  171. }
  172. }
  173. // 轮播广告 // 轮播图片
  174. const carouselList = ref([
  175. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/IHG-banner-new.gif' },
  176. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/Hilton.jpg'},
  177. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/SWISS-HOTEL-MANAGEMENT-SCHOOL-MBA.jpg'},
  178. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/Hong-Kong-Polytechnic-University-banner.jpg' }
  179. ])
  180. </script>
  181. <style lang="scss" scoped>
  182. .box {
  183. position: relative;
  184. width: 100%;
  185. height: 100vh;
  186. background-image: url('https://www.mendunerhr.com/images/userfiles/92d7e4a755e2428b94aab3636d5047f3/images/recruitment/adImages/2018/11/1920x940.jpg');
  187. background-size: cover;
  188. overflow: hidden;
  189. .navBar {
  190. position: absolute;
  191. top: 0;
  192. }
  193. }
  194. .content {
  195. width: 100%;
  196. height: 100%;
  197. overflow-y: auto;
  198. }
  199. .login-content {
  200. display: flex;
  201. align-items: center;
  202. justify-content: center;
  203. width: 100%;
  204. height: 86vh;
  205. }
  206. .login-change {
  207. position: absolute;
  208. top: 0;
  209. right: 0;
  210. padding: 15px 44px;
  211. text-decoration: underline;
  212. color: orange;
  213. cursor: pointer;
  214. font-weight: 400;
  215. &:hover {
  216. text-decoration: underline;
  217. color: #fbb93e;
  218. }
  219. }
  220. .login-card {
  221. position: relative;
  222. width: 450px;
  223. background-color: #fff;
  224. border-radius: 0px;
  225. padding: 36px 50px;
  226. }
  227. .left {
  228. display: flex;
  229. }
  230. .login-tips {
  231. width: 100%;
  232. font-size: 12px;
  233. text-align: center;
  234. }
  235. .tips {
  236. span:hover {
  237. text-decoration: underline;
  238. }
  239. }
  240. .color {
  241. color: var(--v-primary-base);
  242. }
  243. .aboutBox {
  244. width: 100%;
  245. // overflow-x: auto;
  246. }
  247. </style>