微信小程序增加悬浮在线客服

例如在index首页增加客服代码及一键拨打电话

1、index.wxss或者app.wxss文件里增加样式

.img-plus-style {  
  height: 70rpx;  
  width: 70rpx;  
  position: fixed;  
  bottom: 220rpx;  
  right: 30rpx;  
  opacity: 0.7
}  
.img-plus-style1 {  
  height: 70rpx;  
  width: 70rpx;  
  position: fixed;  
  bottom: 130rpx;  
  right: 30rpx;   
  opacity: 0.7
}  
.zindex100{z-index: 100}
.yc{opacity: 0}

2、index.wxml文件增加代码

<view>  
<contact-button type="default-dark" size="20" session-from="weapp" class="img-plus-style zindex100 yc">
</contact-button>
<image src="../../image/xk_kefu.png" class="img-plus-style"></image> 
<image src="../../image/xk_tel.png" class="img-plus-style1" bindtap="calling"></image>
</view>

3、index.js增加 一键拨号

calling: function () {
      wx.makePhoneCall({
        phoneNumber: '10086', 
      })
    },

4、把两个图标放在image目录下

xk_kefu.png xk_tel.png

内容参考:http://www.xkmov.net/jiaocheng/xiaochengxu/s294.html

原文地址:https://www.cnblogs.com/wangyuman26/p/8649029.html