")
messageJQ.hide().appendTo('body')
}
var timeoutMessage;
// 弹窗
function aleartMessage(value){
// 设置弹窗DOM与内容
messageInit(value)
// 显示弹窗
$('.ky-message').show()
// 判断是否有定时器
if(timeoutMessage){
window.clearTimeout(timeoutMessage)
}
// 定时后隐藏弹窗
timeoutMessage = window.setTimeout(function () {
$('.ky-message').hide()
}, 1000);
}
onMessage();
$(window).on('load', function () {
// 菜单初始化
menuInit();
//右边工具栏初始化
toolbarInit();
//导航菜单下划线初始化
menuUnderline()
//百度统计
baiduInit();
//APM性能
kyApmInit();
//导航登录按钮逻辑
handleLoginBtn();
//下载客户端按钮
downloadBtnInit();
// 底部增加点击事件
footerMenuInit();
// 上报侧边栏页面事件
reportEvents.page_official_site_sidebar()
});
function menuInit() {
$('#zlight-nav').zlightMenu({
transform: 'off',
fontSize: '16px'
});
var $nav = $(".ky-header");
$nav.toggleClass('scrolled', $(document).scrollTop() > $nav.height() * 2);
$(document).on('scroll', function () {
$nav.toggleClass('scrolled', $(this).scrollTop() > $nav.height() * 2);
});
$('#zlight-main-nav > li').each(function(i){
$(this).css({width: $(this).innerWidth(), padding: 0})
})
// 给 #zlight-submenu 下的 li 加点击事件:先执行自定义逻辑,再执行 a 标签跳转
$('.zlight-submenu').on('click', 'li:not(.zlight-dropdown)', function (e) {
e.preventDefault(); // 阻止 a 标签的默认跳转
e.stopPropagation(); // 阻止事件冒泡(避免影响父级菜单的展开/收起)
var $this = $(this);
var $link = $this.find('a');
var text = $link.text();
var href = $link.attr('href');
console.log('点击了 #zlight-submenu 下的 li', text, href);
// 埋点上报(先执行你的业务逻辑)
reportEvents.clk_pc_web_product_services_introduction_button(text);
// 业务逻辑执行完毕后,再手动触发 a 标签跳转
if (href && href !== '#' && href !== 'javascript:;' && href !== 'javascript:void(0)') {
window.location.href = href;
}
});
}
function footerMenuInit() {
// 给 #zlight-submenu 下的 li 加点击事件(使用事件委托,避免动态DOM导致事件丢失)
$('.menu-item-warp').on('click', 'li', function (e) {
e.preventDefault(); // 阻止 a 标签的默认跳转
e.stopPropagation(); // 阻止事件冒泡(避免影响父级菜单的展开/收起)
var $this = $(this);
var $link = $this.find('a');
var text = $link.text();
var href = $link.attr('href');
console.log('点击了 #footer-menu-item-warp 下的 li', text, href);
// 埋点上报
reportEvents.clk_pc_web_product_services_services_button(text)
// 业务逻辑执行完毕后,再手动触发 a 标签跳转
if (href && href !== '#' && href !== 'javascript:;' && href !== 'javascript:void(0)') {
window.location.href = href;
}
});
}
function isAllCardMode () {
// 判断是否是整车
let documentTitle = window.document.title
let isUat = window.location.host.includes('uat')
let isAllCard = isUat ? window.location.href.includes('187.html') : window.location.href.includes('187.html')
return documentTitle.includes('整车') || isAllCard
}
function toolbarInit() {
$('#goTop').on('click', function () {
$('body, html').animate({
scrollTop: 0
}, 300);
});
$('#aiService').on('click', function () {
if (isAllCardMode()) {
reportEvents.clk_new_website_product_introduction_vehicle_online_service_button('跨越整车')
} else {
reportEvents.clk_website_home_page_customer_service('运单查询')
}
var iWidth = 1145; //弹出窗口的宽度;
var iHeight = 780;
var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
//获得窗口的水平位置
var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
// var param = "height=".concat(iHeight, ", top=").concat(iTop, ", width=").concat(iWidth, ", left=").concat(iLeft, ", toolbar='no', menubar='no', scrollbars='no', resizable='no', location='no', status='no'");
var param = ""
var url = 'https://kuasheng-h5.kye-erp.com/ccms-jd-web/';
var params = {
source: 'WEB'
};
var keys = Object.keys(params).filter(function (k) {
return params[k];
}).sort();
var rawString = keys.reduce(function (str, cur) {
str += cur + params[cur];
return str;
}, '');
rawString += 'imcloudMethod';
params.sign = hex_md5(rawString).toUpperCase();
var paramsString = Object.keys(params).filter(function (k) {
return params[k];
}).map(function (k) {
return "".concat(k, "=").concat(params[k]);
}).join('&');
window.open("".concat(url, "?").concat(paramsString), '_blank', param);
});
}
// 侧边栏
function sidebarInit() {
$('.sidebar-dropdown > .title').on('click', function () {
if (!$(this).hasClass('link')){
var el = $(this).siblings('.sidebar-submenu');
// el.slideToggle()
if (el.hasClass('hide')) {
var siblings = $(this).parents().siblings();
el.slideDown(400).removeClass('hide');
$(this).find('.ky-arrow-up').removeClass('rotate');
siblings.find('.sidebar-submenu').slideUp(400).addClass('hide');
siblings.find('.ky-arrow-up').addClass('rotate');
} else {
el.slideUp(400).addClass('hide');
$(this).find('.ky-arrow-up').addClass('rotate');
}
}
});
$('.sidebar-submenu .item').on('click', function () {
$('.sidebar-submenu .item').removeClass('active');
$(this).addClass('active');
});
}
//二级tab
function tabInit() {
$('.ky-tab-item').on('click', function () {
if ($(this).hasClass('active')) return false;
$(this).addClass('active').siblings().removeClass('active');
});
}
//百度统计
function baiduInit() {
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?14abfe1895f1102e0c0811ad3bb1dbcc";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
}
//APM性能监控
function kyApmInit() {
var dsn = 'https://quickaplus-api-uat.ky-tech.com.cn:1443';
var appkey = 'p7o74xv9aryrsspw625wko3y';
var url = window.location.href;
/* 生产 */
if (url.indexOf('www.ky-express.com') > -1) {
dsn = 'https://quickaplus-api.ky-tech.com.cn'
appkey = '9g8nnoekoisjdn6kp01ceoq8'
}
void (function (e, t, n, a, o, i, m) {
(e._um_apm_namespace = o),
(e[o] =
e[o] ||
function () {
(e[o].q = e[o].q || []).push(arguments);
}),
(e[o].l = e[o].l || +new Date()),
(i = t.createElement(n)),
i.setAttribute('crossorigin', ''),
(i.src = a),
(m = t.getElementsByTagName(n)[0]),
m.parentNode.insertBefore(i, m);
})(window, document, "script", "https://g.alicdn.com/jssdk/apm/2.0.9/es5/uapm.iife.js", "_apm");
_apm('create',{
pid: appkey,
dsn: dsn,
pageFilter: { mode: 'ignore', rules: [] },
});
}
//导航登录按钮逻辑
function handleLoginBtn(){
var cookieVal = 'Login-data'
var userInfoStr = getCookie(cookieVal)
if(userInfoStr){
var userInfo = JSON.parse(decodeURIComponent(userInfoStr))
if(userInfo.token){
$('.login-btn').on('click',function(){
reportEvents.clk_website_home_page_Login_order('登录/下单')
window.open('https://uc.ky-express.com/#/admin/delivery?sourcePage=official_website&sourceAction=website_order', '_blank')
})
return
}
}
$('.login-btn').on('click',function(){
reportEvents.clk_website_home_page_Login_order('登录/下单')
var loginUrl = 'https://uc.ky-express.com/#/login/password?sourceFrom=website'
window.open(loginUrl, '_blank')
})
}
//获取cookie逻辑
function getCookie(cookieName){
var cookieValue="";
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i -1) {
baseUrl = 'http://api-uat.kyeapi.com/router/rest'
}
if(version.indexOf("Windows NT 5")!=-1 || version.indexOf('Windows XP') != -1){
link='https://ver1.ky-express.com/DATA/Upgrade/KYEClientSetup-0323.exe'
}else {
$.ajax(
{
url:baseUrl,
type:'post',
dateType:'json',
headers:{
'Content-Type':'application/json;charset=utf8',
'appkey':appkey,
'method':'web.version.versionManager.getVersionLink'
},
data: JSON.stringify({
packageType: 'pc'
}),
success:function(res){
if(res.data){
$(".clientDownload").on('click', function () {
window.location.href=res.data
})
}
},
error:function(err){
}
}
)
}
$(".clientDownload").on('click', function () {
reportEvents.clk_official_site_sidebar_download_client('下载客户端')
window.location.href=link
})
}