flat: 兼容平板、等超宽屏幕
This commit is contained in:
@@ -8,13 +8,39 @@ import {
|
|||||||
|
|
||||||
export function useColumnCount(onChange = () => {}) {
|
export function useColumnCount(onChange = () => {}) {
|
||||||
const columnCount = ref(0)
|
const columnCount = ref(0)
|
||||||
|
const columnSpace = ref(2)
|
||||||
|
|
||||||
|
|
||||||
|
// const calcColumn = () => {
|
||||||
|
// const width = uni.getSystemInfoSync().windowWidth
|
||||||
|
// console.log(width)
|
||||||
|
// const count = Math.min(5, Math.floor(width / 375) + 1)
|
||||||
|
// if (count !== columnCount.value) {
|
||||||
|
// columnCount.value = count < 2 ? 2 : count
|
||||||
|
// }
|
||||||
|
// }
|
||||||
const calcColumn = () => {
|
const calcColumn = () => {
|
||||||
const width = uni.getSystemInfoSync().windowWidth
|
const width = uni.getSystemInfoSync().windowWidth
|
||||||
const count = Math.min(5, Math.floor(width / 375) + 1)
|
|
||||||
|
let count = 2
|
||||||
|
if (width >= 1000) {
|
||||||
|
count = 5
|
||||||
|
} else if (width >= 750) {
|
||||||
|
count = 4
|
||||||
|
} else if (width >= 500) {
|
||||||
|
count = 3
|
||||||
|
} else {
|
||||||
|
count = 2
|
||||||
|
}
|
||||||
|
|
||||||
if (count !== columnCount.value) {
|
if (count !== columnCount.value) {
|
||||||
columnCount.value = count
|
columnCount.value = count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算间距:count=2 => 1,count=5 => 2,中间线性插值
|
||||||
|
const spacing = 2 - (count - 2) * (1 / 3)
|
||||||
|
// console.log('列数:', count, '间距:', spacing.toFixed(2))
|
||||||
|
columnSpace.value = spacing
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -40,5 +66,6 @@ export function useColumnCount(onChange = () => {}) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
columnCount,
|
columnCount,
|
||||||
|
columnSpace
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -18,7 +18,7 @@
|
|||||||
</script>
|
</script>
|
||||||
<title></title>
|
<title></title>
|
||||||
<!-- vconsole -->
|
<!-- vconsole -->
|
||||||
<!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
|
<!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var vConsole = new window.VConsole();
|
var vConsole = new window.VConsole();
|
||||||
vConsole.destroy();
|
vConsole.destroy();
|
||||||
|
@@ -234,12 +234,12 @@
|
|||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
"navigationBarTitleText": "uni-app",
|
"navigationBarTitleText": "uni-app",
|
||||||
"navigationBarBackgroundColor": "#F8F8F8",
|
"navigationBarBackgroundColor": "#F8F8F8",
|
||||||
"backgroundColor": "#F8F8F8"
|
"backgroundColor": "#F8F8F8",
|
||||||
// "enablePullDownRefresh": false,
|
// "enablePullDownRefresh": false,
|
||||||
// "navigationStyle": "custom",
|
// "navigationStyle": "custom",
|
||||||
// "rpxCalcBaseDeviceWidth": 3840,
|
"rpxCalcBaseDeviceWidth": 375,
|
||||||
// "rpxCalcMaxDeviceWidth": 3840,
|
"rpxCalcMaxDeviceWidth": 750,
|
||||||
// "rpxCalcIncludeWidth": 750
|
"rpxCalcIncludeWidth": 750
|
||||||
},
|
},
|
||||||
"uniIdRouter": {}
|
"uniIdRouter": {}
|
||||||
}
|
}
|
@@ -67,7 +67,12 @@
|
|||||||
<view class="table-list">
|
<view class="table-list">
|
||||||
<scroll-view :scroll-y="true" class="falls-scroll" @scroll="handleScroll" @scrolltolower="scrollBottom">
|
<scroll-view :scroll-y="true" class="falls-scroll" @scroll="handleScroll" @scrolltolower="scrollBottom">
|
||||||
<view class="falls" v-if="list.length">
|
<view class="falls" v-if="list.length">
|
||||||
<custom-waterfalls-flow :column="columnCount" ref="waterfallsFlowRef" :value="list">
|
<custom-waterfalls-flow
|
||||||
|
:column="columnCount"
|
||||||
|
:columnSpace="columnSpace"
|
||||||
|
ref="waterfallsFlowRef"
|
||||||
|
:value="list"
|
||||||
|
>
|
||||||
<template v-slot:default="job">
|
<template v-slot:default="job">
|
||||||
<view class="item btn-feel" v-if="!job.recommend">
|
<view class="item btn-feel" v-if="!job.recommend">
|
||||||
<view class="falls-card" @click="nextDetail(job)">
|
<view class="falls-card" @click="nextDetail(job)">
|
||||||
@@ -187,7 +192,7 @@ const rangeOptions = ref([
|
|||||||
// { name: '创意总监', highlight: false },
|
// { name: '创意总监', highlight: false },
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
const { columnCount } = useColumnCount(() => {
|
const { columnCount, columnSpace } = useColumnCount(() => {
|
||||||
pageState.pageSize = 10 * (columnCount.value - 1);
|
pageState.pageSize = 10 * (columnCount.value - 1);
|
||||||
getJobRecommend('refresh');
|
getJobRecommend('refresh');
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@@ -726,4 +731,4 @@ function dataToImg(data) {
|
|||||||
.isBut{
|
.isBut{
|
||||||
filter: grayscale(100%);
|
filter: grayscale(100%);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
BIN
unpackage/dist/build/.DS_Store
vendored
BIN
unpackage/dist/build/.DS_Store
vendored
Binary file not shown.
Reference in New Issue
Block a user