From 810a14d1f73193251597bff5a600e5654ee8efe8 Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Tue, 9 Dec 2025 10:34:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0=E8=A7=A3?= =?UTF-8?q?=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/aes_secret.js | 17 ++++++++++++++++- utils/request.js | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/utils/aes_secret.js b/utils/aes_secret.js index eb0fc29..e000103 100644 --- a/utils/aes_secret.js +++ b/utils/aes_secret.js @@ -22,4 +22,19 @@ const encrypt = (word) => { return encrypted.ciphertext.toString(CryptoJS.enc.Base64); }; -export { encrypt }; +function decryptAes(params) { + try { + const key = CryptoJS.enc.Utf8.parse("fa4e0fae59534676"); // 16 bytes key for AES + + const bytes = CryptoJS.AES.decrypt(params.info, key, { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7, + }); + const decryptedText = bytes.toString(CryptoJS.enc.Utf8); + return JSON.parse(decryptedText); + } catch (e) { + console.info(e); + } +} + +export { encrypt, decryptAes }; diff --git a/utils/request.js b/utils/request.js index eda424d..a911796 100644 --- a/utils/request.js +++ b/utils/request.js @@ -7,6 +7,7 @@ export var requestPath = 'https://skqhdg.porthebei.com:9005/regulatory_gwj_2.0/' let videoApiPath = 'https://arqsp.qhdsafety.com:10010'; // 视频平台后台请求地址 import dayjs from "dayjs"; import { setRefreshToken } from "@/api"; +import {decryptAes} from "@/utils/aes_secret"; // export var requestPath = 'https://skqhdg.porthebei.com:9005/qa-regulatory-gwj/'; // 后台请求地址 export var requestPath = 'http://192.168.192.201:8992/regulatory_gwj_2.0/'; @@ -54,6 +55,7 @@ function post(url, data) { 'token': uni.getStorageSync('token') || '' }, success: (res) => { + res.data = decryptAes(res.data); if (data && data.loading !== false) { uni.hideLoading(); } @@ -113,6 +115,7 @@ function upload(url, data) { 'token': uni.getStorageSync('token') || '' }, success: (res) => { + res.data = decryptAes(res.data); uni.hideLoading(); const data = JSON.parse(res.data) if (data.result === 'success') { @@ -158,6 +161,7 @@ function uploads(url, data) { 'token': uni.getStorageSync('token') || '' }, success: (res) => { + res.data = decryptAes(res.data); uni.hideLoading(); const data = JSON.parse(res.data) if (data.result === 'success') { @@ -244,6 +248,7 @@ function loginRequest(url, data = {}) { }, method: "POST", success: (res) => { + res.data = decryptAes(res.data); if (data && data.loading !== false) { uni.hideLoading(); }