index.vue 11 KB

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