hookehuyr

feat(ScrollableFamilyList): 改进列表项布局并添加底部提示

- 将随机偏移改为按行数规律排列(奇数行靠左,偶数行靠右)
- 增加extraPlaceholder属性控制占位数量
- 在FamilyRank页面添加底部提示文本
- 调整RankingCard组件高度和占位配置
1 <!-- 1 <!--
2 * @Date: 2025-01-09 00:00:00 2 * @Date: 2025-01-09 00:00:00
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-10-29 13:07:23 4 + * @LastEditTime: 2025-10-29 13:24:24
5 * @FilePath: /lls_program/src/components/RankingCard.vue 5 * @FilePath: /lls_program/src/components/RankingCard.vue
6 * @Description: 排行榜卡片组件 6 * @Description: 排行榜卡片组件
7 --> 7 -->
...@@ -142,7 +142,8 @@ ...@@ -142,7 +142,8 @@
142 <view v-if="activeTab === 'support'" class="scrollable-family-section mt-1" style="padding: 0 24rpx 34rpx;"> 142 <view v-if="activeTab === 'support'" class="scrollable-family-section mt-1" style="padding: 0 24rpx 34rpx;">
143 <ScrollableFamilyList 143 <ScrollableFamilyList
144 :family-data="familyDanmus" 144 :family-data="familyDanmus"
145 - height="560rpx" 145 + :extra-placeholder="0"
146 + height="600rpx"
146 /> 147 />
147 </view> 148 </view>
148 149
......
...@@ -72,6 +72,11 @@ const props = defineProps({ ...@@ -72,6 +72,11 @@ const props = defineProps({
72 listenExternalScroll: { 72 listenExternalScroll: {
73 type: Boolean, 73 type: Boolean,
74 default: false 74 default: false
75 + },
76 + // 添加额外占位,用于触发滚动事件
77 + extraPlaceholder: {
78 + type: Number,
79 + default: 1
75 } 80 }
76 }) 81 })
77 82
...@@ -93,29 +98,28 @@ const totalPages = computed(() => { ...@@ -93,29 +98,28 @@ const totalPages = computed(() => {
93 const currentPageData = computed(() => { 98 const currentPageData = computed(() => {
94 const start = currentPage.value * props.itemsPerPage 99 const start = currentPage.value * props.itemsPerPage
95 // 每页多显示一个item,有利于滚动触发 100 // 每页多显示一个item,有利于滚动触发
96 - const end = start + props.itemsPerPage + 2 101 + const end = start + props.itemsPerPage + props.extraPlaceholder
97 return props.familyData.slice(start, end) 102 return props.familyData.slice(start, end)
98 }) 103 })
99 104
100 // 随机水平位置数组 105 // 随机水平位置数组
101 const randomOffsets = ref([]) 106 const randomOffsets = ref([])
102 107
103 -// 生成随机水平偏移 108 +// 生成按行数规律排列的偏移
104 const generateRandomOffsets = () => { 109 const generateRandomOffsets = () => {
105 // 为实际显示的item数量生成偏移(包括多出的一个) 110 // 为实际显示的item数量生成偏移(包括多出的一个)
106 - const actualItemCount = Math.min(props.itemsPerPage + 2, props.familyData.length - currentPage.value * props.itemsPerPage) 111 + const actualItemCount = Math.min(props.itemsPerPage + props.extraPlaceholder, props.familyData.length - currentPage.value * props.itemsPerPage)
107 112
108 randomOffsets.value = Array.from({ length: actualItemCount }, (_, index) => { 113 randomOffsets.value = Array.from({ length: actualItemCount }, (_, index) => {
109 - // 确保一屏内有靠最左和最右的简介,但不能被裁切 114 + // 按行数规律排列:奇数行(1,3,5...)靠左,偶数行(2,4,6...)靠右
110 - if (index === 0) { 115 + const rowNumber = index + 1 // 行号从1开始
111 - // 第一个简介靠左,但留出足够边距避免裁切 116 +
112 - return 0 // 不偏移,保持在安全区域 117 + if (rowNumber % 2 === 1) {
113 - } else if (index === actualItemCount - 1) { 118 + // 奇数行靠左边容器
114 - // 最后一个简介靠最右,使用特殊标记 119 + return 0 // 不偏移,靠左
115 - return 100 // 使用特殊值标记需要贴右边
116 } else { 120 } else {
117 - // 其他简介在中间随机分布,避免负偏移 121 + // 偶数行靠右边容器,使用特殊标记
118 - return Math.floor(Math.random() * 81) // 0rpx 到 80rpx 122 + return 100 // 使用特殊值标记需要贴右边
119 } 123 }
120 }) 124 })
121 } 125 }
...@@ -123,10 +127,10 @@ const generateRandomOffsets = () => { ...@@ -123,10 +127,10 @@ const generateRandomOffsets = () => {
123 // 获取每个项目的样式 127 // 获取每个项目的样式
124 const getItemStyle = (index) => { 128 const getItemStyle = (index) => {
125 const offset = randomOffsets.value[index] || 0 129 const offset = randomOffsets.value[index] || 0
126 - const isLastItem = index === randomOffsets.value.length - 1 130 + const rowNumber = index + 1 // 行号从1开始
127 131
128 - // 最后一个item贴右边的特殊处理 132 + // 偶数行贴右边的特殊处理
129 - if (isLastItem && offset === 100) { 133 + if (rowNumber % 2 === 0 && offset === 100) {
130 return { 134 return {
131 marginBottom: '24rpx', 135 marginBottom: '24rpx',
132 maxWidth: '100%', 136 maxWidth: '100%',
...@@ -138,15 +142,13 @@ const getItemStyle = (index) => { ...@@ -138,15 +142,13 @@ const getItemStyle = (index) => {
138 } 142 }
139 } 143 }
140 144
141 - // 其他item的正常处理 145 + // 奇数行靠左的处理
142 return { 146 return {
143 transform: `translateX(${offset}rpx)`, 147 transform: `translateX(${offset}rpx)`,
144 marginBottom: '24rpx', 148 marginBottom: '24rpx',
145 - // 确保内容不被裁切,所有偏移都是正值或0
146 - paddingRight: offset > 50 ? '24rpx' : '0',
147 maxWidth: '100%', 149 maxWidth: '100%',
148 - // 确保左侧有足够的边距 150 + paddingLeft: '0',
149 - paddingLeft: '0' 151 + paddingRight: '0'
150 } 152 }
151 } 153 }
152 154
...@@ -313,7 +315,7 @@ onMounted(() => { ...@@ -313,7 +315,7 @@ onMounted(() => {
313 box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08); 315 box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08);
314 backdrop-filter: blur(12rpx); 316 backdrop-filter: blur(12rpx);
315 border: 2rpx solid rgba(255, 255, 255, 0.5); 317 border: 2rpx solid rgba(255, 255, 255, 0.5);
316 - max-width: 500rpx; 318 + max-width: 550rpx;
317 min-width: 350rpx; 319 min-width: 350rpx;
318 transition: all 0.3s ease; 320 transition: all 0.3s ease;
319 } 321 }
......
1 <!-- 1 <!--
2 * @Date: 2025-09-01 13:07:52 2 * @Date: 2025-09-01 13:07:52
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-10-29 12:49:27 4 + * @LastEditTime: 2025-10-29 13:34:25
5 * @FilePath: /lls_program/src/pages/FamilyRank/index.vue 5 * @FilePath: /lls_program/src/pages/FamilyRank/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -177,6 +177,7 @@ ...@@ -177,6 +177,7 @@
177 height="1200rpx" 177 height="1200rpx"
178 :listen-external-scroll="true" 178 :listen-external-scroll="true"
179 /> 179 />
180 + <view class="scrollable-family-list-footer">上滑有更多助力家庭自荐</view>
180 </view> 181 </view>
181 182
182 <!-- 我的排名悬浮卡片 --> 183 <!-- 我的排名悬浮卡片 -->
...@@ -1107,4 +1108,15 @@ onMounted(async () => { ...@@ -1107,4 +1108,15 @@ onMounted(async () => {
1107 } 1108 }
1108 } 1109 }
1109 } 1110 }
1111 +
1112 +.scrollable-family-list-footer {
1113 + text-align: center;
1114 + font-size: 28rpx;
1115 + color: rgba(255, 255, 255, 0.8);
1116 + margin-top: 32rpx;
1117 + position: absolute;
1118 + bottom: 40rpx;
1119 + left: 0;
1120 + right: 0;
1121 +}
1110 </style> 1122 </style>
......