ai优化bike页面

This commit is contained in:
WindowBird 2025-10-09 15:30:40 +08:00
parent f4c23d8de6
commit ae8c95e4a7
4 changed files with 122 additions and 40 deletions

View File

@ -2,9 +2,8 @@
import {onMounted} from "vue"; import {onMounted} from "vue";
definePageMeta({ definePageMeta({
layout: 'mini' layout: 'no-new'
}) })
onMounted(() => { onMounted(() => {
// CSS // CSS
loadCSSFiles() loadCSSFiles()

View File

@ -2,7 +2,7 @@
import {onMounted} from "vue"; import {onMounted} from "vue";
definePageMeta({ definePageMeta({
layout: 'mini' layout: 'no-new'
}) })
onMounted(() => { onMounted(() => {

View File

@ -2,6 +2,10 @@
import {onMounted} from "vue"; import {onMounted} from "vue";
import {useHead} from "#app"; import {useHead} from "#app";
definePageMeta({
layout: 'no-new'
})
// 使 Nuxt 3 useHead // 使 Nuxt 3 useHead
useHead({ useHead({
link: [ link: [
@ -12,7 +16,6 @@ useHead({
], ],
script: [ script: [
{src: '/jsBike/jquery.min.js'}, {src: '/jsBike/jquery.min.js'},
{src: '/jsBike/minBanner.js'},
{src: '/jsBike/news.js'} {src: '/jsBike/news.js'}
] ]
}) })
@ -20,6 +23,12 @@ useHead({
onMounted(() => { onMounted(() => {
// DOM // DOM
setTimeout(() => { setTimeout(() => {
// jQuery
if (typeof $ === 'undefined') {
console.error('jQuery未加载');
return;
}
// //
$('.index-giant').height($(window).height()); $('.index-giant').height($(window).height());
@ -46,7 +55,7 @@ onMounted(() => {
// //
(function offBar() { (function offBar() {
var off=true; let off = true;
$('.left-bar-1').on('click', function () { $('.left-bar-1').on('click', function () {
if (off) { if (off) {
$('.left-bar').animate({'right': 0}, "1000"); $('.left-bar').animate({'right': 0}, "1000");
@ -86,9 +95,83 @@ onMounted(() => {
}, 1500); }, 1500);
return false; return false;
}); });
}, 100);
//
initBanner();
}, 500);
}) })
//
function initBanner() {
if (typeof $ === 'undefined') {
console.error('jQuery未加载无法初始化轮播图');
return;
}
const pics = [
{url: '/images/minBanner-1.png', link: '#', time: 3000},
{url: '/images/minBanner-2.jpg', link: '', time: 3000},
{url: '/images/minBanner-3.jpg', link: '', time: 3000},
{url: '/images/minBanner-4.jpg', link: '', time: 3000}
];
const $picplayer = $('#picplayer');
const $piccontent = $('#piccontent');
if ($picplayer.length === 0 || $piccontent.length === 0) {
console.error('轮播图容器未找到');
return;
}
//
$piccontent.empty();
//
pics.forEach((pic, index) => {
$piccontent.append(`<a target="_blank" href="${pic.link}"><img id="picitem${index}" style="display: none; z-index: ${index}" src="${pic.url}" /></a>`);
});
//
pics.forEach((pic, index) => {
$(`#picbtn${index}`).data('index', index);
$(`#picbtn${index}`).off('click').on('click', function() {
setSelectedItem(index);
});
});
let selectedIndex = 0;
let playID = null;
function setSelectedItem(index) {
selectedIndex = index;
clearInterval(playID);
//
$piccontent.find('img').fadeOut('fast');
//
$(`#picitem${index}`).fadeIn('slow');
//
$('#picbtns .caption').each(function(i) {
if (i === index) {
$(this).find('span').css('backgroundColor', '#485766');
} else {
$(this).find('span').css('backgroundColor', '#D8D8D8');
}
});
//
playID = setInterval(() => {
const nextIndex = (selectedIndex + 1) % pics.length;
setSelectedItem(nextIndex);
}, pics[index].time);
}
//
setSelectedItem(0);
}
</script> </script>