document.write('') let page = 1 let maxPage = 0 // 鏃堕棿绾挎暟鎹 var TIMELINE_DATA = [ { year: 2015, title: '瀹屾垚澶╀娇杞瀺璧?, events: [ '1鏈埪峰叕鍙告寮忔垚绔嬶紝鎬婚儴璁惧湪娣卞湷', '3鏈埪锋垚閮姐€侀噸搴嗗瓙鍏徃鎴愮珛锛沑n浜查偦寮€闂ˋPP涓婄嚎', '9鏈埪峰箍宸炪€佹繁鍦冲瓙鍏徃鎴愮珛' ] }, { year: 2016, title: '鏈嶅姟瑕嗙洊鍏ㄥ浗20涓煄甯?, events: ['1鏈埪峰寳浜€佷笂娴峰瓙鍏徃鎴愮珛', '9鏈埪峰叏鍥介攢鍞腑蹇冩垚绔?] }, { year: 2017, title: '瀹屾垚A杞瀺璧?, events: ['3鏈埪蜂翰閭昏嚮閫夊晢鍩庝笂绾?, '11鏈埪峰疄鐜板井淇℃壂鐮佸紑闂?, '12鏈埪锋湇鍔¤鐩栧叏鍥?4涓煄甯?] }, { year: 2018, title: '瀹屾垚A锛嬭疆铻嶈祫', events: [ '4鏈埪峰疄鐜板皬绋嬪簭寮€闂?, '6鏈埪稱ADN璧勬簮绠$悊绯荤粺涓婄嚎', '8鏈埪峰疄鐜颁汉鑴歌瘑鍒紑闂?, '11鏈埪峰疄鐜版墜鏈篘FC寮€闂? ] }, { year: 2019, title: '瀹屾垚B杞瀺璧?, events: [ '2鏈埪峰ぉ娲ュ瓙鍏徃鎴愮珛', '3鏈埪稱ADX骞垮憡浜ゆ槗骞冲彴锛堥偦鐩燂級涓婄嚎', '12鏈埪锋湇鍔¤鐩?00+鍩庡競锛?5000锛嬬ぞ鍖? ] }, { year: 2020, title: '鏈嶅姟瑕嗙洊鍏ㄥ浗170+鍩庡競\n48000+绀惧尯', events: ['鎵嬫満寮€闂ㄧ敤鎴风牬700涓囷紝鏈堟洕鍏夎秴2浜挎', '闂ㄧ鏅鸿兘灞忛潰甯傦紝QFAD浜查偦鐢靛瓙灞忓箍鍛婃姇鏀剧郴缁熶笂绾?] }, { year: 2021, title: '鏈嶅姟绀惧尯绐佺牬50,000涓?, events: [ '鎵嬫満寮€闂ㄧ敤鎴风獊鐮?,000涓?, 'AI鏅鸿兘鍗曞厓闂ㄧ-21D鍜岋紙闈炴帴瑙﹀紡锛?, '寮€鍏崇伅绠遍棬绂丵L-CK2601闈㈠競' ] }, { year: 2022, title: '鏈嶅姟瑕嗙洊鍏ㄥ浗220+鍩庡競', events: ['鏈嶅姟绀惧尯绐佺牬58,000涓?, '鎵嬫満寮€闂ㄧ敤鎴风獊鐮?,500涓?, '鏅鸿兘寮€闂ㄦ鏁扮獊鐮?9浜挎'] }, { year: 2023, title: '鏈嶅姟绀惧尯绐佺牬60,000涓?, events: ['鎵嬫満寮€闂ㄧ敤鎴风獊鐮?,800涓?, '鏅鸿兘寮€闂ㄦ鏁扮獊鐮?2浜挎'] }, { year: 2024, title: '鏈嶅姟瑕嗙洊鍏ㄥ浗230涓煄甯?, events: [ '400-900-7070 浜查偦鐑嚎寮€閫?, '鏅鸿兘寮€闂ㄦ鏁扮獊鐮?1浜挎', '鍏ㄩ潰閫傞厤鍥戒骇鍖栵紝浜查偦寮€闂ㄩ缚钂欏師鐢烝PP鍏祴' ] }, { year: 2025, title: '鑾锋矙鍒╂枃鏉冨▉璁よ瘉', events: [ '鈥滀腑鍥界ぞ鍖洪棬绂佸獟浣撴暟閲忕涓€鈥?, '浜查偦绉戞妧鍗佸懆骞村彂甯冨叏鏂板搧鐗孡OGO', '涓庢敮浠樺疂鈥滅涓€涓嬧€ 鎵撻€犳櫤鎱у弸濂界ぞ鍖?, '鎸佺画鐐逛寒鈥滀翰閭诲弸濂界ぞ鍖衡€濆搧鐗 IP' ] } ] $(document).ready(function () { setNav('aboutUs') priviewImg() changeLocation() initTimeline() initAwards() getNewsList(page) }) //濂栭」鏌ョ湅澶у浘 function priviewImg(url) { $('#model-img').attr('src', url) } //鍏徃鍦板潃鍒囨崲 function changeLocation() { $('#location-list') .find('li') .click(function () { // console.log($(this).index()+1); let index = $(this).index() $(this).addClass('active').siblings().removeClass('active') $('#location-imgs').find('img').eq(index).show().siblings().hide() }) } //寮у舰鏃堕棿绾垮垵濮嬪寲 function initTimeline() { var svgPath = document.querySelector('.u-timeline-path') if (!svgPath) return var totalLength = svgPath.getTotalLength() var container = document.getElementById('timelineNodes') var svgEl = document.querySelector('.u-timeline-svg') // 鍔ㄦ€佸畾浣嶅欢浼哥嚎鏉★細璐寸揣娴忚鍣ㄥ乏鍙宠竟缂橈紝涓庤矾寰勮捣鐐?缁堢偣瀵归綈 updateExtLines() // 鐩戝惉绐楀彛瀹藉害鍙樺寲锛屽姩鎬佹洿鏂板欢浼哥嚎鏉 var resizeTimer = null $(window).on('resize', function () { clearTimeout(resizeTimer) resizeTimer = setTimeout(function () { updateExtLines() }, 50) }) // 鍥哄畾 viewBox 鍖归厤瀹瑰櫒瀹藉害锛宻caleX=1锛屽唴瀹瑰眳涓 svgEl.setAttribute('viewBox', '0 0 1310 620') svgPath.setAttribute( 'd', 'M 0,100 H 1100 C 1200,100 1200,300 1100,300 H 200 C 100,300 100,500 200,500 H 1310' ) totalLength = svgPath.getTotalLength() var svgRect = svgEl.getBoundingClientRect() var viewBox = svgEl.viewBox.baseVal var scaleX = svgRect.width / viewBox.width var scaleY = svgRect.height / viewBox.height // 铔囧舰鏃堕棿绾胯妭鐐瑰湪璺緞涓婄殑 x 鍧愭爣鐩爣鍊 // Row1(L鈫扲): 2015-2018, Row2(R鈫扡): 2021-2019, Row3(L鈫扲): 2022-2025 var targetX = [130, 383, 636, 891, 891, 636, 383, 383, 636, 891, 1180] // 姣忎釜鑺傜偣鎵€灞炶 (0/1/2) var rows = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2] // 璁$畻姣忚鐨勮矾寰勯暱搴︽悳绱㈣寖鍥达紙鍩轰簬 y 鍧愭爣鍖归厤锛 var rowBounds = [] var step = totalLength / 500 for (var r = 0; r < 3; r++) { var targetRowY = [100, 300, 500][r] var start = -1 var end = -1 for (var t = 0; t <= totalLength; t += step) { var p = svgPath.getPointAtLength(t) var onRow = Math.abs(p.y - targetRowY) < 20 if (onRow && start === -1) { start = Math.max(0, t - step) } if (!onRow && start !== -1 && end === -1) { end = Math.min(totalLength, t + step) break } } if (start === -1) start = 0 if (end === -1) end = totalLength rowBounds.push({ start: start, end: end }) } var count = TIMELINE_DATA.length for (var i = 0; i < count; i++) { // 鍦ㄥ搴旇鐨勮矾寰勮寖鍥村唴浜屽垎鎼滅储鐩爣 x var bounds = rowBounds[rows[i]] var low = bounds.start var high = bounds.end // 绗?琛屼粠鍙冲埌宸︼紝x闅忚矾寰勯€掑噺锛岄渶鍙嶈浆鎼滅储鏂瑰悜 var isRtl = rows[i] === 1 for (var iter = 0; iter < 40; iter++) { var mid = (low + high) / 2 var pt = svgPath.getPointAtLength(mid) if (isRtl) { // x 閫掑噺: pt.x > target 璇存槑杩樺湪鐩爣鍙充晶锛岄渶缁х画鍓嶈繘 if (pt.x > targetX[i]) { low = mid } else { high = mid } } else { // x 閫掑: pt.x < target 璇存槑杩樻病鍒扮洰鏍囷紝闇€缁х画鍓嶈繘 if (pt.x < targetX[i]) { low = mid } else { high = mid } } } var finalPt = svgPath.getPointAtLength((low + high) / 2) var x = finalPt.x var y = finalPt.y * scaleY var item = TIMELINE_DATA[i] // 鍒涘缓鑺傜偣 var nodeHtml = '
' + '
' + '
' + item.year + '骞滁/div>' + '
' // 鍒涘缓榛樿浜嬩欢鏂囨 - 鍦嗕笅鏂?2px var eventsHtml = '' for (var j = 0; j < item.events.length; j++) { eventsHtml += '

