微信小程序-添加手機聯系人


僅供參考

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, //聯系人手機號  
                            })
                        }
                    }
                })
            },    
         }

 

.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM