WeChat applet clicks the button to jump to the call function

1.wxml page

<view wx:if="{
   
   {datalist.mobile !=''}}" data-contact="{
   
   { datalist.mobile }}" catchtap='makeCall'>手机号:{
   
   { datalist.mobile }} <text style="color: coral;">点击拨打</text></view>
      <view wx:else>手机号:{
   
   { datalist.mobile }}</view>

 2.js page

  // 拨打电话
  makeCall(e) {
    // 获取绑定的电话号码  我这里的电话号是绝对正确的,如果绑定的电话号码有可能不正确建议判断一下
    console.log(e.currentTarget.dataset.contact);
    // 调用微信的拨打电话API 安卓直接跳转到手机拨号页面  苹果要用户点击同意才跳转
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.dataset.contact,
    })
  },

3. Jump 

Then press the back button to return to the page when the applet left by default

Guess you like

Origin blog.csdn.net/weixin_70563937/article/details/131728677