From e432da9c7573186f4bf016e0a111ce4fee8eef9c Mon Sep 17 00:00:00 2001 From: zzc <1761997216@qq.com> Date: Thu, 7 May 2026 11:09:32 +0800 Subject: [PATCH] first commit --- pages/index/index.vue | 107 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 100 insertions(+), 7 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index c45dc0d..ec0293e 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,21 +3,37 @@ - - 全民评分 - 看看全国网友怎么评分 - + + 全民评分 + 看看全国网友怎么评分 + + + + + + + {{ category.name }} + + + + - - + + @@ -98,6 +114,37 @@ const userInfo = computed(() => userStore?.userInfo || {}); const loading = ref(false); const hasMore = ref(true); +const currentCategory = ref(0); + +const categories = ref([ + { id: 0, name: '全部' }, + { id: 1, name: '历史' }, + { id: 2, name: '皇帝' }, + { id: 3, name: '数码' }, + { id: 4, name: '手机' }, + { id: 5, name: '城市' }, + { id: 6, name: '生活' }, +]); + +const switchCategory = (index) => { + if (currentCategory.value === index) return; + currentCategory.value = index; + // 切换分类时重新加载数据 + topicList.value = []; + loading.value = true; + hasMore.value = true; + setTimeout(() => { + // 模拟根据分类筛选数据 + const filteredData = mockData.filter(item => { + if (index === 0) return true; + const categoryName = categories.value[index].name; + return item.tags.includes(categoryName); + }); + topicList.value = [...filteredData]; + loading.value = false; + hasMore.value = filteredData.length >= 10 ? true : false; + }, 500); +}; const mockData = [ { @@ -240,7 +287,6 @@ onShareTimeline(async () => { .header-content { display: flex; - justify-content: space-between; align-items: center; padding: 0 32rpx; height: 120rpx; @@ -270,6 +316,53 @@ onShareTimeline(async () => { border-radius: 50%; border: 2rpx solid #fff; box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); + margin-right: 24rpx; /* 头像在左边时,增加右侧间距 */ +} + +/* Tab 样式 */ +.category-tabs { + width: 100%; + white-space: nowrap; + height: 88rpx; +} + +.tabs-wrapper { + display: inline-flex; + padding: 0 16rpx; + height: 100%; + align-items: center; +} + +.tab-item { + display: inline-flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 0 24rpx; + height: 100%; + position: relative; +} + +.tab-text { + font-size: 30rpx; + color: #666; + transition: all 0.3s ease; +} + +.tab-item.active .tab-text { + font-size: 34rpx; + font-weight: bold; + color: #111; +} + +.tab-line { + position: absolute; + bottom: 12rpx; + width: 32rpx; + height: 6rpx; + background-color: #2953ff; + border-radius: 4rpx; + transition: all 0.3s ease; } .topic-list {