微信小程序实现拨打电话功能

一、

wxml

<button  catchtap="toCall">免费咨询</button>

 

wxjs

toCall:function(e){    
    wx.makePhoneCall({
      phoneNumber: this.data.info.traininfo.phone,
      success: function () {
        console.log('成功拨打电话')
      }
    })
  },

 二、

wxml

<view class="page_li sub" data-phone="{{shop.shopinfo.contact_phone}}" catchtap="tophone">
    <image class="page_phone" src="/image/iocn.png" mode="aspectFill"></image>
    打电话
</view>

wxjs

tophone: function(el) {
    let phone = el.currentTarget.dataset.phone;
    // console.log(phone)
    wx.makePhoneCall({
        phoneNumber: phone,
        success: function() {
            console.log('成功拨打电话')
        }
    })
  },

 

posted @ 2020-06-01 16:15  小桥流水细长流  阅读(2992)  评论(0编辑  收藏  举报