|
@@ -13,7 +13,8 @@ import { rewardEventTrackClick } from '@/api/integral'
|
|
|
import errorCode from './errorCode'
|
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
|
import { sendError } from '@/api/Verifition'
|
|
|
-import { generateUUID } from "@/utils"
|
|
|
+
|
|
|
+import { useSystem } from '@/store/system'
|
|
|
|
|
|
// import { resetRouter } from '@/router'
|
|
|
// import { deleteUserCache } from '@/hooks/web/useCache'
|
|
@@ -60,7 +61,7 @@ const service = axios.create({
|
|
|
|
|
|
// request拦截器
|
|
|
service.interceptors.request.use(
|
|
|
- (config) => {
|
|
|
+ async (config) => {
|
|
|
const userStore = useUserStore()
|
|
|
config.headers['Accept-Language'] = getCurrentLocaleLang() ?? 'zh_CN'
|
|
|
// 是否需要设置 token
|
|
@@ -106,6 +107,7 @@ service.interceptors.request.use(
|
|
|
|
|
|
// 开启参数加密
|
|
|
if (config.openEncryption) {
|
|
|
+ const { getBeijingTimestamp, setBeijingTimestamp, systemInfo } = useSystem()
|
|
|
const raw = config.url.split('?')[1]
|
|
|
// const raw = config.encodeParams ? config.url.split('?')[1] : config.url.split('?')[1]
|
|
|
const body = {
|
|
@@ -117,7 +119,18 @@ service.interceptors.request.use(
|
|
|
* params: { data, params, raw }
|
|
|
* content
|
|
|
*/
|
|
|
- const { noSign, ...header} = encryptionFun({raw, body, appId: 'web_client', AppSecret: 'fa0fc0b5098b974b'})
|
|
|
+ if (systemInfo.beijingTimestamp === 0 && process?.env?.NODE_ENV === 'production') {
|
|
|
+ const _timestamp = await getBeijingTimestamp()
|
|
|
+ setBeijingTimestamp(_timestamp)
|
|
|
+ }
|
|
|
+
|
|
|
+ const { noSign, ...header} = encryptionFun({
|
|
|
+ raw,
|
|
|
+ body,
|
|
|
+ appId: 'web_client',
|
|
|
+ AppSecret: 'fa0fc0b5098b974b',
|
|
|
+ timestamp: process?.env?.NODE_ENV === 'production' ? systemInfo.beijingTimestamp + 3000 : new Date().getTime() + 3000,
|
|
|
+ })
|
|
|
const content = {
|
|
|
data: config.data,
|
|
|
params: config.params,
|