index.wxml里代碼如下
<button bindtap="open">點擊撥號</button>
只需要添加一個觸發按鈕即可
然后index.js里添加一個函數
open: function () {
wx.showActionSheet({
itemList: ['400-900-2250'],
success: function (res) {
console.log(res) //當點擊400-900-2250就相當於點擊了
wx.makePhoneCall({
phoneNumber: '400-900-2250', //此號碼並非真實電話號碼,僅用於測試
success: function () {
console.log("撥打電話成功!")
},
fail: function () {
console.log("撥打電話失敗!")
}
})
if (!res.cancel) {
console.log(res.tapIndex)//console出了下標
}
}
});
}
然后就可以,有問題的話可以留言提問哦