提交 51712e05 authored 作者: 钟是志's avatar 钟是志

鉴权新街口修改

上级 69bdfed6
...@@ -17,6 +17,7 @@ import { offline } from '../location/Toast'; ...@@ -17,6 +17,7 @@ import { offline } from '../location/Toast';
import { giveBase16EnCode, requestFileInfo } from '@/webPublic/one_stop_public/Base16'; import { giveBase16EnCode, requestFileInfo } from '@/webPublic/one_stop_public/Base16';
import objectToFormData from '@/webPublic/zyd_public/utils/object-to-formdata-custom'; import objectToFormData from '@/webPublic/zyd_public/utils/object-to-formdata-custom';
import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils'; import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils';
import { getHeaders } from '@/webPublic/zyd_public/utils/utils';
const codeMessage = { const codeMessage = {
200: '服务器成功返回请求的数据。', 200: '服务器成功返回请求的数据。',
...@@ -170,7 +171,9 @@ export const requestOrigin = (url, data, options = {}) => { ...@@ -170,7 +171,9 @@ export const requestOrigin = (url, data, options = {}) => {
// method: "POST", // method: "POST",
requestType: 'form', requestType: 'form',
...getHeaders(),
...options, ...options,
}) })
.then(response => { .then(response => {
// console.log(response); // console.log(response);
...@@ -256,9 +259,7 @@ export const requestOrigin = (url, data, options = {}) => { ...@@ -256,9 +259,7 @@ export const requestOrigin = (url, data, options = {}) => {
options.prefix = ''; options.prefix = '';
} }
if (getToken()) { if (getToken()) {
options.headers = { options.headers = getHeaders().headers;
Authorization: `bearer ${getToken()}`,
};
} }
return fetchRequest(url, { return fetchRequest(url, {
......
import { getCurrentUser, getToken } from '@/webPublic/one_stop_public/utils/token'; import { getCurrentUser, getToken, getUserInfo } from '@/webPublic/one_stop_public/utils/token';
import Md5 from 'js-md5'; import Md5 from 'js-md5';
import { getIsBei_Dian } from '@/webPublic/zyd_public/utils/utils'; import { getIsBei_Dian } from '@/webPublic/zyd_public/utils/utils';
import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils'; import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils';
...@@ -8,16 +8,18 @@ const isTest = getUrlInfo().test; ...@@ -8,16 +8,18 @@ const isTest = getUrlInfo().test;
export function getHeaders(url = '') { export function getHeaders(url = '') {
const token = getToken(); const token = getToken();
const currentInfo = getCurrentUser(); const currentInfo = getCurrentUser() || {};
const user = getUserInfo() || {};
const userId = user.id || currentInfo.xgUserId;
const timestamp = new Date().getTime() + window.differenceBetweenServerAndClientTime; const timestamp = new Date().getTime() + window.differenceBetweenServerAndClientTime;
const secretString = token + currentInfo.xgUserId + timestamp; const secretString = token + userId + timestamp;
const res = { const res = {
headers: { headers: {
Authorization: `bearer ${token}`, Authorization: `bearer ${token}`,
}, },
}; };
if(getIsBei_Dian() && currentInfo?.userid){ if(getIsBei_Dian() && userId){
res.headers.auth = Md5(secretString); res.headers.auth = Md5(secretString);
res.headers.timestamp = timestamp; res.headers.timestamp = timestamp;
if (isTest) { if (isTest) {
...@@ -26,8 +28,7 @@ export function getHeaders(url = '') { ...@@ -26,8 +28,7 @@ export function getHeaders(url = '') {
secretString, secretString,
md5S: Md5(secretString), md5S: Md5(secretString),
timestamp, timestamp,
xgUserId: currentInfo.xgUserId, userId: userId,
typeString: currentInfo.typeString,
differenceBetweenServerAndClientTime: window.differenceBetweenServerAndClientTime, differenceBetweenServerAndClientTime: window.differenceBetweenServerAndClientTime,
}, },
); );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论