H5端显示三列岗位列表

This commit is contained in:
francis_fh
2025-12-09 17:53:45 +08:00
parent aa4b185aa2
commit be47e94196

View File

@@ -19,37 +19,47 @@ export function useColumnCount(onChange = () => {}) {
// columnCount.value = count < 2 ? 2 : count // columnCount.value = count < 2 ? 2 : count
// } // }
// } // }
const calcColumn = () => { const calcColumn = () => {
// 使用新的API替代已废弃的getSystemInfoSync // 使用新的API替代已废弃的getSystemInfoSync
let width let width
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
const mpSystemInfo = uni.getWindowInfo() const mpSystemInfo = uni.getWindowInfo()
width = mpSystemInfo.windowWidth width = mpSystemInfo.windowWidth
// #endif // #endif
// #ifndef MP-WEIXIN // #ifndef MP-WEIXIN
const otherSystemInfo = uni.getSystemInfoSync() const otherSystemInfo = uni.getSystemInfoSync()
width = otherSystemInfo.windowWidth width = otherSystemInfo.windowWidth
// #endif // #endif
let count = 2 let count = 2
if (width >= 1000) { if (width >= 1000) {
count = 5 // #ifdef H5
} else if (width >= 750) { count = 3 // H5端最多显示3列
count = 4 // #endif
} else if (width >= 500) { // #ifndef H5
count = 3 count = 5
} else { // #endif
count = 2 } else if (width >= 750) {
} // #ifdef H5
count = 3 // H5端最多显示3列
if (count !== columnCount.value) { // #endif
columnCount.value = count // #ifndef H5
} count = 4
// #endif
// 计算间距count=2 => 1count=5 => 2中间线性插值 } else if (width >= 500) {
const spacing = 2 - (count - 2) * (1 / 3) count = 3
// console.log('列数:', count, '间距:', spacing.toFixed(2)) } else {
columnSpace.value = spacing count = 2
}
if (count !== columnCount.value) {
columnCount.value = count
}
// 计算间距count=2 => 1count=5 => 2中间线性插值
const spacing = 2 - (count - 2) * (1 / 3)
// console.log('列数:', count, '间距:', spacing.toFixed(2))
columnSpace.value = spacing
} }
onMounted(() => { onMounted(() => {