mui-H5获取当前手机通讯录
mui.plusReady(function() {
// 扩展API加载完毕,现在可以正常调用扩展API
plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, function(addressbook) {
addressbook.find(["displayName", "phoneNumbers"], function(contacts) {
var arr = [];
var arr_name = [];
var gg = 0;
for(var i = 0, len = contacts.length; i < len; i++) {
var li = document.getElementById("mode").cloneNode(true);
var length = contacts[i].phoneNumbers.length;
if (length == 0) {
} else {
arr[gg] = contacts[i].phoneNumbers[0].value;
arr_name[gg] = contacts[i].displayName;
gg++;
li.innerHTML = contacts[i].displayName + "<br/>手机:" + (contacts[i].phoneNumbers.length == 0 ? "" : contacts[i].phoneNumbers[0].value);
document.getElementById("listArea").appendChild(li);
}
}
console.log(arr);
console.log(arr_name);
}, function() {
mui.toast("获取电话簿失败 ");
}, {
multiple: true
});
}, function(e) {
mui.toast("获取电话簿失败 " + e.message);
});
});