mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-23 20:44:58 +08:00
parent
2c3acbcaaf
commit
c962e9f5fe
4
.env
4
.env
|
@ -1 +1,3 @@
|
|||
VITE_PWD_ENC_KEY='thanks,rax'
|
||||
VITE_PWD_ENC_KEY='thanks,rax4cloud'
|
||||
|
||||
VITE_OAUTH2_PASSWORD_CLIENT='rax:rax'
|
|
@ -1,26 +1,39 @@
|
|||
import axios from "axios";
|
||||
import * as other from "@/utils/other";
|
||||
import {HOST} from "@/utils/request";
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
const FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded';
|
||||
|
||||
export const login = (data: any) => {
|
||||
return new Promise(resolve => {
|
||||
const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_PASSWORD_CLIENT);
|
||||
|
||||
const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_PWD_ENC_KEY);
|
||||
let encPassword = data.password;
|
||||
if (import.meta.env.VITE_PWD_ENC_KEY) {
|
||||
encPassword = other.encryption(data.password, import.meta.env.VITE_PWD_ENC_KEY);
|
||||
}
|
||||
|
||||
let encPassword = data.password;
|
||||
data.grant_type = 'password';
|
||||
data.scope = 'server';
|
||||
|
||||
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,
|
||||
},
|
||||
});
|
||||
axios.request({
|
||||
url: '/api/admin/oauth2/token',
|
||||
method: 'post',
|
||||
data: {...data, password: encPassword},
|
||||
headers: {
|
||||
skipToken: true,
|
||||
Authorization: basicAuth,
|
||||
'Content-Type': FORM_CONTENT_TYPE,
|
||||
},
|
||||
}).then(res => {
|
||||
resolve(res.data);
|
||||
}).catch(err => {
|
||||
if (err && err.response && err.response.data && err.response.data.msg) {
|
||||
ElMessage.error(err.response.data.msg)
|
||||
} else {
|
||||
ElMessage.error('系统异常请联系管理员')
|
||||
}
|
||||
})
|
||||
})
|
||||
};
|
|
@ -1,13 +1,12 @@
|
|||
/*
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
/!**
|
||||
/**
|
||||
* window.localStorage 浏览器永久缓存
|
||||
* @method set 设置永久缓存
|
||||
* @method get 获取永久缓存
|
||||
* @method remove 移除永久缓存
|
||||
* @method clear 移除全部永久缓存
|
||||
*!/
|
||||
*/
|
||||
export const Local = {
|
||||
// 查看 v2.4.3版本更新日志
|
||||
setKey(key: string) {
|
||||
|
@ -33,13 +32,13 @@ export const Local = {
|
|||
},
|
||||
};
|
||||
|
||||
/!**
|
||||
/**
|
||||
* window.sessionStorage 浏览器临时缓存
|
||||
* @method set 设置临时缓存
|
||||
* @method get 获取临时缓存
|
||||
* @method remove 移除临时缓存
|
||||
* @method clear 移除全部临时缓存
|
||||
*!/
|
||||
*/
|
||||
export const Session = {
|
||||
// 设置临时缓存
|
||||
set(key: string, val: any) {
|
||||
|
@ -75,4 +74,3 @@ export const Session = {
|
|||
return Local.get('tenantId') ? Local.get('tenantId') : 1;
|
||||
},
|
||||
};
|
||||
*/
|
||||
|
|
|
@ -137,6 +137,7 @@ import {v4} from "uuid";
|
|||
import {HOST, post} from "@/utils/request";
|
||||
import SliderVerify from "@/components/SliderVerify/index.vue";
|
||||
import * as loginApi from "@/api/acl/login";
|
||||
import {Session} from "@/utils/storage";
|
||||
|
||||
|
||||
//引入用户相关的小仓库
|
||||
|
@ -283,7 +284,7 @@ const register = async () => {
|
|||
loginParams.value.account = registerFormRef.value.account
|
||||
loginParams.value.name = registerFormRef.value.name
|
||||
currentHospital.value = registerFormRef.value.hospital
|
||||
toHome()
|
||||
isShowRegister.value = false;
|
||||
}).catch(() => {
|
||||
})
|
||||
} else {
|
||||
|
@ -364,7 +365,7 @@ function getCaptchaCode() {
|
|||
|
||||
function refreshImg() {
|
||||
const randomStr = v4()
|
||||
captchaImgUrl.value = HOST + '/admin/code/textImage?randomStr=' + randomStr
|
||||
captchaImgUrl.value = '/api/admin/code/textImage?randomStr=' + randomStr
|
||||
}
|
||||
|
||||
function sliderSuccess() {
|
||||
|
@ -373,10 +374,12 @@ function sliderSuccess() {
|
|||
password: loginParams.value.password, // 密码
|
||||
randomStr: v4()
|
||||
}).then((data: any) => {
|
||||
// 存储token 信息
|
||||
Session.set('token', data.access_token);
|
||||
Session.set('refresh_token', data.refresh_token);
|
||||
console.log(data);
|
||||
toHome()
|
||||
})
|
||||
|
||||
// toHome()
|
||||
}
|
||||
|
||||
const toHome = () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user