微信小程序-添加手机联系人
发布时间:2021-09-14 09:12:36作者:顺晟科技点击:
仅供参考
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, //联系人手机号
})
}
}
})
},
}
.
- 上一篇 : 微信小程序Page对象重写
- 下一篇 : 微信小程序开发--客服消息(接收和发送)


