You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
773 lines
28 KiB
JavaScript
773 lines
28 KiB
JavaScript
var JX = window.JX || {};
|
|
JX.HOST = window.location.protocol + '//' + window.location.host;
|
|
(function(JX){
|
|
var gl = function() {
|
|
this.authShopMap = {};
|
|
}, $self;
|
|
JX.autoInterval = false;
|
|
var realHost = JX.HOST;
|
|
var dcRegExp = new RegExp('dc\\.|pre-dc\\.', 'i');
|
|
if (dcRegExp.test(JX.HOST)) {
|
|
realHost = JX.HOST.replace(dcRegExp, '');
|
|
}
|
|
var acUrl = {
|
|
getMallnfoUrl : realHost + '/common/overall/mall_info',
|
|
heartbeat : JX.HOST + '/common/overall/keepAlive',
|
|
getNoticeBannerUrl : JX.HOST + '/common/overall/get_notice_banner',
|
|
saveBannerClickLog : JX.HOST + '/common/overall/saveBannerClickLog',
|
|
getPopupBannerUrl : JX.HOST + '/common/overall/get_popup_banner',
|
|
switchPurchaseVersion : JX.HOST + '/common/overall/switch_purchase_version',
|
|
checkIsNeedShowOutstorageTip : JX.HOST + '/common/overall/checkIsNeedShowOutstorageTip',
|
|
};
|
|
gl.prototype = {
|
|
mallInfo : function(){
|
|
$.ajax({
|
|
url : acUrl.getMallnfoUrl,
|
|
dataType : 'json',
|
|
xhrFields : {
|
|
withCredentials : true
|
|
},
|
|
crossDomain: true,
|
|
}).done(function(ret){
|
|
$('.J_presentNumSurplus').html(ret.presentNumSurplus);
|
|
$('.J_moveAttachTotalSurplus').html(ret.moveAttachTotalSurplus);
|
|
|
|
if (ret.moveSpeedTotalSurplus) {
|
|
$('.J_moveSpeedTotalSurplus').html('提速包:<span class="lightyellow">' + ret.moveSpeedTotalSurplus + '</span> 个');
|
|
}
|
|
|
|
var qqGroupLinkBox = $(".J_qqGroupLinkBox");
|
|
if (!ret.isExtSpyMall) {
|
|
qqGroupLinkBox.removeClass('hidden');
|
|
} else {
|
|
if (qqGroupLinkBox.attr('href').length > 0 && qqGroupLinkBox.attr('data-ExtSpyMallHref')) {
|
|
qqGroupLinkBox.attr('href', qqGroupLinkBox.attr('data-ExtSpyMallHref'));
|
|
}
|
|
}
|
|
|
|
if (ret.isMallExpire > 0) {
|
|
return layer.alert('当前店铺授权失效,请退出重新授权登录', 0, function() {
|
|
window.location.href = ret.refUrl;
|
|
});
|
|
}
|
|
});
|
|
|
|
function getSmsTotal (){
|
|
$.ajax({
|
|
url : JX.HOST + '/crm/sms_assigned/get_mall_sms_total',
|
|
method: 'get',
|
|
dataType : 'jsonp',
|
|
jsonp: 'callback',
|
|
jsonpCallback: 'JX.global.venderSmsTotal',
|
|
success: function(ret){
|
|
ZcLog.log(ret);
|
|
}
|
|
});
|
|
};
|
|
getSmsTotal();
|
|
},
|
|
venderSmsTotal : function(ret){
|
|
$('.J_totalSmsNumInfo').html(ret.smsTotalNum);
|
|
},
|
|
heartbeat : function(){
|
|
$.post(acUrl.heartbeat);
|
|
},
|
|
|
|
processVenderNeedSmsNum : function(haveSmsCallback) {
|
|
var iid = layer.load();
|
|
$.ajax({
|
|
url : JX.HOST + '/crm/sms_assigned/get_mall_sms_total',
|
|
dataType : 'json'
|
|
}).always(function(){
|
|
layer.close(iid);
|
|
}).done(function(ret){
|
|
if (ret.smsTotalNum <= 0) {
|
|
JX.global.processNotSms();
|
|
} else {
|
|
haveSmsCallback();
|
|
}
|
|
}).fail(function(){
|
|
layer.alert('请求失败,请稍后再尝试');
|
|
});
|
|
},
|
|
processNotSms : function() {
|
|
$.ajax({
|
|
url : JX.HOST + '/crm/order_care/check_show_tips',
|
|
method:'post',
|
|
dataType:'json',
|
|
}).done(function(ret){
|
|
if (ret.showTips) {
|
|
$('.J_topTipsBox').removeClass('hide');
|
|
}
|
|
});
|
|
$('#J_smsRechargeBox').modal({"keyboard" : false});
|
|
},
|
|
|
|
init : function(){
|
|
$self = this;
|
|
// setTimeout(function(){
|
|
// JX.global.mallInfo();
|
|
// }, 2000);
|
|
setTimeout(function(){
|
|
JX.global.checkIsNeedShowOutstorageTip();
|
|
}, 2000);
|
|
|
|
setInterval(JX.global.heartbeat, 300000);
|
|
$(document).on('keydown', '.J_setValidNumber', JX.global.setValidNumber);
|
|
$(document).on('keydown', '.J_setValidDottedNumber', JX.global.setValidDottedNumber);
|
|
|
|
if ($('.J_datetimePicker').length > 0) {
|
|
JX.global.datetimepicker($('.J_datetimePicker'));
|
|
}
|
|
if ($('.J_timePicker').length > 0) {
|
|
var def = {language: 'zh-cn',format: 'HH:mm:ss', pickDate: false, useSeconds: true};
|
|
$('.J_timePicker').datetimepicker(def);
|
|
}
|
|
|
|
$(document).on('click', '.J_switchPurchaseVersion', JX.global.switchPurchaseVersion);
|
|
|
|
JX.global.copyClipboard();
|
|
JX.global.initNoticeBanner();
|
|
JX.global.initPopupBanner();
|
|
},
|
|
|
|
initCrxPluginTipPane: function() {
|
|
if ($('.J_crxPluginTipPane').length <= 0) {
|
|
return false;
|
|
}
|
|
|
|
var pluginType = $('.J_crxPluginTipPane').data('type');
|
|
if (pluginType == 'fetch') {
|
|
var version = $("#J_newMsOrderChromeExtReady").data('version');
|
|
}
|
|
|
|
if (!version) {
|
|
$('.J_crxPluginTipPane').removeClass('hide');
|
|
}
|
|
|
|
$('.J_crxPluginTipPane').on('click', '.J_close', function() {
|
|
$('.J_crxPluginTipPane').hide();
|
|
var cookieKey = $(this).data('cookieKey');
|
|
if (!cookieKey) {
|
|
return;
|
|
}
|
|
JX.global.setCookie(cookieKey, 1, 7);
|
|
})
|
|
},
|
|
|
|
setCookie: function(cookieName, cookieValue, expireDays) {
|
|
var exDate = new Date();
|
|
exDate.setDate(exDate.getDate() + expireDays);
|
|
document.cookie = cookieName + "=" + escape(cookieValue) + ((expireDays==null) ? ";expires=Fri, 31 Dec 9999 23:59:59 GMT" : ";expires="+exDate.toGMTString());
|
|
},
|
|
|
|
switchPurchaseVersion: function() {
|
|
var iid = layer.load();
|
|
$.ajax({
|
|
url: acUrl.switchPurchaseVersion,
|
|
method: 'get',
|
|
dataType: 'json'
|
|
}).done(function(ret) {
|
|
window.location.reload();
|
|
});
|
|
},
|
|
|
|
datetimepicker : function($obj, opt){
|
|
var def = {language: 'zh-cn',format: 'YYYY-MM-DD HH:mm:ss', useSeconds : true, sideBySide : true, };
|
|
if($.type($obj) == 'object') {
|
|
def = $.extend(def, opt);
|
|
}
|
|
if($.type($obj) == 'object'){
|
|
$obj.datetimepicker(def);
|
|
}
|
|
},
|
|
|
|
copyClipboard : function (){
|
|
try {
|
|
var clipboard = new ClipboardJS('.J_copyClipboard', {
|
|
});
|
|
|
|
clipboard.on('success', function(e) {
|
|
var tip = $(e.trigger).data('clipboard-tip');
|
|
tip = tip ? tip : '已复制';
|
|
var layerId = layer.tips(tip, $(e.trigger), {
|
|
style: ['background-color:#000000; color:#fff;', '#000000']
|
|
});
|
|
setTimeout(function(){
|
|
layer.close(layerId);
|
|
}, 1000);
|
|
$(e.trigger).blur();
|
|
});
|
|
|
|
clipboard.on('error', function(e) {
|
|
var layerId = layer.tips('复制失败', $(e.trigger), {
|
|
style: ['background-color:#ff0000; color:#fff;', '#ff0000']
|
|
});
|
|
setTimeout(function(){
|
|
layer.close(layerId);
|
|
}, 1000);
|
|
$(e.trigger).blur();
|
|
});
|
|
} catch(e) {
|
|
}
|
|
},
|
|
|
|
setValidNumber : function(event){
|
|
if(event.data && event.data.maxLen > 0) {
|
|
var numberLength = event.data.maxLen;
|
|
}else{
|
|
var numberLength = 10;
|
|
}
|
|
|
|
var curCode = event.keyCode || event.charCode;
|
|
var enableArray = new Array(48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,46,8,37,39);
|
|
var controlArray = new Array(8,46,37,39);//左右键和删除键
|
|
if($.inArray(curCode, enableArray) == -1){
|
|
event.preventDefault();
|
|
return;
|
|
}
|
|
if(($.inArray(curCode, controlArray) == -1) && (this.value.length >= numberLength)){ //当数字达到规定长度且非控制键
|
|
this.value=this.value.substr(0, numberLength - 1);
|
|
}
|
|
},
|
|
setValidDottedNumber : function(event){
|
|
if(event.data && event.data.maxLen > 0) {
|
|
var numberLength = event.data.maxLen;
|
|
}else{
|
|
var numberLength = 10;
|
|
}
|
|
var curCode = event.keyCode || event.charCode;
|
|
var enableArray = new Array(48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,46,8,37,39,110,190);
|
|
var controlArray = new Array(8,46,37,39);//左右键和删除键
|
|
if(($.inArray(curCode, enableArray) == -1) || ((curCode == 110 || curCode == 190) && (this.value.indexOf(".") != -1))){ //只能有一个点
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
if(($.inArray(curCode, controlArray) == -1) && (this.value.length >= numberLength)){ //当数字达到规定长度且非控制键
|
|
this.value=this.value.substr(0, numberLength - 1);
|
|
}
|
|
},
|
|
|
|
initNoticeBanner: function() {
|
|
var self = this, keys = [], $banners = $('[data-toggle="noticeBanner"]');
|
|
$.each($banners, function(){
|
|
var key = $(this).data('key');
|
|
if (_.isEmpty(key)) {
|
|
return ;
|
|
}
|
|
keys.push(key);
|
|
});
|
|
if (keys.length == 0) {
|
|
return ;
|
|
}
|
|
var valueMap = {'keys': keys};
|
|
($('#J_privewBannerKey').length > 0) && (valueMap['privewBannerKey'] = $('#J_privewBannerKey').val())
|
|
$banners.hide();
|
|
$.ajax({
|
|
url: acUrl.getNoticeBannerUrl,
|
|
data: valueMap,
|
|
method: 'get',
|
|
dataType: 'json'
|
|
}).done(function(bRet) {
|
|
$banners.hide();
|
|
if (bRet.result == 'fail') {
|
|
return false;
|
|
}
|
|
var bannerHasClickImgUrlsMap = bRet.bannerHasClickImgUrlsMap;
|
|
!_.isEmpty(bRet.banners) && $.each(bRet.banners, function(key, banner) {
|
|
var $cn = $(banner['content']);
|
|
var $items = $cn.find('.carousel-inner .item');
|
|
if ($items.length > 0) {
|
|
var isRandomShow = banner['is_random_show'];
|
|
var helpBannerId = banner['help_banner_id'];
|
|
var startI = JX.global.getBannerStartItemIndex($items, bannerHasClickImgUrlsMap[helpBannerId], isRandomShow);
|
|
$cn.find('.carousel-inner .item').removeClass('active').eq(startI).addClass('active');
|
|
$cn.find('.carousel-inner .item').data('helpBannerId', helpBannerId);
|
|
$cn.find('.carousel-inner .item').on('click', 'area,a', JX.global.saveBannerClickLog);
|
|
}
|
|
|
|
var $item = $('[data-toggle="noticeBanner"][data-key="'+key+'"]'), radius = $item.data('radius') || '';
|
|
radius && $cn.css('border-radius', radius);
|
|
|
|
if(key == 'INDEXEXPIRENOTICE'){
|
|
$item.find('.J_noticeBannerContent').html(banner['content']);
|
|
$item.find('.J_noticeBannerClose').data('helpBannerId', banner.help_banner_id)
|
|
.on('click', JX.global.saveBannerClickLog).on('click',function () {$item.remove();});
|
|
}else{
|
|
$item.html($cn);
|
|
}
|
|
$item.show();
|
|
});
|
|
});
|
|
},
|
|
|
|
initPopupBanner: function () {
|
|
var $popupBanner = $('[data-toggle="popupBanner"]');
|
|
if ($popupBanner.length === 0) {
|
|
return ;
|
|
}
|
|
$.ajax({
|
|
url: acUrl.getPopupBannerUrl,
|
|
method: 'get',
|
|
dataType: 'json'
|
|
}).done(function(ret) {
|
|
if (ret['result'] == 'fail' || !ret['html']) {
|
|
return false;
|
|
}
|
|
var html = ret['html'];
|
|
var iid = $.layer({
|
|
type: 1,
|
|
title: false,
|
|
area: ['auto','auto'],
|
|
border: [0],
|
|
bgcolor: '',
|
|
shade: [0.5, '#000'],
|
|
closeBtn: false,
|
|
shadeClose: false,
|
|
shift: 'top',
|
|
page: {
|
|
html: html
|
|
}
|
|
});
|
|
$(document).on('click', '#closePopupBannerBtn', function () {
|
|
layer.close(iid);
|
|
});
|
|
});
|
|
},
|
|
|
|
getBannerStartItemIndex: function ($items, hasClickImgUrls, isRandomShow) {
|
|
if (0 == isRandomShow || '0' == isRandomShow) {
|
|
return 0;
|
|
}
|
|
if ($items.length < 2) {
|
|
return 0;
|
|
}
|
|
hasClickImgUrls = isEmpty(hasClickImgUrls) ? [] : hasClickImgUrls;
|
|
|
|
var hasClickIndexList = [], notClickIndexList = [];
|
|
$.each($items, function(itemIndex, item) {
|
|
var imgUrl = $(item).find('img').eq(0).attr('src');
|
|
if ($.inArray(imgUrl, hasClickImgUrls) === -1) {
|
|
notClickIndexList.push(itemIndex);
|
|
} else {
|
|
hasClickIndexList.push(itemIndex);
|
|
}
|
|
});
|
|
|
|
// 所有图片都被点击过或者都未点击过, 直接从itemList 中随机返回一个索引
|
|
if ((notClickIndexList.length == 0) || (hasClickImgUrls.length == 0)) {
|
|
return Math.floor(Math.random() * $items.length);
|
|
}
|
|
|
|
var rd = Math.random();
|
|
var j;
|
|
if (rd <= 0.333333333) {
|
|
j = Math.floor(Math.random() * hasClickIndexList.length);
|
|
return hasClickIndexList[j];
|
|
}
|
|
|
|
j = Math.floor(Math.random() * notClickIndexList.length);
|
|
return notClickIndexList[j];
|
|
},
|
|
|
|
saveBannerClickLog : function(e) {
|
|
var key = $(this).parent().data('key');
|
|
var helpBannerId = 0;
|
|
if(key && key == 'INDEXEXPIRENOTICE'){
|
|
helpBannerId = $(this).data('helpBannerId');
|
|
}else {
|
|
var $triggerItem = $(this).closest('.carousel-inner .item');
|
|
var itemIndex = $triggerItem.index();
|
|
var imgUrl = $triggerItem.find('img').eq(0).attr('src');
|
|
helpBannerId = $triggerItem.data('helpBannerId');
|
|
if (undefined === itemIndex) {
|
|
return '';
|
|
}
|
|
if (-1 === itemIndex) {
|
|
return '';
|
|
}
|
|
}
|
|
if (undefined === helpBannerId) {
|
|
return '';
|
|
}
|
|
$.ajax({
|
|
method : 'post',
|
|
url : acUrl.saveBannerClickLog,
|
|
dataType : 'json',
|
|
data:{'helpBannerId':helpBannerId,'itemIndex':itemIndex, 'imgUrl':imgUrl},
|
|
}).done(function(ret) {
|
|
ZcLog.log(ret);
|
|
});
|
|
},
|
|
toppingBar: function() {
|
|
function showOrHideBarCallback() {
|
|
var bodyClientHeight = document.body.clientHeight;
|
|
var clientHeight = document.documentElement.clientHeight;
|
|
if (bodyClientHeight > clientHeight) {
|
|
$('#J_toppingBarBox').show();
|
|
} else {
|
|
$('#J_toppingBarBox').hide();
|
|
}
|
|
}
|
|
$(window).resize(showOrHideBarCallback);
|
|
$(window).scroll(showOrHideBarCallback);
|
|
},
|
|
attachPddOrderDecryptParams: function (params) {
|
|
params = params || {};
|
|
params.pdd_control_type = 'pdd_std_dp_decrypt';
|
|
params.client_id = $('#J_clientId').val();
|
|
if (!params.hasOwnProperty('outer_platform')) {
|
|
params.outer_platform = JX.global.getPddOuterPlatformId(params.purchasePlatform);
|
|
}
|
|
if (!params.hasOwnProperty('mall_id')) {
|
|
params.mall_id = params.mallId || $('#J_mallId').val();
|
|
}
|
|
return params;
|
|
},
|
|
getMallId: function (orderId, callback) {
|
|
$.ajax({
|
|
url : JX.HOST + '/order/order/getMallId',
|
|
method:'get',
|
|
data: {
|
|
orderId: orderId
|
|
},
|
|
dataType:'json',
|
|
}).done(function(ret) {
|
|
if (ret.result != 'success') {
|
|
return layer.alert(ret.reason);
|
|
}
|
|
typeof callback === 'function' && callback(ret.mallId);
|
|
});
|
|
},
|
|
getPddOuterPlatformId: function (platform) {
|
|
var platformAndOuterPlatformIdMap = {
|
|
'taobao': 0,
|
|
'tmall': 0,
|
|
'jd': 1,
|
|
'1688': 2,
|
|
'wsy': 9,
|
|
'sooxie': 12,
|
|
'vvic': 11,
|
|
'17qcc': 17,
|
|
'zhe800': 15,
|
|
'17zwd': 13,
|
|
'hznzcn': 14,
|
|
'k3': 18,
|
|
'xingfujie': 19,
|
|
};
|
|
return platformAndOuterPlatformIdMap.hasOwnProperty(platform) ? platformAndOuterPlatformIdMap[platform] : 7;
|
|
},
|
|
checkIsNeedShowOutstorageTip: function () {
|
|
$.ajax({
|
|
url : acUrl.checkIsNeedShowOutstorageTip,
|
|
dataType:'json',
|
|
}).done(function(ret) {
|
|
if (ret.result != 'success') {
|
|
return false;
|
|
}
|
|
if (ret.isNeedShowOutstorageTip) {
|
|
$('#J_showOutstorageTipModal').find('.J_redirectUrl').attr('href', ret.redirectUrl);
|
|
$('#J_showOutstorageTipModal').modal('show');
|
|
}
|
|
});
|
|
},
|
|
}
|
|
JX.global = new gl();
|
|
})(window.JX);
|
|
$(function(){
|
|
InitiateWidgets();
|
|
InitiateSideMenu();
|
|
JX.global.init();
|
|
});
|
|
|
|
$(function(){
|
|
$(document).ajaxSend(function(e, xhr, options) {
|
|
var header = $('meta[name="_zc_csrf_param"]').prop("content") || 'X-CSRF-Token';
|
|
var token = $('meta[name="_zc_csrf_token"]').prop("content") || '';
|
|
xhr.setRequestHeader(header, token);
|
|
xhr.setRequestHeader('X-PDD-Pati', $('meta[name="X-PDD-Pati"]').prop("content"));
|
|
xhr.setRequestHeader('X-PDD-PageCode', $('meta[name="X-PDD-PageCode"]').prop("content"));
|
|
});
|
|
$.ajaxSetup({ cache: false });
|
|
});
|
|
function InitiateWidgets() {
|
|
$('.widget-buttons *[data-toggle="maximize"]').on("click", function(n) {
|
|
n.preventDefault();
|
|
var t = $(this).parents(".widget").eq(0),
|
|
i = $(this).find("i").eq(0),
|
|
r = "fa-compress",
|
|
u = "fa-expand";
|
|
t.hasClass("maximized") ? (i && i.addClass(u).removeClass(r), t.removeClass("maximized"), t.find(".widget-body").css("height", "auto")) : (i && i.addClass(r).removeClass(u), t.addClass("maximized"), maximize(t))
|
|
});
|
|
$('.widget-buttons *[data-toggle="collapse"]').on("click", function(n) {
|
|
n.preventDefault();
|
|
var t = $(this).parents(".widget").eq(0),
|
|
r = t.find(".widget-body"),
|
|
i = $(this).find("i"),
|
|
u = "fa-plus",
|
|
f = "fa-minus",
|
|
e = 300;
|
|
t.hasClass("collapsed") ? (i && i.addClass(f).removeClass(u), t.removeClass("collapsed"), r.slideUp(0, function() {
|
|
r.slideDown(e)
|
|
})) : (i && i.addClass(u).removeClass(f), r.slideUp(200, function() {
|
|
t.addClass("collapsed")
|
|
}))
|
|
});
|
|
$('.widget-buttons *[data-toggle="dispose"]').on("click", function(n) {
|
|
n.preventDefault();
|
|
var i = $(this),
|
|
t = i.parents(".widget").eq(0);
|
|
t.hide(300, function() {
|
|
t.remove()
|
|
})
|
|
})
|
|
}
|
|
function InitiateSideMenu() {
|
|
var $cur = $('#J_sidebar ul.sidebar-menu>li.open') || $('#J_sidebar ul.sidebar-menu>li.active');
|
|
$cur.length && $cur.addClass('J_isCur');
|
|
|
|
$("#J_sidebarCollapse").on("click", function() {
|
|
var $t = $(this);
|
|
var faLeftClass = 'fa-arrow-left';
|
|
var faRightClass = 'fa-arrow-right';
|
|
if ($t.data('faLeft')) {
|
|
faLeftClass = $t.data('faLeft');
|
|
}
|
|
if ($t.data('faRight')) {
|
|
faRightClass = $t.data('faRight');
|
|
}
|
|
var headerLogoObj = $t.parent().find('.navbar-header-logo');
|
|
if (!$("#J_sidebar").hasClass("menu-compact")){
|
|
$t.parent().addClass('menu-compact');
|
|
headerLogoObj.attr('src', headerLogoObj.data('smallLogo'));
|
|
$('.page-container .page-title').addClass('menu-compact');
|
|
|
|
$t.addClass("active").find('i.collapse-icon').removeClass(faLeftClass).addClass(faRightClass);
|
|
$("#J_sidebar").addClass('menu-compact');
|
|
$(".J_sidebar > li").removeClass("open");
|
|
} else {
|
|
$t.parent().removeClass('menu-compact');
|
|
headerLogoObj.attr('src', headerLogoObj.data('bigLogo'));
|
|
$('.page-container .page-title').removeClass('menu-compact');
|
|
|
|
$(".J_sidebar > li").addClass("open");
|
|
$("#J_sidebar").removeClass('menu-compact');
|
|
$t.removeClass("active").find('i.collapse-icon').removeClass(faRightClass).addClass(faLeftClass);;
|
|
}
|
|
});
|
|
var n = $("#sidebar").hasClass("menu-compact");
|
|
$(".sidebar-menu").on("click", function(t) {
|
|
var i = $(t.target).closest("a"),
|
|
u, r, f;
|
|
if (i && i.length != 0) {
|
|
if (!i.hasClass("menu-dropdown")) {
|
|
return n && i.get(0).parentNode.parentNode == this && (u = i.find(".menu-text").get(0), t.target != u && !$.contains(u, t.target)) ? !1 : void 0;
|
|
}
|
|
if (r = i.next().get(0), !$(r).is(":visible")) {
|
|
if (f = $(r.parentNode).closest("ul"), n && f.hasClass("sidebar-menu")) return;
|
|
f.find("> .open > .submenu").each(function() {
|
|
this == r || $(this.parentNode).hasClass("active") || $(this).slideUp(200).parent().removeClass("open")
|
|
})
|
|
}
|
|
return n && $(r.parentNode.parentNode).hasClass("sidebar-menu") ? !1 : ($(r).slideToggle(200).parent().toggleClass("open"), !1)
|
|
}
|
|
});
|
|
|
|
var navbarHoverT = null;
|
|
$(".J_topNavbarMenu").on('mouseenter', function(){
|
|
var $t = $(this);
|
|
navbarHoverT = setTimeout(function() {
|
|
clearTimeout(navbarHoverT);
|
|
var d = $t.parent().position(), e = $t.position(), g = $t.find(".dropdown-menu"), w = g.outerWidth();
|
|
var pw = $t.parent().outerWidth();
|
|
var maxWidth = pw > w ? pw : w;
|
|
g.css({
|
|
'max-width': maxWidth + "px"
|
|
});
|
|
|
|
$t.toggleClass('open');
|
|
$t.find('i.fa').removeClass("fa-angle-down").addClass("fa-angle-up");
|
|
}, 100);
|
|
}).on('mouseleave',function(){
|
|
var $t = $(this);
|
|
clearTimeout(navbarHoverT);
|
|
$(this).removeClass('open');
|
|
$t.find('i.fa').removeClass("fa-angle-up").addClass("fa-angle-down");
|
|
});
|
|
|
|
var $sideLi = $('#J_sidebar ul.sidebar-menu>li');
|
|
var $at = $('#J_sidebar ul.sidebar-menu li.active');
|
|
if (!$at.length) {
|
|
return ;
|
|
}
|
|
|
|
var wH = $(window).height(), atT = $at.offset().top;
|
|
if (atT <= (wH - 100)) {
|
|
return ;
|
|
}
|
|
|
|
var $box = $('#J_sidebar .sidebar-menu-box');
|
|
if (!$box.length) {
|
|
return ;
|
|
}
|
|
var bT = $box.offset().top, bsT = $box.scrollTop();
|
|
$box.animate({
|
|
scrollTop: (atT - bT + bsT) - 10
|
|
}, 0);
|
|
}
|
|
function autoSetFixRightContent() {
|
|
var $t = $('.J_autoWithFixRightConent');
|
|
if (!$t.length) {
|
|
return ;
|
|
}
|
|
var width = $(window).width();
|
|
$t.css({
|
|
'width': (width - 240) + 'px',
|
|
'left': '220px'
|
|
});
|
|
$(window).on('resize', function(){
|
|
width = $(window).width();
|
|
$t.css({
|
|
'width': (width - 240) + 'px',
|
|
'left:': '220px'
|
|
})
|
|
})
|
|
}
|
|
function debounce(fun, delay) {
|
|
return function (args) {
|
|
let that = this
|
|
let _args = args
|
|
clearTimeout(fun.id)
|
|
fun.id = setTimeout(function () {
|
|
fun.call(that, _args)
|
|
}, delay)
|
|
} ();
|
|
}
|
|
|
|
$(function(){
|
|
function showLLoadingLayer(loadingMap, href) {
|
|
if (!href) {
|
|
return ;
|
|
}
|
|
var matchMap = href.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
if (!matchMap) {
|
|
return ;
|
|
}
|
|
var mt = matchMap[5], route = mt.substr(1);
|
|
|
|
for (var i in loadingMap) {
|
|
var s = loadingMap[i];
|
|
if (route.indexOf(s) > -1){
|
|
$(".J_loadingContainer").removeClass("loading-inactive");
|
|
}
|
|
}
|
|
}
|
|
|
|
var loadingMap = [];
|
|
if ((typeof loadingRtMap !== 'undefined')) {
|
|
loadingMap = loadingRtMap;
|
|
}
|
|
|
|
if (loadingMap.length > 0) {
|
|
$('a[href*="http"]').on('click', function(e){
|
|
var disabled = $(this).attr("disabled");
|
|
if (disabled) {
|
|
return false;
|
|
}
|
|
|
|
var href = $(this).attr("href");
|
|
showLLoadingLayer(loadingMap, href);
|
|
});
|
|
$("form").submit(function(e) {
|
|
var href = $(this).attr("action");
|
|
showLLoadingLayer(loadingMap, href);
|
|
});
|
|
}
|
|
setTimeout(function() {
|
|
$(".J_loadingContainer").addClass("loading-inactive")
|
|
}, 0);
|
|
$('ul.dropdown-menu').on('click', function(e) {
|
|
if ($(this).data('stopPropagation')) {
|
|
e.stopPropagation();
|
|
}
|
|
});
|
|
autoSetFixRightContent();
|
|
});
|
|
|
|
function pushLog(log){
|
|
try {
|
|
if (Object.prototype.toString.call(log) !== '[object Object]') {
|
|
log = {
|
|
'log': log
|
|
};
|
|
}
|
|
|
|
var server = window.location.protocol + '//' + window.location.host;
|
|
$.ajax({
|
|
url: server + '/open/push/log',
|
|
type: 'post',
|
|
data: log,
|
|
dataType: 'text',
|
|
global: false
|
|
});
|
|
} catch (err) {
|
|
}
|
|
}
|
|
|
|
$(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
|
|
var log = {
|
|
result: event.result,
|
|
status: jqXHR.status,
|
|
statusText: jqXHR.statusText,
|
|
crossDomain: ajaxSettings.crossDomain,
|
|
url: ajaxSettings.url,
|
|
dataType: ajaxSettings.dataType,
|
|
thrownError: thrownError
|
|
};
|
|
pushLog(log);
|
|
});
|
|
$(function(){
|
|
$('[data-hover="dropdown"]').hover(function() {
|
|
$(this).addClass('open');
|
|
$(this).find('.dropdown-menu').stop(true, true).delay(200).show();
|
|
}, function() {
|
|
$(this).removeClass('open');
|
|
$(this).find('.dropdown-menu').stop(true, true).delay(200).hide();
|
|
});
|
|
|
|
function searchMall() {
|
|
console.log('s')
|
|
let keyword = $('.J_mallListContainer .J_searchMallKeyword').val().trim();
|
|
if (!keyword) {
|
|
$('.J_mallListContainer .J_mallItem').show();
|
|
$('.J_mallListContainer .J_noMallItem').hide();
|
|
return;
|
|
}
|
|
|
|
$('.J_mallListContainer .J_mallName').each(function () {
|
|
if ($(this).text().indexOf(keyword) > -1) {
|
|
$(this).closest('.J_mallItem').show();
|
|
} else {
|
|
$(this).closest('.J_mallItem').hide();
|
|
}
|
|
});
|
|
if ($('.J_mallListContainer .J_mallItem:visible').length == 0) {
|
|
$('.J_mallListContainer .J_noMallItem').show();
|
|
} else {
|
|
$('.J_mallListContainer .J_noMallItem').hide();
|
|
}
|
|
}
|
|
$('.J_mallListContainer').on('input', '.J_searchMallKeyword', function() {
|
|
debounce(searchMall, 200);
|
|
});
|
|
|
|
});
|
|
/* console shim*/
|
|
(function () {
|
|
var f = function () {};
|
|
if (!window.console) {
|
|
window.console = {
|
|
log:f, info:f, warn:f, debug:f, error:f
|
|
};
|
|
}
|
|
}()); |