加上下拉刷新
This commit is contained in:
@@ -71,7 +71,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { onShow, onPullDownRefresh } from '@dcloudio/uni-app'
|
||||
import { getVillageList, getFeeTypes } from '@/api/api.js'
|
||||
import FeeOverviewCard from './components/FeeOverviewCard.vue'
|
||||
import ParkingFeeCard from './components/ParkingFeeCard.vue'
|
||||
@@ -158,7 +158,7 @@ const fetchVillageList = () => {
|
||||
}
|
||||
|
||||
const fetchManagedArea = (villageId) => {
|
||||
getManagedArea({ villageId: villageId || '' }).then(res => {
|
||||
return getManagedArea({ villageId: villageId || '' }).then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
manageArea.value = res.data.manageArea
|
||||
serviceHouseholds.value = res.data.serviceHouseCount
|
||||
@@ -167,7 +167,7 @@ const fetchManagedArea = (villageId) => {
|
||||
}
|
||||
|
||||
const fetchRate = (villageId) => {
|
||||
getRate({ villageId: villageId || '' }).then(res => {
|
||||
return getRate({ villageId: villageId || '' }).then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
occupancyRate.value = res.data.occupancyRate
|
||||
rentalRate.value = res.data.rentalRate
|
||||
@@ -176,7 +176,7 @@ const fetchRate = (villageId) => {
|
||||
}
|
||||
// 车位收费总览
|
||||
const fetchParkingFee = (villageId) => {
|
||||
getParkingFee({ villageId: villageId || '' }).then(res => {
|
||||
return getParkingFee({ villageId: villageId || '' }).then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
const d = res.data
|
||||
parkingCount.value = Number(d.parkingCount) || 0
|
||||
@@ -189,7 +189,7 @@ const fetchParkingFee = (villageId) => {
|
||||
|
||||
// 收费总览
|
||||
const fetchFeeSummary = () => {
|
||||
getFeeSummary({
|
||||
return getFeeSummary({
|
||||
villageId: selectedProject.value || '',
|
||||
chargeTypeId: selectedFeeType.value || '',
|
||||
timeScope: activeTab.value
|
||||
@@ -226,7 +226,7 @@ const fetchFeeTypes = () => {
|
||||
}
|
||||
// 押金余额统计
|
||||
const fetchDepositBalance = (villageId) => {
|
||||
getDepositBalance({ villageId: villageId}).then(res => {
|
||||
return getDepositBalance({ villageId: villageId}).then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
const d = res.data
|
||||
depositBalance.value = d.totalBalance
|
||||
@@ -236,7 +236,7 @@ const fetchDepositBalance = (villageId) => {
|
||||
}
|
||||
// 巡检总览
|
||||
const fetchInspection = (villageId) => {
|
||||
getInspection({ villageId: villageId || '' }).then(res => {
|
||||
return getInspection({ villageId: villageId || '' }).then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
const d = res.data
|
||||
inspectionList.value = [
|
||||
@@ -249,15 +249,30 @@ const fetchInspection = (villageId) => {
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
Promise.all([fetchVillageList(), fetchFeeTypes()]).then(() => {
|
||||
fetchManagedArea(selectedProject.value)
|
||||
fetchRate(selectedProject.value)
|
||||
fetchFeeSummary()
|
||||
fetchParkingFee(selectedProject.value)
|
||||
fetchDepositBalance(selectedProject.value)
|
||||
fetchInspection(selectedProject.value)
|
||||
// 加载全部数据(首屏 / 下拉刷新共用)
|
||||
const loadAll = () => {
|
||||
return Promise.all([fetchVillageList(), fetchFeeTypes()]).then(() => {
|
||||
return Promise.allSettled([
|
||||
fetchManagedArea(selectedProject.value),
|
||||
fetchRate(selectedProject.value),
|
||||
fetchFeeSummary(),
|
||||
fetchParkingFee(selectedProject.value),
|
||||
fetchDepositBalance(selectedProject.value),
|
||||
fetchInspection(selectedProject.value)
|
||||
])
|
||||
})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
loadAll()
|
||||
})
|
||||
|
||||
onPullDownRefresh(async () => {
|
||||
try {
|
||||
await loadAll()
|
||||
} finally {
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user