如何添加一键拨号悬浮按钮?

swan部分(放在每个swan页面最后),图片最好自己下载上传到自己的站点,再修改下面的图片地址:

   

css部分(只需放在index.css最后的空白位置即可):

.tel__wrap {

 position:fixed;right:26rpx;bottom:30rpx;z-index:999;

}

.tel__wrap .tel_image {

 width:80rpx;height:80rpx;visibility:visible;opacity:0.6;

}

.tel__wrap .button10 {

 visibility:hidden;margin:0;

}


js部分(放在每个js页面最后的   });  前面):

 ,calling_tel: function (e) {

    let mobile = e.currentTarget.dataset.id;

    if (!mobile) {

      mobile = app.globaldata.settings.cfg_kefu_tel;

    }

    swan.makePhoneCall({

      phoneNumber: mobile,

      success: function () {

        console.log("拨打电话成功!")

      },

      fail: function () {

        console.log("拨打电话失败!")

      }

    })

  }

发表评论

邮箱地址不会被公开。 必填项已用*标注

联系我们

在线咨询:点击这里给我发消息