微信小程序例子——添加手机联系人

xiaoxiao2021-02-28  119

1、效果展示

      

2、关键代码

1)WXML文件

{{phoneNum}}

2)JS文件

Page({ data:{ phoneNum:'12345678901'//测试用的号码,并非真实号码 }, // 长按号码响应函数 phoneNumTap:function(){ var that=this; // 提示呼叫号码还是将号码添加到手机通讯录 wx.showActionSheet({ itemList: ['呼叫','添加联系人'], success:function(res){ if(res.tapIndex===0){ // 呼叫号码 wx.makePhoneCall({ phoneNumber: that.data.phoneNum, }) }else if(res.tapIndex==1){ // 添加到手机通讯录 wx.addPhoneContact({ firstName: 'test',//联系人姓名 mobilePhoneNumber: that.data.phoneNum,//联系人手机号 }) } } }) } })

3)WXSS文件

view{ color: blue; padding: 15px; border-bottom: 1px solid gainsboro; }

3、源码获取方式

百度云链接:http://pan.baidu.com/s/1gfzMJXT

4、在添加手机联系人的过程中有遇到任何问题或者不明白的地方,欢迎添加我的微信进行咨询,感谢支持!微信号:FutureJet

5、觉得不错请打赏,您的十分满意是笔者的无限动力

   

转载请注明原文地址: https://www.6miu.com/read-97272.html

最新回复(0)