使用方法
<script>
(function(d, w, c) {
if (w[c]) return;
var s = d.createElement("script");
w[c] = function() { (w[c].z = w[c].z || []).push(arguments); };
s.async = true;
s.src = "https://kf.peiwanquan.com/widget.js";
if (d.head) d.head.appendChild(s);
})(document, window, "_CSWIDGET");
</script>
自定义配置
<script>
(function(d, w, c) {
if (w[c]) return;
var s = d.createElement("script");
w[c] = function(method) {
if (method === 'config') {
var params = arguments[1] || {};
for (var key in params) {
if (params.hasOwnProperty(key)) {
window['_' + c.toUpperCase() + '_CONFIG'][key] = params[key];
}
}
} else {
(w[c].z = w[c].z || []).push(arguments);
}
};
s.async = true;
s.src = "https://kf.peiwanquan.com/widget.js";
if (d.head) d.head.appendChild(s);
})(document, window, "_CSWIDGET");
_CSWIDGET('config', {
qrCodeUrl: 'https://your-domain.com/wechat-qr.png',
officialQrCodeUrl: 'https://your-domain.com/official-qr.png'
});
</script>
API 方法
_CSWIDGET('config', {...}) // 配置参数
_CSWIDGET('openChat') // 打开微信客服弹窗
_CSWIDGET('openOfficial') // 打开公众号弹窗
_CSWIDGET('closeModal', 'chat') // 关闭指定弹窗
_CSWIDGET('copy', 'xxx') // 复制文本
配置参数
{
qrCodeUrl: 'https://...', // 微信客服二维码
qrCodeTitle: '微信客服', // 客服弹窗标题
qrCodeDesc: '扫码添加客服', // 客服弹窗描述
officialQrCodeUrl: 'https://...', // 公众号二维码
officialQrCodeTitle: '微信公众号', // 公众号弹窗标题
officialQrCodeDesc: '扫码关注公众号' // 公众号弹窗描述
}
预览区域
客服按钮会在右下角显示(桌面端)或底部显示(移动端)