minix-template
Version:
minix template
120 lines (118 loc) • 2.44 kB
JavaScript
/*
* @Description:
* @Autor: tangsj
* @Date: 2022-05-06 17:23:22
* @LastEditTime: 2022-05-23 16:13:15
*/
import router from '@system.router'
import prompt from '@system.prompt'
export default {
data: {
encryptionList:[
{
name:'encrypt',
// url:'pages/base/canlUse/index',
describe:'加密'
},
{
name:'decodeAES128',
// url:'pages/base/log/index',
describe:'AES128解密'
},
{
name:'encodeAES128',
// url:'pages/base/log/index',
describe:'AES128加密'
}
]
},
goRouter(url){
router.push({
uri: url,
})
},
/**
* @description: 加密
* @param {*}
* @return {*}
*/
encrypt(){
const params = {
type: 'md5',
data: 'testdata'
}
this.$app.$def.bridge.encrypt(params)
.then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description: AES128解密
* @param {*}
* @return {*}
*/
decodeAES128(){
const params={
decode: '1468f853fbef92dbf58b742e69aa89e2', //待解密的密文
key: '127', //AES128密钥,选传参数,如果不传则取原生的密钥
}
this.$app.$def.bridge.decodeAES128(params)
.then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description: AES128加密
* @param {*}
* @return {*}
*/
encodeAES128(){
const params={
encode: '待加密的密文', //待加密的密文,
key: '', //AES128密钥,选传参数,如果不传则取原生的密钥
}
this.$app.$def.bridge.encodeAES128(params)
.then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
testBridge(name){
switch(name){
case 'encrypt':
this.encrypt()
break;
case 'decodeAES128':
this.decodeAES128()
break;
case 'encodeAES128':
this.encodeAES128()
break;
default:
break;
}
}
}