flat: 体验优化,swiper优化,添加uploadfile Class方法
This commit is contained in:
@@ -11,21 +11,31 @@
|
||||
<view class="button-click" :class="{ active: type === 1 }" @click="changeType(1)">公司企业</view>
|
||||
</view>
|
||||
<view class="coll-main">
|
||||
<swiper class="swiper" :current="type" @change="changeSwiperType">
|
||||
<swiper-item class="list">
|
||||
<swiper class="swiper" :disable-touch="disableTouch" :current="type" @change="changeSwiperType">
|
||||
<swiper-item
|
||||
class="list"
|
||||
@touchstart.passive="handleTouchStart"
|
||||
@touchmove.passive="handleTouchMove"
|
||||
@touchend="disableTouch = false"
|
||||
>
|
||||
<scroll-view scroll-y class="main-scroll" @scrolltolower="handleScrollToLower">
|
||||
<view class="mian">
|
||||
<renderJobCollectionRecord
|
||||
<renderJobCollectionRecord
|
||||
v-if="pageState.list.length"
|
||||
:list="pageState.list"
|
||||
:longitude="longitudeVal"
|
||||
:latitude="latitudeVal">
|
||||
</renderJobCollectionRecord>
|
||||
:latitude="latitudeVal"
|
||||
></renderJobCollectionRecord>
|
||||
<empty v-else pdTop="200"></empty>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</swiper-item>
|
||||
<swiper-item class="list">
|
||||
<swiper-item
|
||||
class="list"
|
||||
@touchstart.passive="handleTouchStart"
|
||||
@touchmove.passive="handleTouchMove"
|
||||
@touchend="disableTouch = false"
|
||||
>
|
||||
<scroll-view scroll-y class="main-scroll" @scrolltolower="handleScrollToLowerCompany">
|
||||
<view class="mian">
|
||||
<renderCompanyCollectionRecord
|
||||
@@ -69,14 +79,79 @@ const pageCompanyState = reactive({
|
||||
pageSize: 10,
|
||||
});
|
||||
|
||||
const disableTouch = ref(false);
|
||||
const startPointX = ref(0);
|
||||
const totalPage = 2;
|
||||
const THRESHOLD = 5;
|
||||
|
||||
onShow(() => {
|
||||
getJobList();
|
||||
getCompanyList();
|
||||
});
|
||||
|
||||
function handleTouchStart(e) {
|
||||
// 确保有触摸点
|
||||
if (e.touches.length > 0) {
|
||||
startPointX.value = e.touches[0].clientX;
|
||||
disableTouch.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleTouchMove(e) {
|
||||
if (e.touches.length === 0) return;
|
||||
|
||||
const currentX = e.touches[0].clientX;
|
||||
const diffX = currentX - startPointX.value;
|
||||
|
||||
if (type.value === 0) {
|
||||
if (diffX > THRESHOLD) {
|
||||
disableTouch.value = true;
|
||||
} else {
|
||||
disableTouch.value = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (type.value === totalPage - 1) {
|
||||
if (diffX < -THRESHOLD) {
|
||||
disableTouch.value = true;
|
||||
} else {
|
||||
disableTouch.value = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
disableTouch.value = false;
|
||||
}
|
||||
|
||||
function changeSwiperType(e) {
|
||||
const newIndex = e.detail.current;
|
||||
const lastIndex = type.value;
|
||||
|
||||
const isSwipingRight = newIndex < lastIndex;
|
||||
const isSwipingLeft = newIndex > lastIndex;
|
||||
|
||||
if (lastIndex === 0 && isSwipingRight) {
|
||||
disableTouch.value = true;
|
||||
type.value = 0;
|
||||
setTimeout(() => {
|
||||
disableTouch.value = false;
|
||||
}, 50);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastIndex === totalPage - 1 && isSwipingLeft) {
|
||||
disableTouch.value = true;
|
||||
type.value = lastIndex;
|
||||
|
||||
setTimeout(() => {
|
||||
disableTouch.value = false;
|
||||
}, 50);
|
||||
return;
|
||||
}
|
||||
|
||||
const current = e.detail.current;
|
||||
type.value = current;
|
||||
disableTouch.value = false;
|
||||
}
|
||||
|
||||
function changeType(e) {
|
||||
|
||||
Reference in New Issue
Block a user