微信小程序-一键拨打电话功能

先来说明一下我们需要实现的最终效果:
用户点击之后直接跳转到拨打电话界面,并且已输入了要拨打的号码。参考详情

我们看一下最终效果:
在这里插入图片描述
微信小程序提供了很多Api,其中wx.makePhoneCall就是我们此次需要用到的。具体介绍可以查看官方介绍

话不多说,我们直接上代码

1.WXML

<view bindtap="phoneCall" data-item='{
   
   {phone}}'>联系商家:{
   
   {phone}}</view>

2.JS

Page({
  data: {
   phone:"123456789",
  },

   phoneCall: function (e) {
        let item = e.currentTarget.dataset.item;
        console.log("一键拨打电话", e, item);
          wx.makePhoneCall({
        phoneNumber: item
       })
    },
})

------------- The End -------------

许可协议: 转载请保留原文链接及作者。

猜你喜欢

转载自blog.csdn.net/weixin_43937466/article/details/99549826
今日推荐