首页加下拉刷新,公告显示问题;报修优化
This commit is contained in:
@@ -125,7 +125,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad, onUnload, onShow, onReady } from '@dcloudio/uni-app'
|
||||
import { onLoad, onUnload, onShow, onReady, onPullDownRefresh } from '@dcloudio/uni-app'
|
||||
import {
|
||||
getCurrentVillage,
|
||||
getTodayInspection,
|
||||
@@ -308,7 +308,7 @@ const handleFunctionClick = item => {
|
||||
// 获取当前小区
|
||||
const currentVillageData = () => {
|
||||
currentCommunity.value = '请先绑定房屋'
|
||||
getCurrentVillage()
|
||||
return getCurrentVillage()
|
||||
.then(res => {
|
||||
const data = res.data
|
||||
if (data) {
|
||||
@@ -323,7 +323,7 @@ const currentVillageData = () => {
|
||||
}
|
||||
// 获取今日巡检数据
|
||||
const getInspectionData = () => {
|
||||
getTodayInspection()
|
||||
return getTodayInspection()
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
if (res.data) {
|
||||
@@ -346,7 +346,7 @@ const getInspectionData = () => {
|
||||
// 获取消息通知
|
||||
const getNoticeData = () => {
|
||||
getNewNoticeData().then(res => {
|
||||
const notice = res.code === 200 && res.data ? (res.data.notice || '') : '暂无公告'
|
||||
const notice = res.code === 200 && res.data ? (res.data.problem || res.data.notice) : '暂无公告'
|
||||
// 仅在内容真正变化时才更新
|
||||
if (noticeText.value !== notice) {
|
||||
noticeText.value = notice
|
||||
@@ -369,7 +369,7 @@ function getbannarData(forceRefresh = false) {
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
getBannarList()
|
||||
return getBannarList()
|
||||
.then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
const newData = res.data
|
||||
@@ -397,7 +397,7 @@ function getbannarData(forceRefresh = false) {
|
||||
const MyOrderNum = ref(0)
|
||||
// 查询我的工单-待办数量
|
||||
function getMyOrderNum() {
|
||||
myOrderCount()
|
||||
return myOrderCount()
|
||||
.then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
MyOrderNum.value = res.data
|
||||
@@ -432,6 +432,7 @@ onShow(() => {
|
||||
// 从其他页面返回 / 从后台恢复:只刷新可能变化的数据
|
||||
getbannarData()
|
||||
getMyOrderNum()
|
||||
getNoticeData()
|
||||
// 换账号登录后 currentVillage 缓存已被清除,需要重新获取小区
|
||||
if (!uni.getStorageSync('currentVillage')) {
|
||||
currentVillageData()
|
||||
@@ -470,6 +471,24 @@ onReady(() => {
|
||||
onUnload(() => {
|
||||
uni.$off('confirm', slelctHomeData)
|
||||
})
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh(async () => {
|
||||
if (!isLoggedIn.value) {
|
||||
uni.stopPullDownRefresh()
|
||||
return
|
||||
}
|
||||
try {
|
||||
await Promise.allSettled([
|
||||
currentVillageData(),
|
||||
getInspectionData(),
|
||||
getbannarData(true),
|
||||
getMyOrderNum()
|
||||
])
|
||||
} finally {
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user