|
楼主 |
发表于 2019-11-30 11:13:34
|
显示全部楼层
感谢。
//查找联系人--读取所有联系人
Model.prototype.getmobiletx = function(event){
var me = this;
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var options = new ContactFindOptions();
options.filter = "";
options.multiple=true;
var fields = ["displayName","phoneNumbers"];
navigator.contacts.find(fields, onSuccess, onError,options);
}
function onSuccess(contacts) {
var tempdata =[];
for (var i = 0; i < contacts.length; i++) {
var displayName = contacts[i].displayName;
if(displayName){
var phoneNumbers = contacts[i].phoneNumbers;
var phoneNumber='';
for(var j = 0;j<phoneNumbers.length;j++){
phoneNumber = phoneNumbers[j].value;
}
var iidex = i+1;
var arr = {"id":iidex,"name":displayName,"tel":phoneNumber} ;
tempdata.push(arr);
me.telcontent=tempdata;
alert(me.telcontent); //这里可以看到结果
}
}
alert("完成"); //这二条不起做用,不会执行 。
me.comp("telData").loadData(me.telcontent);
me.comp("telData").refreshData();
}
function onError(contactError) {
throw justep.Error.create(contactError);
}
};
|
|