' + item.events[j].replace(/\n/g, '
') + '

' } var cardOffsetY = 22 var eventHtml = '
' + '
' + item.title + '
' + eventsHtml + '
' // 鍒涘缓閫変腑寮圭獥鍗$墖 var popupEventsHtml = '' for (var j = 0; j < item.events.length; j++) { popupEventsHtml += '
' + item.events[j].replace(/\n/g, '
') + '
' } var popupLeftInit = x - 60 var popupHtml = '
' + '
' + item.title + '
' + popupEventsHtml + '
' container.innerHTML += nodeHtml + eventHtml + popupHtml } // 缁戝畾鎮仠浜嬩欢锛堝鍣ㄧ骇 mousemove 妫€娴嬶紝閬垮厤鍗曞厓绱 enter/leave 闂儊锛 var activeIndex = null var leaveTimer = null function resetLeaveTimer() { if (leaveTimer) { clearTimeout(leaveTimer) leaveTimer = null } } function activate(index) { resetLeaveTimer() if (activeIndex === index) return activeIndex = index activateTimelineNode(index) } function deactivate() { if (activeIndex === null) return var prevIndex = activeIndex activeIndex = null $('.u-timeline-node').removeClass('u-timeline-node--active') $('.u-timeline-event[data-index="' + prevIndex + '"]').removeClass('u-timeline-event--hidden') $('.u-timeline-popup').removeClass('u-timeline-popup--active') $('.u-timeline-glow').remove() } $(container).on('mousemove', function (e) { var target = $(e.target).closest('.u-timeline-node, .u-timeline-event, .u-timeline-popup') if (target.length) { var index = target.data('index') if (index !== undefined) { activate(index) return } } // 榧犳爣涓嶅湪浠讳綍鑺傜偣/浜嬩欢鍖哄煙锛屽欢杩熷彇娑堟縺娲 if (activeIndex !== null && !leaveTimer) { leaveTimer = setTimeout(function () { deactivate() leaveTimer = null }, 100) } }) $(container).on('mouseleave', function () { leaveTimer = setTimeout(function () { deactivate() leaveTimer = null }, 100) }) } // 鏇存柊寤朵几绾挎潯浣嶇疆锛堥殢绐楀彛瀹藉害鍔ㄦ€佽皟鏁达級 function updateExtLines() { var tlSection = document.querySelector('.m-timeline') var tlContainer = document.querySelector('.u-timeline-container') if (!tlSection || !tlContainer) return var secRect = tlSection.getBoundingClientRect() var conRect = tlContainer.getBoundingClientRect() var conTop = conRect.top - secRect.top var conH = conRect.height var viewBoxH = 620 var lineH = 4 // 璺緞璧风偣 y=100锛岀粓鐐 y=500锛岃浆鎹负灞忓箷鍍忕礌 var startY = conTop + (100 / viewBoxH) * conH - lineH / 2 var endY = conTop + (500 / viewBoxH) * conH - lineH / 2 var leftExt = document.querySelector('.u-timeline-ext--left') var rightExt = document.querySelector('.u-timeline-ext--right') if (leftExt) { leftExt.style.top = startY + 'px' leftExt.style.left = '0' leftExt.style.width = conRect.left + 'px' } if (rightExt) { rightExt.style.top = endY + 'px' rightExt.style.left = conRect.right + 'px' rightExt.style.width = window.innerWidth - conRect.right + 'px' } } function activateTimelineNode(index) { // 閲嶇疆鎵€鏈夎妭鐐 $('.u-timeline-node').removeClass('u-timeline-node--active') // 娓呴櫎涔嬪墠鐨勮矾寰勬笎鍙 $('.u-timeline-glow').remove() // 鍙殣钘忓綋鍓嶉€変腑鑺傜偣鐨勯粯璁ゆ枃妗 $('.u-timeline-event').removeClass('u-timeline-event--hidden') $('.u-timeline-event[data-index="' + index + '"]').addClass('u-timeline-event--hidden') // 闅愯棌鎵€鏈夊脊绐楋紝鏄剧ず褰撳墠寮圭獥 $('.u-timeline-popup').removeClass('u-timeline-popup--active') var popup = $('.u-timeline-popup[data-index="' + index + '"]') popup.addClass('u-timeline-popup--active') // 寮圭獥瀹氫綅锛氱澶磋窛鍗$墖宸﹁竟60px锛屽皷绔鍑嗗渾蹇 var node = $('.u-timeline-node[data-index="' + index + '"]') if (node.length && popup.length) { var nodeLeft = node.position().left popup.css('left', nodeLeft - 60 + 'px') } // 婵€娲诲綋鍓嶈妭鐐 $('.u-timeline-node[data-index="' + index + '"]').addClass('u-timeline-node--active') // 娣诲姞璺緞娓愬彉鏁堟灉 addPathGlow(index) } function addPathGlow(index) { var node = document.querySelector('.u-timeline-node[data-index="' + index + '"]') if (!node) return var pathLength = parseFloat(node.getAttribute('data-path-length')) var svgPath = document.querySelector('.u-timeline-path') var svgEl = document.querySelector('.u-timeline-svg') if (!svgPath || !svgEl) return var totalLength = svgPath.getTotalLength() var svgRect = svgEl.getBoundingClientRect() var viewBox = svgEl.viewBox.baseVal var scaleX = svgRect.width / viewBox.width // 25px screen distance 鈫 viewBox units var glowLen = 60 / scaleX // 鍦嗙幆澶栬竟缂樺崐寰?8px灞忓箷)杞崲涓簐iewBox鍗曚綅锛屾笎鍙樿矾寰勪笉瑕嗙洊鍦嗙幆 var dotOffset = 8 / scaleX var strokeW = 4 var color = '#fb4747' var ns = 'http://www.w3.org/2000/svg' var defs = document.createElementNS(ns, 'defs') var glowStart = pathLength - dotOffset var glowEnd = pathLength + dotOffset var clampedStart = Math.max(0, glowStart - glowLen) var clampedEnd = Math.min(totalLength, glowEnd + glowLen) // 宸︽笎鍙 var leftGrad = document.createElementNS(ns, 'linearGradient') leftGrad.id = 'glow-left-' + index leftGrad.setAttribute('gradientUnits', 'userSpaceOnUse') var ls = svgPath.getPointAtLength(clampedStart) var le = svgPath.getPointAtLength(glowStart) leftGrad.setAttribute('x1', ls.x) leftGrad.setAttribute('y1', ls.y) leftGrad.setAttribute('x2', le.x) leftGrad.setAttribute('y2', le.y) var ls1 = document.createElementNS(ns, 'stop') ls1.setAttribute('offset', '0%') ls1.setAttribute('stop-color', color) ls1.setAttribute('stop-opacity', '0.1') var ls2 = document.createElementNS(ns, 'stop') ls2.setAttribute('offset', '100%') ls2.setAttribute('stop-color', color) ls2.setAttribute('stop-opacity', '1') leftGrad.appendChild(ls1) leftGrad.appendChild(ls2) defs.appendChild(leftGrad) // 鍙虫笎鍙 var rightGrad = document.createElementNS(ns, 'linearGradient') rightGrad.id = 'glow-right-' + index rightGrad.setAttribute('gradientUnits', 'userSpaceOnUse') var rs = svgPath.getPointAtLength(glowEnd) var re = svgPath.getPointAtLength(clampedEnd) rightGrad.setAttribute('x1', rs.x) rightGrad.setAttribute('y1', rs.y) rightGrad.setAttribute('x2', re.x) rightGrad.setAttribute('y2', re.y) var rs1 = document.createElementNS(ns, 'stop') rs1.setAttribute('offset', '0%') rs1.setAttribute('stop-color', color) rs1.setAttribute('stop-opacity', '1') var rs2 = document.createElementNS(ns, 'stop') rs2.setAttribute('offset', '100%') rs2.setAttribute('stop-color', color) rs2.setAttribute('stop-opacity', '0.1') rightGrad.appendChild(rs1) rightGrad.appendChild(rs2) defs.appendChild(rightGrad) svgEl.appendChild(defs) // 宸︽瑕嗙洊璺緞 if (glowStart - clampedStart > 0.5) { var leftD = 'M ' + ls.x + ',' + ls.y + ' L ' + le.x + ',' + le.y var leftPath = document.createElementNS(ns, 'path') leftPath.setAttribute('d', leftD) leftPath.setAttribute('fill', 'none') leftPath.setAttribute('stroke', 'url(#glow-left-' + index + ')') leftPath.setAttribute('stroke-width', strokeW) leftPath.setAttribute('stroke-linecap', 'round') leftPath.setAttribute('class', 'u-timeline-glow') svgEl.appendChild(leftPath) } // 鍙虫瑕嗙洊璺緞 if (clampedEnd - glowEnd > 0.5) { var rightD = 'M ' + rs.x + ',' + rs.y + ' L ' + re.x + ',' + re.y var rightPath = document.createElementNS(ns, 'path') rightPath.setAttribute('d', rightD) rightPath.setAttribute('fill', 'none') rightPath.setAttribute('stroke', 'url(#glow-right-' + index + ')') rightPath.setAttribute('stroke-width', strokeW) rightPath.setAttribute('stroke-linecap', 'round') rightPath.setAttribute('class', 'u-timeline-glow') svgEl.appendChild(rightPath) } } // 婊戝姩绐楀彛鍒嗛〉绠楁硶 // 棣栭〉鍜屾湯椤靛缁堟樉绀猴紝涓棿绐楀彛闅忓綋鍓嶉〉婊戝姩 // 褰撶獥鍙d笌棣?鏈〉涔嬮棿鏃犻棿闅旀椂锛屼笉鏄剧ず鐪佺暐鍙 function generatePagination(currentPage, totalPages) { // 鎬婚〉鏁 <= 7锛屽叏閮ㄦ樉绀猴紝鏃犵渷鐣ュ彿 if (totalPages <= 7) { var pages = [] for (var p = 1; p <= totalPages; p++) pages.push(p) return pages } var result = [] var showLeftMore = currentPage > 4 var showRightMore = currentPage < totalPages - 3 if (!showLeftMore && !showRightMore) { // 鎬婚〉鏁 8锛屾棤鐪佺暐鍙凤紝鍏ㄩ儴鏄剧ず for (var p = 1; p <= totalPages; p++) result.push(p) } else if (!showLeftMore) { // 闈犺繎璧峰绔細鏄剧ず鍓 6 椤 + ... + 鏈〉 for (var p = 1; p <= 6; p++) result.push(p) result.push('more') result.push(totalPages) } else if (!showRightMore) { // 闈犺繎鏈锛氶椤 + ... + 鍚 6 椤 result.push(1) result.push('more') for (var p = totalPages - 5; p <= totalPages; p++) result.push(p) } else { // 涓棿鐘舵€侊細棣栭〉 + ... + [c-2,c-1,c,c+1,c+2] + ... + 鏈〉 result.push(1) result.push('more') for (var p = currentPage - 2; p <= currentPage + 2; p++) result.push(p) result.push('more') result.push(totalPages) } return result } //鑾峰彇鏂伴椈鍒楄〃 function getNewsList(page) { $.ajax({ url: 'https://official.qinlinkeji.com/news', data: { page: page }, type: 'get', async: true, dataType: 'json', success: function (res) { // '璇︾粏浠嬬粛'+ // ''+ // console.log(res) let page = '' let list = '' maxPage = res._meta.pageCount var totalPages = res._meta.pageCount var currentPage = res._meta.currentPage var pagesToShow = generatePagination(currentPage, totalPages) for (var pi = 0; pi < pagesToShow.length; pi++) { var pg = pagesToShow[pi] if (pg === 'more') { page += '
  • ' + '' + '
  • ' } else { var curClass = pg == currentPage ? 'active' : '' page += '
  • ' + pg + '
  • ' } } if (res._meta.totalCount > 2) { $('.content-news').find('.carousel-inner').height('auto') } else { $('.content-news').find('.carousel-inner').height('auto') } for (let i = 0; i < res.items.length; i++) { var news = '', display = '', coverImg = res.items[i].cover_img, time = res.items[i].create_time, title = res.items[i].title, resume = res.items[i].resume, url = res.items[i].ext_url if (i == 0) { news = 'big-news' display = 'none' } else { news = 'small-news' display = 'block' } if (i == 0) list += '
    ' if (i == 2) list += '
    ' list += '
  • ' + '
    ' + '
    ' + '' + time + '' + '

    ' + title + '

    ' + '

    ' + resume + '

    ' + '
    鏌ョ湅璇︽儏
    ' + '
    ' + '
  • ' } if (res.items.length > 0) list += '
    ' $('#newsPage').html(page) $('#news-carousel-inner').html(list) // 涓?涓嬩竴椤垫寜閽潯浠舵樉绀猴細鎬婚〉鏁 <= 7 闅愯棌锛屽惁鍒欐牴鎹綋鍓嶉〉缃伆 var $newsSliderBtns = $('.news-slider-btns') if (totalPages <= 7) { $newsSliderBtns.hide() } else { $newsSliderBtns.show() $newsSliderBtns.find('.left-btn').toggleClass('disabled', currentPage == 1) $newsSliderBtns.find('.right-btn').toggleClass('disabled', currentPage == maxPage) } }, error: function (res) {} }) } //鏌ョ湅鏂伴椈璇︽儏 function goNewsDetail(url) { if (url) { window.open(url) } } function goNewsDetail2(type, url) { console.log(type) console.log(url) if (type == 'big-news' && url) { window.open(url) } } //涓婁竴椤 function changePage(type, num) { if (type == 'prev' || type == 'next') { if (type == 'prev') { if (page == 1) return page-- } else if (type == 'next') { if (page == maxPage) return page++ } } else { page = num } getNewsList(page) } $(function () { $('.mytab a').click(function (e) { e.preventDefault() //闃绘a閾炬帴鐨勮烦杞涓 $(this).tab('show') //鏄剧ず褰撳墠閫変腑鐨勯摼鎺ュ強鍏宠仈鐨刢ontent var index = $(this).data('index') // $('#passagewayVideo'+index).get(0).play(); if (index !== 0) { $('.geneVideo1').get(0).pause() $('.mask').show() } if (index !== 1) { $('.geneVideo2').get(0).pause() $('.mask').show() } if (index !== 2) { $('.geneVideo3').get(0).pause() $('.mask').show() } if (index !== 3) { $('.geneVideo4').get(0).pause() $('.mask').show() } if (index !== 4) { $('.geneVideo5').get(0).pause() $('.mask').show() } if (index !== 5) { $('.geneVideo6').get(0).pause() $('.mask').show() } if (index === 0) { for (var i = 1; i < 6; i++) { $('.mytab').find('.video-wrap').eq(i).hide().css({ top: '20px' }) } $('.mytab').find('.video-wrap').eq(0).show().animate( { top: '0' }, 300 ) } else if (index !== 0) { for (var i = 0; i < 6; i++) { if (i !== index) { $('.mytab').find('.video-wrap').eq(i).hide().css({ top: '20px' }) } } $('.mytab').find('.video-wrap').eq(index).show().animate( { top: '0' }, 300 ) } }) }) function playVideo(self, type) { $(self).parent().hide() $('#passagewayVideo' + type) .get(0) .play() // if(type == '0'){ // $('#passagewayVideo1').get(0).pause(); // $('#manageMask').show(); // }else{ // $('#passagewayVideo0').get(0).pause(); // $('#videoMask').show(); // } $('#passagewayVideo' + type) .get(0) .addEventListener('ended', function () { $('#passagewayVideo' + type).get(0).currentTime = 0 $(self).parent().show() }) } // 鑽h獕濂栭」鍔ㄦ€佸姞杞 function initAwards() { $.getJSON('award.json', function (data) { if (!data || !data.length) return var ITEMS_PER_PAGE = 4 var tabConfig = [ { key: 'award', jsonIndex: 0, carouselId: 'award-carousel' }, { key: 'patent', jsonIndex: 1, carouselId: 'patent-carousel' }, { key: 'protect', jsonIndex: 2, carouselId: 'protect-carousel' } ] for (var t = 0; t < tabConfig.length; t++) { var cfg = tabConfig[t] var category = data[cfg.jsonIndex] if (!category || !category.list) continue var items = category.list var totalPages = Math.ceil(items.length / ITEMS_PER_PAGE) var carouselInner = document.getElementById(cfg.carouselId + '-inner') if (!carouselInner) continue var html = '' for (var p = 0; p < totalPages; p++) { var isActive = p === 0 ? ' active' : '' html += '' } carouselInner.innerHTML = html // 鏇存柊椤电爜鎬绘暟 var sliderWrap = $(carouselInner).closest('.slider-wrap') sliderWrap.find('.u-ym .total').text(totalPages) // 鎵嬪姩鍒濆鍖 carousel锛堟湭浣跨敤 data-ride 閬垮厤鏃跺簭闂锛 $('#' + cfg.carouselId).carousel() } // 缁戝畾 carousel 婊戝姩浜嬩欢 bindCarouselEvents() }) } // 缁戝畾鎵€鏈夎崳瑾 carousel 鐨勬粦鍔ㄤ簨浠 function bindCarouselEvents() { var carousels = ['award-carousel', 'patent-carousel', 'protect-carousel'] for (var i = 0; i < carousels.length; i++) { ;(function (id) { $('#' + id).on('slid.bs.carousel', function (e) { $(this) .closest('.slider-wrap') .find('.u-ym .span') .text(e.to + 1) }) })(carousels[i]) } }