|
@@ -1,3 +1,59 @@
|
|
|
|
+/**
|
|
|
|
+ * 获取用户信息 (用于兼用旧页面使用 ajaxUserInfo)
|
|
|
|
+ */
|
|
|
|
+function getNowUserInfo () {
|
|
|
|
+ $.post("/jypay/user/getSimpleData?t="+new Date().getTime(),{},function(r) {
|
|
|
|
+ if (r) {
|
|
|
|
+ Object.keys(ajaxUserInfo).forEach(function (v) {
|
|
|
|
+ if (r[v] && r[v] !== '') {
|
|
|
|
+ ajaxUserInfo[v] = r[v]
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ // 存储userId 大会员中标预测历史记录要用到
|
|
|
|
+ localStorage.setItem('BIGMEMBER_PC', r.userId)
|
|
|
|
+ }
|
|
|
|
+ typeof window.getUserInfoCallback === 'function' ? getUserInfoCallback() : null
|
|
|
|
+ }).fail(function () {
|
|
|
|
+ ajaxUserInfo = {
|
|
|
|
+ headImage: '',
|
|
|
|
+ nickName: '',
|
|
|
|
+ userId: '',
|
|
|
|
+ }
|
|
|
|
+ typeof window.getUserInfoCallback === 'function' ? getUserInfoCallback() : null
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+$(function () {
|
|
|
|
+ getNowUserInfo()
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 前往剑鱼客服
|
|
|
|
+ */
|
|
|
|
+function goCustomerUrl () {
|
|
|
|
+ $.post({
|
|
|
|
+ url: '/jyapi/social/obtainShunt',
|
|
|
|
+ contentType: 'application/json',
|
|
|
|
+ data: JSON.stringify({type: 'PC', isFind: true}),
|
|
|
|
+ success: function(res) {
|
|
|
|
+ if (res && res.data && res.data.url) {
|
|
|
|
+ location.href = res.data.url
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 前往客服页面 (兼容旧业务逻辑,检查登录状态)
|
|
|
|
+ */
|
|
|
|
+function checkCustomerService () {
|
|
|
|
+ // 登录判断
|
|
|
|
+ if (!loginflag) {
|
|
|
|
+ return openLoginDig()
|
|
|
|
+ }
|
|
|
|
+ goCustomerUrl()
|
|
|
|
+}
|
|
|
|
+
|
|
$(".jy_classify_list ul li").mouseenter(function(){
|
|
$(".jy_classify_list ul li").mouseenter(function(){
|
|
$(".jy_classify_list ul li").removeClass('active')
|
|
$(".jy_classify_list ul li").removeClass('active')
|
|
$(".jy_classify_list ul li div").hide()
|
|
$(".jy_classify_list ul li div").hide()
|
|
@@ -69,189 +125,15 @@ function scrollSideIconHide(el) {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-/**
|
|
|
|
- * 智齿客服相关初始化
|
|
|
|
- */
|
|
|
|
-var __registerSobotStatus = false
|
|
|
|
-var ajaxUserInfo = {
|
|
|
|
- headImage: '',
|
|
|
|
- nickName: '默认昵称',
|
|
|
|
- userId: '',
|
|
|
|
-}
|
|
|
|
|
|
|
|
-function registerSobotCustomerService (callback) {
|
|
|
|
- if (__registerSobotStatus) {
|
|
|
|
- return callback()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ;(function (w, d, e, x) {
|
|
|
|
- w[e] = function () { w.cbk = w.cbk || []; w.cbk.push(arguments); }
|
|
|
|
- x = d.createElement('script');
|
|
|
|
- x.async = true;
|
|
|
|
- x.id = 'zhichiScript';
|
|
|
|
- x.src = 'https://pc-jianyu.sobot.com/chat/frame/v2/entrance.js?sysnum=9d1e3980f91e4b75b8f04e2d206a4c76&t=' + new Date().getTime();
|
|
|
|
- d.body.appendChild(x);
|
|
|
|
- })(window, document, 'zc');
|
|
|
|
-
|
|
|
|
- function setConfig () {
|
|
|
|
- typeof window.getUserInfoCallback === 'function' ? getUserInfoCallback() : null
|
|
|
|
- console.log(JSON.stringify(ajaxUserInfo.userId + ajaxUserInfo.headImage))
|
|
|
|
- zc("config", {
|
|
|
|
- custom: false,
|
|
|
|
- auto_expand: false,
|
|
|
|
- show_face: 1,
|
|
|
|
- partnerid: ajaxUserInfo.userId,
|
|
|
|
- face: ajaxUserInfo.headImage || '',
|
|
|
|
- height: '640',
|
|
|
|
- async: false,
|
|
|
|
- manual: true
|
|
|
|
- })
|
|
|
|
- // zc("frame_manual", function (res) {
|
|
|
|
- // console.log("init sobot")
|
|
|
|
- // zc("offline_message_count",function(res){
|
|
|
|
- // // console.log(res, 'offline_message_count')
|
|
|
|
- // if (res && res.size && res.size > 0) {
|
|
|
|
- // var omc = res.size > 99 ? '99+' : res.size
|
|
|
|
- // $(".icon-badge-number").attr('data-badge-number', omc)
|
|
|
|
- // } else {
|
|
|
|
- // $(".icon-badge-number").removeAttr('data-badge-number')
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
- // })
|
|
|
|
- callback()
|
|
|
|
- }
|
|
|
|
- $.post("/jypay/user/getSimpleData?t="+new Date().getTime(),{},function(r) {
|
|
|
|
- if (r) {
|
|
|
|
- Object.keys(ajaxUserInfo).forEach(function (v) {
|
|
|
|
- if (r[v] && r[v] !== '') {
|
|
|
|
- ajaxUserInfo[v] = r[v]
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- // 存储userId 大会员中标预测历史记录要用到
|
|
|
|
- localStorage.setItem('BIGMEMBER_PC', r.userId)
|
|
|
|
- }
|
|
|
|
- setConfig()
|
|
|
|
- }).fail(function () {
|
|
|
|
- ajaxUserInfo = {
|
|
|
|
- headImage: '',
|
|
|
|
- nickName: '默认昵称',
|
|
|
|
- userId: '',
|
|
|
|
- }
|
|
|
|
- setConfig()
|
|
|
|
- })
|
|
|
|
- __registerSobotStatus = true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-function ajaxObtainShunt (isFind, callback) {
|
|
|
|
- $.post({
|
|
|
|
- url: '/jyapi/social/obtainShunt',
|
|
|
|
- type: 'POST',
|
|
|
|
- data: JSON.stringify({ type: 'PC', isFind: isFind }),
|
|
|
|
- contentType: 'application/json',
|
|
|
|
- success: function (res) {
|
|
|
|
- // 是否需要设置分流
|
|
|
|
- const needSetAjax = res.data.isShunt && !res.data.url
|
|
|
|
- if (needSetAjax) {
|
|
|
|
- return ajaxObtainShunt(false, callback)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const isUseNewJyCustomerService = res.data.isShunt && res.data.url && res.data.url !== 'zcpc' && !res.data.isOld
|
|
|
|
- callback(isUseNewJyCustomerService, res.data.url)
|
|
|
|
- },
|
|
|
|
- error: function () {
|
|
|
|
- callback(false)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-var callTm = null
|
|
|
|
-var callStatus = false
|
|
|
|
-var initSobotStatus = false
|
|
|
|
-function tryCallMaxCount (time) {
|
|
|
|
- if (callStatus) {
|
|
|
|
- return clearTimeout(callTm)
|
|
|
|
- }
|
|
|
|
- console.log('tryCallMaxCount')
|
|
|
|
- clearTimeout(callTm)
|
|
|
|
- if (!initSobotStatus) {
|
|
|
|
- zc("frame_manual", function (res) {
|
|
|
|
- console.log("init sobot status")
|
|
|
|
- initSobotStatus = true
|
|
|
|
- zc('frame_status', function(data) {
|
|
|
|
- console.log(data, 'sobot frame_status')
|
|
|
|
- if (typeof data === 'string') {
|
|
|
|
- openCustomDig = data === 'expand'
|
|
|
|
- callStatus = true
|
|
|
|
- clearTimeout(callTm)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- zc('frame_status', function(data) {
|
|
|
|
- console.log(data, 'sobot frame_status')
|
|
|
|
- if (typeof data === 'string') {
|
|
|
|
- openCustomDig = data === 'expand'
|
|
|
|
- callStatus = true
|
|
|
|
- clearTimeout(callTm)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- callTm = setTimeout(function () {
|
|
|
|
- tryCallMaxCount(time)
|
|
|
|
- }, time)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-function checkCustomerService () {
|
|
|
|
- // 登录判断
|
|
|
|
- if (!loginflag) {
|
|
|
|
- return openLoginDig()
|
|
|
|
- }
|
|
|
|
- // 检查智齿是否打开,需要关闭
|
|
|
|
- if (openCustomDig) {
|
|
|
|
- try {
|
|
|
|
- zc('frame_status', function(data) {
|
|
|
|
- console.log(data, 'click')
|
|
|
|
- openCustomDig = data === 'expand'
|
|
|
|
- })
|
|
|
|
- } catch (e) {}
|
|
|
|
- }
|
|
|
|
- // 检查分流状态
|
|
|
|
- ajaxObtainShunt(true, function (isNewJyCustomerService, link) {
|
|
|
|
- // 是否使用剑鱼客服
|
|
|
|
- if (isNewJyCustomerService) {
|
|
|
|
- window.open(link + '&mini=0')
|
|
|
|
- } else {
|
|
|
|
- registerSobotCustomerService(function () {
|
|
|
|
- callStatus = false
|
|
|
|
- tryCallMaxCount(150)
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
|
|
|
|
$(function () {
|
|
$(function () {
|
|
scrollSideIconHide()
|
|
scrollSideIconHide()
|
|
localStorage.removeItem('kf-shunt-data')
|
|
localStorage.removeItem('kf-shunt-data')
|
|
})
|
|
})
|
|
-var openCustomDig = false
|
|
|
|
-window.onmessage = function(e){
|
|
|
|
- if(e&&e.data&&e.data!== ''){
|
|
|
|
- try {
|
|
|
|
- var dd = JSON.parse(e.data);
|
|
|
|
- if(dd.name==='zc_post_message'){
|
|
|
|
- switch(dd.data.action){
|
|
|
|
- case 'chat_collapse_window':
|
|
|
|
- openCustomDig = false
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } catch (e) {
|
|
|
|
- // console.log('!not call message')
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
|
|
+/**
|
|
|
|
+ * 全局客服事件拦截(用于旧客服业务 open-customer 改造)
|
|
|
|
+ */
|
|
$(window).on('click', function (e) {
|
|
$(window).on('click', function (e) {
|
|
var openDom = $(e.target).hasClass('open-customer') || $(e.target).parents().hasClass('open-customer')
|
|
var openDom = $(e.target).hasClass('open-customer') || $(e.target).parents().hasClass('open-customer')
|
|
if (openDom) {
|
|
if (openDom) {
|
|
@@ -276,14 +158,6 @@ $(window).on('click', function (e) {
|
|
_hmt && _hmt.push(['_trackEvent','客服', 'click', '右侧客服问题测试']);
|
|
_hmt && _hmt.push(['_trackEvent','客服', 'click', '右侧客服问题测试']);
|
|
console.log('未初始化百度统计')
|
|
console.log('未初始化百度统计')
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- // 收起客服
|
|
|
|
- if (openCustomDig) {
|
|
|
|
- zc('frame_status', function(data) {
|
|
|
|
- console.log(data, 'click')
|
|
|
|
- openCustomDig = data === 'expand'
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
})
|
|
})
|
|
$(function () {
|
|
$(function () {
|