contacts 模块管理系统通讯录

contacts 模块管理系统通讯录

contacts模块管理系统通讯录, 用于可对系统通讯录进行增删改查等操作. 通过plus.contacts获取系统通讯录管理对象

一.获取通讯录方法: getAddressBook

getAddressBook 获取通讯录对象

void plus.contacts.getAddressBook(type,succesCB,errorCB);

1.1参数

  1. type(Number):(必选)要获取的通讯录类型
  2. successCB: (AddressBookSuccessCallback)(必选)获取通讯录对象成功回调.
  3. errorCB: (ContactsErrorCallback)(可选)获取通讯录对象失败回调

二.常量

2.1 手机通讯录 ADDRESSBOOK_PHONE

plus.contacts.ADDRESSBOOK_PHONE;
  1. 说明:

    Number类型, 通讯录类型常量, 数值类型, 固定值为0, 用户获取系统的联系人信息.

2.2 SIM卡通讯录 ADDRESSBOOK_SIM

plus.contacts.ADDRESSBOOK_SIM;
  1. 说明:

    Number类型, 通讯录类型常量, 数值类型, 固定值为1, 用于获取SIM卡上的联系人信息.

三.通讯录管理对象 AddressBook

通讯录管理对象, 可对系统通讯录进行联系人的增删改查操作.

interface AddressBook{
    function Contact create();
    function void find( contactFields,successCB,errorCB,findOptions );
}
<template>
	<view>
		<button type="default" @tap='get'>获取</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			};
		},
		methods: {
			get() {
				  plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, function( addressbook ) {
					 //  console.log(addressbook)
					  addressbook.find(["displayName","phoneNumbers"],res=>{
						console.log(res)
				        for(var i in res){
				          console.log(res[i]);
				        }
					  })
				  }, function(error) {
				    console.log(error.message);
				  });
			},
			onSuccess(res) {
				console.log(res)
			}
		}
	}
</script>

<style lang="scss">

</style>

3.1 方法:

3.1.1 create: 创建联系人

创建一个系统联系人, 并返回联系人对象, 可对联系人对象进行操作设置联系人信息, 如名称 地址 电话等.

Contact addressbook.create();
3.1.2 find: 在通讯录中查找联系人

在通讯录中安装指定的规则查找联系人, contactFields可设定查找返回的联系人中包含的字段值.

void addressbook.find( contacFields.successCB, errorCB, findOptions);
<template>
	<view>
		<button type="default" @tap='get'>获取</button>
		<view class="">
			{{content}}
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: ''
			};
		},
		methods: {
			get() {
				  plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, function( addressbook ) {
					  // 向通讯录中添加联系人
					  var contact = addressbook.create();
					  contact.displayName = "A";
					  contact.phoneNumbers = [{type: "手机",value:"12345678911",preferred: true}];
					  contact.save();
					 //  console.log(addressbook)
					  addressbook.find(["displayName","phoneNumbers"],res=>{
						  // console.log(res)
				        for(var i in res){
				          console.log(res[i]);
				        }
					  })
				  }, function(error) {
				    console.log(error.message);
				  });
			},
			onSuccess(res) {
				console.log(res)
			}
		}
	}
</script>

<style lang="scss">

</style>

参数:

  1. contactFields: (String[])(必选) 查找返回联系人中需要包含的信息

    可取Contact对象的属性名称, 若指定为null或"“或空数组则包含所有联系人信息. 可通过”."来分割子项, 如"name.familyName"指定获取联系人名称中的姓.

  2. successCB:(FindSuccessCallback)(必选)查找联系人操作成功回调

  3. errorCB: (ContactsErrorCallback)(可选)查找联系人操作失败回调

  4. findOptions: (ContactFindOption)(可选)查找联系人的参数

    ContactFindOption JSON对象, 查找联系人参数

    interface ContactFindOption{
        attribute ContactFindFilte[] filter;//数组, 查找时的过滤器
        attribute Boolean multiple;//是否查找多个联系人, 默认值为true
    }
    

3.2 Contact 联系人对象

