Get Mobile Contact + scrolling Selector (MUI Mobile development Framework) __H5

Source: Internet
Author: User
There are times when a bug is stuck in the afternoon, after a while to see the problem, do not know whether it is happy or sad, the following is to get mobile contact and add a scrolling selector (picker) part of the code, no collation, attention to contact data in the PhoneNumber this attribute, 0 is the mobile phone number, 1 is the residential number, must be judged whether it is undefined, angered undefined may cause the logic of the following can not go on, the afternoon I was the return button listening to put the contact after the contact to appear undefined, I even return are not returned
Showuserpickerbutton.addeventlistener (' Tap ', function (event) {//extract user mobile contact to data source Contact_arr Plus.contacts.getAddressBook (Plus.contacts.ADDRESSBOOK_PHONE, function (addressbook) {Addressbook.find ([" DisplayName "," phonenumbers "], function (contacts) {for (var i = 0; i < contacts.length; i++) {//contact_arr_text is cont Act_arr each item in the data source for display at this place for the contact name + mobile number//here must be judged the contact name is not empty once angered undefined all logic is not executed!! if (Contacts[i]!== undefined && contacts[i].displayname!== undefined) {//To determine if the user's mobile phone number is not empty, take the mobile number if (contacts[i].ph Onenumbers[0]!== undefined) {var contact_arr_text = contacts[i].displayname + "\ T" + contacts[i].phonenumbers[0].value; ///If the cell phone number is empty, judge whether the residence number is empty or not, then use the residential number if the home number is empty this user does not display else if (contacts[i].phonenumbers[1]!== undefined) {var contact_arr_ Text = Contacts[i].displayname + "T" + contacts[i].phonenumbers[1].value; } console.log (Contact_arr_text); Pass data to data source contact_arr[i] = {value:i, text:contact_arr_text}; ///Contact data extraction shutdown load into selector userpicker.setdata (Contact_arr); usErpicker.show (function (items) {//Userresult.innertext = Json.stringify (Items[0]);//return False to prevent the selection box from turning off//return false ; }); }, False); The function (e) {Plus.ui.toast ("failed to get contact data!");} The function (e) {Plus.ui.toast ("failed to get to the phone address Book!");})  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.