微信小程序-添加手机联系人

仅供参考

1,wxml:

<view bindlongtap="phoneNumTap">{{phoneNum}}</view>

2,js:

        data = {
            phoneNum: '123456789014'
        }

        methods = {
            // 长按号码响应函数  
            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: '张三', //联系人姓名  
                                mobilePhoneNumber: that.data.phoneNum, //联系人手机号  
                            })
                        }
                    }
                })
            },    
         }

 

.

posted @ 2018-05-07 14:23  谭翔随笔  阅读(2350)  评论(0编辑  收藏  举报