|
@@ -33,6 +33,7 @@ $(function () {
|
|
|
getNowUserInfo()
|
|
|
})
|
|
|
|
|
|
+var customerUrl = ''
|
|
|
/**
|
|
|
* 前往剑鱼客服
|
|
|
* conf.openNewWindow 新窗口打开
|
|
@@ -44,11 +45,17 @@ function goCustomerUrl (conf) {
|
|
|
data: JSON.stringify({type: 'PC', isFind: true}),
|
|
|
success: function(res) {
|
|
|
if (res && res.data && res.data.url) {
|
|
|
- if (conf && conf.openNewWindow) {
|
|
|
- window.open(res.data.url)
|
|
|
- } else {
|
|
|
- location.href = res.data.url
|
|
|
- }
|
|
|
+ // if (conf && conf.openNewWindow) {
|
|
|
+ // window.open(res.data.url)
|
|
|
+ // } else {
|
|
|
+ // location.href = res.data.url
|
|
|
+ // }
|
|
|
+ customerUrl = location.origin + res.data.url
|
|
|
+ var url = location.origin + res.data.url + '&from=aside'
|
|
|
+ // var url = '/page_pc_social/customer?userId=455b495c5c&userType=1&from=aside'
|
|
|
+ var iframe = '<iframe id="custom-iframe" src="' + url + '" name="_blank" marginwidth="0" marginheight="0" frameborder="0" width="100%" height="100%"></iframe>'
|
|
|
+ // 发送消息到 iframe
|
|
|
+ $('.mini-custom').prepend(iframe).show()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
@@ -142,6 +149,22 @@ function scrollSideIconHide(el) {
|
|
|
$(function () {
|
|
|
scrollSideIconHide()
|
|
|
localStorage.removeItem('kf-shunt-data')
|
|
|
+ // 接收聊天子页面发来的消息
|
|
|
+ window.addEventListener('message', function(event) {
|
|
|
+ console.log(event);
|
|
|
+ // 子页面发送来得消息是关闭或是全屏操作时 关闭当前侧边栏会话窗口
|
|
|
+ if (event.data && event.data.action) {
|
|
|
+ if (event.data.action === 'close') {
|
|
|
+ $('.mini-custom').hide()
|
|
|
+ $('#custom-iframe').remove()
|
|
|
+ } else if (event.data.action ==='fullScreen') {
|
|
|
+ $('.mini-custom').hide(function(){
|
|
|
+ $('#custom-iframe').remove()
|
|
|
+ window.open(customerUrl + '&mini=1')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, false);
|
|
|
})
|
|
|
/**
|
|
|
* 全局客服事件拦截(用于旧客服业务 open-customer 改造)
|