$(function () { $('.QRcodeswrap,.Telswrap').click(function () { $(this).hide() }) $('.show_code').click(function () { $('.Telswrap').hide() $('.QRcodeswrap').show() }) $('.showTel').click(function () { $('.QRcodeswrap').hide() $('.Telswrap').show() }) $(".goToTop").click(function () { $('body,html').animate({ scrollTop: 0 }, 500); }) // 实现当前图片响应式效果 // 排除不需要进行改变的页面 if (!location.pathname.includes('/fangan/') && !location.pathname.includes('/solution/')) { $('img').each(function (index, item) { const currentBg = $(item).prop('style')['backgroundImage'] const currentSrc = $(item).attr('src') if (currentBg) { const srcList = currentSrc.split('/') const info = srcList[srcList.length - 1].replace('.png', '') const srcReg = /(w\d{1,})(h\d{1,})/ const w = srcReg.exec(info)[1].slice(1) const h = srcReg.exec(info)[2].slice(1) const ratio = (h / w).toFixed(2) const percent = ratio * 100 + '%' console.log('当前比例', ratio) console.log(currentBg) let bgUrl = currentBg.split("(")[1].split(")")[0].replace(/"/g, '') $(item).attr('src', bgUrl) $(item).prop('style', 'position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover') if ($(item).attr('class') == 'index_list_more_ul_img') { $(item).wrap(`
`) } else { $(item).wrap(`
`) } } }) } })