641 lines
20 KiB
Vue
641 lines
20 KiB
Vue
<template>
|
||
<!-- 需求共享大厅 -->
|
||
<view class="h5-container lease-demand-container">
|
||
<!-- <van-nav-bar title="需求共享大厅" /> -->
|
||
|
||
<view style="padding: 15px 0; display: flex; align-items: center; justify-content: center">
|
||
<view>
|
||
<text style="color: #000"> 需求共享大厅 </text>
|
||
</view>
|
||
</view>
|
||
<view class="demand-header">
|
||
<!-- <view>
|
||
<SearchIpt
|
||
v-model:activeTypeName="activeTypeName"
|
||
v-model:searchModelValue="searchModelValue"
|
||
@onSearchByType="onSearchByType"
|
||
/>
|
||
</view> -->
|
||
|
||
<navigator class="demand-release" url="/pages/demand-release/index">
|
||
<view>
|
||
<van-highlight
|
||
:keywords="keywords"
|
||
source-string="需求发布"
|
||
highlight-class="custom-class"
|
||
/>
|
||
</view>
|
||
<view>发布机具需求信息</view>
|
||
</navigator>
|
||
</view>
|
||
|
||
<view class="goods-items">
|
||
<view class="filter-box">
|
||
<view class="filter-items">
|
||
<text> 发布时间 </text>
|
||
<view class="filter-type">
|
||
<van-icon
|
||
name="play"
|
||
:color="searchParams.startTime === 'ASC' ? '#00a288' : ''"
|
||
@click="onClickStartTime(searchParams.startTime === 'ASC' ? '' : 'ASC')"
|
||
size="12"
|
||
/>
|
||
<van-icon
|
||
name="play"
|
||
:color="searchParams.startTime === 'DESC' ? '#00a288' : ''"
|
||
@click="
|
||
onClickStartTime(searchParams.startTime === 'DESC' ? '' : 'DESC')
|
||
"
|
||
size="12"
|
||
/>
|
||
</view>
|
||
</view>
|
||
<view class="filter-items">
|
||
<text> 租期 </text>
|
||
<view class="filter-type">
|
||
<van-icon
|
||
name="play"
|
||
:color="searchParams.rentDay === 'ASC' ? '#00a288' : ''"
|
||
@click="onClickRentDay(searchParams.rentDay === 'ASC' ? '' : 'ASC')"
|
||
size="12"
|
||
/>
|
||
<van-icon
|
||
name="play"
|
||
:color="searchParams.rentDay === 'DESC' ? '#00a288' : ''"
|
||
@click="onClickRentDay(searchParams.rentDay === 'DESC' ? '' : 'DESC')"
|
||
size="12"
|
||
/>
|
||
</view>
|
||
</view>
|
||
<view class="filter-items">
|
||
<text> 截止时间 </text>
|
||
<view class="filter-type">
|
||
<van-icon
|
||
name="play"
|
||
:color="searchParams.endTime === 'ASC' ? '#00a288' : ''"
|
||
@click="onClickEndTime(searchParams.endTime === 'ASC' ? '' : 'ASC')"
|
||
size="12"
|
||
/>
|
||
<van-icon
|
||
name="play"
|
||
:color="searchParams.endTime === 'DESC' ? '#00a288' : ''"
|
||
@click="onClickEndTime(searchParams.endTime === 'DESC' ? '' : 'DESC')"
|
||
size="12"
|
||
/>
|
||
</view>
|
||
</view>
|
||
<view class="filter-items">
|
||
<text> 租赁数量 </text>
|
||
<view class="filter-type">
|
||
<van-icon
|
||
name="play"
|
||
:color="searchParams.rentNum === 'ASC' ? '#00a288' : ''"
|
||
@click="onClickRentNum(searchParams.rentNum === 'ASC' ? '' : 'ASC')"
|
||
size="12"
|
||
/>
|
||
<van-icon
|
||
name="play"
|
||
:color="searchParams.rentNum === 'DESC' ? '#00a288' : ''"
|
||
@click="onClickRentNum(searchParams.rentNum === 'DESC' ? '' : 'DESC')"
|
||
size="12"
|
||
/>
|
||
</view>
|
||
</view>
|
||
|
||
<view @click="onFilter" class="filter-items">
|
||
<text> 筛选 </text>
|
||
<van-icon name="filter-o" />
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<scroll-view scroll-y class="scroll-item" @scrolltolower="onScrollTolower">
|
||
<van-grid :column-num="1" :gutter="4">
|
||
<van-grid-item v-for="d in leaseDemandLis" :key="d.id">
|
||
<view class="demand-items">
|
||
<view style="font-weight: bold; font-size: 16px">
|
||
{{ d.leaseName }}
|
||
</view>
|
||
<view class="count-down">
|
||
剩余:
|
||
<van-count-down :time="d.countDownTime">
|
||
<template #default="timeData">
|
||
<text class="block">
|
||
{{
|
||
timeData.days > 10 ? timeData.days : '0' + timeData.days
|
||
}}
|
||
</text>
|
||
<text class="colon">天</text>
|
||
<text class="block">
|
||
{{
|
||
timeData.hours > 10
|
||
? timeData.hours
|
||
: '0' + timeData.hours
|
||
}}
|
||
</text>
|
||
<text class="colon">时</text>
|
||
<text class="block">
|
||
{{
|
||
timeData.minutes > 10
|
||
? timeData.minutes
|
||
: '0' + timeData.minutes
|
||
}}
|
||
</text>
|
||
<text class="colon">分</text>
|
||
</template>
|
||
</van-count-down>
|
||
</view>
|
||
</view>
|
||
<view class="demand-items">
|
||
<view> 装备类目: </view>
|
||
</view>
|
||
|
||
<view class="demand-items">
|
||
<view> 租赁公司: {{ d.companyName }} </view>
|
||
<view> 联系电话: {{ d.personPhone }} </view>
|
||
</view>
|
||
<view class="demand-items">
|
||
<view> 联系人: {{ d.person }} </view>
|
||
<view> 预估租期(天): {{ d.leaseDay }} </view>
|
||
</view>
|
||
<view class="demand-items"> 发布时间: {{ d.startTime }} </view>
|
||
<view class="demand-items"> 截止时间: {{ d.endTime }} </view>
|
||
<view class="demand-items"> 租赁开始日期: {{ d.leaseStartTime }} </view>
|
||
<view class="demand-items"> 租赁结束日期: {{ d.leaseEndTime }} </view>
|
||
|
||
<view class="demand-items">
|
||
<view style="text-align: right">
|
||
<van-button
|
||
type="success"
|
||
size="mini"
|
||
@click="onDemandDetails(d.id)"
|
||
style="padding: 4px 12px"
|
||
>
|
||
需求详情
|
||
</van-button>
|
||
<van-button
|
||
type="primary"
|
||
size="mini"
|
||
class="primary-lease"
|
||
style="margin-left: 10px; padding: 4px 12px"
|
||
:disabled="userCompanyId == d.publishCompany"
|
||
@click="onReceivingOrders(d.id)"
|
||
v-if="memberStore.userType === 1"
|
||
>
|
||
接单
|
||
</van-button>
|
||
</view>
|
||
</view>
|
||
</van-grid-item>
|
||
</van-grid>
|
||
|
||
<view class="loading-text">
|
||
{{ finish ? '没有更多数据了~' : '正在加载...' }}
|
||
</view>
|
||
</scroll-view>
|
||
|
||
<van-popup position="bottom" v-model:show="showBottom" :style="{ height: '60%' }">
|
||
<view class="filter-bottom">
|
||
<view
|
||
style="text-align: right; padding: 4px 8px"
|
||
@click="
|
||
() => {
|
||
showBottom = false
|
||
}
|
||
"
|
||
>
|
||
<van-icon name="close" color="#575B66" size="20" />
|
||
</view>
|
||
<view
|
||
style="
|
||
text-align: center;
|
||
font-weight: bold;
|
||
color: #333333;
|
||
font-family: PingFangSC, PingFang SC;
|
||
"
|
||
>
|
||
全部筛选
|
||
</view>
|
||
|
||
<view class="filter-content">
|
||
<van-sidebar v-model="activeSelect">
|
||
<van-sidebar-item
|
||
:key="index"
|
||
:title="item.selectName"
|
||
v-for="(item, index) in selectList"
|
||
/>
|
||
</van-sidebar>
|
||
|
||
<scroll-view scroll-y class="right-btns">
|
||
<view>
|
||
<view> {{ selectList[activeSelect].selectName }} </view>
|
||
<view class="btns">
|
||
<view
|
||
:class="{ active_btn: item.isChecked }"
|
||
v-for="(item, index) in selectList[activeSelect].val_list"
|
||
:key="index"
|
||
@click="onClickTags(item)"
|
||
>
|
||
{{ item.name }}
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
</view>
|
||
</van-popup>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import SearchIpt from '@/components/SearchIpt/index'
|
||
import { getLeaseDemandListAPI } from '@/services/demand/index.js'
|
||
import { acceptLeaseDemandOrderAPI } from '@/services/demand/index.js'
|
||
import { getTypeListAPI, getAreaAPI } from '@/services/common/index.js'
|
||
import { ref, computed } from 'vue'
|
||
import { onHide, onLoad, onShow } from '@dcloudio/uni-app'
|
||
import { useMemberStore } from '@/stores/index.js'
|
||
import { debounce } from 'lodash-es'
|
||
import moment from 'moment'
|
||
const memberStore = useMemberStore()
|
||
const userCompanyId = ref()
|
||
const keywords = ref('发布')
|
||
const leaseDemandLis = ref([])
|
||
const showBottom = ref(false)
|
||
const activeSelect = ref(0)
|
||
const total = ref(0)
|
||
const activeTypeName = ref('需求')
|
||
const searchModelValue = ref('')
|
||
const searchParams = ref({
|
||
keyWord: '',
|
||
companyId: '',
|
||
typeId: '',
|
||
level: '',
|
||
cityCode: '',
|
||
pageNum: 1,
|
||
pageSize: 10,
|
||
startTime: '',
|
||
rentDay: '',
|
||
endTime: '',
|
||
rentNum: '',
|
||
})
|
||
const selectList = ref([
|
||
{
|
||
selectName: '装备分类',
|
||
val_list: [
|
||
{
|
||
name: '全部',
|
||
value: '',
|
||
isChecked: true,
|
||
},
|
||
],
|
||
},
|
||
|
||
{
|
||
selectName: '项目所在地',
|
||
val_list: [
|
||
{
|
||
name: '全部',
|
||
value: '',
|
||
isChecked: true,
|
||
},
|
||
],
|
||
},
|
||
{
|
||
selectName: '需求单位',
|
||
val_list: [
|
||
{
|
||
name: '全部',
|
||
value: '',
|
||
isChecked: true,
|
||
},
|
||
],
|
||
},
|
||
])
|
||
|
||
const onClickLeft = () => {
|
||
uni.navigateBack()
|
||
}
|
||
|
||
// 获取装备分类
|
||
const getTypeListData = async () => {
|
||
const { data: res } = await getTypeListAPI()
|
||
const typeList = res.map((e) => {
|
||
return { ...e, name: e.typeName, value: e.typeId, isChecked: false }
|
||
})
|
||
selectList.value[0].val_list.push(...typeList)
|
||
}
|
||
|
||
const onScrollTolower = debounce(() => {
|
||
if (total.value > leaseDemandLis.value.length) {
|
||
searchParams.value.pageNum++
|
||
getLeaseDemandListData()
|
||
}
|
||
}, 500)
|
||
|
||
const onSearchByType = (value, type) => {
|
||
/**
|
||
* @type 1 查询机具 2 查询需求
|
||
* @value 搜索框值
|
||
*/
|
||
if (type === 2) {
|
||
searchParams.value.keyWord = value
|
||
getLeaseDemandListData(true)
|
||
} else {
|
||
// uni.navigateTo({ url: '/pages/goods-list/index' })
|
||
uni.navigateTo({
|
||
url: `/pages/goods-list/index?value=${value}&type=1`,
|
||
})
|
||
}
|
||
}
|
||
|
||
// 判断数据是否加载完毕
|
||
const finish = computed(() => {
|
||
if (total.value === leaseDemandLis.value.length) return true
|
||
})
|
||
|
||
// 获取需求列表
|
||
const getLeaseDemandListData = async (isTap = false) => {
|
||
if (isTap) searchParams.value.pageNum = 1
|
||
const { data: res } = await getLeaseDemandListAPI(searchParams.value)
|
||
total.value = res.total
|
||
|
||
if (isTap) {
|
||
leaseDemandLis.value = res.rows
|
||
} else {
|
||
if (res.rows.length == 0) {
|
||
leaseDemandLis.value = []
|
||
} else {
|
||
leaseDemandLis.value.push(...res.rows)
|
||
}
|
||
}
|
||
const nowTime = moment()
|
||
leaseDemandLis.value.forEach((e) => {
|
||
e.countDownTime =
|
||
moment.duration(moment(e.endTime, 'YYYY-MM-DD HH:mm:ss').diff(nowTime)).asSeconds() *
|
||
1000
|
||
})
|
||
}
|
||
|
||
// 接单
|
||
const onReceivingOrders = (id) => {
|
||
showConfirmDialog({
|
||
title: '温馨提示',
|
||
message: '是否确认接单',
|
||
})
|
||
.then(async () => {
|
||
const res = await acceptLeaseDemandOrderAPI({ id })
|
||
if (res.code === 200) {
|
||
showSuccessToast('接单成功')
|
||
getLeaseDemandListData()
|
||
}
|
||
})
|
||
.catch(() => {})
|
||
}
|
||
|
||
// 需求详情
|
||
const onDemandDetails = (id) => {
|
||
uni.navigateTo({
|
||
url: `/pages/demand-details/index?id=${id}`,
|
||
})
|
||
}
|
||
|
||
const onClickStartTime = (type) => {
|
||
searchParams.value.startTime = type
|
||
searchParams.value.endTime = ''
|
||
searchParams.value.rentNum = ''
|
||
searchParams.value.rentDay = ''
|
||
getLeaseDemandListData(true)
|
||
}
|
||
const onClickRentDay = (type) => {
|
||
searchParams.value.rentDay = type
|
||
searchParams.value.endTime = ''
|
||
searchParams.value.rentNum = ''
|
||
searchParams.value.startTime = ''
|
||
getLeaseDemandListData(true)
|
||
}
|
||
const onClickEndTime = (type) => {
|
||
searchParams.value.endTime = type
|
||
searchParams.value.startTime = ''
|
||
searchParams.value.rentNum = ''
|
||
searchParams.value.rentDay = ''
|
||
getLeaseDemandListData(true)
|
||
}
|
||
const onClickRentNum = (type) => {
|
||
searchParams.value.rentNum = type
|
||
searchParams.value.endTime = ''
|
||
searchParams.value.startTime = ''
|
||
searchParams.value.rentDay = ''
|
||
getLeaseDemandListData(true)
|
||
}
|
||
|
||
const onFilter = () => {
|
||
showBottom.value = true
|
||
}
|
||
|
||
// 标签点击
|
||
const onClickTags = (item) => {
|
||
selectList.value[activeSelect.value].val_list.forEach((e) => {
|
||
e.isChecked = false
|
||
})
|
||
item.isChecked = true
|
||
|
||
if (activeSelect.value == 0) {
|
||
searchParams.value.typeId = item.value
|
||
searchParams.value.level = item.value ? 1 : ''
|
||
}
|
||
if (activeSelect.value == 1) {
|
||
searchParams.value.cityCode = item.value
|
||
}
|
||
if (activeSelect.value == 2) {
|
||
searchParams.value.companyId = item.value
|
||
}
|
||
getLeaseDemandListData(true)
|
||
}
|
||
onLoad(async () => {
|
||
getTypeListData()
|
||
const { data: res } = await getAreaAPI(34)
|
||
const addressList = res.map((e) => {
|
||
return { ...e, name: e.areaName, value: e.areaCode, isChecked: false, index: 1 }
|
||
})
|
||
const companyList = memberStore.companyList.map((e) => {
|
||
return { ...e, name: e.companyName, value: e.companyId, isChecked: false, index: 2 }
|
||
})
|
||
selectList.value[1].val_list.push(...addressList)
|
||
selectList.value[2].val_list.push(...companyList)
|
||
userCompanyId.value = memberStore.userInfo.companyId
|
||
})
|
||
onShow(() => {
|
||
const params = uni.getStorageSync('myParam')
|
||
// console.log(params, 'params---')
|
||
if (params.type == 2) {
|
||
activeTypeName.value = '需求'
|
||
}
|
||
searchParams.value.keyWord = params.value
|
||
searchModelValue.value = params.value
|
||
getLeaseDemandListData(true)
|
||
})
|
||
|
||
onHide(() => {
|
||
uni.removeStorageSync('myParam')
|
||
})
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.lease-demand-container {
|
||
padding: 10px;
|
||
color: #333;
|
||
box-sizing: border-box;
|
||
background: linear-gradient(to bottom, #c0e9ce, #e4f2f2, #f9f9f9);
|
||
}
|
||
.demand-header {
|
||
padding: 5px 10px 15px;
|
||
box-sizing: border-box;
|
||
// background: linear-gradient(to bottom, #6caf97, #78b0a9, #b8d0cf);
|
||
border-bottom-left-radius: 40px;
|
||
border-bottom-right-radius: 40px;
|
||
}
|
||
.demand-release {
|
||
padding: 15px 6px;
|
||
margin-bottom: 10px;
|
||
margin-top: 15px;
|
||
background-color: #fff;
|
||
border-radius: 6px;
|
||
background: linear-gradient(to left, #73cabe, #a2dcd5, #ccebe8);
|
||
view {
|
||
font-style: italic;
|
||
font-size: 13px;
|
||
letter-spacing: 2px;
|
||
}
|
||
|
||
& view:first-child {
|
||
margin-bottom: 6px;
|
||
font-size: 15px;
|
||
font-weight: bold;
|
||
}
|
||
}
|
||
|
||
.goods-items {
|
||
padding: 10px;
|
||
|
||
// background: $uni-bg-color;
|
||
|
||
.filter-box {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
|
||
.filter-items {
|
||
display: flex;
|
||
align-items: center;
|
||
font-size: 13px;
|
||
text {
|
||
margin-right: 6px;
|
||
}
|
||
.filter-type {
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
align-items: center;
|
||
|
||
& .van-icon:first-child {
|
||
transform: rotateZ(-90deg);
|
||
margin-bottom: -3px;
|
||
}
|
||
& .van-icon:last-child {
|
||
transform: rotateZ(90deg);
|
||
margin-top: -3px;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
.scroll-item {
|
||
// background-color: $uni-bg-color;
|
||
:deep(.van-grid-item__content) {
|
||
background-color: #f6fbfd;
|
||
border-radius: 6px;
|
||
}
|
||
|
||
.demand-items {
|
||
width: 100%;
|
||
padding: 4px 0;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
font-size: 14px;
|
||
color: #333;
|
||
|
||
view {
|
||
flex: 1;
|
||
}
|
||
|
||
.count-down {
|
||
display: flex;
|
||
align-items: center;
|
||
color: #ee0a24;
|
||
font-size: 14px;
|
||
|
||
.van-count-down {
|
||
color: #ee0a24;
|
||
letter-spacing: 1px;
|
||
font-size: 14px;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
:deep(.van-highlight__tag) {
|
||
color: $el-color-primary;
|
||
}
|
||
|
||
:deep(.van-nav-bar__title) {
|
||
color: #333;
|
||
}
|
||
.filter-bottom {
|
||
height: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow-y: hidden;
|
||
}
|
||
|
||
.filter-content {
|
||
flex: 1;
|
||
height: 100%;
|
||
display: flex;
|
||
|
||
.right-btns {
|
||
flex: 1;
|
||
padding: 10px;
|
||
box-sizing: border-box;
|
||
|
||
.btns {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
margin-top: 15px;
|
||
view {
|
||
min-width: calc((100% - 20px) / 3);
|
||
padding: 0 8px;
|
||
box-sizing: border-box;
|
||
margin-bottom: 10px;
|
||
margin-right: 10px;
|
||
min-height: 28px;
|
||
line-height: 28px;
|
||
text-align: center;
|
||
border-radius: 14px;
|
||
}
|
||
|
||
.active_btn {
|
||
color: #22ab9b;
|
||
background-color: #d1eae7;
|
||
}
|
||
|
||
& view:nth-child(3n) {
|
||
margin-right: 0;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style>
|