$(document).ready(function () {
// 首页头部悬浮固定
if (window.location.pathname == '/') {
var header = $("#header").offset().top;
$(window).scroll(function () {
var top = $(window).scrolltop();
if (top >= header) {
$("#header").addclass("header_fixed");
} else {
$("#header").removeclass("header_fixed");
}
});
}
$('.header').mouseenter(function (e) {
$(this).addclass("over");
});
$('.header').mouseleave(function (e) {
$(this).removeclass("over");
$('.nav_cont.on').removeclass('on');
$('.header .nav_list li.on').removeclass('on');
});
// 头部--nav 效果
$('.header .nav_list li').mouseenter(function (e) {
$(this).addclass("on").siblings().removeclass('on');
var index = $(this).index();
if ($(this).hasclass('no-expands')) {
$('.nav_content .nav_cont').removeclass('on');
return;
}
$('.nav_content .nav_cont').removeclass('on');
$('.nav_content .nav_cont').eq(index).addclass('on');
});
// banner 轮播图
bannerslider();
// 新闻资讯--轮播图
newsslider();
// 新闻资讯--tab切换
$(".news_tab li").click(function () {
$(this).addclass('on').siblings().removeclass('on');
var index = $(this).index();
var content = '.news_con_con';
switch (index) {
case 0:
$(content).hide();
$(content + '01').show();
break;
case 1:
$(content).hide();
$(content + '02').show();
break;
default:
break;
}
});
// 新闻资讯--新闻划过效果
var $newtanli = $(".news_tab_list li");
$newtanli.eq(0).addclass("active");
$newtanli.eq(6).addclass("active");
if ($newtanli.eq(0).hasclass("active")) {
$newtanli.eq(0).css("border-top", "0");
}
if ($newtanli.eq(6).hasclass("active")) {
$newtanli.eq(6).css("border-top", "0");
}
$newtanli.hover(function () {
$(this).addclass("active").siblings().removeclass("active");
});
$(".list_con a").each(function () {
var maxwidth = 80;
if ($(this).text().length > maxwidth) {
$(this).text($(this).text().substring(0, maxwidth));
$(this).html($(this).html() + '…');
}
});
// 大旅游生态
heartslider(); //用心陪着你
$(".ly_list01 li").eq(3).addclass("mar0");
$(".ly_list02 li").eq(2).addclass("mar0");
// 数字中青旅
$(".num_zqv_list li").eq(2).addclass("mar0");
$(".num_zqv_list li").eq(5).addclass("mar0");
// 关于我们--点击返回顶部
gototop();
$(window).scroll(function () {
fixedgototoppos();
});
// 关于我们--荣誉奖项
us_ryjx_tab();
$(".us_ryjx_tab_ul .us_ryjx_tab_li").click(function () {
var index = $(this).index();
$(this).addclass("active").siblings().removeclass("active");
$(".us_ryjx_box .us_ryjx_list").eq(index).addclass("show").siblings().removeclass("show");
});
// 新闻资讯--新闻报道
$('.news_search_box').click(function (event) {
event.stoppropagation();
//$(this).addclass("on");
});
$(document).click(function (e) {
if ($("#search").val() == "") {
$('.news_search_box').removeclass("on");
$(".news_search_text").val("");
}
});
$(".dtbd_tab li").click(function () {
var index = $(this).index();
$(this).addclass('active').siblings().removeclass('active');
$(".dtbd_box .dtbd_list").eq(index).addclass("show").siblings().removeclass("show");
});
// 新闻资讯--新闻报道--列表数据
getdatapro("news01", 1, 8, "", "");
getdatadq("dqjs_list_box", 1, 8)
getdatacsr("shzr_list_box", 1, 6)
getdatair("xxpl_list_box", 1, 8, "")
getdatahr("recruit_list", 1, 8, "")
// 新闻资讯--图片库
$(".photos_tab li").click(function () {
var index = $(this).index();
$(this).addclass('active').siblings().removeclass('active');
$(".photos_box .photos_list").eq(index).addclass("show").siblings().removeclass("show");
});
$(".photos_list_box .photos_list_li").click(function () {
$("#alterdiv").empty();
$("#alterdivt").empty();
$("#alterdiv").attr("style", "");
$("#alterdivt").attr("style", "");
var divhtml = "";
var divt = "";
var info = json.parse($(this).attr("data-con"));
$.each(info, function (e, ele) {
if (e == "pvview") {
$.each(ele, function (i, div) {
divhtml += "
";
if (divt == "") {
divt = "";
divt += "" + div.summary + "
";
}
});
}
});
$("#alterdiv").html(divhtml);
$("#alterdivt").html(divt);
$(".photos_pop").show();
photosslider();
});
$(".photos_close_btn").click(function () {
$(".photos_pop").hide();
});
// 新闻资讯--视频影像
$(".video_tab li").click(function () {
var index = $(this).index();
$(this).addclass('active').siblings().removeclass('active');
$(".video_box .video_list").eq(index).addclass("show").siblings().removeclass("show");
});
$(".video_list_box .video_list_li").click(function () {
$("#alterdiv").empty();
var s = "";
var info = json.parse($(this).attr("data-con"));
$.each(info, function (e, ele) {
if (e == "pvview") {
$.each(ele, function (i, div) {
s += "";
s += "
";
s += "
";
s += "
"+div.title+"
";
s += "
发布时间:" + div.createtime + "
";
s += "
";
s += "
";
});
}
});
$("#alterdiv").html(s);
$(".videos_pop").show();
videoslider();
});
$(".video_close_btn").click(function () {
$(".videos_pop").hide();
});
// 大旅游生态轮播
if (window.location.pathname == "/tourismeco/" || window.location.pathname == "/tourismeco/scenicspot/") {
lystslider1("ts1");
lystslider1("ts0");
} else {
lystslider();
}
if (window.location.pathname == "/ir/periodicreport/") {
$(".irm_tit_box li a").eq(1).click()
}
// 社会责任
shzrslider();
// 投资者关系--tab切换
$(".irm_tab li").click(function () {
var index = $(this).index();
$(this).addclass('active').siblings().removeclass('active');
});
// 锚点滑动
$("a[href*='#'],area[href*='#']").click(function () {
if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
if ($target.length) {
var targetoffset = $target.offset().top;
$('html,body').animate({
scrolltop: targetoffset
},
1000);
return false;
}
}
});
$(".news_search_btn").click(function () {
var txt = $("#search").val()
if (txt == "") {
$(".news_search_box").addclass("on")
} else {
$("#nojieguo").hide();
var str = $(".news_tit_box li").eq(0).hasclass("active") ? "news01" : "news02";
var guid = $(".news_tit_box li").eq(0).hasclass("active") ? $(".news_tit_box li").eq(0).attr("data-rel") : $(".news_tit_box li").eq(1).attr("data-rel");
getdatapro(str, 1, 8, guid, $("#search").val());
}
});
});
function bannerslider() {
var index = 1,
len = $('.mobile-pic li').length,
timer,
str = '';
for (var i = 1; i <= len; i++) {
if (i === 1) {
str += ' ';
} else {
str += ' ';
}
}
$('.navlist').append(str);
for (var i = 0; i < len; i++) {
$('.mobile-pic li').eq(i).css({ 'z-index': len - i });
$('.banner-list li').eq(i).css({ 'z-index': len - i });
}
$('.mobile').hover(function () {
clearinterval(timer);
}, function () {
timer = setinterval(function () {
play(index + 1);
}, 5000);
}).mouseleave();
$('.navlist li').hover(function () {
play($(this).index() + 1);
});
function play(num) {
if (!$('.mobile-pic').is(':animated')) {
if (num > len) {
num = 1;
} else if (num <= 0) {
num = len;
}
index = num;
$('.mobile-pic li').eq(index - 1).show().siblings().hide();
$('.banner-list li').eq(index - 1).show().siblings().hide();
$('.navlist li').eq(index - 1).addclass('navactive').siblings().removeclass('navactive');
}
}
}
function newsslider() {
var index = 1,
len = $('.slider-con li').length,
timer,
str = '',
text,
href;
for (var i = 1; i <= len; i++) {
if (i === 1) {
str += ' ';
} else {
str += ' ';
}
}
$('.slider-list').append(str);
for (var i = 0; i < len; i++) {
$('.slider-con li').eq(i).css({ 'z-index': len - i });
}
$('.slider').hover(function () {
clearinterval(timer);
}, function () {
timer = setinterval(function () {
play(index + 1);
}, 3000);
}).mouseleave();
$('.slider-list li').hover(function () {
play($(this).index() + 1);
});
function play(num) {
if (!$('.slider').is(':animated')) {
if (num > len) {
num = 1;
} else if (num <= 0) {
num = len;
}
index = num;
text = $(".slider-con li").eq(index - 1).attr("data-text");
href = $(".slider-con li").eq(index - 1).find("a").attr("href");
$('.slider-con li').eq(index - 1).show().siblings().hide();
$('.slider-list li').eq(index - 1).addclass('on').siblings().removeclass('on');
$(".slider-text a").html(text);
$(".slider-text a").attr("title", text);
$(".slider-text a").attr("href", href);
}
}
}
function heartslider() {
var curindex = 0,
listlen = $(".heart_list li").length, //图片总数
listwid = $(".heart_list li").outerwidth(true); //图片宽度
if (listlen === 4) {
$(".btn_box").hide();
} else {
$(".btn_box").show();
}
$(".l_btn").click(function () {
if ($(this).hasclass("l_btn_def")) {
return false;
} else {
curindex = (curindex > 0) ? (--curindex) : (listlen - 1);
changeto(curindex);
if (curindex > 0) {
$(".r_btn").removeclass("r_btn_def");
} else {
$(".l_btn").addclass("l_btn_def");
$(".r_btn").removeclass("r_btn_def");
return false;
}
}
});
$(".r_btn").click(function () {
if ($(this).hasclass("r_btn_def")) {
return false;
} else {
curindex = (curindex < listlen - 1) ? (++curindex) : 0;
changeto(curindex);
if (curindex < listlen - 4) {
$(".l_btn").removeclass("l_btn_def");
} else {
$(".r_btn").addclass("r_btn_def");
$(".l_btn").removeclass("l_btn_def");
return false;
}
}
});
function changeto(num) {
var goleft = num * listwid;
$(".heart_list").animate({ left: "-" + goleft + "px" }, 500);
}
}
function gototop() {
$(".go_to_top").on("click", function () {
$("body,html").animate({
scrolltop: 0
}, 500)
})
}
function fixedgototoppos() {
var windowheight = $(window).height();
var t = $(window).scrolltop()
, e = $(".footer_box").offset().top
, a = e - t - windowheight;
if (t > 600) {
if ($(".go_to_top").fadein(),
a < 0) {
var o = t + windowheight - e + 100;
$(".go_to_top").css("bottom", o)
} else
$(".go_to_top").css("bottom", "100px");
} else
$(".go_to_top").fadeout()
}
// 荣誉奖项
function us_ryjx_tab() {
var curindex = 0,
$tabul = $(".us_ryjx_tab_ul"),
$tabli = $(".us_ryjx_tab_ul .us_ryjx_tab_li"),
$btnleft = $(".us_ryjx_l_btn"),
$btnright = $(".us_ryjx_r_btn"),
listlen = $tabli.length,
ulwid = $tabul.outerwidth(true),
liwid = $tabli.outerwidth(true);
$(".us_ryjx_tab_wrap").width(ulwid);
$(".us_ryjx_tab_ul .us_ryjx_tab_li:last-child").addclass("w170")
if (listlen < 6) {
$btnleft.addclass("us_ryjx_l_btn_def");
$btnright.addclass("us_ryjx_r_btn_def");
}
$btnleft.click(function () {
if ($(this).hasclass("us_ryjx_l_btn_def")) {
return false;
} else {
curindex = (curindex > 0) ? (--curindex) : (listlen - 1);
changeto(curindex);
if (curindex > 0) {
$btnright.removeclass("us_ryjx_r_btn_def");
} else {
$btnleft.addclass("us_ryjx_l_btn_def");
return false;
}
}
});
$btnright.click(function () {
if ($(this).hasclass("us_ryjx_r_btn_def")) {
return false;
} else {
curindex = (curindex < listlen - 1) ? (++curindex) : 0;
changeto(curindex);
if (curindex < listlen - 6) {
$btnleft.removeclass("us_ryjx_l_btn_def");
} else {
$btnright.addclass("us_ryjx_r_btn_def");
return false;
}
}
});
function changeto(num) {
var goleft;
if (num < listlen - 6) {
goleft = num * (liwid);
} else {
goleft = num * (liwid) + 50;
}
$(".us_ryjx_tab_ul").animate({left: "-" + goleft + "px"}, 500);
}
}
//新闻资讯
function getdatapro(id, p, other, guid, tit) {
var $id = $("#" + id);
if ($("#search").length > 0) {
tit = $("#search").val();
}
if (guid == "") {
guid = "b5eb5cb5-9e72-474b-93be-1ed628f83043";
}
$.ajax({
type: "post",
url: "/news/dtbdlist?guid=" + guid + "&page=" + p + "&row=" + other + "&title=" + tit,
datatype: "json",
success: function (datapro) {
if (datapro == null) {
$("#frist").hide();
$("#nojieguo").show();
var hmtl = "抱歉,暂时没找到与 ’" + tit + "‘ 匹配的结果";
$("#nojieguo .text01").html(hmtl);
}
else {
var hmtl = "搜索“" + tit + " ”,找到相关新闻约" + datapro[0].dataid + "篇"
$("#nojieguo").hide();
var pagesize = math.ceil(datapro[0].dataid / other);
if (pagesize > 0) {
if ($id.next().hasclass("page")) {
$id.empty();
$.each(datapro, function (i, obj) {
var txt = obj.summary
if (txt.length > 80) {
txt = txt.substring(0, 80) + "...";
}
$id.append('' + txt + '
发布时间:' + getfdate(obj.createtime) + ' ');
});
$id.children(".loading").remove();
if (tit != "") {
var txt01 = id == "news01" ? "n1" : "n2";
$("#" + txt01).html(hmtl);
$("#" + txt01).show();
}
$("#frist").show();
}
else {
$id.after("
");
$id.empty();
$.each(datapro, function (i, obj) {
var txt = obj.summary
if (txt.length > 80) {
txt = txt.substring(0, 80) + "...";
}
$id.append('' + txt + '
发布时间:' + getfdate(obj.createtime) + ' ');
});
if (tit != "") {
var txt01 = id == "news01" ? "n1" : "n2";
$("#" + txt01).html(hmtl);
$("#" + txt01).show();
}
$("#frist").show();
}
kkpager.init({
//divid
pagerid: id + "pages",
//当前页码
pno: p,
//总页码
total: pagesize,
//总数据条数
totalrecords: datapro[0].dataid,
//链接前部
hrefformer: "javascript:getdatapro(\'" + id + "\'",
hreflatter: "," + other + ",'" + guid + "','" + tit + "');"
});
kkpager.generpagehtml();
//if (guid == "00000000-0000-0000-0000-000000000000") {
// var hmtl = "搜索“" + tit + " ”,找到相关新闻约" + datapro[0].dataid + "篇";
// $("#searchresultdiv .text01").html(hmtl);
// $("#searchresultdiv").show()
//}
}
}
},
error: function () {
console.log("新闻资讯接口报错");
}
});
}
function getdatadq(id, p, other) {
var guid = $("#dqjs").val();
var $id = $("." + id);
if (guid != undefined) {
$.ajax({
type: "post",
url: "/cpc/dtbdlist?guid=" + guid + "&page=" + p + "&row=" + other,
datatype: "json",
success: function (datapro) {
if (datapro == null) {
alert("暂无数据")
}
else {
var pagesize = math.ceil(datapro[0].dataid / other);
if (pagesize > 0) {
if ($id.next().hasclass("page")) {
$id.empty();
$id.html(" ");
$id.empty();
$.each(datapro, function (i, obj) {
$id.append('' + obj.summary + '
发布时间:' + getfdate(obj.createtime) + ' ')
});
$id.children(".loading").remove();
}
else {
$id.after("
");
$id.empty();
$.each(datapro, function (i, obj) {
$id.append('' + obj.summary + '
发布时间:' + getfdate(obj.createtime) + ' ')
});
}
kkpager.init({
//divid
pagerid: id + "pages",
//当前页码
pno: p,
//总页码
total: pagesize,
//总数据条数
totalrecords: datapro[0].dataid,
//链接前部
hrefformer: "javascript:getdatadq(\'" + id + "\'",
hreflatter: "," + other + ");"
});
kkpager.generpagehtml();
}
}
},
error: function () {
console.log("党群建设接口报错");
}
});
}
}
function getdatacsr(id, p, other) {
var guid = "7b204d62-bccd-476d-b2c6-8261d1e1f262";
var $id = $("." + id);
$.ajax({
type: "post",
url: "/csr/dtbdlist?guid=" + guid + "&page=" + p + "&row=" + other,
datatype: "json",
success: function (datapro) {
if (datapro == null) {
alert("暂无数据")
}
else {
var pagesize = math.ceil(datapro[0].dataid / other);
if (pagesize > 0) {
if ($id.next().hasclass("page")) {
$id.empty();
$id.html(" ");
$id.empty();
$.each(datapro, function (i, obj) {
$id.append(" " + obj.summary + "
发布时间:" + getfdate(obj.createtime) + " ");
});
$id.children(".loading").remove();
}
else {
$id.after("
");
$id.empty();
$.each(datapro, function (i, obj) {
$id.append(" " + obj.summary + "
发布时间:" + getfdate(obj.createtime) + " ");
});
}
kkpager.init({
//divid
pagerid: id + "pages",
//当前页码
pno: p,
//总页码
total: pagesize,
//总数据条数
totalrecords: datapro[0].dataid,
//链接前部
hrefformer: "javascript:getdatacsr(\'" + id + "\'",
hreflatter: "," + other + ");"
});
kkpager.generpagehtml();
}
}
},
error: function () {
console.log("社会责任接口报错");
}
});
}
function getdatair(id, p, other, guid) {
var $id = $("." + id);
if (guid == "") {
guid = $("#dqbg").val();
}
if (guid != undefined) {
$.ajax({
type: "post",
url: "/ir/dtbdlist?guid=" + guid + "&page=" + p + "&row=" + other,
datatype: "json",
success: function (datapro) {
if (datapro == null) {
alert("暂无数据")
}
else {
$id.empty();
var pagesize = math.ceil(datapro[0].dataid / other);
if (pagesize > 0) {
if ($id.next().hasclass("page")) {
$id.empty();
$id.html(" ");
$id.empty();
$.each(datapro, function (i, obj) {
$id.append("");
});
$id.children(".loading").remove();
}
else {
$id.after("
");
$id.empty();
$.each(datapro, function (i, obj) {
$id.append("");
});
}
kkpager.init({
//divid
pagerid: id + "pages",
//当前页码
pno: p,
//总页码
total: pagesize,
//总数据条数
totalrecords: datapro[0].dataid,
//链接前部
hrefformer: "javascript:getdatair(\'" + id + "\'",
hreflatter: "," + other + ",'" + guid + "');"
});
kkpager.generpagehtml();
}
}
},
error: function () {
console.log("投资接口报错");
}
});
}
}
function getdatahr(id, p, other, guid) {
var $id = $("." + id);
var nname = $("#typename").val();
if (guid == "") {
guid = $("#hr_dqbg").val();
}
if (guid != undefined && nname != "" && nname != undefined) {
$.ajax({
type: "post",
url: "/hr/dtbdlist?guid=" + guid + "&page=" + p + "&row=" + other,
datatype: "json",
success: function (datapro) {
if (datapro == null) {
alert("暂无数据")
}
else {
$id.empty();
var pagesize = math.ceil(datapro[0].dataid / other);
if (pagesize > 0) {
if ($id.next().hasclass("page")) {
$id.empty();
$id.html(" ");
$id.empty();
$.each(datapro, function (i, obj) {
$id.append("发布时间:" + getfdate(obj.createtime) + "
");
});
$id.children(".loading").remove();
}
else {
$id.after("
");
$id.empty();
$.each(datapro, function (i, obj) {
$id.append("发布时间:" + getfdate(obj.createtime) + "
");
});
}
kkpager.init({
//divid
pagerid: id + "pages",
//当前页码
pno: p,
//总页码
total: pagesize,
//总数据条数
totalrecords: datapro[0].dataid,
//链接前部
hrefformer: "javascript:getdatahr(\'" + id + "\'",
hreflatter: "," + other + ",'" + guid + "');"
});
kkpager.generpagehtml();
}
}
},
error: function () {
console.log("人才接口报错");
}
});
}
}
function getdatairnew(id, p, other, guid, tit) {
var $id = $("#" + id);
$.ajax({
type: "post",
url: "/news/dtbdlist?guid=" + guid + "&page=" + p + "&row=" + other + "&title=" + tit,
datatype: "json",
success: function (datapro) {
$id.empty();
if (datapro != null) {
var pagesize = math.ceil(datapro[0].dataid / other);
if (pagesize > 0) {
if ($id.next().hasclass("page")) {
$id.empty();
$.each(datapro, function (i, obj) {
var txt = obj.summary
if (txt.length > 80) {
txt = txt.substring(0, 80) + "...";
}
$id.append('' + txt + '
发布时间:' + getfdate(obj.createtime) + ' ');
});
$id.children(".loading").remove();
}
else {
$id.after("
");
$id.empty();
$.each(datapro, function (i, obj) {
var txt = obj.summary
if (txt.length > 80) {
txt = txt.substring(0, 80) + "...";
}
$id.append('' + txt + '
发布时间:' + getfdate(obj.createtime) + ' ');
});
}
kkpager.init({
//divid
pagerid: id + "pages",
//当前页码
pno: p,
//总页码
total: pagesize,
//总数据条数
totalrecords: datapro[0].dataid,
//链接前部
hrefformer: "javascript:getdatairnew(\'" + id + "\'",
hreflatter: "," + other + ",'" + guid + "','" + tit + "');"
});
kkpager.generpagehtml();
}
}
},
error: function () {
console.log("新闻资讯接口报错");
}
});
}
function getfdate(date) {
var d = eval('new ' + date.substr(1, date.length - 2));
var ar_date = [d.getfullyear(), d.getmonth() + 1, d.getdate()];
for (var i = 0; i < ar_date.length; i++) ar_date[i] = dformat(ar_date[i]);
return ar_date.join('-');
}
function dformat(i) {
return i < 10 ? "0" + i.tostring() : i;
}
// 新闻资讯--分页
var kkpager = {
//divid
pagerid: 'div_pager',
//当前页码
pno: 1,
//总页码
total: 1,
//总数据条数
totalrecords: 0,
//是否显示总页数
isshowtotalpage: false,
//是否显示总记录数
isshowtotalrecords: false,
//是否显示页码跳转输入框
isgopage: false,
//链接前部
hrefformer: '',
//链接尾部
hreflatter: '',
/****链接算法****/
getlink: function (n) {
//这里的算法适用于比如:
//hrefformer=http://www.xx.com/news/20131212
//hreflatter=.html
//那么首页(第1页)就是http://www.xx.com/news/20131212.html
//第2页就是http://www.xx.com/news/20131212_2.html
//第n页就是http://www.xx.com/news/20131212_n.html
if (n == 0) {
return this.hrefformer + this.hreflatter;
} else {
return this.hrefformer + ',' + n + this.hreflatter;
}
},
//跳转框得到输入焦点时
focus_gopage: function () {
var btngo = $('#btn_go');
$('#btn_go_input').attr('hidefocus', true);
btngo.show();
btngo.css('left', '0px');
$('#go_page_wrap').css('border-color', '#6694e3');
btngo.animate({ left: '+=44' }, 50, function () {
//$('#go_page_wrap').css('width','88px');
});
},
//跳转框失去输入焦点时
blur_gopage: function () {
settimeout(function () {
var btngo = $('#btn_go');
//$('#go_page_wrap').css('width','44px');
btngo.animate({
left: '-=44'
}, 100, function () {
$('#btn_go').css('left', '0px');
$('#btn_go').hide();
$('#go_page_wrap').css('border-color', '#dfdfdf');
});
}, 400);
},
//跳转框页面跳转
gopage: function () {
var str_page = $("#btn_go_input").val();
if (isnan(str_page)) {
$("#btn_go_input").val(this.next);
return;
}
var n = parseint(str_page);
if (n < 1 || n > this.total) {
$("#btn_go_input").val(this.next);
return;
}
//这里可以按需改window.open
window.location = this.getlink(n);
},
//分页按钮控件初始化
init: function (config) {
//赋值
this.pno = isnan(config.pno) ? 1 : parseint(config.pno);
this.total = isnan(config.total) ? 1 : parseint(config.total);
this.totalrecords = isnan(config.totalrecords) ? 0 : parseint(config.totalrecords);
if (config.pagerid) {
this.pagerid = config.pagerid;
}
if (config.isshowtotalpage != undefined) {
this.isshowtotalpage = config.isshowtotalpage;
}
if (config.isshowtotalrecords != undefined) {
this.isshowtotalrecords = config.isshowtotalrecords;
}
if (config.isgopage != undefined) {
this.isgopage = config.isgopage;
}
this.hrefformer = config.hrefformer || '';
this.hreflatter = config.hreflatter || '';
if (config.getlink && typeof (config.getlink) == 'function') {
this.getlink = config.getlink;
}
//验证
if (this.pno < 1) this.pno = 1;
this.total = (this.total <= 1) ? 1 : this.total;
if (this.pno > this.total) this.pno = this.total;
this.prv = (this.pno <= 2) ? 1 : (this.pno - 1);
this.next = (this.pno >= this.total - 1) ? this.total : (this.pno + 1);
this.hasprv = (this.pno > 1);
this.hasnext = (this.pno < this.total);
this.inited = true;
},
//生成分页控件html
generpagehtml: function () {
if (!this.inited) {
return;
}
var str_prv = '', str_next = '';
if (this.hasprv) {
str_prv = '上一页 ';
} else {
str_prv = '上一页 ';
}
if (this.hasnext) {
str_next = '下一页 ';
} else {
str_next = '下一页 ';
}
var str = '';
var dot = '... ';
var total_info = '';
if (this.isshowtotalpage || this.isshowtotalrecords) {
total_info = '共';
if (this.isshowtotalpage) {
total_info += this.total + '页';
if (this.isshowtotalrecords) {
total_info += ' / ';
}
}
if (this.isshowtotalrecords) {
total_info += this.totalrecords + '条产品';
}
total_info += ' ';
}
var gopage_info = '';
if (this.isgopage) {
gopage_info = ' 转到' +
' ' +
' 页';
}
//分页处理
if (this.total <= 8) {
for (var i = 1; i <= this.total; i++) {
if (this.total == 1) {
}
else if (this.pno == i) {
str += '' + i + ' ';
} else {
str += '' + i + ' ';
}
}
} else {
if (this.pno <= 3) {
for (var i = 1; i <= 5; i++) {
if (this.pno == i) {
str += '' + i + ' ';
} else {
str += '' + i + ' ';
}
}
str += dot + '' + this.total + ' ';
} else {
str += '1 ';
str += dot;
var begin = this.pno - 2;
var end = this.pno + 2;
if (end > this.total) {
end = this.total;
begin = end - 4;
if (this.pno - begin < 2) {
begin = begin - 1;
}
} else if (end + 1 == this.total) {
end = this.total;
}
for (var i = begin; i <= end; i++) {
if (this.pno == i) {
str += '' + i + ' ';
} else {
str += '' + i + ' ';
}
}
if (end != this.total) {
str += dot + '' + this.total + ' ';
}
}
}
str = " " + str_prv + str + str_next + total_info + gopage_info;
$("#" + this.pagerid).html(str);
}
};
function photosslider() {
var winheight = $(window).height(), //浏览器窗口高度
conwidth = $(".photos_con").width(), //图片宽度
listlen = $(".photos_con .photos_img").length, //图片总数
$photosbox = $(".photos_box"),
$photosimg = $(".photos_img"),
$photosbtn = $(".btn_photos"),
$photosbtnleft = $(".l_btn_photos"),
$photosbtnright = $(".r_btn_photos");
// 初始化
var curindex = 1;
$photosbtnleft.unbind("click");
$photosbtnright.unbind("click");
$photosbox.attr("style", "");
$photosimg.attr("style", "");
$photosbox.width((conwidth * listlen) + "px");
$photosimg.css({"width": conwidth + "px", "height": winheight + "px", "line-height": winheight + "px"});
$(".photos_pop .cur").html(curindex);
$(".photos_pop .zong").html(listlen);
if (listlen === 1) {
$photosbtn.hide();
} else {
$photosbtn.show();
$photosbtnleft.addclass("l_btn_photos_def");
$photosbtn.removeclass("r_btn_photos_def");
$photosbtnleft.click(function () {
if ($(this).hasclass("l_btn_photos_def")) {
return false;
} else {
curindex = (curindex > 1) ? (--curindex) : (listlen - 1);
changeto(curindex);
if (curindex > 1) {
$photosbtnright.removeclass("r_btn_photos_def");
} else {
$photosbtnleft.addclass("l_btn_photos_def");
$photosbtnright.removeclass("r_btn_photos_def");
return false;
}
}
});
$photosbtnright.click(function () {
if ($(this).hasclass("r_btn_photos_def")) {
return false;
} else {
curindex = (curindex < listlen) ? (++curindex) : 0;
changeto(curindex);
if (curindex < listlen) {
$photosbtnleft.removeclass("l_btn_photos_def");
} else {
$photosbtnright.addclass("r_btn_photos_def");
$photosbtnleft.removeclass("l_btn_photos_def");
return false;
}
}
});
}
function changeto(num) {
var goleft = (num - 1) * conwidth;
settimeout(function () {
var imgtit = $(".photos_img img").eq(curindex - 1).attr("alt");
var imgcon = $photosimg.eq(curindex - 1).attr("data-con");
$photosbox.animate({left: "-" + goleft + "px"}, 300);
$(".photos_pop .cur").html(curindex);
$(".photos_pop .zong").html(listlen);
$(".photos_img_tit h3").html(imgtit);
$(".photos_img_jj").html(imgcon);
}, 500);
}
}
function videoslider() {
var winheight = $(window).height(), //浏览器窗口高度
conwidth = $(".video_con").width(), //视频宽度
listlen = $(".video_con .video_list").length, //视频总数
$videobox = $(".video_box"),
$videobtn = $(".btn_video"),
$videobtnleft = $(".l_btn_video"),
$videobtnright = $(".r_btn_video");
// 初始化
var curindex = 1;
$videobtnleft.unbind("click");
$videobtnright.unbind("click");
$videobox.attr("style", "");
$videobox.width((conwidth * listlen) + "px");
if (listlen === 1) {
$videobtn.hide();
} else {
$videobtn.show();
$videobtnleft.addclass("l_btn_video_def");
$videobtn.removeclass("r_btn_video_def");
$videobtnleft.click(function () {
if ($(this).hasclass("l_btn_video_def")) {
return false;
} else {
curindex = (curindex > 1) ? (--curindex) : (listlen - 1);
changeto(curindex);
if (curindex > 1) {
$videobtnright.removeclass("r_btn_video_def");
} else {
$videobtnleft.addclass("l_btn_video_def");
$videobtnright.removeclass("r_btn_video_def");
return false;
}
}
});
$videobtnright.click(function () {
if ($(this).hasclass("r_btn_video_def")) {
return false;
} else {
curindex = (curindex < listlen) ? (++curindex) : 0;
changeto(curindex);
if (curindex < listlen) {
$videobtnleft.removeclass("l_btn_video_def");
} else {
$videobtnright.addclass("r_btn_video_def");
$videobtnleft.removeclass("l_btn_video_def");
return false;
}
}
});
}
function changeto(num) {
var goleft = (num - 1) * conwidth;
settimeout(function () {
$videobox.animate({left: "-" + goleft + "px"}, 300);
}, 500);
}
}
function lystslider() {
var index = 1,
len = $('.lyst_slider_con li').length,
timer,
str = '';
for (var i = 1; i <= len; i++) {
if (i === 1) {
str += ' ';
} else {
str += ' ';
}
}
$('.lyst_slider_list').append(str);
for (var i = 0; i < len; i++) {
$('.lyst_slider_con li').eq(i).css({ 'z-index': len - i });
}
$('.lyst_slider').hover(function () {
clearinterval(timer);
}, function () {
timer = setinterval(function () {
play(index + 1);
}, 3000);
}).mouseleave();
$(".lyst_slider_right").click(function () {
play(index + 1);
}).hover(function (e) {
clearinterval(timer);
}, function (e) {
});
$(".lyst_slider_left").click(function () {
play(index - 1);
}).hover(function (e) {
clearinterval(timer);
}, function (e) {
});
$('.lyst_slider_list li').hover(function () {
play($(this).index() + 1);
});
function play(num) {
if (!$('.lyst_slider').is(':animated')) {
if (num > len) {
num = 1;
} else if (num <= 0) {
num = len;
}
index = num;
$('.lyst_slider_con li').eq(index - 1).show().siblings().hide();
$('.lyst_slider_list li').eq(index - 1).addclass('on').siblings().removeclass('on');
}
}
}
function lystslider1(id) {
var index = 1,
len = $('#' + id + ' .lyst_slider_con li').length,
timer,
str = '';
for (var i = 1; i <= len; i++) {
if (i === 1) {
str += ' ';
} else {
str += ' ';
}
}
$('#' + id + ' .lyst_slider_list').append(str);
for (var i = 0; i < len; i++) {
$('#' + id + ' .lyst_slider_con li').eq(i).css({ 'z-index': len - i });
}
$('#' + id).hover(function () {
clearinterval(timer);
}, function () {
timer = setinterval(function () {
play(index + 1);
}, 3000);
}).mouseleave();
$('#' + id + " .lyst_slider_right").click(function () {
play(index + 1);
}).hover(function (e) {
clearinterval(timer);
}, function (e) {
});
$('#' + id + " .lyst_slider_left").click(function () {
play(index - 1);
}).hover(function (e) {
clearinterval(timer);
}, function (e) {
});
$('#' + id + ' .lyst_slider_list li').hover(function () {
play($(this).index() + 1);
});
function play(num) {
if (!$('#' + id).is(':animated')) {
if (num > len) {
num = 1;
} else if (num <= 0) {
num = len;
}
index = num;
$('#' + id + ' .lyst_slider_con li').eq(index - 1).show().siblings().hide();
$('#' + id + ' .lyst_slider_list li').eq(index - 1).addclass('on').siblings().removeclass('on');
}
}
}
function shzrslider() {
var curindex = 0,
listlen = $(".shzr_baogao_list li").length, //图片总数
listwid = $(".shzr_baogao_list li").outerwidth(true); //图片宽度
$(".shzr_baogao_box").width((listwid * listlen) + "px");
$(".shzr_baogao_l_btn").click(function () {
if ($(this).hasclass("shzr_baogao_l_btn_def")) {
return false;
} else {
curindex = (curindex > 0) ? (--curindex) : (listlen - 1);
changeto(curindex);
if (curindex > 0) {
$(".shzr_baogao_r_btn").removeclass("shzr_baogao_r_btn_def");
} else {
$(".shzr_baogao_l_btn").addclass("shzr_baogao_l_btn_def");
return false;
}
}
});
$(".shzr_baogao_r_btn").click(function () {
if ($(this).hasclass("shzr_baogao_r_btn_def")) {
return false;
} else {
curindex = (curindex < listlen - 1) ? (++curindex) : 0;
changeto(curindex);
if (curindex < listlen - 4) {
$(".shzr_baogao_l_btn").removeclass("shzr_baogao_l_btn_def");
} else {
$(".shzr_baogao_r_btn").addclass("shzr_baogao_r_btn_def");
return false;
}
}
});
function changeto(num) {
var goleft = num * listwid;
$(".shzr_baogao_list").animate({ left: "-" + goleft + "px" }, 500);
}
}