获取动态form表单的ref实例
:ref="el => (items.el = el)"
Object.hasOwnProperty.call
Object.hasOwnProperty.call() - 简书
//判断一个对象,每个属性是否有值
let data = {
code: "code",
name: "name"
}
let flag = Object.values(data).every(item=>{
return item != '' ? true : false
})
import CryptoJS from "crypto-js";
const {
http
} = uni.$u;
import config from '@/common/config';
/**
* AES加密 单数据加密
* --方法需要异转同!!!!!
* @param {String} plaintext 要加密的明文
* @returns {obj} {encrypted:密文,redisKey:传给后端的参}
*/
export async function encryptByAES(plaintext) {
return await http({
url: "/memberApp/getFrontendKey",
method: "GET"
}).then(r => {
if (r.data.code === 200) {
//进行加密
let key = CryptoJS.enc.Base64.parse(r.data.data.key);
let encrypted = CryptoJS.AES.encrypt(plaintext, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
});
return {
encrypted: encodeURIComponent(encrypted.ciphertext.toString(CryptoJS.enc.Base64)),
redisKey: r.data.data.redisKey
}
} else {
uni.showToast(r.data.msg)
}
}).catch(() => {
uni.showToast("网络连接失败!")
})
}
/**
* AES加密 多数据加密
* --方法需要异转同!!!!!
* @param {Array} plaintexts [{name:"键名",value:"明文"}]
* @returns {obj} {...name:密文,redisKey:传给后端的参}
*/
export async function encryptByAESarr(plaintexts) {
return await http.post(config.baseUrl + "/memberApp/getFrontendKey", {}, {
method: "GET"
}
).then(r => {
if (r.data.code === 200) {
let encryptedObj = {};
plaintexts.forEach(item => {
let key = CryptoJS.enc.Base64.parse(r.data.data.key);
let encrypted = CryptoJS.AES.encrypt(item.value, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
});
encryptedObj[item.name] = encodeURIComponent(encrypted.ciphertext.toString(CryptoJS
.enc.Base64));
})
encryptedObj.redisKey = r.data.data.redisKey;
return encryptedObj
} else {
uni.showToast(r.data.msg)
}
}).catch(() => {
uni.showToast("网络连接失败!")
})
}
/**
* AES解密
* 方法不用转同
* @param {String} cipherText 密文
* @return {String} 明文
*/
export async function decryptByAES(cipherText) {
// let key = CryptoJS.enc.Base64.parse(keyInBase64Str);
// // 返回的是一个Word Array Object,其实就是Java里的字节数组
// let decrypted = CryptoJS.AES.decrypt(cipherText, key, {
// mode: CryptoJS.mode.ECB,
// padding: CryptoJS.pad.Pkcs7,
// });
return await http.post(config.baseUrl + "/memberApp/memberName/decrypt?encryptMessage=" + cipherText,
{},{method:"GET"}
).then(r => {
if (r.data.code === 200) {
return r.data.data;
} else {
uni.showToast(r.data.msg)
}
}).catch(() => {
uni.showToast("网络连接失败!")
})
// return decrypted.toString(CryptoJS.enc.Utf8);
}
2665

被折叠的 条评论
为什么被折叠?



