function hasPermission(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; } function reqPermissions(perms, callback){ api.requestPermission({ list: perms, code: 1 }, function(ret, err){ if(ret && ret.list.length > 0){ callback(ret); console.log(JSON.stringify(ret)); } }); } function reqPermission(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); // console.log(JSON.stringify(ret)); } }); }