[Small program] Realize the direct call function wx.makePhoneCall

If you want to call the customer service hotline or business phone number in the applet, it would be very unfriendly if you have to copy it and dial it on the dial pad. Can you click the dial button to directly call up the dial pad for the customer? In fact, the official documentation of the WeChat applet provides an interface for making calls, we just need to get it in the project and use it directly.

<van-cell title="客服热线" is-link bindtap='callPhone' value="4001-111-111" />
// 拨打热线热线
  callPhone:function(){
    wx.makePhoneCall({
      phoneNumber: "4001-111-111",
      success: function () {
        console.log("拨打电话成功!")
      },
      fail: function () {
        console.log("拨打电话失败!")
      }
    })
  },

The approximate effect can already be seen on the simulator, as shown in the figure below:

 

 

 The final effect can be achieved when previewing on the mobile phone:

 

 

 

Guess you like

Origin blog.csdn.net/weixin_44266024/article/details/128457822