flat: 暂存
This commit is contained in:
@@ -15,12 +15,14 @@
|
||||
<swiper-item class="list">
|
||||
<scroll-view scroll-y class="main-scroll" @scrolltolower="handleScrollToLower">
|
||||
<view class="mian">
|
||||
<renderJobs
|
||||
<renderJobsCheckBox
|
||||
ref="jobListRef"
|
||||
:list="pageState.list"
|
||||
v-if="pageState.list.length"
|
||||
:longitude="longitudeVal"
|
||||
:latitude="latitudeVal"
|
||||
></renderJobs>
|
||||
@update:selected="updateSelectedCount"
|
||||
></renderJobsCheckBox>
|
||||
<empty v-else pdTop="200"></empty>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -41,18 +43,28 @@
|
||||
</swiper>
|
||||
</view>
|
||||
</view>
|
||||
<template #footer>
|
||||
<view v-if="selectedJobCount > 0 && type === 0" class="compare-bar">
|
||||
<view class="selected-count">已选中 {{ selectedJobCount }} 个岗位</view>
|
||||
<button class="compare-btn" @click="handleCompare">岗位对比</button>
|
||||
</view>
|
||||
</template>
|
||||
</AppLayout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { inject, ref, reactive } from 'vue';
|
||||
import { inject, ref, reactive, nextTick } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import useLocationStore from '@/stores/useLocationStore';
|
||||
import renderJobsCheckBox from '@/components/renderJobs/renderJobsCheckBox.vue';
|
||||
const { longitudeVal, latitudeVal } = storeToRefs(useLocationStore());
|
||||
const { $api, navBack } = inject('globalFunction');
|
||||
const { $api, navBack, navTo } = inject('globalFunction');
|
||||
const type = ref(0);
|
||||
|
||||
// 新增:获取renderJobs组件实例
|
||||
const jobListRef = ref(null);
|
||||
// 新增:选中的岗位数量
|
||||
const selectedJobCount = ref(0);
|
||||
const pageState = reactive({
|
||||
page: 0,
|
||||
list: [],
|
||||
@@ -83,6 +95,32 @@ function changeType(e) {
|
||||
type.value = e;
|
||||
}
|
||||
|
||||
// 监听选中数量变化
|
||||
function updateSelectedCount() {
|
||||
nextTick(() => {
|
||||
if (jobListRef.value) {
|
||||
selectedJobCount.value = jobListRef.value.selectedJobs.length;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 新增:对比按钮点击事件
|
||||
function handleCompare() {
|
||||
if (selectedJobCount.value < 2) {
|
||||
uni.showToast({
|
||||
title: '请至少选择2个岗位进行对比',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 获取选中的岗位数据
|
||||
const selectedJobs = jobListRef.value.selectedJobs;
|
||||
const selectedJobData = pageState.list.filter((job) => selectedJobs.includes(job.jobId));
|
||||
uni.setStorageSync('compare', selectedJobData);
|
||||
// 跳转到对比页面(假设已创建对比页面)
|
||||
navTo('/packageA/pages/collection/compare');
|
||||
}
|
||||
|
||||
function handleScrollToLower() {
|
||||
getJobList();
|
||||
}
|
||||
@@ -149,6 +187,35 @@ function getCompanyList(type = 'add') {
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
// 新增底部对比栏样式
|
||||
.compare-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20rpx 30rpx;
|
||||
background-color: #fff;
|
||||
border-top: 1rpx solid #eee;
|
||||
box-shadow: 0 -2rpx 10rpx rgba(0,0,0,0.05);
|
||||
|
||||
.selected-count {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.compare-btn {
|
||||
width: 200rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
background-color: #4C6EFB;
|
||||
color: #fff;
|
||||
border-radius: 30rpx;
|
||||
font-size: 28rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0
|
||||
}
|
||||
}
|
||||
.btn {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
Reference in New Issue
Block a user