执行addressBookObj.find("", function(contacts) {
var list = "";
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].phoneNumbers.length > 0) {
var str = contacts[i].displayName;
var id = "button_" + i;
var num = contacts[i].phoneNumbers[0].value
list += "<a type='" + num + "' style='width:100% ;height:15vw;font-size: 5vw;' id='" + id +
"' onclick='dianji()' name='" + str + "' class='mui-btn mui-btn-block'>" + str +
"</a><h3> <a class='tiana ordercar' id='" + id + "'>" + "<br/>" + "(" + contacts[i].phoneNumbers[0].value +
")" + " </a></h3>";
}
}
var str_01 =
"<header class='mui-bar mui-bar-nav' style='min-height: 13vw;height:12%;background-color: #FF6600;-webkit-box-shadow: none;box-shadow: none;'><a class='mui-action-back mui-icon mui-icon-left-nav mui-pull-left' ></a><h1 class='mui-title' style='height: 6vw;line-height: 6vw;font-size: 6vw;bottom: 10%;color: #FFFFFF;font-weight: 700;'>选择联系人</h1></header>";
mui('#div_')[0].insertAdjacentHTML('beforeend', str_01 + list);
}, function(e) {
alert("失败!!");
alert("请去权限设置里面打开允许访问通讯录权限");
},{
multiple: true
});这个函数查找联系人之前会有一次系统提示的权限开启,只有允许了访问联系人信息才会执行这个函数,若是没有开启权限就会闪退
3 个回复
4everv君
同求
8***@qq.com
执行addressBookObj.find("", function(contacts) {
var list = "";
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].phoneNumbers.length > 0) {
var str = contacts[i].displayName;
var id = "button_" + i;
var num = contacts[i].phoneNumbers[0].value
8***@qq.com
关键在于怎么自动开启应用权限提示