index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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(entPassRef.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. captchaStr.value = '' // 清空人机验证
  163. phoneRef.value.clearCaptcha() // 清空人机验证
  164. if (!err.code) return
  165. if (err.code === 1100017022) {
  166. // 密码不安全
  167. router.push('/forgotPassword?forgot=1')
  168. return
  169. }
  170. if (err.code === 1100021016) {
  171. // 企业注册申请中
  172. handleCheckEnterprise()
  173. return
  174. }
  175. // 登录未注册过的账号跳转注册
  176. const text = err.code === 1100016002 ? '您的手机号还未注册过' : '您的邮箱还未注册过'
  177. Confirm('系统提示', `${text},去注册?`, {
  178. cancelCallback: true
  179. }).then(() => {
  180. localStorage.setItem('loginAccount', isEnterpriseLogin.value ? entPassRef.value.loginData.phone : tab.value === 1 ? phoneRef.value.loginData.phone : passRef.value.loginData.phone)
  181. router.push(err.code === 1100016002 ? '/register/person?type=noLoginToRegister' : '/register/company?type=noLoginToRegister')
  182. })
  183. } finally {
  184. loginLoading.value = false
  185. }
  186. }
  187. // const getSocialAuthRedirect = async () => {
  188. // const params = {
  189. // type: '34',
  190. // redirectUri: 'https://www.baidu.com'
  191. // }
  192. // const res = await socialAuthRedirect(params)
  193. // const otherUrl = res?.url
  194. // if (otherUrl) window.open(otherUrl)
  195. // }
  196. // const showQrCode = ref(false)
  197. const tabChange = (val) => {
  198. if (val === 3) {
  199. // getSocialAuthRedirect()
  200. }
  201. }
  202. // 轮播广告 // 轮播图片
  203. const carouselList = ref([
  204. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/IHG-banner-new.gif' },
  205. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/SWISS-HOTEL-MANAGEMENT-SCHOOL-MBA.jpg'},
  206. { src: 'https://minio.citupro.com/dev/menduner/preferredGroup/Hong-Kong-Polytechnic-University-banner.jpg' },
  207. { src: 'https://minio.menduner.com/dev/menduner/Grand-Mercure.jpg' },
  208. { src: 'https://minio.menduner.com/dev/menduner/quZhouHuangGuan.jpg' }
  209. ])
  210. // 获取验证码
  211. const verify = ref()
  212. const getCode = async () => {
  213. // 弹出验证码 // 已开启:则展示验证码;只有完成验证码的情况,才进行登录
  214. verify.value.show()
  215. }
  216. const captchaStr = ref('')
  217. const verifySuccess = (params) => {
  218. captchaStr.value = params.captchaVerification
  219. handleLogin()
  220. }
  221. const windowOpen = (url) => {
  222. // router.push(url)
  223. if (url) window.open(url)
  224. }
  225. </script>
  226. <style lang="scss" scoped>
  227. .box {
  228. position: relative;
  229. width: 100%;
  230. height: 100vh;
  231. background-image: url('https://minio.menduner.com/dev/menduner/login-bgc.jpg');
  232. background-size: cover;
  233. overflow: hidden;
  234. .navBar {
  235. position: absolute;
  236. top: 0;
  237. }
  238. }
  239. .content {
  240. width: 100%;
  241. height: 100%;
  242. overflow-y: auto;
  243. }
  244. .login-content {
  245. display: flex;
  246. align-items: center;
  247. justify-content: center;
  248. width: 100%;
  249. height: 78vh;
  250. // height: calc(100vh - 50px);
  251. margin-top: 50px;
  252. }
  253. .login-change {
  254. position: absolute;
  255. top: 0;
  256. right: 0;
  257. padding: 15px 44px;
  258. text-decoration: underline;
  259. color: orange;
  260. cursor: pointer;
  261. font-weight: 400;
  262. &:hover {
  263. text-decoration: underline;
  264. color: #fbb93e;
  265. }
  266. }
  267. .login-card {
  268. position: relative;
  269. width: 450px;
  270. background-color: #fff;
  271. border-radius: 8px;
  272. padding: 36px 50px;
  273. // margin-right: 12px;
  274. }
  275. .left {
  276. display: flex;
  277. }
  278. .login-tips {
  279. width: 100%;
  280. font-size: 12px;
  281. display: flex;
  282. justify-content: center;
  283. align-items: center;
  284. }
  285. .tips {
  286. span:hover {
  287. text-decoration: underline;
  288. }
  289. }
  290. .color {
  291. color: var(--v-primary-base);
  292. }
  293. .aboutBox {
  294. width: 100%;
  295. background-color: #fff;
  296. }
  297. .carousel {
  298. :deep(.v-window) {
  299. height: 392px !important;
  300. }
  301. }
  302. </style>