TMRAppBle/script/permission.js

49 lines
959 B
JavaScript
Raw Normal View History

2023-10-19 15:00:17 +08:00
var Permission = {
hasPermission: function (one_per) {
var perms = new Array();
if (one_per) {
perms.push(one_per);
} else {
var prs = document.getElementsByName("p_list");
for (var i = 0; i < prs.length; i++) {
if (prs[i].checked) {
perms.push(prs[i].value);
}
}
}
var rets = api.hasPermission({
list: perms
});
if (!one_per) {
console.log('判断结果:' + JSON.stringify(rets));
return;
}
return rets;
},
reqPermission:function(perm, callback){
var perms = new Array();
perms.push(perm);
api.requestPermission({
list: perms,
code: 1
}, function (ret, err) {
if (ret && ret.list.length > 0) {
callback(ret);
}
});
},
reqPermissions:function(perms, callback){
api.requestPermissions({
list: perms,
code: 1
}, function (ret, err) {
if (ret && ret.list.length > 0) {
callback(ret);
console.log(JSON.stringify(ret));
}
});
}
}
export {Permission}