mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-23 20:44:58 +08:00
登录调试通了
This commit is contained in:
parent
e42ec83d42
commit
2c3acbcaaf
13
index.html
13
index.html
|
@ -1,12 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="referrer" content="no-referrer"/>
|
||||
<title>瑞鞍星医疗科技</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
"vant": "^4.8.3",
|
||||
"vue": "^3.2.45",
|
||||
"vue-router": "^4.1.6",
|
||||
"xlsx": "^0.18.5"
|
||||
"xlsx": "^0.18.5",
|
||||
"crypto-js": "4.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
import axios from "axios";
|
||||
import * as other from "@/utils/other";
|
||||
import {HOST} from "@/utils/request";
|
||||
|
||||
const FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded';
|
||||
|
||||
export const login = (data: any) => {
|
||||
|
||||
const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_PWD_ENC_KEY);
|
||||
|
||||
let encPassword = data.password;
|
||||
|
||||
encPassword = other.encryption(data.password, "thanks,rax");
|
||||
data.grant_type = 'password';
|
||||
data.scope = 'server';
|
||||
return axios.request({
|
||||
url: '/api/admin/oauth2/token',
|
||||
method: 'post',
|
||||
data: {...data, password: encPassword},
|
||||
headers: {
|
||||
skipToken: true,
|
||||
Authorization: basicAuth,
|
||||
'Content-Type': FORM_CONTENT_TYPE,
|
||||
},
|
||||
});
|
||||
};
|
|
@ -0,0 +1,33 @@
|
|||
// @ts-ignore
|
||||
import * as CryptoJS from 'crypto-js';
|
||||
|
||||
/**
|
||||
*加密处理
|
||||
*/
|
||||
export function encryption(src: string, keyWord: string) {
|
||||
const key = CryptoJS.enc.Utf8.parse(keyWord);
|
||||
// 加密
|
||||
var encrypted = CryptoJS.AES.encrypt(src, key, {
|
||||
iv: key,
|
||||
mode: CryptoJS.mode.CFB,
|
||||
padding: CryptoJS.pad.NoPadding,
|
||||
});
|
||||
return encrypted.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
* @param {*} params 参数列表
|
||||
* @returns 明文
|
||||
*/
|
||||
export function decryption(src: string, keyWord: string) {
|
||||
const key = CryptoJS.enc.Utf8.parse(keyWord);
|
||||
// 解密逻辑
|
||||
var decryptd = CryptoJS.AES.decrypt(src, key, {
|
||||
iv: key,
|
||||
mode: CryptoJS.mode.CFB,
|
||||
padding: CryptoJS.pad.NoPadding,
|
||||
});
|
||||
|
||||
return decryptd.toString(CryptoJS.enc.Utf8);
|
||||
}
|
|
@ -1,139 +1,142 @@
|
|||
<template>
|
||||
<div class="login-page">
|
||||
<div class="left-content move_4"></div>
|
||||
<div class="right-content">
|
||||
<div class="select-hospital-box">
|
||||
<el-select class="select-hospital" v-model="currentHospital" size="small" @change="selectHospital">
|
||||
<el-option v-for="item in hospitals" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<img v-show="!isShowRegister" class="logo move_2" src="@/assets/imgs/logo.png">
|
||||
<div v-if="!isShowRegister" class="login-block move_2">
|
||||
<div class="login-way">
|
||||
<span :class="passwordLogin && 'active'" @click="passwordLogin = true">密码登录</span>
|
||||
<span :class="!passwordLogin && 'active'" @click="passwordLogin = false">验证码登录</span>
|
||||
</div>
|
||||
<el-form ref="loginFormRef" :model="loginParams" :rules="loginRules" label-width="0" size="small">
|
||||
<div class="login-form password-login" v-if="passwordLogin">
|
||||
<el-form-item prop="account">
|
||||
<el-input v-model="loginParams.account" placeholder="请输入用户名">
|
||||
<template #prepend>
|
||||
<el-icon>
|
||||
<User/>
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
<el-input v-model="loginParams.password" type="password" show-password placeholder="请输入密码">
|
||||
<template #prepend>
|
||||
<el-icon>
|
||||
<Lock/>
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-button :loading="loading" class="login-btn" type="primary" @click="login('password')">登录</el-button>
|
||||
<span class="register-btn" @click="getCaptchaCode()">注册账号</span>
|
||||
</div>
|
||||
<div class="login-form code-login" v-else>
|
||||
<el-form-item prop="phone">
|
||||
<el-input v-model="loginParams.phone" placeholder="请输入手机号">
|
||||
<template #prepend>
|
||||
<div @click.stop style="display: flex;align-items: center;">
|
||||
<el-dropdown @command="selectPhoneArea">
|
||||
<span style="color: #909399;">{{ loginParams.phoneArea }}<el-icon>
|
||||
<DCaret />
|
||||
</el-icon></span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="item in phoneAreas" :command="item">{{ item
|
||||
}}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code">
|
||||
<el-input v-model="loginParams.code" placeholder="请输入6位短信验证码">
|
||||
<template #append>
|
||||
<span class="send-btn" @click="sendCode">{{ loginParams.sendText }}</span>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-button class="login-btn" type="primary" @click="login('code')">登录</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
<div v-else class="register-block move_2">
|
||||
<div class="header-box">
|
||||
<span class="title">新用户申请</span>
|
||||
<el-icon @click="isShowRegister = false">
|
||||
<Close />
|
||||
</el-icon>
|
||||
</div>
|
||||
|
||||
<el-form ref="registerFormRef" :model="registerParams" :rules="registerRules" label-width="100">
|
||||
<el-form-item label="用户名" prop="account">
|
||||
<el-input v-model="registerParams.account" placeholder="请输入用户名"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="registerParams.password" type="password" show-password
|
||||
placeholder="请输入密码"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="name">
|
||||
<el-input v-model="registerParams.name" placeholder="请输入姓名"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="registerParams.phone" placeholder="请输入手机号"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="医院" prop="hospital">
|
||||
<el-select v-model="registerParams.hospital" style="width: 100%;">
|
||||
<el-option v-for="item in hospitals" :key="item.value" :label="item.label"
|
||||
:value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="性别" prop="sex">
|
||||
<el-radio-group v-model="registerParams.sex">
|
||||
<el-radio label="男" />
|
||||
<el-radio label="女" />
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="验证码" prop="code">
|
||||
<el-input v-model="registerParams.code" placeholder="请输入验证码"
|
||||
style="width: calc(100% - 110px);"></el-input>
|
||||
<img width="100" height="32" style="margin-left: 10px;" :src="captchaImgUrl" />
|
||||
<a class="change_img" @click="refreshImg" href="#">看不清?</a>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<div class="footer-box">
|
||||
<el-button type="primary" @click="register">注 册</el-button>
|
||||
<span @click="isShowRegister = false">已有账号?</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login-page">
|
||||
<div class="left-content move_4"></div>
|
||||
<div class="right-content">
|
||||
<div class="select-hospital-box">
|
||||
<el-select class="select-hospital" v-model="currentHospital" size="small" @change="selectHospital">
|
||||
<el-option v-for="item in hospitals" :key="item.value" :label="item.label" :value="item.value"/>
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<img v-show="!isShowRegister" class="logo move_2" src="@/assets/imgs/logo.png">
|
||||
<div v-if="!isShowRegister" class="login-block move_2">
|
||||
<div class="login-way">
|
||||
<span :class="passwordLogin && 'active'" @click="passwordLogin = true">密码登录</span>
|
||||
<span :class="!passwordLogin && 'active'" @click="passwordLogin = false">验证码登录</span>
|
||||
</div>
|
||||
<el-form ref="loginFormRef" :model="loginParams" :rules="loginRules" label-width="0" size="small">
|
||||
<div class="login-form password-login" v-if="passwordLogin">
|
||||
<el-form-item prop="account">
|
||||
<el-input v-model="loginParams.account" placeholder="请输入用户名">
|
||||
<template #prepend>
|
||||
<el-icon>
|
||||
<User/>
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
<el-input v-model="loginParams.password" type="password" show-password placeholder="请输入密码">
|
||||
<template #prepend>
|
||||
<el-icon>
|
||||
<Lock/>
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-button :loading="loading" class="login-btn" type="primary" @click="login('password')">登录</el-button>
|
||||
<span class="register-btn" @click="getCaptchaCode()">注册账号</span>
|
||||
</div>
|
||||
<div class="login-form code-login" v-else>
|
||||
<el-form-item prop="phone">
|
||||
<el-input v-model="loginParams.phone" placeholder="请输入手机号">
|
||||
<template #prepend>
|
||||
<div @click.stop style="display: flex;align-items: center;">
|
||||
<el-dropdown @command="selectPhoneArea">
|
||||
<span style="color: #909399;">{{ loginParams.phoneArea }}<el-icon>
|
||||
<DCaret/>
|
||||
</el-icon></span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="item in phoneAreas" :command="item">{{
|
||||
item
|
||||
}}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code">
|
||||
<el-input v-model="loginParams.code" placeholder="请输入6位短信验证码">
|
||||
<template #append>
|
||||
<span class="send-btn" @click="sendCode">{{ loginParams.sendText }}</span>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-button class="login-btn" type="primary" @click="login('code')">登录</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
<div v-else class="register-block move_2">
|
||||
<div class="header-box">
|
||||
<span class="title">新用户申请</span>
|
||||
<el-icon @click="isShowRegister = false">
|
||||
<Close/>
|
||||
</el-icon>
|
||||
</div>
|
||||
|
||||
<el-form ref="registerFormRef" :model="registerParams" :rules="registerRules" label-width="100">
|
||||
<el-form-item label="用户名" prop="account">
|
||||
<el-input v-model="registerParams.account" placeholder="请输入用户名"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="registerParams.password" type="password" show-password
|
||||
placeholder="请输入密码"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="name">
|
||||
<el-input v-model="registerParams.name" placeholder="请输入姓名"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="registerParams.phone" placeholder="请输入手机号"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="医院" prop="hospital">
|
||||
<el-select v-model="registerParams.hospital" style="width: 100%;">
|
||||
<el-option v-for="item in hospitals" :key="item.value" :label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="性别" prop="sex">
|
||||
<el-radio-group v-model="registerParams.sex">
|
||||
<el-radio label="男"/>
|
||||
<el-radio label="女"/>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="验证码" prop="code">
|
||||
<el-input v-model="registerParams.code" placeholder="请输入验证码"
|
||||
style="width: calc(100% - 110px);"></el-input>
|
||||
<img width="100" height="32" style="margin-left: 10px;" :src="captchaImgUrl"/>
|
||||
<a class="change_img" @click="refreshImg" href="#">看不清?</a>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<div class="footer-box">
|
||||
<el-button type="primary" @click="register">注 册</el-button>
|
||||
<span @click="isShowRegister = false">已有账号?</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<SliderVerify v-model:isShowSelf="sliderVConf.isShowSelf" :width="sliderVConf.width" :imgUrl="sliderImgUrl"
|
||||
:height="sliderVConf.height" @success="toHome"></SliderVerify>
|
||||
</div>
|
||||
<SliderVerify v-model:isShowSelf="sliderVConf.isShowSelf" :width="sliderVConf.width" :imgUrl="sliderImgUrl"
|
||||
:height="sliderVConf.height" @success="sliderSuccess"></SliderVerify>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import { ElNotification } from 'element-plus';
|
||||
import {ElNotification} from 'element-plus';
|
||||
//引入获取当前时间的函数
|
||||
import { getTime } from '@/utils/time';
|
||||
import {getTime} from '@/utils/time';
|
||||
import {onMounted, reactive, ref, toRefs, watch} from 'vue'
|
||||
import {useRouter,useRoute} from 'vue-router'
|
||||
import {useRouter, useRoute} from 'vue-router'
|
||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||
import {useLoginStore} from '@/stores/user-info-store'
|
||||
import {getHospitalsData, getPhoneAreasData} from '@/static-data/core'
|
||||
import {v4} from "uuid";
|
||||
import {HOST} from "@/utils/request";
|
||||
import {HOST, post} from "@/utils/request";
|
||||
import SliderVerify from "@/components/SliderVerify/index.vue";
|
||||
import * as loginApi from "@/api/acl/login";
|
||||
|
||||
|
||||
//引入用户相关的小仓库
|
||||
|
@ -144,7 +147,7 @@ const router = useRouter()
|
|||
|
||||
const hospitals = ref([] as any)
|
||||
getHospitalsData().then((res: any) => {
|
||||
hospitals.value = res
|
||||
hospitals.value = res
|
||||
})
|
||||
const phoneAreas: any = getPhoneAreasData()
|
||||
|
||||
|
@ -189,38 +192,38 @@ const validatorPhone = (rule: any, value: any, callback: any) => {
|
|||
}
|
||||
|
||||
const loginRules = reactive({
|
||||
account: [
|
||||
{ required: true, validator: validatorUserName, trigger: 'change' },
|
||||
],
|
||||
password: [
|
||||
{ required: true, validator: validatorPassword, trigger: 'change' },
|
||||
],
|
||||
phone: [
|
||||
{ required: true, validator:validatorPhone, trigger: 'blur' },
|
||||
],
|
||||
code: [
|
||||
{ required: true, message: '请输入验证码', trigger: 'blur' },
|
||||
]
|
||||
account: [
|
||||
{required: true, validator: validatorUserName, trigger: 'change'},
|
||||
],
|
||||
password: [
|
||||
{required: true, validator: validatorPassword, trigger: 'change'},
|
||||
],
|
||||
phone: [
|
||||
{required: true, validator: validatorPhone, trigger: 'blur'},
|
||||
],
|
||||
code: [
|
||||
{required: true, message: '请输入验证码', trigger: 'blur'},
|
||||
]
|
||||
})
|
||||
const registerRules = reactive({
|
||||
account: [
|
||||
{ required: true, validator: validatorUserName, trigger: 'change' },
|
||||
],
|
||||
password: [
|
||||
{ required: true, validator: validatorUserName, trigger: 'change' },
|
||||
],
|
||||
name: [
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||||
],
|
||||
phone: [
|
||||
{ required: true, validator:validatorPhone, trigger: 'change' },
|
||||
],
|
||||
hospital: [
|
||||
{ required: true, message: '请选择医院', trigger: 'blur' },
|
||||
],
|
||||
code: [
|
||||
{ required: true, message: '请输入验证码', trigger: 'blur' },
|
||||
]
|
||||
account: [
|
||||
{required: true, validator: validatorUserName, trigger: 'change'},
|
||||
],
|
||||
password: [
|
||||
{required: true, validator: validatorUserName, trigger: 'change'},
|
||||
],
|
||||
name: [
|
||||
{required: true, message: '请输入用户名', trigger: 'blur'},
|
||||
],
|
||||
phone: [
|
||||
{required: true, validator: validatorPhone, trigger: 'change'},
|
||||
],
|
||||
hospital: [
|
||||
{required: true, message: '请选择医院', trigger: 'blur'},
|
||||
],
|
||||
code: [
|
||||
{required: true, message: '请输入验证码', trigger: 'blur'},
|
||||
]
|
||||
})
|
||||
|
||||
//获取路由器
|
||||
|
@ -234,109 +237,110 @@ const currentHospital = ref(useLoginStore().getlogin().hospital)
|
|||
const isShowRegister = ref(false)
|
||||
const passwordLogin = ref(true)
|
||||
const loginParams = ref({
|
||||
account: 'admin',
|
||||
name: '',
|
||||
password: '123456',
|
||||
phone: '',
|
||||
phoneArea: phoneAreas[0],
|
||||
code: '',
|
||||
isSendCode: false,
|
||||
sendTimer: 0,
|
||||
sendText: '获取短信验证码'
|
||||
account: 'admin',
|
||||
name: '',
|
||||
password: '123456',
|
||||
phone: '',
|
||||
phoneArea: phoneAreas[0],
|
||||
code: '',
|
||||
isSendCode: false,
|
||||
sendTimer: 0,
|
||||
sendText: '获取短信验证码'
|
||||
})
|
||||
const registerParams = ref({
|
||||
account: '',
|
||||
password: '',
|
||||
name: '',
|
||||
phone: '',
|
||||
hospital: '',
|
||||
sex: '',
|
||||
code: ''
|
||||
account: '',
|
||||
password: '',
|
||||
name: '',
|
||||
phone: '',
|
||||
hospital: '',
|
||||
sex: '',
|
||||
code: ''
|
||||
})
|
||||
const sliderVConf = ref({
|
||||
isShowSelf: false,
|
||||
width: 400,
|
||||
height: 200
|
||||
isShowSelf: false,
|
||||
width: 400,
|
||||
height: 200
|
||||
})
|
||||
|
||||
const captchaImgUrl = ref('')
|
||||
const sliderImgUrl = ref('')
|
||||
|
||||
const selectHospital = (e: string) => {
|
||||
// console.log(e)
|
||||
// console.log(e)
|
||||
}
|
||||
const register = async () => {
|
||||
await registerFormRef.value.validate((valid: any, fields: any) => {
|
||||
if (valid) {
|
||||
ElMessageBox.confirm(
|
||||
'注册成功,是否登录?',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'success',
|
||||
draggable: true
|
||||
}
|
||||
).then(() => {
|
||||
loginParams.value.account = registerFormRef.value.account
|
||||
loginParams.value.name = registerFormRef.value.name
|
||||
currentHospital.value = registerFormRef.value.hospital
|
||||
toHome()
|
||||
}).catch(() => { })
|
||||
} else {
|
||||
// console.log('error submit!', fields)
|
||||
}
|
||||
})
|
||||
await registerFormRef.value.validate((valid: any, fields: any) => {
|
||||
if (valid) {
|
||||
ElMessageBox.confirm(
|
||||
'注册成功,是否登录?',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'success',
|
||||
draggable: true
|
||||
}
|
||||
).then(() => {
|
||||
loginParams.value.account = registerFormRef.value.account
|
||||
loginParams.value.name = registerFormRef.value.name
|
||||
currentHospital.value = registerFormRef.value.hospital
|
||||
toHome()
|
||||
}).catch(() => {
|
||||
})
|
||||
} else {
|
||||
// console.log('error submit!', fields)
|
||||
}
|
||||
})
|
||||
}
|
||||
const selectPhoneArea = (e: string) => {
|
||||
loginParams.value.phoneArea = e
|
||||
loginParams.value.phoneArea = e
|
||||
}
|
||||
const sendCode = () => {
|
||||
if (loginParams.value.isSendCode) return
|
||||
let num = 60
|
||||
ElMessage.success('发送成功!')
|
||||
loginParams.value.isSendCode = true
|
||||
loginParams.value.sendText = '请' + num + '秒后重新发送'
|
||||
loginParams.value.sendTimer = setInterval(() => {
|
||||
num--
|
||||
if (num > 0) {
|
||||
loginParams.value.sendText = '请' + num + '秒后重新发送'
|
||||
} else {
|
||||
loginParams.value.isSendCode = false
|
||||
loginParams.value.sendText = '重新获取短信验证码'
|
||||
clearInterval(loginParams.value.sendTimer)
|
||||
}
|
||||
if (loginParams.value.isSendCode) return
|
||||
let num = 60
|
||||
ElMessage.success('发送成功!')
|
||||
loginParams.value.isSendCode = true
|
||||
loginParams.value.sendText = '请' + num + '秒后重新发送'
|
||||
loginParams.value.sendTimer = setInterval(() => {
|
||||
num--
|
||||
if (num > 0) {
|
||||
loginParams.value.sendText = '请' + num + '秒后重新发送'
|
||||
} else {
|
||||
loginParams.value.isSendCode = false
|
||||
loginParams.value.sendText = '重新获取短信验证码'
|
||||
clearInterval(loginParams.value.sendTimer)
|
||||
}
|
||||
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
}
|
||||
const login = async (type: string) => {
|
||||
const obj = loginParams.value
|
||||
if (!currentHospital.value) {
|
||||
ElMessage.warning('请在右上角选择院区')
|
||||
return
|
||||
const obj = loginParams.value
|
||||
if (!currentHospital.value) {
|
||||
ElMessage.warning('请在右上角选择院区')
|
||||
return
|
||||
}
|
||||
await loginFormRef.value.validate((valid: any, fields: any) => {
|
||||
if (valid) {
|
||||
// console.log('submit!')
|
||||
sliderVConf.value.isShowSelf = true
|
||||
|
||||
} else {
|
||||
// console.log('error submit!', fields)
|
||||
}
|
||||
await loginFormRef.value.validate((valid: any, fields: any) => {
|
||||
if (valid) {
|
||||
// console.log('submit!')
|
||||
sliderVConf.value.isShowSelf = true
|
||||
|
||||
} else {
|
||||
// console.log('error submit!', fields)
|
||||
}
|
||||
//加载效果:开始加载
|
||||
loading.value = true;
|
||||
|
||||
//加载效果:开始加载
|
||||
loading.value = true;
|
||||
/*try {
|
||||
//保证登录成功
|
||||
await useStore.userLogin(loginFormRef);
|
||||
//编程式导航跳转到展示数据首页
|
||||
//判断登录的时候,路由路径当中是否有query参数,如果有就往query参数挑战,没有跳转到首页
|
||||
let redirect: any = $route.query.redirect;
|
||||
$router.push({ path: redirect || '/' });
|
||||
|
||||
/*try {
|
||||
//保证登录成功
|
||||
await useStore.userLogin(loginFormRef);
|
||||
//编程式导航跳转到展示数据首页
|
||||
//判断登录的时候,路由路径当中是否有query参数,如果有就往query参数挑战,没有跳转到首页
|
||||
let redirect: any = $route.query.redirect;
|
||||
$router.push({ path: redirect || '/' });
|
||||
|
||||
//登录成功加载效果也消失
|
||||
loading.value = false;
|
||||
}*/
|
||||
//登录成功加载效果也消失
|
||||
loading.value = false;
|
||||
}*/
|
||||
|
||||
|
||||
/*} catch (error) {
|
||||
|
@ -348,7 +352,7 @@ const login = async (type: string) => {
|
|||
message: (error as Error).message
|
||||
})*/
|
||||
|
||||
})
|
||||
})
|
||||
//登录成功加载效果也消失
|
||||
loading.value = false;
|
||||
}
|
||||
|
@ -363,6 +367,18 @@ function refreshImg() {
|
|||
captchaImgUrl.value = HOST + '/admin/code/textImage?randomStr=' + randomStr
|
||||
}
|
||||
|
||||
function sliderSuccess() {
|
||||
loginApi.login({
|
||||
username: loginParams.value.account, // 用户名
|
||||
password: loginParams.value.password, // 密码
|
||||
randomStr: v4()
|
||||
}).then((data: any) => {
|
||||
console.log(data);
|
||||
})
|
||||
|
||||
// toHome()
|
||||
}
|
||||
|
||||
const toHome = () => {
|
||||
|
||||
ElNotification({
|
||||
|
@ -372,186 +388,193 @@ const toHome = () => {
|
|||
});
|
||||
|
||||
|
||||
const getPermissions = () => {
|
||||
let permissions = '普通用户'
|
||||
switch (loginParams.value.account) {
|
||||
const getPermissions = () => {
|
||||
let permissions = '普通用户'
|
||||
switch (loginParams.value.account) {
|
||||
|
||||
case 'admin':
|
||||
permissions = '超级管理员'
|
||||
break;
|
||||
case 'dev1':
|
||||
permissions = '高级管理员'
|
||||
break;
|
||||
case 'dev2':
|
||||
permissions = '中级管理员'
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return permissions
|
||||
case 'admin':
|
||||
permissions = '超级管理员'
|
||||
break;
|
||||
case 'dev1':
|
||||
permissions = '高级管理员'
|
||||
break;
|
||||
case 'dev2':
|
||||
permissions = '中级管理员'
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
useLoginStore().setlogin('isLogin', true)
|
||||
useLoginStore().setlogin('account', loginParams.value.account)
|
||||
useLoginStore().setlogin('name', loginParams.value.name || '暂未设置姓名')
|
||||
useLoginStore().setlogin('hospital', currentHospital.value)
|
||||
useLoginStore().setlogin('permissions', getPermissions())
|
||||
router.push('/home')
|
||||
return permissions
|
||||
}
|
||||
useLoginStore().setlogin('isLogin', true)
|
||||
useLoginStore().setlogin('account', loginParams.value.account)
|
||||
useLoginStore().setlogin('name', loginParams.value.name || '暂未设置姓名')
|
||||
useLoginStore().setlogin('hospital', currentHospital.value)
|
||||
useLoginStore().setlogin('permissions', getPermissions())
|
||||
router.push('/home')
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.login-page {
|
||||
width: 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
background-color: #F8F8F8;
|
||||
|
||||
.left-content {
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
background: url(@/assets/imgs/login/login_bck.png) no-repeat;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.right-content {
|
||||
position: relative;
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
background-color: #F8F8F8;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.left-content {
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
background: url(@/assets/imgs/login/login_bck.png) no-repeat;
|
||||
background-size: cover;
|
||||
.select-hospital-box {
|
||||
position: absolute;
|
||||
top: 25px;
|
||||
right: 25px;
|
||||
}
|
||||
.right-content {
|
||||
position: relative;
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
|
||||
.logo {
|
||||
height: 70px;
|
||||
}
|
||||
|
||||
.login-block {
|
||||
width: 65%;
|
||||
height: 430px;
|
||||
min-width: 500px;
|
||||
min-height: 300px;
|
||||
padding: 50px;
|
||||
margin-top: 20px;
|
||||
background: white;
|
||||
|
||||
.login-way {
|
||||
font-size: 18px;
|
||||
color: #909399;
|
||||
|
||||
span {
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.active {
|
||||
color: $main-color;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.login-form {
|
||||
:deep(.el-input) {
|
||||
font-size: 16px;
|
||||
margin-top: 20px;
|
||||
|
||||
.el-input-group__prepend,
|
||||
.el-input__wrapper,
|
||||
.el-input-group__append {
|
||||
box-shadow: none;
|
||||
border-bottom: 1px solid $border-color;
|
||||
background-color: transparent;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.el-input-group__prepend,
|
||||
.el-input-group__append {
|
||||
position: relative;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 16px;
|
||||
top: calc(50% - 8px);
|
||||
right: 0;
|
||||
background-color: $border-color;
|
||||
}
|
||||
}
|
||||
|
||||
.el-input-group__append::after {
|
||||
right: auto;
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
cursor: pointer;
|
||||
color: $main-color;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
margin-top: 40px;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
padding: 25px 0 25px 0.3em;
|
||||
border-radius: 0px;
|
||||
letter-spacing: 0.3em;
|
||||
}
|
||||
|
||||
.register-btn {
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
color: $main-color;
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.register-block {
|
||||
width: 65%;
|
||||
min-width: 500px;
|
||||
min-height: 300px;
|
||||
padding: 50px;
|
||||
background: white;
|
||||
|
||||
.header-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 30px;
|
||||
|
||||
.title {
|
||||
font-size: 20px;
|
||||
color: $main-color;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.el-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.footer-box {
|
||||
padding-left: 100px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.select-hospital-box {
|
||||
position: absolute;
|
||||
top: 25px;
|
||||
right: 25px;
|
||||
.el-button {
|
||||
font-size: 16px;
|
||||
padding: 5px 50px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 70px;
|
||||
}
|
||||
|
||||
.login-block {
|
||||
width: 65%;
|
||||
height: 430px;
|
||||
min-width: 500px;
|
||||
min-height: 300px;
|
||||
padding: 50px;
|
||||
margin-top: 20px;
|
||||
background: white;
|
||||
|
||||
.login-way {
|
||||
font-size: 18px;
|
||||
color: #909399;
|
||||
|
||||
span {
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.active {
|
||||
color: $main-color;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.login-form {
|
||||
:deep(.el-input) {
|
||||
font-size: 16px;
|
||||
margin-top: 20px;
|
||||
|
||||
.el-input-group__prepend,
|
||||
.el-input__wrapper,
|
||||
.el-input-group__append {
|
||||
box-shadow: none;
|
||||
border-bottom: 1px solid $border-color;
|
||||
background-color: transparent;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.el-input-group__prepend,
|
||||
.el-input-group__append {
|
||||
position: relative;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 16px;
|
||||
top: calc(50% - 8px);
|
||||
right: 0;
|
||||
background-color: $border-color;
|
||||
}
|
||||
}
|
||||
|
||||
.el-input-group__append::after {
|
||||
right: auto;
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
cursor: pointer;
|
||||
color: $main-color;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
margin-top: 40px;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
padding: 25px 0 25px 0.3em;
|
||||
border-radius: 0px;
|
||||
letter-spacing: 0.3em;
|
||||
}
|
||||
|
||||
.register-btn {
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
color: $main-color;
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.register-block {
|
||||
width: 65%;
|
||||
min-width: 500px;
|
||||
min-height: 300px;
|
||||
padding: 50px;
|
||||
background: white;
|
||||
.header-box {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 30px;
|
||||
.title {
|
||||
font-size: 20px;
|
||||
color: $main-color;
|
||||
font-weight: 600;
|
||||
}
|
||||
.el-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.footer-box {
|
||||
padding-left: 100px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.el-button {
|
||||
font-size: 16px;
|
||||
padding: 5px 50px;
|
||||
}
|
||||
&>span {
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
& > span {
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -19,5 +19,15 @@ export default defineConfig({
|
|||
additionalData: '@import "./src/assets/css/variable.scss";' //引入scss文件
|
||||
}
|
||||
}
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:9999', // 目标服务器地址
|
||||
ws: true, // 是否启用 WebSocket
|
||||
changeOrigin: true, // 是否修改请求头中的 Origin 字段
|
||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user