index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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" @click="handleClick(item)">
  8. <div style="height: 392px; overflow: hidden;" :class="{'cursor-pointer': item.link}">
  9. <v-img :src="item.src" :lazy-src="item.src" cover style="height: 100%; overflow: hidden;">
  10. <template v-slot:placeholder>
  11. <v-row align="center" class="fill-height ma-0" justify="center">
  12. <v-progress-circular color="grey-lighten-5" indeterminate></v-progress-circular>
  13. </v-row>
  14. </template>
  15. </v-img>
  16. </div>
  17. </v-carousel-item>
  18. </v-carousel>
  19. </v-card>
  20. <div class="login-card">
  21. <div class="login-change" @click="handleChangeLogin">{{ isEnterpriseLogin ? '切换个人登录' : '切换企业登录' }}</div>
  22. <!-- 企业邮箱登录 -->
  23. <div v-show="isEnterpriseLogin" class="login-tab">
  24. <v-tabs v-model="tab1" align-tabs="center" color="primary" class="mb-10">
  25. <v-tab :value="1">企业邮箱登录</v-tab>
  26. </v-tabs>
  27. <passwordFrom ref="entPassRef" placeholder="请输入企业邮箱" :isCounter="true" :validEmail="true" @handleEnter="handleLogin"></passwordFrom>
  28. </div>
  29. <!-- 个人登录 -->
  30. <div v-show="!isEnterpriseLogin" class="login-tab">
  31. <v-tabs v-model="tab" align-tabs="center" color="primary" class="mb-10" @update:modelValue="tabChange">
  32. <v-tab :value="2">账号</v-tab>
  33. <v-tab :value="1">验证码</v-tab>
  34. <!-- <v-tab :value="3">微信</v-tab> -->
  35. </v-tabs>
  36. <v-window v-model="tab">
  37. <!-- 验证码登录 -->
  38. <v-window-item :value="1">
  39. <phoneFrom ref="phoneRef" openVerify @handleEnter="handleLogin"></phoneFrom>
  40. </v-window-item>
  41. <!-- 账号密码登录 -->
  42. <v-window-item :value="2">
  43. <passwordFrom ref="passRef" @handleEnter="handleLogin"></passwordFrom>
  44. </v-window-item>
  45. <!-- <v-window-item :value="3">
  46. <div v-if="showQrCode" class="d-flex align-center flex-column">
  47. <span class="text-decoration-underline">微信扫描二维码进行登录</span>
  48. <v-img src="https://minio.citupro.com/dev/menduner/login-qrCode.png" width="150" height="150"></v-img>
  49. </div>
  50. <div v-else style="height: 150px; line-height: 150px; text-align: center;">
  51. 加载中 . . .
  52. </div>
  53. </v-window-item> -->
  54. </v-window>
  55. </div>
  56. <div class="font-size-14 tips">
  57. <span class="float-left color-666 cursor-pointer" v-if="tab === 2" @click="router.push(isEnterpriseLogin ? '/forgotPasswordEnt': '/forgotPassword')">忘记密码</span>
  58. <span class="float-right color-error cursor-pointer text-decoration-underline" @click="router.push('/register/selected')">还没有登录账户?去注册</span>
  59. </div>
  60. <v-btn :loading="loginLoading" color="primary" class="white--text mt-5" min-width="350" @click.stop="handleLogin">
  61. {{ $t('login.login') }}
  62. </v-btn>
  63. <div class="login-tips mt-3">
  64. <v-icon v-if="isAgree" size="18" color="primary" class="mr-2" @click="isAgree = !isAgree">mdi-check-circle</v-icon>
  65. <v-icon v-else size="18" color="grey" class="mr-2" @click="isAgree = !isAgree">mdi-circle-outline</v-icon>
  66. {{ $t('login.agreeLogin') }}
  67. <span class="color" style="cursor: pointer;" @click="windowOpen('/userAgreement')"> [{{ $t('login.userAgreement') }}] </span>和
  68. <span class="color" style="cursor: pointer;" @click="windowOpen('/privacyPolicy')">[{{ $t('login.privacyPolicy') }}]</span>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="aboutBox">
  73. <about :showBanner="false"></about>
  74. </div>
  75. </div>
  76. <navBar v-if="!isMobile" :showLoginBtn="false" class="navBar"></navBar>
  77. </div>
  78. <Verify
  79. ref="verify"
  80. captchaType="blockPuzzle"
  81. :imgSize="{ width: '400px', height: '200px' }"
  82. mode="pop"
  83. @success="verifySuccess"
  84. />
  85. </template>
  86. <script setup>
  87. defineOptions({ name: 'login-index' })
  88. import { nextTick, ref, onMounted } from 'vue'
  89. import passwordFrom from './components/passwordPage.vue'
  90. import phoneFrom from '@/components/VerificationCode'
  91. import { useUserStore } from '@/store/user'
  92. import { useRouter } from 'vue-router'
  93. import { useI18n } from '@/hooks/web/useI18n'
  94. import {
  95. getEnterpriseRegisterApply,
  96. // socialAuthRedirect,
  97. } from '@/api/common'
  98. import Snackbar from '@/plugins/snackbar'
  99. import Confirm from '@/plugins/confirm'
  100. import navBar from '@/layout/personal/navBar.vue'
  101. import about from '@/views/about/index.vue'
  102. import { useRoute } from 'vue-router'; const route = useRoute()
  103. import Verify from '@/components/Verifition'
  104. const isMobile = ref(false)
  105. onMounted(() => {
  106. const userAgent = navigator.userAgent
  107. 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)
  108. })
  109. const { t } = useI18n()
  110. const router = useRouter()
  111. const tab = ref(2) // 密码登录
  112. const tab1 = ref(1)
  113. const isAgree = ref(false)
  114. const isEnterpriseLogin = ref(route.query?.entLogin || false)
  115. const handleChangeLogin = () => {
  116. isEnterpriseLogin.value = !isEnterpriseLogin.value
  117. nextTick(() => {
  118. // tab.value = isEnterpriseLogin.value ? 2 : 1 // 为了验证邮箱validate,企业邮箱登录时需要tab
  119. tab.value = 2 // 为了验证邮箱validate,企业邮箱登录时需要tab=2
  120. })
  121. }
  122. // 验证码登录
  123. const phoneRef = ref()
  124. const passRef = ref()
  125. const entPassRef = ref()
  126. const loginLoading = ref(false)
  127. const userStore = useUserStore()
  128. const handleCheckEnterprise = async () => {
  129. const data = await getEnterpriseRegisterApply(entPassRef.value.loginData.phone)
  130. if (data && Object.keys(data).length) {
  131. // 查看申请状态
  132. localStorage.setItem('entRegisterData', JSON.stringify(data))
  133. localStorage.setItem('loginAccount', data.phone)
  134. router.push({ path: '/recruit/entRegister/inReview', query: { type: 'noLoginToRegister', noLogin: true } })
  135. }
  136. }
  137. const handleLogin = async () => {
  138. const { valid } = isEnterpriseLogin.value ? await entPassRef.value.passwordForm.validate() : tab.value === 1 ? await phoneRef.value.phoneForm.validate() : await passRef.value.passwordForm.validate()
  139. if (!valid) return
  140. if (!isAgree.value) return Snackbar.warning('请阅读并勾选底部协议')
  141. loginLoading.value = true
  142. try {
  143. let params, api = {}
  144. // if (tab.value === 1) { params = { ...phoneRef.value.loginData }; api = 'handleSmsLogin'}
  145. // else { params = { ...passRef.value.loginData }; api = 'handlePasswordLogin'}
  146. if (isEnterpriseLogin.value) { params = { ...entPassRef.value.loginData }; api = 'handlePasswordLogin'}
  147. else { params = tab.value === 1 ? { ...phoneRef.value.loginData } : { ...passRef.value.loginData }; api = tab.value === 1 ? 'handleSmsLogin' : 'handlePasswordLogin'}
  148. if (!params.captchaVerification && captchaStr.value) params.captchaVerification = captchaStr.value
  149. if (!params.captchaVerification) {
  150. getCode() // 验证码组件
  151. return
  152. }
  153. // 邮箱为企业招聘, 手机号为个人求职
  154. if (isEnterpriseLogin.value) {
  155. 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,}))$/
  156. const isEnterprise = pattern.test(params.phone)
  157. if (!isEnterprise) return // 选中企业登录但输入内容非邮箱
  158. params.isEnterprise = isEnterprise
  159. }
  160. await userStore[api](params)
  161. // 跳转
  162. if (params.isEnterprise) return // 企业邮箱登录
  163. else localStorage.setItem('simpleCompleteDialogHaveBeenShow', true) // 个人登录简易基本信息填写弹窗open-status
  164. Snackbar.success(t('login.loginSuccess'))
  165. router.push({ path: '/recruitHome' })
  166. } catch (err) {
  167. console.log(err)
  168. captchaStr.value = '' // 清空人机验证
  169. if (tab.value === 1) phoneRef.value.clearCaptcha() // 清空人机验证
  170. if (!err.code || (err?.message && err.message.includes('timeout'))) return
  171. if (err.code === 1100017022) {
  172. // 密码不安全
  173. router.push('/forgotPassword?forgot=1')
  174. return
  175. }
  176. if (err.code === 1100021016) {
  177. // 企业注册申请中
  178. handleCheckEnterprise()
  179. return
  180. }
  181. // 登录未注册过的账号跳转注册
  182. const text = err.code === 1100016002 ? '您的手机号还未注册过' : '您的邮箱还未注册过'
  183. Confirm('系统提示', `${text},去注册?`, {
  184. cancelCallback: true
  185. }).then(() => {
  186. localStorage.setItem('loginAccount', isEnterpriseLogin.value ? entPassRef.value.loginData.phone : tab.value === 1 ? phoneRef.value.loginData.phone : passRef.value.loginData.phone)
  187. router.push(err.code === 1100016002 ? '/register/person?type=noLoginToRegister' : '/register/company?type=noLoginToRegister')
  188. }).catch(() => {})
  189. } finally {
  190. loginLoading.value = false
  191. }
  192. }
  193. // const getSocialAuthRedirect = async () => {
  194. // const params = {
  195. // type: '34',
  196. // redirectUri: 'https://www.baidu.com'
  197. // }
  198. // const res = await socialAuthRedirect(params)
  199. // const otherUrl = res?.url
  200. // if (otherUrl) window.open(otherUrl)
  201. // }
  202. // const showQrCode = ref(false)
  203. const tabChange = (val) => {
  204. if (val === 3) {
  205. // getSocialAuthRedirect()
  206. }
  207. }
  208. // 轮播广告 // 轮播图片
  209. const carouselList = ref([
  210. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/IHG-banner-new.gif' },
  211. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/SWISS-HOTEL-MANAGEMENT-SCHOOL-MBA.jpg'},
  212. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/Hong-Kong-Polytechnic-University-banner.jpg' },
  213. { src: 'https://minio.menduner.com/dev/menduner/Grand-Mercure.jpg' },
  214. { src: 'https://minio.menduner.com/dev/5cca497a87187f541359c6b327a217b963e397dc39042327be5cc1cbc9447818.jpg' },
  215. { src: 'https://minio.menduner.com/dev/fbff08c5608d746380f859a97241109fe4726f776a25301d7d0fb43d9ba7df67.png', link: 'https://mp.weixin.qq.com/s/CBv7xhWopp8uby4yS5ojsA' }
  216. ])
  217. const handleClick = (item) => {
  218. if (item.link) window.open(item.link)
  219. }
  220. // 获取验证码
  221. const verify = ref()
  222. const getCode = async () => {
  223. // 弹出验证码 // 已开启:则展示验证码;只有完成验证码的情况,才进行登录
  224. verify.value.show()
  225. }
  226. const captchaStr = ref('')
  227. const verifySuccess = (params) => {
  228. captchaStr.value = params.captchaVerification
  229. handleLogin()
  230. }
  231. const windowOpen = (url) => {
  232. // router.push(url)
  233. if (url) window.open(url)
  234. }
  235. </script>
  236. <style lang="scss" scoped>
  237. .box {
  238. position: relative;
  239. width: 100%;
  240. height: 100vh;
  241. background-image: url('https://minio.menduner.com/dev/menduner/login-bgc.jpg');
  242. background-size: cover;
  243. overflow: hidden;
  244. .navBar {
  245. position: absolute;
  246. top: 0;
  247. }
  248. }
  249. .content {
  250. width: 100%;
  251. height: 100%;
  252. overflow-y: auto;
  253. }
  254. .login-content {
  255. display: flex;
  256. align-items: center;
  257. justify-content: center;
  258. width: 100%;
  259. height: 78vh;
  260. // height: calc(100vh - 50px);
  261. margin-top: 50px;
  262. }
  263. .login-change {
  264. position: absolute;
  265. top: 0;
  266. right: 0;
  267. padding: 15px 44px;
  268. text-decoration: underline;
  269. color: orange;
  270. cursor: pointer;
  271. font-weight: 400;
  272. &:hover {
  273. text-decoration: underline;
  274. color: #fbb93e;
  275. }
  276. }
  277. .login-card {
  278. position: relative;
  279. width: 450px;
  280. background-color: #fff;
  281. border-radius: 8px;
  282. padding: 36px 50px;
  283. // margin-right: 12px;
  284. }
  285. .left {
  286. display: flex;
  287. }
  288. .login-tips {
  289. width: 100%;
  290. font-size: 12px;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. }
  295. .tips {
  296. span:hover {
  297. text-decoration: underline;
  298. }
  299. }
  300. .color {
  301. color: var(--v-primary-base);
  302. }
  303. .aboutBox {
  304. width: 100%;
  305. background-color: #fff;
  306. }
  307. .carousel {
  308. :deep(.v-window) {
  309. height: 392px !important;
  310. }
  311. }
  312. </style>