|
发表于 2017-7-6 10:01:13
|
显示全部楼层
我改了一下,可以获取用户名和电话的!
- Model.prototype.modelLoad = function(event){
- alert("aaa")
- 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) {
- for (var i = 0; i < contacts.length; i++) {
- alert("Display Name = " + JSON.stringify(contacts[i]));
- alert("displayName = " + contacts[i].displayName);
- var phoneNumbers = contacts[i].phoneNumbers;
- for(var j = 0;j<phoneNumbers.length;j++)
- alert("phoneNumbers= " + phoneNumbers[j].value);
- }
- }
- function onError(contactError) {
- alert('onError!');
- }
- };
复制代码 |
|