更新记录
1.0.2(2026-06-29)
优化项目同时有nvue和vue页面切换时可能获取不到的问题
1.0.1(2026-06-21)
证书文件可以放到插件的assets目录下
1.0.0(2026-06-15)
无
查看更多平台兼容性
uni-app(5.07)
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | Android插件版本 | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|---|
| × | × | × | × | × | × | 5.0 | 1.0.0 | × | × |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| × | × | × | × | × | × | × | × | × | × | × | × |
uni-app x(5.07)
| Chrome | Safari | Android | Android插件版本 | iOS | 鸿蒙 | 微信小程序 |
|---|---|---|---|---|---|---|
| × | × | 5.0 | 1.0.0 | × | × | × |
sl-oaid
oaid插件说明
接入安全联盟官方 oaid_sdk_2.8.0.aar 版本的oaid
使用注意事项:
1、购买前请先在自己的项目试用!(重要)
2、购买前请先在自己的项目试用!(重要)
3、需要在 manifest.json 配置文件设置 "enableOAID" : false
4、 assets/supplierconfig.json 配置文件根据 安全联盟官方 说明配置即可
插件使用示例
<script>
/*
manifest.json 配置文件 android打包配置 不要打包uni接入的oaid sdk
"android" : {
"enableOAID" : false,
*/
import {set_init,certSyncFunc,set_cert_path,getOAID,getDeviceIds} from "@/uni_modules/sl-oaid";
function down_cert(c_url) {
return new Promise(function(resolve, reject){
uni.downloadFile({
url: c_url,
success: (res) => {
console.log('down_cert res', res);
if (res.statusCode === 200) {
uni.saveFile({
tempFilePath: res.tempFilePath,
success: function (res) {
console.log('saveFile', res);
// 证书本地路径
uni.setStorage({
key:"sl-oaid-path-cert",
data: res.savedFilePath
});
resolve(res.savedFilePath);
},
fail(){
console.log('saveFile fail');
resolve(false);
}
});
}else{
resolve(false);
}
},
fail(){
console.log('down_cert fail');
resolve(false);
}
});
});
}
let is_dow_cert = false, oaid_time = 0;
getOaid = async function(c_call) {
let call_obj = {
complete:function(e){
clearTimeout(oaid_time);
oaid_time=0;
if(c_call.complete){
c_call.complete(e)
}
},
success: function(res){
if(res.oaid){
c_call.success(res)
}else{
call_obj.fail(res);
}
},
fail: function(res){
c_call.fail(res || {"code":-1,"message":'not'})
}
};
// 防止超时
if(oaid_time){
clearTimeout(oaid_time);
}
oaid_time = setTimeout(call_obj.fail, 6000);
if (getOAID) {
// 缓存 , 日志
set_init(true, false);// 初始化,必须
let oaid_path = uni.getStorageSync("sl-oaid-path-cert");
if(oaid_path){
oaid_path = 'file://' + plus.io.convertLocalFileSystemURL(oaid_path);
set_cert_path(oaid_path); // 设置证书
}else{
set_cert_path("com.cert.pem"); // assets目录下的证书文件名
}
let cert = certSyncFunc(); // 获取证书信息
/*
{
type : Valid | Expired | NotYetValid
cert: true | false // 证书是否读取成功
Before: 证书开始时间
After: 证书过期时间
SubjectName: 证书信息
}
*/
if(!cert['cert'] || cert['type'] != 'Valid'){
// 下载过证书也是过期的
if(is_dow_cert){
console.log('证书 加载失败');
call_obj.fail(cert);
return;
}
// 下载证书,证书一年申请一次,所以要放在服务器端
oaid_path = await down_cert(' 证书url地址 ');
if (oaid_path) {
is_dow_cert = true;
oaid_path = 'file://' + plus.io.convertLocalFileSystemURL(oaid_path);
set_cert_path(oaid_path); // 设置证书
} else{
console.log('证书 下载失败');
call_obj.fail(cert);
return;
}
}
getOAID(function(res){
/*
getDeviceIds 包含 vaid 和 aaid
{
init : "msaoaidsec" | null
cert: true | false // 证书是否读取成功
oaid:
vaid:
aaid:
}
*/
call_obj.success(res);
call_obj.complete(res);
});
} else {
plus.device.getOAID(call_obj);
}
}
</script>

收藏人数:
购买源码授权版(
试用
赞赏(0)
下载 44
赞赏 1
下载 12469543
赞赏 1936
赞赏
京公网安备:11010802035340号