diff --git a/package.json b/package.json index 12a4190..3f74dfa 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "axios": "0.24.0", "clipboard": "2.0.8", "core-js": "3.19.1", + "crypto-js": "^4.2.0", "echarts": "4.9.0", "element-ui": "2.15.8", "file-saver": "2.0.5", diff --git a/src/api/crypto.js b/src/api/crypto.js new file mode 100644 index 0000000..1115a1b --- /dev/null +++ b/src/api/crypto.js @@ -0,0 +1,29 @@ +import CryptoJS from "crypto-js"; +const CRYPTOJSKEY = "60afL1G1b39c5Z27"; +function encrypt(plaintText) { + var options = { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7 + }; + var key = CryptoJS.enc.Utf8.parse(CRYPTOJSKEY); + var encryptedData = CryptoJS.AES.encrypt(plaintText, key, options); + var encryptedBase64Str = encryptedData.toString().replace(/\//g, "_"); + encryptedBase64Str = encryptedBase64Str.replace(/\+/g, "-"); + return encryptedBase64Str; +} + +//解密 +function decrypt(encryptedBase64Str) { + var vals = encryptedBase64Str.replace(/_/g, '/'); + var options = { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7 + }; + var key = CryptoJS.enc.Utf8.parse(CRYPTOJSKEY); + var decryptedData = CryptoJS.AES.decrypt(vals, key, options); + var decryptedStr = CryptoJS.enc.Utf8.stringify(decryptedData); + return decryptedStr + +} + +export { encrypt, decrypt } diff --git a/src/api/system/OperateGoodsInfo.js b/src/api/system/OperateGoodsInfo.js index 9585cec..e897c01 100644 --- a/src/api/system/OperateGoodsInfo.js +++ b/src/api/system/OperateGoodsInfo.js @@ -53,7 +53,7 @@ export function goodsCategory(query) { export function updateGoodsInfo(data) { return request({ url: '/system/operateGoodInfo/edit', - method: 'POST', + method: 'post', data: data }) } diff --git a/src/api/system/area.js b/src/api/system/area.js index fa736d6..3171215 100644 --- a/src/api/system/area.js +++ b/src/api/system/area.js @@ -57,7 +57,7 @@ export function addArea(data) { export function updateArea(data) { return request({ url: '/system/area/edit', - method: 'POST', + method: 'post', data: data }) } @@ -66,7 +66,7 @@ export function updateArea(data) { export function delArea(id) { return request({ url: '/system/area/' + id, - method: 'POST' + method: 'post' }) } @@ -74,6 +74,6 @@ export function delArea(id) { export function updateRemoteSigns(id, remoteSigns) { return request({ url: `/system/area/updateRemoteSigns?id=${id}&remoteSigns=${remoteSigns}`, - method: 'POST' + method: 'post' }) } \ No newline at end of file diff --git a/src/api/system/goodsCategory.js b/src/api/system/goodsCategory.js index c47e589..66b3ac6 100644 --- a/src/api/system/goodsCategory.js +++ b/src/api/system/goodsCategory.js @@ -38,7 +38,7 @@ export function addGoodsCategory(data) { export function updateGoodsCategory(data) { return request({ url: '/system/goodsCategory/edit', - method: 'POST', + method: 'post', data: data }) } @@ -47,7 +47,7 @@ export function updateGoodsCategory(data) { export function delGoodsCategory(id) { return request({ url: '/system/goodsCategory/' + id, - method: 'POST' + method: 'post' }) } diff --git a/src/api/system/poser.js b/src/api/system/poser.js index ceada46..99f064d 100644 --- a/src/api/system/poser.js +++ b/src/api/system/poser.js @@ -44,7 +44,7 @@ export function addPoser(data) { export function getListByUser(query) { return request({ url: '/system/station/list', - method: 'GET', + method: 'get', params: query }) } @@ -71,6 +71,6 @@ export function delPoser(nurseStationId, moduleType, nurseItemId) { export function selectPosterImageJump() { return request({ url: '/system/poser/selectPosterImageJump', - method: 'GET', + method: 'get', }) } \ No newline at end of file diff --git a/src/api/system/signingagencyCount.js b/src/api/system/signingagencyCount.js index f116285..d32cefb 100644 --- a/src/api/system/signingagencyCount.js +++ b/src/api/system/signingagencyCount.js @@ -12,7 +12,7 @@ export function listTrainingCategory(query) { export function getCounty(data) { return request({ url: '/applet/signinfo/getCounty', - method: 'POST', + method: 'post', data: data, headers: { region: 2, diff --git a/src/api/system/userlist.js b/src/api/system/userlist.js index 8fe2e54..77822de 100644 --- a/src/api/system/userlist.js +++ b/src/api/system/userlist.js @@ -3,7 +3,7 @@ import request from '@/utils/request' export function getListByUser(query) { return request({ url: '/system/station/list', - method: 'GET', + method: 'get', params: query }) } \ No newline at end of file diff --git a/src/utils/request.js b/src/utils/request.js index 6431e83..c99db46 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,5 +1,6 @@ import axios from 'axios' import { Notification, MessageBox, Message, Loading } from 'element-ui' +import { encrypt, decrypt } from "@/api/crypto"; import store from '@/store' import { getToken } from '@/utils/auth' import errorCode from '@/utils/errorCode' @@ -7,6 +8,8 @@ import { tansParams, blobValidate } from "@/utils/xinyilu"; import cache from '@/plugins/cache' import { saveAs } from 'file-saver' +var witch = '1' //1加密 2不加密 + let downloadLoadingInstance; // 是否显示重新登录 export let isRelogin = { show: false }; @@ -22,6 +25,7 @@ const service = axios.create({ // request拦截器 service.interceptors.request.use(config => { + let configtwo = JSON.parse(JSON.stringify(config)) // 是否需要设置 token const isToken = (config.headers || {}).isToken === false // 是否需要防止数据重复提交 @@ -59,14 +63,22 @@ service.interceptors.request.use(config => { } } } + if (witch == '1' && config.method == 'post' && config.url != "/logout" && config.url != '/system/station/updateNurseStationHeads') { + config.data = encrypt(JSON.stringify(config.data)) + } + console.log(configtwo) return config }, error => { - console.log(error) Promise.reject(error) }) // 响应拦截器 service.interceptors.response.use(res => { + if (witch == '1' && res.config.url != "/logout" && res.config.url != "/getInfo" && res.config.url != '/system/station/updateNurseStationHeads') { + res.data = decrypt(res.data) + res.data = JSON.parse(res.data) + } + console.log(res.data) // 未设置状态码则默认成功状态 const code = res.data.code || 200; // 获取错误信息 diff --git a/src/views/system/Specializedlist/index.vue b/src/views/system/Specializedlist/index.vue index c563f45..fa4a141 100644 --- a/src/views/system/Specializedlist/index.vue +++ b/src/views/system/Specializedlist/index.vue @@ -1,143 +1,71 @@