diff --git a/src/components/KeyInfoForm/index.vue b/src/components/KeyInfoForm/index.vue index f8a76ef..3c9f721 100644 --- a/src/components/KeyInfoForm/index.vue +++ b/src/components/KeyInfoForm/index.vue @@ -344,12 +344,12 @@ const afterRead = (e) => { if (data.code === 200) { keyInfoForm.value.faceImg = [e.file[0]] } else { - // uni.$u.toast('人脸识别失败:' + data.msg) + uni.$u.toast('人脸识别失败:' + data.msg) keyInfoForm.value.faceImg = [e.file[0]] } }, fail: (err) => { - uni.$u.toast('人脸识别失败:' + err.msg) + uni.$u.toast('人脸识别失败') }, }) // diff --git a/src/pages/attendance/index.vue b/src/pages/attendance/index.vue index 2d3edae..db4e502 100644 --- a/src/pages/attendance/index.vue +++ b/src/pages/attendance/index.vue @@ -151,7 +151,7 @@ const onAttendanceHandle = () => { }, }) } else { - uni.$u.toast('人脸识别失败,请重新识别') + uni.$u.toast('人脸识别失败,请重新识别' + data.msg) } }, fail: (err) => { diff --git a/src/pages/person-check/index.vue b/src/pages/person-check/index.vue index cb66d76..19fd343 100644 --- a/src/pages/person-check/index.vue +++ b/src/pages/person-check/index.vue @@ -61,12 +61,12 @@ const onFaceRecognition = () => { }) }, 500) } else { - uni.$u.toast('人脸识别失败,请重新识别') + uni.$u.toast('人脸识别失败,请重新识别' + data.msg) } }, fail: (err) => { showLoading.value = false - uni.$u.toast('人脸识别失败:' + err.msg) + uni.$u.toast('人脸识别失败') }, }) }, diff --git a/src/pages/person-entry/index.vue b/src/pages/person-entry/index.vue index 1239555..a17160b 100644 --- a/src/pages/person-entry/index.vue +++ b/src/pages/person-entry/index.vue @@ -96,13 +96,13 @@ const handleTapPersonEntry = (item) => { }) }, 500) } else { - uni.$u.toast('人脸识别失败,请重新识别') + uni.$u.toast('人脸识别失败,请重新识别' + data.msg) } }, fail: (err) => { showLoading.value = false console.log(err, 'err人脸识别失败') - uni.$u.toast('人脸识别失败:' + err.msg) + uni.$u.toast('人脸识别失败') }, }) }, diff --git a/src/utils/getConfig.js b/src/utils/getConfig.js new file mode 100644 index 0000000..397ad2d --- /dev/null +++ b/src/utils/getConfig.js @@ -0,0 +1,21 @@ +export const getCurrentEnv = () => { + const systemInfo = uni.getSystemInfoSync() + const { platform } = systemInfo + + // 平台判断 + switch (platform) { + case 'android': + return 'Android' + case 'ios': + return 'iOS' + case 'devtools': + return 'H5' // 注意:H5 环境下 platform 为 'devtools' + case 'mp-weixin': + return '微信小程序' + case 'mp-alipay': + return '支付宝小程序' + // 其他平台可以继续补充 + default: + return platform + } +} diff --git a/src/utils/http.js b/src/utils/http.js index 2ceab85..59368a0 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -2,6 +2,7 @@ import { useMemberStore, useCommonStore } from '@/stores' import { encrypt, decrypt } from './encrypt' // 引入加解密方法 import { cloneDeep } from 'lodash-es' // 引入深拷贝函数 import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt, tansParams } from '@/utils/sm' +import { getCurrentEnv } from '@/utils/getConfig' /** * 添加拦截器 @@ -113,8 +114,17 @@ export const http = (options) => { success(res) { console.log(res, '请求拦截器处解密后的返回值') + const currentEnv = getCurrentEnv() + console.log(currentEnv, 'currentEnv') + // 判断是H5 还是App环境 + let isEncryptResponse = '' + if (currentEnv === 'windows') { + isEncryptResponse = 'encryptresponse' + } else { + isEncryptResponse = 'encryptResponse' + } - if (res.header.encryptResponse) { + if (res.header[isEncryptResponse]) { console.log(JSON.parse(decryptWithSM4(res.data)), '解密后') res.data = JSON.parse(decryptWithSM4(res.data))