对接切换小区接口
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
<template>
|
||||
<!-- 通知列表 -->
|
||||
<scroll-view
|
||||
class="notice-list"
|
||||
scroll-y
|
||||
:refresher-enabled="true"
|
||||
:refresher-triggered="refreshing"
|
||||
<scroll-view
|
||||
class="notice-list"
|
||||
scroll-y
|
||||
:refresher-enabled="true"
|
||||
:refresher-triggered="refreshing"
|
||||
@refresherrefresh="onRefresh"
|
||||
@scrolltolower="loadMore"
|
||||
:style="{ height: `calc(100vh - ${statusBarHeight + navBarHeight}px)` }"
|
||||
>
|
||||
<view class="status_bar"></view>
|
||||
@@ -17,25 +19,25 @@
|
||||
<uni-icons type="spinner-cycle" size="20" color="#999" class="loading"></uni-icons>
|
||||
<text class="refresh-text">刷新中...</text>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 通知列表项 -->
|
||||
<view
|
||||
v-for="(notice, index) in noticeList"
|
||||
:key="notice.id"
|
||||
<view
|
||||
v-for="(notice, index) in noticeList"
|
||||
:key="notice.noticeId"
|
||||
class="notice-item"
|
||||
@click="goToDetail(notice)"
|
||||
>
|
||||
<!-- 通知标题 -->
|
||||
<view class="notice-header">
|
||||
<view class="notice-title">
|
||||
{{notice.title}}
|
||||
{{notice.noticeTitle}}
|
||||
</view>
|
||||
<view class="unread-dot" v-if="notice.hasRead"></view>
|
||||
<view class="unread-dot" v-if="notice.readStatus"></view>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 红点 -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 发布者和时间 -->
|
||||
<view class="notice-meta">
|
||||
<view class="notice-author">
|
||||
@@ -44,11 +46,11 @@
|
||||
<text class="publish-time">{{notice.publishTime}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 通知摘要 -->
|
||||
<view class="notice-summary">
|
||||
{{ notice.summary }}
|
||||
</view>
|
||||
{{ notice.noticeContent }}
|
||||
</view>
|
||||
<!-- 详情 -->
|
||||
<view class="notice-actions" @click.stop="goToDetail(notice)">
|
||||
<!-- <view class="read-status" :class="{ unread: !notice.hasRead }">
|
||||
@@ -63,63 +65,101 @@
|
||||
<!-- </button> -->
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="loadingMore" class="load-more">
|
||||
<uni-icons type="spinner-cycle" size="18" color="#999" class="loading"></uni-icons>
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 没有更多数据 -->
|
||||
<view v-if="noMoreData && noticeList.length > 0" class="no-more">
|
||||
没有更多通知了
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view v-if="noticeList.length === 0 && !loading" class="empty-state">
|
||||
<image src="/static/empty-notice.png" mode="aspectFit" class="empty-image"></image>
|
||||
<!-- <image src="/static/empty-notice.png" mode="aspectFit" class="empty-image"></image> -->
|
||||
<text class="empty-text">暂无通知</text>
|
||||
<button class="btn-refresh" @click="loadNotices">刷新试试</button>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
|
||||
const noticeList = ref([
|
||||
{
|
||||
id:'1',
|
||||
title:'我那我是咖啡牛奶附件说的都是vv的v给v梵蒂冈v辅导报告发布',
|
||||
author:'张三',
|
||||
publishTime:'2026.3.5',
|
||||
summary:'为保障社区居民生命财产安全,维护社区和谐稳定,根据上级部门要求,结合我社区实际情况,现就进一步加强社区安全管理工作通知如下',
|
||||
hasRead:true
|
||||
},
|
||||
{
|
||||
id:'2',
|
||||
title:'今天停水了',
|
||||
author:'张三',
|
||||
publishTime:'2026.3.5',
|
||||
summary:'为保障社区居民生命财产安全,维护社区和谐稳定,根据上级部门要求,结合我社区实际情况,现就进一步加强社区安全管理工作通知如下',
|
||||
hasRead:true
|
||||
|
||||
}
|
||||
])
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { getNoticeList } from '../api/api.js'
|
||||
|
||||
const noticeList = ref([])
|
||||
const refreshing = ref(false)
|
||||
const loadingMore = ref(false)
|
||||
const noMoreData = ref(false)
|
||||
const loading = ref(false)
|
||||
const pageNum = ref(1)
|
||||
const pageSize = 10
|
||||
const statusBarHeight = ref(0)
|
||||
const navBarHeight = 44
|
||||
|
||||
// --方法----
|
||||
const goToDetail = () =>{
|
||||
const goToDetail = (notice) =>{
|
||||
uni.navigateTo({
|
||||
url:'/pageSubPack/notice-list/noticeListDetails'
|
||||
url:'/pageSubPack/notice-list/noticeListDetails?id=' + (notice.id || '')
|
||||
})
|
||||
}
|
||||
|
||||
// 获取列表接口
|
||||
const loadNotices = async (isRefresh = false) => {
|
||||
if (loading.value) return
|
||||
loading.value = true
|
||||
|
||||
if (isRefresh) {
|
||||
pageNum.value = 1
|
||||
noMoreData.value = false
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await getNoticeList({
|
||||
pageNum: pageNum.value,
|
||||
pageSize: pageSize
|
||||
})
|
||||
if (res.code === 200) {
|
||||
const list = res.data.rows
|
||||
if (isRefresh) {
|
||||
noticeList.value = list
|
||||
} else {
|
||||
noticeList.value = [...noticeList.value, ...list]
|
||||
}
|
||||
if (list.length < pageSize) {
|
||||
noMoreData.value = true
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '加载失败', icon: 'none' })
|
||||
}
|
||||
} catch (err) {
|
||||
uni.showToast({ title: '网络异常', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
refreshing.value = false
|
||||
loadingMore.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 下拉刷新
|
||||
const onRefresh = () => {
|
||||
refreshing.value = true
|
||||
loadNotices(true)
|
||||
}
|
||||
|
||||
// 上拉加载更多
|
||||
const loadMore = () => {
|
||||
if (noMoreData.value || loadingMore.value || loading.value) return
|
||||
loadingMore.value = true
|
||||
pageNum.value++
|
||||
loadNotices()
|
||||
}
|
||||
|
||||
// 返回
|
||||
const narBack = () =>{
|
||||
if(uni.getStorageSync('sourcePage') === "index"){
|
||||
@@ -133,7 +173,13 @@
|
||||
}
|
||||
uni.removeStorageSync('sourcePage')
|
||||
}
|
||||
|
||||
|
||||
onLoad(() => {
|
||||
const sysInfo = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = sysInfo.statusBarHeight || 0
|
||||
loadNotices(true)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@@ -162,12 +208,12 @@
|
||||
padding: 20px 0;
|
||||
color: #999;
|
||||
font-size: 14px;
|
||||
|
||||
|
||||
.loading {
|
||||
animation: rotate 1s linear infinite;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
|
||||
.refresh-text {
|
||||
font-size: 12px;
|
||||
}
|
||||
@@ -181,11 +227,11 @@
|
||||
margin-bottom: 12px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
||||
position: relative;
|
||||
|
||||
|
||||
&:active {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
|
||||
/* 重要通知标记 */
|
||||
&.important::before {
|
||||
content: '';
|
||||
@@ -215,8 +261,8 @@
|
||||
// -webkit-line-clamp: 2;
|
||||
width: 290px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
// 未读红点
|
||||
.unread-dot {
|
||||
@@ -234,29 +280,29 @@
|
||||
margin-bottom: 12px;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
|
||||
|
||||
.notice-author {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
|
||||
.author-name {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
|
||||
.separator {
|
||||
margin: 0 6px;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
|
||||
.publish-time {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.notice-time {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
|
||||
.date-text {
|
||||
margin-left: 4px;
|
||||
color: #999;
|
||||
@@ -283,20 +329,20 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
|
||||
.read-status {
|
||||
font-size: 12px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 10px;
|
||||
background-color: #f0f0f0;
|
||||
color: #999;
|
||||
|
||||
|
||||
&.unread {
|
||||
background-color: #e6f7ff;
|
||||
color: #1890ff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.detail-btn {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
@@ -306,11 +352,11 @@
|
||||
font-size: 14px;
|
||||
padding: 0;
|
||||
margin-right: 10rpx;
|
||||
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
|
||||
text {
|
||||
margin-right: 4px;
|
||||
}
|
||||
@@ -332,7 +378,7 @@
|
||||
padding: 20px 0;
|
||||
color: #999;
|
||||
font-size: 14px;
|
||||
|
||||
|
||||
.loading {
|
||||
animation: rotate 1s linear infinite;
|
||||
margin-right: 8px;
|
||||
@@ -353,31 +399,31 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 60px 20px;
|
||||
|
||||
|
||||
.empty-image {
|
||||
width: 200px;
|
||||
height: 150px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
|
||||
.empty-text {
|
||||
font-size: 16px;
|
||||
color: #999;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
|
||||
.btn-refresh {
|
||||
background-color: #007AFF;
|
||||
color: #fff;
|
||||
padding: 8px 20px;
|
||||
border-radius: 20px;
|
||||
font-size: 14px;
|
||||
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user