| | |
| | | <template>
|
| | | <div class="login">
|
| | | <el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
|
| | | <h3 class="title">{{ title }}</h3>
|
| | | <el-divider />
|
| | | <el-form-item prop="username">
|
| | | <el-input
|
| | | v-model="loginForm.username"
|
| | | type="text"
|
| | | size="large"
|
| | | auto-complete="off"
|
| | | placeholder="账号"
|
| | | >
|
| | | <template #prefix><el-icon><User /></el-icon></template>
|
| | | </el-input>
|
| | | </el-form-item>
|
| | | <el-form-item prop="password">
|
| | | <el-input
|
| | | v-model="loginForm.password"
|
| | | type="password"
|
| | | size="large"
|
| | | auto-complete="off"
|
| | | placeholder="密码"
|
| | | show-password
|
| | | @keyup.enter="handleLogin"
|
| | | >
|
| | | <template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template>
|
| | | </el-input>
|
| | | </el-form-item>
|
| | | <!-- <el-form-item prop="code" v-if="captchaEnabled">-->
|
| | | <!-- <el-input-->
|
| | | <!-- v-model="loginForm.code"-->
|
| | | <!-- size="large"-->
|
| | | <!-- auto-complete="off"-->
|
| | | <!-- placeholder="验证码"-->
|
| | | <!-- style="width: 63%"-->
|
| | | <!-- @keyup.enter="handleLogin"-->
|
| | | <!-- >-->
|
| | | <!-- <template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template>-->
|
| | | <!-- </el-input>-->
|
| | | <!-- <div class="login-code">-->
|
| | | <!-- <img :src="codeUrl" @click="getCode" class="login-code-img"/>-->
|
| | | <!-- </div>-->
|
| | | <!-- </el-form-item>-->
|
| | | <el-form-item style="width:100%;">
|
| | | <el-button
|
| | | :loading="loading"
|
| | | size="large"
|
| | | type="primary"
|
| | | style="width:100%;"
|
| | | @click.prevent="handleLogin"
|
| | | >
|
| | | <span v-if="!loading">登 录</span>
|
| | | <span v-else>登 录 中...</span>
|
| | | </el-button>
|
| | | <div style="float: right;" v-if="register">
|
| | | <router-link class="link-type" :to="'/register'">立即注册</router-link>
|
| | | </div>
|
| | | </el-form-item>
|
| | | <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
|
| | | </el-form>
|
| | | <!-- 底部 -->
|
| | | <!-- <div class="el-login-footer">-->
|
| | | <!-- <span>Copyright © 2018-2025 ruoyi.vip All Rights Reserved.</span>-->
|
| | | <!-- </div>-->
|
| | | </div>
|
| | | </template>
|
| | |
|
| | | <script setup>
|
| | | import {getCodeImg} from "@/api/login"
|
| | | import Cookies from "js-cookie"
|
| | | import { encrypt, decrypt } from "@/utils/jsencrypt"
|
| | | import useUserStore from '@/store/modules/user'
|
| | |
|
| | | const title = import.meta.env.VITE_APP_TITLE
|
| | | const userStore = useUserStore()
|
| | | const route = useRoute()
|
| | | const router = useRouter()
|
| | | const { proxy } = getCurrentInstance()
|
| | |
|
| | | const loginForm = ref({
|
| | | username: "",
|
| | | password: "",
|
| | | rememberMe: false,
|
| | | })
|
| | |
|
| | | const loginRules = {
|
| | | username: [{ required: true, trigger: "blur", message: "请输入您的账号" }],
|
| | | password: [{ required: true, trigger: "blur", message: "请输入您的密码" }],
|
| | | // code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
| | | }
|
| | |
|
| | | const codeUrl = ref("")
|
| | | const loading = ref(false)
|
| | | // 验证码开关
|
| | | const captchaEnabled = ref(true)
|
| | | // 注册开关
|
| | | const register = ref(false)
|
| | | const redirect = ref(undefined)
|
| | |
|
| | | watch(route, (newRoute) => {
|
| | | redirect.value = newRoute.query && newRoute.query.redirect
|
| | | }, { immediate: true })
|
| | |
|
| | | function handleLogin() {
|
| | | proxy.$refs.loginRef.validate(valid => {
|
| | | if (valid) {
|
| | | loading.value = true
|
| | | // 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
|
| | | Cookies.set("username", loginForm.value.username, { expires: 30 })
|
| | | Cookies.set("password", encrypt(loginForm.value.password), { expires: 30 })
|
| | | Cookies.set("rememberMe", loginForm.value.rememberMe, { expires: 30 })
|
| | | userStore.loginCheckFactory(loginForm.value).then(res => {
|
| | | const query = route.query
|
| | | const otherQueryParams = Object.keys(query).reduce((acc, cur) => {
|
| | | if (cur !== "redirect") {
|
| | | acc[cur] = query[cur]
|
| | | }
|
| | | return acc
|
| | | }, {})
|
| | | router.push({ path: redirect.value || "/", query: otherQueryParams })
|
| | | }).catch(() => {
|
| | | loading.value = false
|
| | | // 重新获取验证码
|
| | | if (captchaEnabled.value) {
|
| | | getCode()
|
| | | }
|
| | | })
|
| | | }
|
| | | })
|
| | | }
|
| | |
|
| | | function getCode() {
|
| | | getCodeImg().then(res => {
|
| | | captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
| | | if (captchaEnabled.value) {
|
| | | codeUrl.value = "data:image/gif;base64," + res.img
|
| | | loginForm.value.uuid = res.uuid
|
| | | }
|
| | | })
|
| | | }
|
| | |
|
| | | function getCookie() {
|
| | | const username = Cookies.get("username")
|
| | | const password = Cookies.get("password")
|
| | | const rememberMe = Cookies.get("rememberMe")
|
| | | loginForm.value = {
|
| | | username: username === undefined ? loginForm.value.username : username,
|
| | | password: password === undefined ? loginForm.value.password : decrypt(password),
|
| | | rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
| | | }
|
| | | }
|
| | |
|
| | | getCode()
|
| | | getCookie()
|
| | | </script>
|
| | |
|
| | | <style lang='scss' scoped>
|
| | | .login {
|
| | | height: 100%;
|
| | | background-image: url("../assets/images/login-background.png");
|
| | | background-size: cover;
|
| | | position: relative;
|
| | | }
|
| | | .title {
|
| | | margin: 20px auto 14px auto;
|
| | | text-align: center;
|
| | | color: #2C51D9;
|
| | | font-size: 28px;
|
| | | font-weight: 700;
|
| | | }
|
| | |
|
| | | .login-form {
|
| | | position: absolute;
|
| | | top: 50%;
|
| | | right: 15%;
|
| | | transform: translate(0, -50%);
|
| | | border-radius: 6px;
|
| | | background: #ffffff;
|
| | | width: 420px;
|
| | | height: 500px;
|
| | | padding: 40px;
|
| | | z-index: 1;
|
| | | box-shadow: 0 0 5px 1px #ccc;
|
| | | .el-input {
|
| | | height: 40px;
|
| | | input {
|
| | | height: 40px;
|
| | | }
|
| | | }
|
| | | .input-icon {
|
| | | height: 39px;
|
| | | width: 14px;
|
| | | margin-left: 0px;
|
| | | }
|
| | | }
|
| | | .login-tip {
|
| | | font-size: 13px;
|
| | | text-align: center;
|
| | | color: #bfbfbf;
|
| | | }
|
| | | .login-code {
|
| | | width: 33%;
|
| | | height: 40px;
|
| | | float: right;
|
| | | img {
|
| | | cursor: pointer;
|
| | | vertical-align: middle;
|
| | | }
|
| | | }
|
| | | .el-login-footer {
|
| | | height: 40px;
|
| | | line-height: 40px;
|
| | | position: fixed;
|
| | | bottom: 0;
|
| | | width: 100%;
|
| | | text-align: center;
|
| | | color: #fff;
|
| | | font-family: Arial;
|
| | | font-size: 12px;
|
| | | letter-spacing: 1px;
|
| | | }
|
| | | .login-code-img {
|
| | | height: 40px;
|
| | | padding-left: 12px;
|
| | | }
|
| | | :deep() {
|
| | | .el-form-item--default {
|
| | | margin-bottom: 36px;
|
| | | }
|
| | | }
|
| | | </style>
|
| | | <template> |
| | | <div class="login"> |
| | | <LoginBrand /> |
| | | |
| | | <main class="login-panel"> |
| | | <div class="login-card"> |
| | | <div class="login-card__header"> |
| | | <img :src="logo" alt="健齿齿科器材" class="login-card__logo" /> |
| | | <h2 class="login-card__title">欢迎登录</h2> |
| | | <p class="login-card__subtitle">开启您的数字化工作台</p> |
| | | </div> |
| | | |
| | | <el-form ref="loginRef" :model="loginForm" :rules="loginRules"> |
| | | <el-form-item prop="username"> |
| | | <el-input |
| | | v-model="loginForm.username" |
| | | type="text" |
| | | size="large" |
| | | maxlength="30" |
| | | auto-complete="off" |
| | | placeholder="请输入用户名" |
| | | @keyup.enter="handleLogin" |
| | | > |
| | | <template #prefix><el-icon><User /></el-icon></template> |
| | | </el-input> |
| | | </el-form-item> |
| | | |
| | | <el-form-item prop="password"> |
| | | <el-input |
| | | v-model="loginForm.password" |
| | | type="password" |
| | | size="large" |
| | | maxlength="20" |
| | | auto-complete="off" |
| | | placeholder="请输入密码" |
| | | show-password |
| | | @keyup.enter="handleLogin" |
| | | > |
| | | <template #prefix><el-icon><Lock /></el-icon></template> |
| | | </el-input> |
| | | </el-form-item> |
| | | |
| | | <div class="login-card__options"> |
| | | <el-checkbox v-model="loginForm.rememberMe">记住账号</el-checkbox> |
| | | <span class="login-card__link" @click="handleForgot">忘记密码?</span> |
| | | </div> |
| | | |
| | | <el-button |
| | | :loading="loading" |
| | | size="large" |
| | | type="primary" |
| | | class="login-btn" |
| | | @click.prevent="handleLogin" |
| | | > |
| | | <span v-if="!loading">登 录</span> |
| | | <span v-else>登 录 中...</span> |
| | | </el-button> |
| | | </el-form> |
| | | |
| | | <div class="login-card__others"> |
| | | <div class="login-card__divider"> |
| | | <span>其他登录方式</span> |
| | | </div> |
| | | <div class="login-card__wecom" @click="handleWecom"> |
| | | <svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"> |
| | | <path fill="#2C51D9" d="M12 3C7.6 3 4 5.9 4 9.5c0 2 1.1 3.8 2.9 5l-.7 2.1 2.4-1.2c1 .3 2.1.5 3.4.5 4.4 0 8-2.9 8-6.4S16.4 3 12 3z"/> |
| | | <circle cx="9" cy="9.5" r="1" fill="#fff"/> |
| | | <circle cx="15" cy="9.5" r="1" fill="#fff"/> |
| | | </svg> |
| | | <span>企业微信登录</span> |
| | | </div> |
| | | </div> |
| | | |
| | | <p class="login-card__foot">健齿科技 · 服务全球</p> |
| | | </div> |
| | | </main> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import Cookies from "js-cookie" |
| | | import { encrypt, decrypt } from "@/utils/jsencrypt" |
| | | import useUserStore from '@/store/modules/user' |
| | | import LoginBrand from './login/components/LoginBrand.vue' |
| | | import logo from '@/assets/login/JCCKLogo.png' |
| | | |
| | | const userStore = useUserStore() |
| | | const route = useRoute() |
| | | const router = useRouter() |
| | | const { proxy } = getCurrentInstance() |
| | | |
| | | const loginForm = ref({ |
| | | username: "", |
| | | password: "", |
| | | rememberMe: false, |
| | | }) |
| | | |
| | | const loginRules = { |
| | | username: [{ required: true, trigger: "blur", message: "请输入您的账号" }], |
| | | password: [{ required: true, trigger: "blur", message: "请输入您的密码" }], |
| | | } |
| | | |
| | | const loading = ref(false) |
| | | const redirect = ref(undefined) |
| | | |
| | | watch(route, (newRoute) => { |
| | | redirect.value = newRoute.query && newRoute.query.redirect |
| | | }, { immediate: true }) |
| | | |
| | | function handleLogin() { |
| | | proxy.$refs.loginRef.validate(valid => { |
| | | if (valid) { |
| | | loading.value = true |
| | | // 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码 |
| | | Cookies.set("username", loginForm.value.username, { expires: 30 }) |
| | | Cookies.set("password", encrypt(loginForm.value.password), { expires: 30 }) |
| | | Cookies.set("rememberMe", loginForm.value.rememberMe, { expires: 30 }) |
| | | userStore.loginCheckFactory(loginForm.value).then(res => { |
| | | const query = route.query |
| | | const otherQueryParams = Object.keys(query).reduce((acc, cur) => { |
| | | if (cur !== "redirect") { |
| | | acc[cur] = query[cur] |
| | | } |
| | | return acc |
| | | }, {}) |
| | | router.push({ path: redirect.value || "/", query: otherQueryParams }) |
| | | }).catch(() => { |
| | | loading.value = false |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | function handleForgot() { |
| | | proxy.$modal.msg("请联系系统管理员重置密码") |
| | | } |
| | | |
| | | function handleWecom() { |
| | | proxy.$modal.msg("企业微信登录暂未开放") |
| | | } |
| | | |
| | | function getCookie() { |
| | | const username = Cookies.get("username") |
| | | const password = Cookies.get("password") |
| | | const rememberMe = Cookies.get("rememberMe") |
| | | loginForm.value = { |
| | | ...loginForm.value, |
| | | username: username === undefined ? loginForm.value.username : username, |
| | | password: password === undefined ? loginForm.value.password : decrypt(password), |
| | | rememberMe: rememberMe === undefined ? false : Boolean(rememberMe) |
| | | } |
| | | } |
| | | |
| | | getCookie() |
| | | </script> |
| | | |
| | | <style lang='scss' scoped> |
| | | .login { |
| | | display: flex; |
| | | height: 100%; |
| | | min-height: 100vh; |
| | | background: var(--app-bg, #f4f6f9); |
| | | } |
| | | |
| | | .login-panel { |
| | | flex: 1; |
| | | min-width: 0; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | padding: 24px; |
| | | background: linear-gradient(180deg, #f6f8fd 0%, #eef2f9 100%); |
| | | } |
| | | |
| | | .login-card { |
| | | width: 100%; |
| | | max-width: 400px; |
| | | padding: 40px 44px 28px; |
| | | box-sizing: border-box; |
| | | background: #fff; |
| | | border-radius: var(--app-radius-lg, 14px); |
| | | box-shadow: 0 12px 40px rgba(16, 42, 96, 0.08); |
| | | |
| | | .el-form-item { |
| | | margin-bottom: 22px; |
| | | } |
| | | } |
| | | |
| | | .login-card__header { |
| | | text-align: center; |
| | | margin-bottom: 30px; |
| | | } |
| | | |
| | | .login-card__logo { |
| | | height: 40px; |
| | | object-fit: contain; |
| | | } |
| | | |
| | | .login-card__title { |
| | | margin: 18px 0 0; |
| | | font-size: 22px; |
| | | font-weight: 700; |
| | | color: var(--app-text, #1d2129); |
| | | letter-spacing: 2px; |
| | | } |
| | | |
| | | .login-card__subtitle { |
| | | margin: 8px 0 0; |
| | | font-size: 13px; |
| | | color: var(--app-text-tertiary, #86909c); |
| | | } |
| | | |
| | | .login-card__options { |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | margin: -4px 0 20px; |
| | | font-size: 14px; |
| | | } |
| | | |
| | | .login-card__link { |
| | | color: var(--app-primary, #2c51d9); |
| | | font-size: 14px; |
| | | cursor: pointer; |
| | | transition: color var(--app-transition, 0.2s); |
| | | |
| | | &:hover { |
| | | color: var(--app-primary-hover, #4a6cf0); |
| | | } |
| | | } |
| | | |
| | | .login-btn { |
| | | width: 100%; |
| | | height: 46px; |
| | | border: none; |
| | | border-radius: 10px; |
| | | font-size: 16px; |
| | | font-weight: 600; |
| | | letter-spacing: 6px; |
| | | background: linear-gradient(90deg, #2c51d9 0%, #4a6cf0 100%); |
| | | box-shadow: 0 8px 20px rgba(44, 81, 217, 0.28); |
| | | transition: filter var(--app-transition, 0.2s), transform var(--app-transition, 0.2s); |
| | | |
| | | &:hover, |
| | | &:focus { |
| | | filter: brightness(1.08); |
| | | } |
| | | |
| | | &:active { |
| | | transform: translateY(1px); |
| | | } |
| | | } |
| | | |
| | | .login-card__others { |
| | | margin-top: 26px; |
| | | } |
| | | |
| | | .login-card__divider { |
| | | position: relative; |
| | | text-align: center; |
| | | font-size: 12px; |
| | | color: var(--app-text-tertiary, #86909c); |
| | | |
| | | &::before { |
| | | content: ''; |
| | | position: absolute; |
| | | left: 0; |
| | | right: 0; |
| | | top: 50%; |
| | | height: 1px; |
| | | background: var(--app-border, #e8ecf1); |
| | | } |
| | | |
| | | span { |
| | | position: relative; |
| | | padding: 0 12px; |
| | | background: #fff; |
| | | } |
| | | } |
| | | |
| | | .login-card__wecom { |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | gap: 8px; |
| | | margin-top: 18px; |
| | | font-size: 14px; |
| | | color: var(--app-text-secondary, #4e5969); |
| | | cursor: pointer; |
| | | transition: color var(--app-transition, 0.2s); |
| | | |
| | | &:hover { |
| | | color: var(--app-primary, #2c51d9); |
| | | } |
| | | } |
| | | |
| | | .login-card__foot { |
| | | margin: 26px 0 0; |
| | | text-align: center; |
| | | font-size: 12px; |
| | | letter-spacing: 4px; |
| | | color: #b6c0cf; |
| | | } |
| | | |
| | | // 输入框统一样式 |
| | | :deep(.el-input__wrapper) { |
| | | border-radius: 10px; |
| | | padding: 5px 14px; |
| | | box-shadow: 0 0 0 1px var(--app-border, #e8ecf1) inset; |
| | | transition: box-shadow var(--app-transition, 0.2s); |
| | | |
| | | &:hover { |
| | | box-shadow: 0 0 0 1px var(--app-text-tertiary, #86909c) inset; |
| | | } |
| | | |
| | | &.is-focus { |
| | | box-shadow: 0 0 0 1.5px var(--app-primary, #2c51d9) inset; |
| | | } |
| | | } |
| | | |
| | | @media (max-width: 480px) { |
| | | .login-panel { |
| | | padding: 20px 16px; |
| | | background: #fff; |
| | | } |
| | | |
| | | .login-card { |
| | | padding: 28px 24px 20px; |
| | | box-shadow: none; |
| | | } |
| | | } |
| | | </style> |