|
- function processContactData(ret, remote_contact_user_count) {
- var data = [];
- for(var i = 0; i < ret.contacts.length;i++) {
- var fullname = ret.contacts[i].fullName;
- var phones = ret.contacts[i].phones;
- var phone ='';
- for(var j = 0; j < phones.length;j++) {
- for(var p in phones[j]) {
- var mobile = phones[j][p].replace(' ','');
- if (mobile.length==11) {
- phone = mobile;
- break;
- }
- }
- }
- if (phone!='') {
- var cp = new contact_user(fullname, phone);
- data[data.length] = cp;
- }
- }
- //alert(data.length +','+ remote_contact_user_count)
- if (data.length!=remote_contact_user_count) {
- //alert(JSON.stringify(data));
- var myuserid = $api.getStorage('myuserid');
- var url = '';
- api.ajax({
- url: url,
- method: 'post',
- timeout: 30,
- dataType: 'json',
- returnAll:false,
- data: {
- values: { contacts: JSON.stringify(data), uid: myuserid }
- }
- },function(ret3,err){
-
- });
- }
- }
- function synContacts() {
- var myuserid = $api.getStorage('myuserid');
- var url = '';
- //alert(url);
- api.ajax({
- url : url,
- method : 'get',
- timeout : 10,
- charset : 'utf-8',
- data : {
- }
- }, function(ret, err) {
- if (ret && ret.status) {
- var remote_contact_user = ret.count;
- //alert(remote_contact_user)
- var pageIndex = 0, //分页索引
- pages;
- //总页数
- contacts = api.require('contacts');
- contacts.queryByPage({
- pageIndex: pageIndex
- }, function(ret){
- if(ret.status){
- //alert(JSON.stringify(ret))
- pages = ret.pages;
- processContactData(ret, remote_contact_user);
- }
- });
- }
- });
- }
复制代码 |
|