|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- $(function () {
-
- $(".footer_root").load("./comm/footer.html");
-
-
- var datalist = [
- { time: 2023 },
- { time: 2022 },
- { time: 2021 },
- { time: 2020 },
- { time: 2019 },
- { time: 2018 },
- { time: 2017 }
- ];
-
-
- $.ajax({
- type: "POST",
- url: $.baseUrl + "dh/listc",
- dataType: "json",
- async: false,
- contentType: "application/json; charset=utf-8",
- success: function (data) {
- if (data.code === 0) {
- datalist = data.obj;
- } else {
- alert(data.msg);
- }
- }
- });
- var html = "";
- $.each(datalist, (idx, item) => {
- html += `<div class="round_q" index = "${idx + 1}">
- <div class="round_item">
- <div class="round_i"></div>
- <div class="round_d">${item.dhyear || item.time}</div>
- </div></div>`;
- });
- $(".rounds").width(datalist.length * 2.34 + "rem");
- $(".rounds").html(html);
- $(".round_q:first").addClass("active");
- function showdata(index) {
- var list = datalist[index].details,
- html = '<div class="dev_list">';
- if (!list || list.length == 0) {
- return;
- }
- $.each(list, (idx, item) => {
- if (idx % 4 == 0 && idx) {
- html += '</div><div class="dev_list">';
- }
-
- html += `<div class="dev_item" title="${item.content}">
- <span>${item.dhmonth}</span> - ${item.content}
- </div>`;
- });
- if (list.length < 9) {
- html += '</div><div class="dev_list">';
- } else if (list.length < 5) {
- html += '</div><div class="dev_list"></div><div class="dev_list"></div>';
- }
- $(".develop_data").html(html);
- }
-
- var divwidth = $(".round_q:first").width();
- var list = $(".rounds");
- var buts = $(".round_q");
- var prev = $(".leftjt");
- var next = $(".rightjt");
-
- var index = 1;
- var len = 5;
- var interval = 5000;
- var timer;
- var offsetpx = (datalist.length - len) * divwidth;
- var offleft = 0;
- function animate(offset) {
- var left = parseInt(list.css("left")) + offset;
- var absnum = Math.abs(offset);
- if (left < 0 - offsetpx) {
-
- return;
- }
-
- if (offset > 0) {
- offset = "+=" + offset;
- offleft = offleft + absnum;
- } else {
- offset = "-=" + Math.abs(offset);
- offleft = offleft - absnum;
- }
- if (index < 5 && offleft >= 0) {
- return;
- }
- list.animate({ left: offset }, 300, function () {
- if (left > -200) {
-
- }
- if (index == datalist.length) {
-
- offset = 0 - (datalist.length - 5) * absnum;
- offleft = offset;
- list.css("left", offset);
- }
- });
- }
-
- function animates(offset) {
- var left = parseInt(list.css("left")) + offset;
- if (index < 6 && left >= 0) {
- list.animate({ left: 0 }, 300, function () {});
- return;
- }
-
- if (left < 0 - offsetpx) {
- offset = 0 - offsetpx;
- } else {
- if (offset > 0) {
- offset = "+=" + divwidth;
- offleft = offleft;
- } else {
- offset = "-=" + divwidth;
- offleft = offset;
- }
- }
- list.animate({ left: offset }, 300, function () {});
- }
-
- function showButton() {
-
- buts
- .eq(index - 1)
- .addClass("active")
- .siblings()
- .removeClass("active");
- }
-
-
- function play() {
- timer = setTimeout(function () {
- next.trigger("click");
- play();
- }, interval);
- }
-
-
- function stop() {
- if (timer) {
- clearTimeout(timer);
- timer = null;
- }
- }
-
-
- next.bind("click", function () {
-
- if (list.is(":animated")) {
- return;
- }
-
-
- if (index == datalist.length) {
- index = 1;
- offleft = 0;
- list.animate({ left: 0 }, 300, () => {});
- } else {
- index += 1;
- }
- animate(0 - divwidth);
- showdata(index - 1);
- showButton();
- stop();
- });
-
-
- prev.bind("click", function () {
-
- if (list.is(":animated")) {
- return;
- }
-
-
- if (index == 1) {
- index = datalist.length;
- } else {
- index -= 1;
- }
- stop();
- animate(divwidth);
- showdata(index - 1);
- showButton();
- });
-
-
- buts.each(function () {
- $(this).bind("click", function () {
-
- if (list.is(":animated") || $(this).attr("class") == "on") {
- return;
- }
- var myIndex = parseInt($(this).attr("index"));
- if (myIndex == index) {
- return;
- }
-
- var offset = (0 - divwidth) * (myIndex - index);
- index = myIndex;
- animates(offset);
-
- showdata(index - 1);
- showButton();
- stop();
- });
- });
- showdata(0);
- $(".develop_container").hover(stop, play);
-
- play();
- });
|