interface Contact {
    readonly attribute String id;
    attribute String displayName;
    attribute ContactName name;
    attribute String nickname;
    attribute ContackField[] phoneNumbers;
    attribute ContackField[] emails;
    attribute ContackAddress[] addresses;
    attribute ContackField[] ims;
    attribute ContackOriganization[] organizations;
    attribute Date birthday;
    attribute String note;
    attribute ContactField[] photos;
    attribute ContactField[] categories;
    attribute ContactField[] categories;
    function Contact clone();
    function void remove(SuccessCB, errorCB);
    function void save(successCB, errorCB);
}
3.2.1 属性:
  1. id: 联系人的id

  2. displayName: 联系人显示的名字

  3. name: 联系人的名称

    ContactName类型

    interface ContactName{
        attribute String formatted;//联系人的完整姓名, 由其它字段组合生成
        attribute String familyNmae;//联系人的姓
        attribute String givenName;//联系人的名
        attribute String middleName;//联系人的中间名
        attribute String honorificPrefix;//联系人的前缀
        attribute String honorificSuffix;//联系人的后缀
    }
    
  4. nickname: 联系人的昵称

  5. phoneNumbers: 数组, 联系人的电话

  6. emails: 数组, 联系人的邮箱

  7. addresses: 数组, 联系人的地址

    ContactAddress 类型

    interface ContactAddress{
        attribute String type;//联系人地址类型, 如"home"表示家庭地址,"company"表示单位地址
        attribute String formatted;//完整地址
        attribute String streetAddress;//完整的街道地址
        attribute String locality; //城市或地区
        attribute String region; //省或地区
        attribute String country; //国家
        attribute String postalCode; //邮政编码
        attribute Boolean preferred; //是否为首选项
    }
    
  8. ims: 数组, 联系人的即时通讯地址

  9. organizations: 数组, 联系人所属组织信息

    ContactOrganization 类型

    interface ContactOrganization {
        attribute String type;//联系人所属组织类型
        attribute String name;//联系人所属组织名称
        attribute String department;//联系人所属组织部门
        attribute String title;//联系人在组织中的职位
        attribute String preferred;//是否为首选项
    }
    
  10. birthday: 联系人的生日

  11. note: 联系人的备注

  12. photos: 数组, 联系人的头像

  13. categories: 数组, 联系人的组名

  14. urls: 数组, 联系人网址

3.2.2 方法
  1. clone: 克隆联系人

克隆联系人, 创建出一个新的联系人对象

Contact contact.clone();
  1. remove: 删除联系人
void contact.remove( successCB, errorCB);
get() {
    plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, function( addressbook ) {
        addressbook.find(null,res=>{
        // console.log(res)
            for(var i in res){
                console.log(res[i]);
				//找到联系人显示的名字为A
                if(res[i].displayName=="A"){
                    //删除这个联系人
                    res[i].remove(()=>{
                    	console.log(res[i].id)
                    })
                }
            }
        })
    }, function(error) {
    	console.log(error.message);
    });
},
  1. save: 保存联系人
void contact.save(successCB, errorCB);
contact.save( function () {
    alert( "保存联系人成功" );
}, function ( e ) {
    alert( "保存联系人失败:" + e.message );
} );
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
企业通讯录管理系统,向企业员工随时随地的提供企业通讯录信息,用户可在手机端实时查看人员联系方式,拨打电话等全面提高了企业内部沟通效率。 主要功能有:用户管理(添加用户,删除用户用户,更新用户资料);通讯录管理(添加通讯录,更新通讯录,删除),个人中心,配置管理等。 EML企业客户关系管理系统,是基于Linux开放性内核和Apache基础上Php+Mysql的智能B/S交互式服务系统。 EML系统移动端由移动端采用javascript、html5、ajax、json等技术。 中间件层包括函数库,由java开发,android操作系统、中间件、用户界面和应用软件组成。 最佳分辨率: 1440x900 最佳浏览器: 火狐Firefox功能描述: 1.用户管理 2.通讯录管理: 3.角色管理: 4.个人中心 5.配置管理 目录说明: ./action 执行文件目录 ./css 样式目录 ./img 图片目录 ./js 脚本目录 ./lib 类文件及配置文件 ./tpl 网页模版目录 ./index.php 首页文件,网站配置信息 ./m.php MD5加密测试文件 ./contacts.sql 数据库文件 使用说明: .数据库文件 contacts.sql (提前创建mysql数据库,并导入此数据)2.数据库配置入口文件index.php(数据库配置相关信息)3.访问地址 http://127.0.0.1/ (如果放在网站根目录的话)4.首页路径 ./ 默认用户 普通用户wangjun 密码:123456 管理员用户:admin 密码:admin 使用技巧: 配置文件: ./lib/cfg.class.php 1.数据库配置 通过修改配置文件 2.管理员帐号密码 通过修改配置文件 修复说明 1、修复页面信息错误问题; 2、修复BUG,后台参数过滤提高安全性; 3、优化数据库结构,提高列表查询速度;

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值