以下是添加客服按钮的代码,使用了微信官方提供的iconfont:

在CSS中定义样式:

.customer-service { position: fixed; right: 30rpx; bottom: 50rpx; display: flex; justify-content: center; align-items: center; border-radius: 50%; width: 50rpx; height: 50rpx; background-color: #fff; box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2); }

.iconfont { font-family: 'iconfont' !important; font-size: 30rpx; }

.icon-kefu:before { content: "\e61d"; }

在JS中处理点击事件:

handleCustomerService() { wx.openCustomerServiceConversation({ success: function() { console.log("打开客服会话成功"); }, fail: function() { console.log("打开客服会话失败"); } });


原文地址: https://www.cveoy.top/t/topic/gocz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录