小程序點擊撥號功能


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出了下標
        }
      }
    });
  }

然后就可以,有問題的話可以留言提問哦


免責聲明!

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



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