var gameSeoName = myUrl;
var currency = Currency;
var offers = [];
var apiName = 'api/game/';
var currentPage = 1;
var _Pager = {
//PageSize: 30, //默认15条
PageIndex: GetQueryString('PageIndex') || 1,
TotalNumber: 0,
PageCount: 0
}
var _filters = {
Pager: {
//PageSize: _Pager.PageSize, //移除PageSize
PageIndex: _Pager.PageIndex
}
}
function setOffersCount(result) {
$.each(result, function (index, obj) {
$('.header-nav-tabs li span:not(".type-title")').each(function (i, v) {
if (v.className == obj.Name) {
$(v).html('(' + obj.Count + ')');
}
});
});
};
function getOffersCountByUrl() {
var types = [];
//获取需要查询的类型
$('.header-nav-tabs li span').each(function (i, v) {
types.push(v.className);
});
var url = api + apiName + myUrl + '/offers/Count?PTypes=' + types;
$.ajax({
url: url,
type: 'GET',
dataType: 'json',
success: function (data) {
setOffersCount(data.Result);
}, error: function (reason) {
}
});
};
//计算评分星级
function ratingStars(ratingOuter, rating) {
rating = rating * 20;
$(ratingOuter).children('.vote-star').children('i').css('width', rating + '%');
};
function init(filters) {
$.ajax({
url: api + apiName + myUrl + '/' + Currency + '/offers',
type: 'POST',
contentType: "application/json;charset=utf-8",
dataType: 'json',
async: false,
data: JSON.stringify(filters),
success: function (data) {
offers = data.Result ? data.Result : [];
$('.offer-search-count .count').html(offers.Pager.TotalNumber);
if (data.Result.Pager.PageCount > 1) {
pagination(data.Result);
}
}, error: function (reason) {
offers = [];
$('.offer-search-count .count').html('0');
}
});
$('.mask-normal').hide();
resetTabs();
return offers;
};
function pagination(data) {
$('#pagination').empty();
$('#pagination').removeData("twbs-pagination");
$('#pagination').unbind("page");
currentPage = data.Pager.PageIndex;
$('#pagination').twbsPagination({
totalPages: data.Pager.PageCount,
visiblePages: 5,
initiateStartPageClick: false,
currentPage: currentPage,
startPage: currentPage,
first: '',
last: '',
prev: '
',
next: '
',
//页面点击时触发事件
onPageClick: function (event, page) {
$('#page-content').text('Page ' + page);
filters.Pager.PageIndex = page;
window.location = queryConfig(filters);
}
});
};
function initOffersFeedback(table, data) {
$.each($(table).children('.offer-item'), function () {
var _td = $(this);
var username = $(_td).find('.username').text();
$.each(data, function (i, v) {
if (username == v.UserName) {
if (!v.TotalReviews) {
$(_td).find('.offer-item-rating').html('New Seller');
} else {
$(_td).find('.offer-item-rating').html('' + v.TotalReviews + '');
}
}
});
});
};
function initItemAutoDelivery(table, data) {
$.each($(table).find('.offer-item'), function () {
var _td = $(this);
var offerid = $(_td).find('.offerid').text();
$.each(data, function (i, v) {
if (offerid == v.OfferId) {
$(_td).find('.table-time').html('
' + v.DeliverySpeed.en.replace("Customize by amount", "Variable") + '');
$(_td).find('.time-xs').html('
' + v.DeliverySpeed.en.replace("Customize by amount", "Variable") + '');
}
});
});
}
function initVolumeDiscounts(table, data) {
$.each($(table).find('.offer-item'), function () {
var _td = $(this);
var offerid = $(_td).find('.offerid').text();
$.each(data, function (i, v) {
if (offerid == v.OfferId) {
$(_td).find('.table-time').html('
' + v.DeliverySpeed.en.replace("Customize by amount", "Variable") + '');
$(_td).find('.time-xs').html('
' + v.DeliverySpeed.en.replace("Customize by amount", "Variable") + '');
}
});
});
}
function initItemVolumeDiscounts(table, data) {
$.each($(table).find('.offer-item'), function () {
var _td = $(this);
var offerid = $(_td).find('.offerid').text();
$.each(data, function (i, v) {
if (offerid == v.OfferId && v.IsExistence) {
$(_td).find('.table-btnbox .detail-buy-now').append('');
$(_td).find('.discount-xs').html('
');
}
});
});
}
function getAccountAutoDelivery(table, className) {
var url = api + 'api/Offer/IsAccountAutoDelivery';
var search = {
"OfferIds": OfferIds
}
var search = JSON.stringify(search);
$.ajax({
type: 'POST',
url: url,
contentType: 'application/json; charset=utf-8',
dataType: "json",
data: search,
success: function (data) {
result = data.Result;
initOffersAutoDelivery(table, result);
if (className == 'item-offers') {
initItemAutoDelivery(table, result);
}
}, error: function (reason) {
}
});
};
function initOffersAutoDelivery(table, data) {
$.each($(table).children('.offer-item'), function () {
var _td = $(this);
var offerid = $(_td).find('.offerid').text();
$.each(data, function (i, v) {
if (offerid == v.OfferId) {
if (v.DeliverySpeed.en == "Instant") {
$(_td).find('.offer-delivery-rating .offer-delivery').html('
Instant');
} else {
$(_td).find('.offer-delivery-rating .offer-delivery').html('
' + v.DeliverySpeed.en + '');
}
}
});
});
};
function getOffersVolumeDiscounts(table, className) {
var url = api + 'api/Offer/ISVolumeDiscounts';
var search = {
"OfferIds": OfferIds
}
var search = JSON.stringify(search);
$.ajax({
type: 'POST',
url: url,
contentType: 'application/json; charset=utf-8',
dataType: "json",
data: search,
success: function (data) {
result = data.Result;
if (className == 'item-offers') {
initItemVolumeDiscounts(table, result);
} else {
initOffersVolumeDiscounts(table, result);
}
}, error: function (reason) {
}
});
};
function initOffersVolumeDiscounts(table, data) {
$.each($(table).children('.offer-item'), function () {
var _td = $(this);
var offerid = $(_td).find('.offerid').text();
$.each(data, function (i, v) {
if (offerid == v.OfferId) {
if (v.IsExistence) {
$(_td).find('.offer-buttons .offer-details').append('');
}
}
});
});
};
$(document).ready(function () {
setTimeout(function() {
var _iframes = $('iframe[attr-src]');
_iframes.each(function(i) {
$(this).attr('src', $(this).attr('attr-src'));
});
},
3500);
// swiper(addGameTool);
if (typeof ProductTypeID === 'undefined' || (ProductTypeID != 2 && ProductTypeID != 3 && ProductTypeID != 4 && ProductTypeID != 1))
getOffersCountByUrl();
$(".filter-search").keydown(function (event) {
event = document.all ? window.event : event;
if ((event.keyCode || event.which) == 13) {
$(".input-group-btn").click();
}
});
});
function swiper(callback) {
var _index = 0;
$('.swiper-wrapper div').each(function (i, v) {
if ($(v).hasClass('active')) {
_index = i;
}
});
//头部菜单动态效果
var swiper1 = new Swiper('.swiper1', {
//设置slider容器能够同时显示的slides数量(carousel模式)。
//可以设置为number或者 'auto'则自动根据slides的宽度来设定数量。
//loop模式下如果设置为'auto'还需要设置另外一个参数loopedSlides。
width: window.innerWidth,
initialSlide: _index,
slidesPerView: 'auto',
paginationClickable: true,//此参数设置为true时,点击分页器的指示点分页器会控制Swiper切换。
spaceBetween: 0,//slide之间的距离(单位px)。
freeMode: true,//默认为false,普通模式:slide滑动时只滑动一格,并自动贴合wrapper,设置为true则变为free模式,slide会根据惯性滑动且不会贴合。
loop: false,//是否可循环
onTab: function (swiper) {
var n = swiper1.clickedIndex;
},
breakpoints: {
//这里的断点区间控制,键为小于的尺寸范围
//noSwiping属性设置为true时候将会停止掉滑动事件,可通过设置noSwipingClass来设置停掉滑动项目的类名
768: {
noSwiping: false,
},
1100: {
noSwiping: true,
noSwipingClass: 'swiper-slide',
}
}
});
typeof callback == "function" && callback(swiper1);
};
function addGameTool(swiperMob) {
var renderToolEntryKey = false;
renderMobKey = $(".game-tools-box-wrapper").length > 0;
if (!renderMobKey) { return; } //如果不存在pc端的dom结构那么就不必去添加事件以及添加移动端的入口
var actNavItem = null;
$("#coverGt").on("click", function () {
$(".game-tools-box-wrapper").removeClass("active");
$("#game-tool-bar-mob").removeClass("active");
actNavItem && actNavItem.addClass("active");
$("#coverGt").stop().fadeOut();
actNavItem = null;
});
var gameVals = gameSeoName.toLowerCase();
var mobGameToolHtml = '';
if (gameVals === "osrs") {
mobGameToolHtml = '