You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_php/public/pc/scripts/customerServer.js

515 lines
40 KiB

10 months ago
// 图片
var base64ImageObject = {
// 手机端客服图片
mobileIcon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEEAAABBCAYAAAH58PnTAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAQaADAAQAAAABAAAAQQAAAADfX4J5AAAWJ0lEQVR4AcVbC7BV1Xle+5xz4fIQIo9MeAUUiigPFV/BR2M6QVtJKjbT2tDJVGdipxOjUxhDFER5CwhC1dQxdaadmlIzYyqOoqPUmhELikoUNb4uRGuCSU0RLlxe95yz+33fv/699zn3SrhRp2u4e631P7//X4+999qHEArl4qfTysg76lXWBXJIvDP8jnpaqtdDGX9Wp6FtXh/xSxQafkctJdP+UtT2d+qiAyn5CU3vfLHaScYv5raQpjJx8YFQqtXDkNKAluSLa2rVUrVWLrpxdxSqpKFWOXlqqfX9rUc7S7D09vw+biicsWCv3J/Qa1CrgI1fejAtpynM18KEoUnY+UFVuGjxhRVDkiy6ibe2x+ggrCDS8MLKIXl09PH6ogHJ4PLAlpZ6qA3oPajFBTL/3hixNn3yi2uqT3qftUwNW5emjMKiY34sme/M75skw9elm8G80P1bDQEqpOmzFURxIZP39uxy6FU27BOXdITEAF9YKlMSf86k39cX9AMtunJ/Cx8/Sp7K6bfsMxxQTMYvO7QZfpswWE4q9fqzcnraov0p3ZSQWdUa6Xp4fhVSXCxnzfvoyXNu+t+ueSgKDfv7dHNg2JglVGc0CcdM/ZTtZ3fd2HpRUSdzM2xtPaVwAuFSQA0oWV9070eDMP7mLf2lr8vwNbVUivRGBRg4f1QI67+ZT9BTlh0Csty4kEH2NcyHZBTGGd6nBw5lNLLr+72KaBvakxZhtkPZ5UtJ2FThAIWUcSOMCLtBq6nDrCcuD2RcCApn3G2HU7fMcLQygWz91X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AAggqUwkk4CANHpgkkEEwCIYCmMpJMAQHS6YBLBBAAiWAoj6SQAEJ0umEQwAYAIlsJIOgkARKcLJhFMACCCpTCSTgIA0emCSQQTAIhgKYykkwBAdLpgEsEE/gf9UbX2kaDu0wAAAABJRU5ErkJggg=='
}
const settingObj = {};
//悬浮按钮样式
function customerServerStyle() {
//PC端悬浮按钮样式
this.customerServer_container = {
position: 'fixed',
bottom: '10px',
right: '2px',
// background: 'linear-gradient(270deg, #1890FF 0%, #3875EA 100%)',
// color: '#fff',
// 'border-radius': '4px',
// width: '230px',
// padding: '8px 10px',
'box-sizing': 'border-box',
cursor: 'pointer',
'z-index': 99
};
this.connect_customerServer = {
display: 'flex',
'align-items': 'center',
'justify-content': 'space-between',
};
this.connect_customerServer_img = {
width: '100%',
};
//移动端悬浮按钮样式
this.customerServer_container_mobile = {
position: 'fixed',
right: 0,
top: '500px',
margin: 'auto',
width: '40px',
height: '40px',
background: 'linear-gradient(270deg, #1890FF 0%, #3875EA 100%)',
'border-radius': '50%',
'z-index': 998
};
this.customerServer_container_mobile_image = {
width: '100%',
height: 'auto',
};
//未读消息演示
this.connent_count = {
position: 'absolute',
top: '-12px',
right: 0,
background: 'red',
width: '25px',
height: '25px',
'border-radius': '50%',
display: 'flex',
'align-items': 'center',
'justify-content': 'center',
'font-size': '12px',
opacity: '.9'
};
//iframe样式
this.iframe_content = {
position: 'fixed',
'z-index': 999,
right: 0,
'border-radius': '4px',
transition: '.3s',
}
}
const customerServerStyleObject = new customerServerStyle();
//初始化函数
function initCustomerServer(option) {
this.outLine = false; // 是否在离线界面
this.settingObj = settingObj;
this.settingObj.openUrl = `${option.openUrl || location.origin}/chat/index`; //服务器地址加路由, 若不传入则自动获取引入应用所在服务器的域名
this.settingObj.domId = option.customerServerTip || 'customerServerTip'; //浮动客服dom
this.settingObj.insertDomNode = option.insertDomNode || 'body' // 插入的标签
this.settingObj.token = option.token; // token为必填项
this.settingObj.pcIcon = option.pcIcon || base64ImageObject.pcIcon; // pcIcon 电脑端客服图片
this.settingObj.mobileIcon = option.mobileIcon || base64ImageObject.mobileIcon; // mobile 手机端客服图片
this.settingObj.deviceType = option.deviceType || ''; // Mobile 手机端打开
this.settingObj.isShowTip = option.isShowTip; // false隐藏 true 展示 客服悬浮按钮默认展示
this.settingObj.windowStyle = option.windowStyle || ''; // pc 端打开默认最精简模式,center居中模式
this.settingObj.kefuid = option.kefuid || 0; // 指定客服,默认随机
this.settingObj.sendUserData = option.sendUserData || {}; // 用户信息,默认游客
this.settingObj.productInfo = option.productInfo || {}; // 携带产品信息,默认空
this.appDom = null;
this.initStatus = false;//是否初始化过
// 判断当前环境下的设备是pc端 || 移动端, 将客户信息挂载到iframe的链接上
this.setMatchMedia = () => {
if (!this.settingObj.deviceType) {
const matchMedia = window.matchMedia;
// 自动判断启动端 pc 或是 移动
if (matchMedia('(max-width: 600px)').matches) {
this.settingObj.deviceType = 'Mobile';
} else if (matchMedia('(max-width: 992px)').matches) {
this.settingObj.deviceType = 'pc';
} else {
this.settingObj.deviceType = 'pc';
}
;
}
// console.log(this.settingObj.deviceType);
// 获取客服客户相关参数
let params = {
token: this.settingObj.token,
deviceType: this.settingObj.deviceType,
windowStyle: this.settingObj.windowStyle,
isShowTip: this.settingObj.isShowTip,
kefuid: this.settingObj.kefuid
};
this.settingObj.openUrl += `?` + toParams(params) + `&`;
let customerServerData = '';
if (this.settingObj.sendUserData && Object.keys(this.settingObj.sendUserData).length) {
customerServerData = toParams(this.settingObj.sendUserData);
this.settingObj.openUrl += `${customerServerData}&`;
}
}
// 创建 联系客服小弹窗按钮(点击时打开聊天界面),创建iframe容器 并将iframe添加至body中
this.createCustomerServerContainer = () => {
let iframeHtml = `<iframe src="${this.settingObj.openUrl}" frameborder="0" class="iframe_contanier" style="width:100%; height:100%;"></iframe>`;
var app = document.createElement('div');
this.appDom = app;
app.setAttribute('id', 'app');
if (this.settingObj.deviceType == 'Mobile') {
// 联系客服按钮dom结构 移动端悬浮按钮样式
let kefuMobilehtml = `
<div class="customerServer_container_mobile" id="${this.settingObj.domId}">
<img class="customerServer_container_mobile_image" src="${this.settingObj.mobileIcon}"></img>
<div class="connent_count"></div>
</div>
`;
app.innerHTML = kefuMobilehtml;
this.body = document.querySelector(this.settingObj.insertDomNode);
this.body.appendChild(app);
var fwuss = document.querySelector('.customerServer_container_mobile');
var maxW = document.body.clientWidth - 50;
var maxH = document.body.clientHeight - 50;
var oL, oT;
fwuss.addEventListener('touchstart', (e) => {
var ev = e || window.event;
var touch = ev.targetTouches[0];
oL = touch.clientX - fwuss.offsetLeft;
oT = touch.clientY - fwuss.offsetTop;
document.addEventListener("touchmove", defaultEvent, false);
})
fwuss.addEventListener('touchmove', (e) => {
var ev = e || window.event;
var touch = ev.targetTouches[0];
var oLeft = touch.clientX - oL;
var oTop = touch.clientY - oT;
if (oLeft < 0) {
oLeft = 0;
} else if (oLeft >= maxW) {
oLeft = maxW;
}
if (oTop < 0) {
oTop = 0;
} else if (oTop >= maxH) {
oTop = maxH;
}
fwuss.style.left = oLeft + 'px';
fwuss.style.top = oTop + 'px';
});
fwuss.addEventListener('touchend', function () {
document.removeEventListener("touchmove", defaultEvent);
});
function defaultEvent(e) {
e.preventDefault();
}
} else {
//电脑端悬浮按钮样式
let kefuhtml = `
<div class="customerServer_container" id="${this.settingObj.domId}">
<div class="connect_customerServer">
<img class="connect_customerServer_img" src="${this.settingObj.pcIcon}"></img>
</div>
<div class="connent_count"></div>
</div>
`;
app.innerHTML = kefuhtml;
this.body = document.querySelector(this.settingObj.insertDomNode);
this.body.appendChild(app);
}
// 创建完毕后,添加样式,样式可以从外部传入
this.iframeLayout = document.createElement('div');
this.iframeLayout.setAttribute('id', 'iframe_content');
this.setStyleOfCustomerServer(this.iframeLayout, customerServerStyleObject.iframe_content);
this.iframeLayout.style['z-index'] = 999;
this.iframeLayout.innerHTML = iframeHtml;
this.body.appendChild(this.iframeLayout);
// 获取联系客服按钮dom对象
this.connentServerDom = document.querySelector(`#${this.settingObj.domId}`);
// 判断联系客服按钮是否默认展示
if (this.settingObj.isShowTip === false) {
this.connentServerDom.style.display = 'none';
}
// 获取 iframe 弹框dom对象,便于后期数据交互
this.iframe_contanier = document.querySelector('.iframe_contanier');
}
// 设置基本样式样式
this.batchSetStyle = () => {
Object.keys(customerServerStyleObject).forEach(item => {
if (document.querySelector(`.${item}`)) {
this.setStyleOfCustomerServer(document.querySelector(`.${item}`), customerServerStyleObject[item]);
}
})
}
// 设置初始化样式,包括iframe弹宽初始定位,未读消息等
this.initPositionStyle = () => {
//移动端初始化样式
let mobileInitStyle = {
width: '100%',
height: '100%',
top: '100%',
left: 0
}
// pc端初始化样式
let pcInitStyle = {
width: '377px',
bottom: '-645px',
height: '645px',
'z-index': 999,
'box-shadow': '1px 1px 15px 0px rgba(0, 0, 0, 0.3)'
}
// 判断设备的类型,是移动端或是pc端
if (this.settingObj.deviceType == 'Mobile') {
this.setStyleOfCustomerServer(this.iframeLayout, mobileInitStyle);
} else {
this.setStyleOfCustomerServer(this.iframeLayout, pcInitStyle);
}
// 用来展示未读消息数的小圆点
this.connent_count = document.querySelector('.connent_count');
this.connent_count.style.display = 'none';
}
//加载聊天框
this.loadwindow = () => {
// 接收来自iframe中的参数
window.addEventListener("message", e => {
// 关闭弹框
if (e.data.type == 'closeWindow') {
if (this.settingObj.deviceType == 'Mobile') {
this.iframeLayout.style.top = '100%';
} else if (this.settingObj.windowStyle == 'center') {
this.setStyleOfCustomerServer(this.iframeLayout, {
display: 'none'
});
} else {
this.iframeLayout.style.bottom = '-645px';
this.iframeLayout.style.opacity = '0';
}
if (this.settingObj.isShowTip !== false) {
this.connentServerDom.style.display = 'block';
}
}
// 收取未读消息
if (e.data.type == 'message_num') {
if (e.data.num > 0) {
this.connent_count.style.display = 'flex';
this.connent_count.innerHTML = e.data.num;
} else {
this.connent_count.style.display = 'none';
}
}
// 跳转到离线留言界面
if (e.data.type == 'customerOutLine') {
this.outLine = true;
this.setStyleOfCustomerServer(this.iframeLayout, {
width: this.outLine ? '378px' : '730px',
})
}
// 监听,跳转回中间页,重置outline(来自反馈成功界面)
if (e.data.type == 'reload') {
this.outLine = false;
}
});
};
// 打开客服聊天框
this.getCustomeServer = () => {
//检测是否初始化过
if(this.initStatus === false){
this.init();
}
if (this.settingObj.deviceType == 'Mobile') {
this.iframeLayout.style.top = '0';
} else if (this.settingObj.windowStyle == 'center') {
this.setStyleOfCustomerServer(this.iframeLayout, {
top: 0,
left: 0,
bottom: 0,
right: 0,
margin: 'auto',
width: this.outLine ? '378px' : '730px',
display: 'block',
transition: 'none',
'border-radius': '8px',
overflow: 'hidden',
'box-shadow': '1px 1px 15px 0px rgba(0, 0, 0, 0.3)'
});
} else {
this.iframeLayout.style.bottom = 0;
this.iframeLayout.style.opacity = '1';
}
//悬浮按钮隐藏
this.connentServerDom.style.display = 'none';
this.iframe_contanier.contentWindow.postMessage({
type: 'getImgOrText',
productInfo: this.settingObj.productInfo
}, "*"); // 传送图文数据
this.iframe_contanier.contentWindow.postMessage({type: 'openCustomeServer'}, "*"); //通知iframe 打开了客服弹框
}
// 更新传送的图文信息
this.postProductMessage = (productInfo) => {
this.iframe_contanier.contentWindow.postMessage({type: 'getImgOrText', productInfo: productInfo}, "*"); // 传送图文数据
}
}
initCustomerServer.prototype.destroy = function(){
this.appDom.remove()
this.iframeLayout.remove();
this.initStatus = false;
}
//初始化
initCustomerServer.prototype.init = function () {
this.setMatchMedia();
this.createCustomerServerContainer();
this.batchSetStyle();
this.initPositionStyle();
this.loadwindow();
this.initStatus = true;
this.connentServerDom.removeEventListener('click',this.getCustomeServer);
// 联系客服小按钮,点击事件
this.connentServerDom.addEventListener('click', this.getCustomeServer)
};
//封装全局设置样式方法
initCustomerServer.prototype.setStyleOfCustomerServer = function (dom, styleObj) {
Object.keys(styleObj).forEach(item => {
dom['style'][item] = styleObj[item]
})
};
//封装全局获取openUle方法
initCustomerServer.prototype.getOpenUrl = function () {
return this.settingObj.openUrl;
}
//vue 开发调试专用,vue开发请去掉下一行注释
// export default initCustomerServer;
// let useCustomerServer = new initCustomerServer(option);
// useCustomerServer.init();
// 生成指定范围内的随机数
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function ajax(options) {
var xhr = null;
var params = options.data;
//创建对象
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest()
} else {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
switch (options.type) {
case 'GET':
xhr.open(options.type, options.url + "?" + params, options.async);
xhr.send(null);
break;
case 'POST':
xhr.open(options.type, options.url, options.async);
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xhr.setRequestHeader("Authori-zation", `Bearer ${token}`);
xhr.send(JSON.stringify(params));
break;
default:
break;
}
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
options.success(xhr.responseText);
}
}
}
// 将Object 改装成以 & 符号连接的字符串
function toParams(param) {
var result = ""
for (let name in param) {
if (typeof param[name] != 'function') {
result += "&" + name + "=" + encodeURI(param[name]);
}
}
return result.substring(1)
}
//set session
function setSen(k, val) {
if (typeof val == 'string') {
sessionStorage.setItem(k, val);
return val;
}
sessionStorage.setItem(k, JSON.stringify(val));
return val;
}
//get session
function getSen(k) {
let uu = sessionStorage.getItem(k);
try {
if (typeof JSON.parse(uu) != 'number') {
uu = JSON.parse(uu);
}
} catch (e) {
}
return uu;
}
//set local
function setLoc(k, val) {
if (typeof val == 'string') {
localStorage.setItem(k, val);
return val;
}
localStorage.setItem(k, JSON.stringify(val));
return val;
}
//get local
function getLoc(k) {
let uu = localStorage.getItem(k);
try {
if (typeof JSON.parse(uu) != 'number') {
uu = JSON.parse(uu);
}
} catch (e) {
}
return uu;
}
//序列化对象和数组
function serialize(data) {
if (data != null && data != '') {
try {
return JSON.parse(JSON.stringify(data));
} catch (e) {
if (data instanceof Array) {
return [];
}
return {};
}
}
return data;
}