(二十七) 获取通讯录
程序员文章站
2022-04-09 08:52:55
...
本节知识点
- 获取通讯录 plus.contacts.getAddressBook
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<style>
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">联系人</h1>
</header>
<div class="mui-content">
<ul class="mui-table-view" id="listArea">
<li class="mui-table-view-cell" id="mode">
#
</li>
</ul>
</div>
<link href="css/mui.min.css" rel="stylesheet" />
<script src="js/mui.min.js"></script>
<script type="text/javascript">
mui.init();
mui.plusReady(function() {
// 扩展API加载完毕,现在可以正常调用扩展API
plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, function(addressbook) {
addressbook.find(["displayName", "phoneNumbers"], function(contacts) {
for(var i = 0, len = contacts.length; i < len; i++) {
var li = document.getElementById("mode").cloneNode(true);
li.innerHTML = contacts[i].displayName + "<br/>手机:" + (contacts[i].phoneNumbers.length == 0 ? "" : contacts[i].phoneNumbers[0].value);
document.getElementById("listArea").appendChild(li);
}
}, function() {
mui.toast("获取电话簿失败 ");
}, {
multiple: true
});
}, function(e) {
mui.toast("获取电话簿失败 " + e.message);
});
});
</script>
</body>
</html>
作者:我拥抱着我的未来
链接:https://www.jianshu.com/p/79b35ab18214
來源:简书
上一篇: ajax在joomla中的原生态应用代码
下一篇: Java核心技术梳理-泛型