11.13早上提交
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import crypto from "crypto-js";
|
||||
//解密
|
||||
|
||||
const decryptAesEcb = (sSrc, sKey) => {
|
||||
try {
|
||||
if (!sKey) {
|
||||
console.error("Key为空null");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 1. 将密钥转为 WordArray(crypto 内部格式)
|
||||
const key = crypto.enc.Utf8.parse(sKey);
|
||||
|
||||
// 2. Base64 解码密文,得到 WordArray
|
||||
const encryptedBytes = crypto.enc.Base64.parse(sSrc);
|
||||
|
||||
// 3. 使用 AES/ECB/PKCS7 解密
|
||||
const decrypted = crypto.AES.decrypt(
|
||||
{ ciphertext: encryptedBytes }, // 加密数据
|
||||
key, // 密钥
|
||||
{
|
||||
mode: crypto.mode.ECB, // ECB 模式
|
||||
padding: crypto.pad.Pkcs7, // PKCS7(等同于 Java 的 PKCS5Padding)
|
||||
}
|
||||
);
|
||||
|
||||
// 4. 将解密结果转为 UTF-8 字符串
|
||||
const decryptedText = decrypted.toString(crypto.enc.Utf8);
|
||||
|
||||
return decryptedText; // 如果解密失败,可能返回空字符串或非法字符
|
||||
} catch (error) {
|
||||
console.error("解密失败:", error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
//加密
|
||||
const encryptAesEcb = (sSrc, sKey) => {
|
||||
try {
|
||||
if (!sKey) {
|
||||
console.error("Key为空null");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 1. 将密钥转为 WordArray(crypto 内部格式)
|
||||
const key = crypto.enc.Utf8.parse(sKey);
|
||||
|
||||
// 2. 将明文转为 WordArray
|
||||
const srcBytes = crypto.enc.Utf8.parse(sSrc);
|
||||
|
||||
// 3. 使用 AES/ECB/PKCS7 加密
|
||||
const encrypted = crypto.AES.encrypt(
|
||||
srcBytes, // 明文数据
|
||||
key, // 密钥
|
||||
{
|
||||
mode: crypto.mode.ECB, // ECB 模式
|
||||
padding: crypto.pad.Pkcs7, // PKCS7 填充
|
||||
}
|
||||
);
|
||||
|
||||
// 4. 将加密结果转为 Base64 字符串
|
||||
// crypto-js 的 encrypt 方法返回的对象中,ciphertext 是 WordArray 格式
|
||||
const encryptedBase64 = encrypted.ciphertext.toString(crypto.enc.Base64);
|
||||
|
||||
return encryptedBase64;
|
||||
} catch (error) {
|
||||
console.error("加密失败:", error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
export { decryptAesEcb, encryptAesEcb };
|
||||
@@ -14,5 +14,6 @@ if(process.env.UNI_PLATFORM =="h5"){
|
||||
}
|
||||
}else{
|
||||
BASE_URL='https://dev-app.igandan.com/app'
|
||||
//BASE_URL='https://app.igandan.com/app'
|
||||
}
|
||||
export default BASE_URL
|
||||
@@ -14,5 +14,6 @@ if(process.env.UNI_PLATFORM =="h5"){
|
||||
}
|
||||
}else{
|
||||
DOC_URL='https://dev-doc.igandan.com/app/'
|
||||
//DOC_URL='https://doc.igandan.com/app/'
|
||||
}
|
||||
export default DOC_URL
|
||||
@@ -0,0 +1,9 @@
|
||||
const formatNumber = (number) => {
|
||||
|
||||
if(number < 10000){
|
||||
return number;
|
||||
}else{
|
||||
return (number / 10000).toFixed(1) + 'w';
|
||||
}
|
||||
}
|
||||
export default formatNumber;
|
||||
@@ -0,0 +1,13 @@
|
||||
let OTHER_HOST=''
|
||||
if(process.env.UNI_PLATFORM =="mp-weixin"){
|
||||
const { envVersion } = uni.getAccountInfoSync().miniProgram;
|
||||
if (envVersion == "release") {
|
||||
OTHER_HOST='https://wx.igandan.com'
|
||||
}else{
|
||||
OTHER_HOST='https://dev-wx.igandan.com'
|
||||
}
|
||||
}else{
|
||||
OTHER_HOST='https://dev-wx.igandan.com'
|
||||
//OTHER_HOST='https://wx.igandan.com'
|
||||
}
|
||||
export default OTHER_HOST
|
||||
@@ -0,0 +1,35 @@
|
||||
import permision from "@/js_sdk/wa-permission/permission.js"
|
||||
const getCameraPermission = async(callback) => {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
// 判断平台
|
||||
if (systemInfo.platform === 'android') {
|
||||
let result = await permision.requestAndroidPermission('android.permission.CAMERA');
|
||||
if(result == 1){
|
||||
callback();
|
||||
}else{
|
||||
openModal('请授权相机权限');
|
||||
}
|
||||
} else if (systemInfo.platform === 'ios') {
|
||||
let iosResult = await permision.judgeIosPermission("camera")
|
||||
if(iosResult){
|
||||
callback();
|
||||
}else{
|
||||
openModal('请授权相机权限');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
const openModal=(content)=>{
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content:content,
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if(res.confirm){
|
||||
permision.gotoAppPermissionSetting();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
export { getCameraPermission };
|
||||
+3
-1
@@ -137,8 +137,10 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
|
||||
n(res)
|
||||
} else {
|
||||
|
||||
if(url.indexOf('addOutPatientA')!=-1){
|
||||
if(url.indexOf('addOutPatientA')!=-1 || url.indexOf('checkVersion')!=-1){
|
||||
e(res.data)
|
||||
}else if(res.data.code==35002){
|
||||
n(res)
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: res.data.message,
|
||||
|
||||
Reference in New Issue
Block a user