小程序调出手机拨号功能

<!-- 一键报警 -->
<view id="callPolice" bindtap="makePhoneCall">
    报警
</view>
/* 一键报警 */
#callPolice{
    width:80rpx;
    height: 80rpx;
    background: #e07959;
    position: fixed;
    right: 0;
    top: 50%;
    text-align: center;
    line-height: 80rpx;
}
 //报警
  makePhoneCall(e){
    wx.showModal({
      title: '警告',
      content: '恶意报警需承担法律责任,您确实需要报警吗?',
      success: function (sm) {
        // console.log('sm...',sm); // {errMsg: "showModal:ok", cancel: true, confirm: false}     
        if (sm.confirm) {
          wx.makePhoneCall({
            phoneNumber: '12345678910', //hst大警长的电话号码!!!
            success: function () {
              console.log("报警喽!!!!")
            },
            fail: function () {
              console.log("oops,打不了!")
            }
          })
        }else if (sm.cancel) {
          console.log("好吧,你取消了");
          
        }
      }
    })
  },

猜你喜欢

转载自blog.csdn.net/hst_gogogo/article/details/103368139