index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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="entPassRef" 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" @click="router.push(isEnterpriseLogin ? '/forgotPasswordEnt': '/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 v-if="!isMobile" :showLoginBtn="false" class="navBar"></navBar>
  69. </div>
  70. <Verify
  71. ref="verify"
  72. captchaType="blockPuzzle"
  73. :imgSize="{ width: '400px', height: '200px' }"
  74. mode="pop"
  75. @success="verifySuccess"
  76. />
  77. </template>
  78. <script setup>
  79. defineOptions({ name: 'login-index' })
  80. import { nextTick, ref, onMounted } from 'vue'
  81. import passwordFrom from './components/passwordPage.vue'
  82. import phoneFrom from '@/components/VerificationCode'
  83. import { useUserStore } from '@/store/user'
  84. import { useRouter } from 'vue-router'
  85. import { useI18n } from '@/hooks/web/useI18n'
  86. import {
  87. getEnterpriseRegisterApply,
  88. // socialAuthRedirect,
  89. } from '@/api/common'
  90. import Snackbar from '@/plugins/snackbar'
  91. import Confirm from '@/plugins/confirm'
  92. import navBar from '@/layout/personal/navBar.vue'
  93. import about from '@/views/about/index.vue'
  94. import { useRoute } from 'vue-router'; const route = useRoute()
  95. import Verify from '@/components/Verifition'
  96. const isMobile = ref(false)
  97. onMounted(() => {
  98. const userAgent = navigator.userAgent
  99. isMobile.value = /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(userAgent)
  100. })
  101. const { t } = useI18n()
  102. const router = useRouter()
  103. const tab = ref(1)
  104. const tab1 = ref(1)
  105. const isEnterpriseLogin = ref(route.query?.entLogin || false)
  106. const handleChangeLogin = () => {
  107. isEnterpriseLogin.value = !isEnterpriseLogin.value
  108. nextTick(() => {
  109. tab.value = isEnterpriseLogin.value ? 2 : 1 // 为了验证邮箱validate
  110. })
  111. }
  112. // 验证码登录
  113. const phoneRef = ref()
  114. const passRef = ref()
  115. const entPassRef = ref()
  116. const loginLoading = ref(false)
  117. const userStore = useUserStore()
  118. const handleCheckEnterprise = async () => {
  119. const data = await getEnterpriseRegisterApply(passRef.value.loginData.phone)
  120. if (data && Object.keys(data).length) {
  121. // 查看申请状态
  122. localStorage.setItem('entRegisterData', JSON.stringify(data))
  123. localStorage.setItem('loginAccount', data.phone)
  124. router.push({ path: '/recruit/entRegister/inReview', query: { type: 'noLoginToRegister', noLogin: true } })
  125. }
  126. }
  127. const handleLogin = async () => {
  128. const { valid } = isEnterpriseLogin.value ? await entPassRef.value.passwordForm.validate() : tab.value === 1 ? await phoneRef.value.phoneForm.validate() : await passRef.value.passwordForm.validate()
  129. if (!valid) return
  130. if (!captchaVerification) {
  131. getCode() // 验证码组件
  132. return
  133. }
  134. loginLoading.value = true
  135. try {
  136. let params, api = {}
  137. // if (tab.value === 1) { params = { ...phoneRef.value.loginData }; api = 'handleSmsLogin'}
  138. // else { params = { ...passRef.value.loginData, captchaVerification }; api = 'handlePasswordLogin'}
  139. if (isEnterpriseLogin.value) { params = { ...entPassRef.value.loginData, captchaVerification }; api = 'handlePasswordLogin'}
  140. else { params = tab.value === 1 ? { ...phoneRef.value.loginData, captchaVerification } : { ...passRef.value.loginData, captchaVerification }; api = tab.value === 1 ? 'handleSmsLogin' : 'handlePasswordLogin'}
  141. // 邮箱为企业招聘, 手机号为个人求职
  142. if (isEnterpriseLogin.value) {
  143. 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,}))$/
  144. const isEnterprise = pattern.test(params.phone)
  145. if (!isEnterprise) return // 选中企业登录但输入内容非邮箱
  146. params.isEnterprise = isEnterprise
  147. }
  148. await userStore[api](params)
  149. // 跳转
  150. if (params.isEnterprise) return // 企业邮箱登录
  151. else localStorage.setItem('simpleCompleteDialogHaveBeenShow', true) // 个人登录简易基本信息填写弹窗open-status
  152. Snackbar.success(t('login.loginSuccess'))
  153. router.push({ path: '/recruitHome' })
  154. } catch (err) {
  155. console.log(err)
  156. if (!err.code) return
  157. // 企业注册申请中
  158. if (err.code === 1100017022) {
  159. // 密码不安全
  160. router.push('/forgotPassword?forgot=1')
  161. return
  162. }
  163. if (err.code === 1100021016) {
  164. handleCheckEnterprise()
  165. return
  166. }
  167. // 登录未注册过的账号跳转注册
  168. const text = err.code === 1100016002 ? '您的手机号还未注册过' : '您的邮箱还未注册过'
  169. Confirm('系统提示', `${text},去注册?`, {
  170. cancelCallback: true
  171. }).then(() => {
  172. localStorage.setItem('loginAccount', isEnterpriseLogin.value ? entPassRef.value.loginData.phone : tab.value === 1 ? phoneRef.value.loginData.phone : passRef.value.loginData.phone)
  173. router.push(err.code === 1100016002 ? '/register/person?type=noLoginToRegister' : '/register/company?type=noLoginToRegister')
  174. })
  175. } finally {
  176. loginLoading.value = false
  177. }
  178. }
  179. // const getSocialAuthRedirect = async () => {
  180. // const params = {
  181. // type: '34',
  182. // redirectUri: 'https://www.baidu.com'
  183. // }
  184. // const res = await socialAuthRedirect(params)
  185. // const otherUrl = res?.url
  186. // if (otherUrl) window.open(otherUrl)
  187. // }
  188. // const showQrCode = ref(false)
  189. const tabChange = (val) => {
  190. if (val === 3) {
  191. // getSocialAuthRedirect()
  192. }
  193. }
  194. // 轮播广告 // 轮播图片
  195. const carouselList = ref([
  196. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/IHG-banner-new.gif' },
  197. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/SWISS-HOTEL-MANAGEMENT-SCHOOL-MBA.jpg'},
  198. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/Hong-Kong-Polytechnic-University-banner.jpg' }
  199. ])
  200. // 验证码
  201. const verify = ref()
  202. // 获取验证码
  203. const getCode = async () => {
  204. // 弹出验证码 // 已开启:则展示验证码;只有完成验证码的情况,才进行登录
  205. verify.value.show()
  206. }
  207. let captchaVerification = ''
  208. const verifySuccess = (params) => {
  209. captchaVerification = params.captchaVerification
  210. handleLogin()
  211. }
  212. </script>
  213. <style lang="scss" scoped>
  214. .box {
  215. position: relative;
  216. width: 100%;
  217. height: 100vh;
  218. background-image: url('https://minio.menduner.com/dev/menduner/login-banner.png');
  219. background-size: cover;
  220. overflow: hidden;
  221. .navBar {
  222. position: absolute;
  223. top: 0;
  224. }
  225. }
  226. .content {
  227. width: 100%;
  228. height: 100%;
  229. overflow-y: auto;
  230. }
  231. .login-content {
  232. display: flex;
  233. align-items: center;
  234. justify-content: center;
  235. width: 100%;
  236. // height: 84vh;
  237. height: calc(100vh - 50px);
  238. margin-top: 50px;
  239. }
  240. .login-change {
  241. position: absolute;
  242. top: 0;
  243. right: 0;
  244. padding: 15px 44px;
  245. text-decoration: underline;
  246. color: orange;
  247. cursor: pointer;
  248. font-weight: 400;
  249. &:hover {
  250. text-decoration: underline;
  251. color: #fbb93e;
  252. }
  253. }
  254. .login-card {
  255. position: relative;
  256. width: 450px;
  257. background-color: #fff;
  258. border-radius: 8px;
  259. padding: 36px 50px;
  260. // margin-right: 12px;
  261. }
  262. .left {
  263. display: flex;
  264. }
  265. .login-tips {
  266. width: 100%;
  267. font-size: 12px;
  268. text-align: center;
  269. }
  270. .tips {
  271. span:hover {
  272. text-decoration: underline;
  273. }
  274. }
  275. .color {
  276. color: var(--v-primary-base);
  277. }
  278. .aboutBox {
  279. width: 100%;
  280. background-color: #fff;
  281. // overflow-x: auto;
  282. }
  283. .carousel {
  284. :deep(.v-window) {
  285. height: 392px !important;
  286. }
  287. }
  288. </style>