对接我的活动接口,修改其他页面样式

This commit is contained in:
zhouyanli
2026-05-21 17:00:46 +08:00
parent 40c9e75b2e
commit 6b520fb70e
9 changed files with 95 additions and 39 deletions

View File

@@ -65,7 +65,7 @@
<up-row justify="space-between" customStyle="margin-bottom: 10px"> <up-row justify="space-between" customStyle="margin-bottom: 10px">
<up-col span="4"> <up-col span="4">
<view class="info-image-left"> <view class="info-image-left">
<image :src="activity.coverImage" style="width: 100%;height: 100%;"></image> <image :src="activity.coverImage" style="width: 100%;height: 100%;border-radius: 16rpx;"></image>
</view> </view>
</up-col> </up-col>
<up-col span="8"> <up-col span="8">
@@ -123,25 +123,25 @@
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { onLoad, onUnload, onShow } from '@dcloudio/uni-app' import { onLoad, onUnload, onShow } from '@dcloudio/uni-app'
import moment from 'moment'; import moment from 'moment';
import { getActivityList } from '../api/api.js' import { getActivityList,getMyActivityList} from '../api/api.js'
// ===================== 响应式数据 ===================== // ===================== 响应式数据 =====================
const activeTab = ref('list') // 'list' 或 'my' const activeTab = ref('list') // 'list' 或 'my'
const myFilter = ref('reviewing') // 我的活动筛选条件 const myFilter = ref('') // 我的活动筛选条件''审核中, '0'未开始, '1'进行中, '2'已结束
const isLoading = ref(false) const isLoading = ref(false)
const hasMoreData = ref(true) const hasMoreData = ref(true)
const currentPage = ref(1) const currentPage = ref(1)
const pageSize = ref(5) const pageSize = ref(10)
const total = ref(0) const total = ref(0)
const displayedActivities = ref([]) // 当前显示的活动列表 const displayedActivities = ref([]) // 当前显示的活动列表
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0) const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
// 筛选条件 // 筛选条件status ''全部, '0'未开始, '1'进行中, '2'已结束
const filters = ref([ const filters = ref([
{ label: '审核中', value: 'reviewing' }, { label: '审核中', value: '' },
{ label: '已通过', value: 'passed' }, { label: '未开始', value: '0' },
{ label: '未通过', value: 'rejected' }, { label: '进行中', value: '1' },
{ label: '已结束', value: 'ended' } { label: '已结束', value: '2' }
]) ])
// ===================== 核心方法 ===================== // ===================== 核心方法 =====================
@@ -178,20 +178,27 @@ const switchTab = (tab) => {
if (tab === 'list') { if (tab === 'list') {
resetAndLoad() resetAndLoad()
} else { } else {
// 暂无审核功能,"我的活动"默认显示暂无数据 resetAndLoadMy()
displayedActivities.value = []
hasMoreData.value = false
currentPage.value = 1
} }
} }
/**
* 重置并刷新我的活动第一页数据
*/
const resetAndLoadMy = () => {
currentPage.value = 1
displayedActivities.value = []
hasMoreData.value = true
getMyActivityListData(1)
}
/** /**
* 切换我的活动筛选条件 * 切换我的活动筛选条件
* @param {string} filter - 筛选值 * @param {string} filter - 筛选值
*/ */
const switchFilter = (filter) => { const switchFilter = (filter) => {
myFilter.value = filter myFilter.value = filter
// resetAndLoad() resetAndLoadMy()
} }
/** /**
@@ -204,12 +211,10 @@ const getActivityListData = async (pageNum = 1) => {
isLoading.value = true isLoading.value = true
try { try {
// 构造请求参数(区分活动列表/我的活动 + 筛选条件 // 构造请求参数(活动列表)
const params = { const params = {
pageNum: pageNum, pageNum: pageNum,
pageSize: pageSize.value, pageSize: pageSize.value,
//tabType: activeTab.value, // 传给后端list/my
//filterType: activeTab.value === 'my' ? myFilter.value : '' // 我的活动筛选条件
} }
const res = await getActivityList(params) const res = await getActivityList(params)
@@ -240,12 +245,60 @@ const getActivityListData = async (pageNum = 1) => {
} }
} }
/**
* 获取我的活动列表数据
* @param {number} pageNum - 页码
*/
const getMyActivityListData = async (pageNum = 1) => {
if (isLoading.value) return
isLoading.value = true
try {
const params = {
pageNum: pageNum,
pageSize: pageSize.value,
}
// status 为空时不传,返回全部
if (myFilter.value !== '') {
params.status = myFilter.value
}
const res = await getMyActivityList(params)
if (res.code === 200) {
const list = res.rows || []
total.value = res.total || 0
if (pageNum === 1) {
displayedActivities.value = list
} else {
displayedActivities.value = [...displayedActivities.value, ...list]
}
hasMoreData.value = displayedActivities.value.length < total.value
currentPage.value = pageNum
} else {
uni.showToast({ title: res.msg || '加载失败', icon: 'error' })
if (pageNum === 1) displayedActivities.value = []
}
} catch (err) {
uni.showToast({ title: '网络异常', icon: 'none' })
if (pageNum === 1) displayedActivities.value = []
} finally {
isLoading.value = false
}
}
/** /**
* 加载更多数据 * 加载更多数据
*/ */
const loadMoreData = () => { const loadMoreData = () => {
if (isLoading.value || !hasMoreData.value) return if (isLoading.value || !hasMoreData.value) return
getActivityListData(currentPage.value + 1) if (activeTab.value === 'list') {
getActivityListData(currentPage.value + 1)
} else {
getMyActivityListData(currentPage.value + 1)
}
} }
/** /**
@@ -294,7 +347,9 @@ const viewActivityDetail = (activity) => {
*/ */
onShow(() => { onShow(() => {
if (activeTab.value === 'list') { if (activeTab.value === 'list') {
getActivityListData(1) // 强制刷新第一页 getActivityListData(1)
} else {
getMyActivityListData(1)
} }
}) })
@@ -304,7 +359,6 @@ onShow(() => {
onLoad(() => { onLoad(() => {
// 监听详情页报名/取消报名后的刷新通知 // 监听详情页报名/取消报名后的刷新通知
uni.$on('refreshActivityList', (data) => { uni.$on('refreshActivityList', (data) => {
// console.log('收到活动列表刷新通知:', data)
getActivityListData(1) getActivityListData(1)
}) })
}) })
@@ -320,7 +374,9 @@ onUnload(() => {
* 监听我的活动筛选条件变化 * 监听我的活动筛选条件变化
*/ */
watch(() => myFilter.value, () => { watch(() => myFilter.value, () => {
// 暂无审核功能,筛选条件暂不触发加载 if (activeTab.value === 'my') {
resetAndLoadMy()
}
}) })
</script> </script>
@@ -451,7 +507,7 @@ watch(() => myFilter.value, () => {
.activity-card { .activity-card {
background-color: #fff; background-color: #fff;
border-radius: 16rpx; border-radius: 16rpx;
padding: 30rpx; padding: 12rpx;
margin-bottom: 30rpx; margin-bottom: 30rpx;
/* box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05); */ /* box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05); */
position: relative; position: relative;
@@ -461,8 +517,8 @@ watch(() => myFilter.value, () => {
/* 活动状态标签 */ /* 活动状态标签 */
.status-badge { .status-badge {
position: absolute; position: absolute;
top: 10rpx; top: 33rpx;
left: 20rpx; left: 11rpx;
padding: 6rpx 20rpx; padding: 6rpx 20rpx;
font-size: 22rpx; font-size: 22rpx;
border-radius: 15rpx 0rpx 15rpx 0rpx; border-radius: 15rpx 0rpx 15rpx 0rpx;
@@ -492,7 +548,7 @@ watch(() => myFilter.value, () => {
/* 活动信息 */ /* 活动信息 */
.activity-info { .activity-info {
padding-top: 50rpx; padding-top: 24rpx;
} }
/* 活动信息 */ /* 活动信息 */
@@ -633,7 +689,7 @@ watch(() => myFilter.value, () => {
} }
.empty-text { .empty-text {
font-size: 32rpx; font-size: 28rpx;
color: #999; color: #999;
margin-top: 20rpx; margin-top: 20rpx;
margin-bottom: 10rpx; margin-bottom: 10rpx;

View File

@@ -84,8 +84,8 @@ export const cancelActivity = (id) =>{
return post(`/api/resident/activity/${id}/cancel`) return post(`/api/resident/activity/${id}/cancel`)
} }
// =========我的活动======== // =========我的活动========
export const getMyActivityList = () =>{ export const getMyActivityList = (data) =>{
return get("/api/resident/activity/my") return get("/api/resident/activity/my",data)
} }
// ===========活动实况============ // ===========活动实况============
// 活动实况列表 // 活动实况列表

View File

@@ -41,7 +41,7 @@
</view> </view>
<!-- 空状态 --> <!-- 空状态 -->
<view v-if="doorList.length === 0" class="empty-state"> <view v-if="doorList.length === 0" class="empty-state">
<uni-icons type="info" size="60" color="#ccc"></uni-icons> <uni-icons type="info" size="30" color="#ccc"></uni-icons>
<text class="empty-text">暂无可用门禁</text> <text class="empty-text">暂无可用门禁</text>
</view> </view>
@@ -298,7 +298,7 @@ onLoad(() =>{
} }
.empty-text { .empty-text {
font-size: 32rpx; font-size: 28rpx;
color: #999; color: #999;
margin-top: 20rpx; margin-top: 20rpx;
margin-bottom: 10rpx; margin-bottom: 10rpx;

View File

@@ -64,13 +64,13 @@
<!-- 空状态 --> <!-- 空状态 -->
<view v-if="displayedCommunities.length === 0 && !isSearching && !isLoading" class="empty-state"> <view v-if="displayedCommunities.length === 0 && !isSearching && !isLoading" class="empty-state">
<uni-icons type="info" size="60" color="#ccc"></uni-icons> <uni-icons type="info" size="30" color="#ccc"></uni-icons>
<text class="empty-text">暂无小区数据</text> <text class="empty-text">暂无小区数据</text>
</view> </view>
<!-- 搜索无结果 --> <!-- 搜索无结果 -->
<view v-if="displayedCommunities.length === 0 && isSearching && !isLoading" class="empty-state"> <view v-if="displayedCommunities.length === 0 && isSearching && !isLoading" class="empty-state">
<uni-icons type="search" size="60" color="#ccc"></uni-icons> <uni-icons type="search" size="30" color="#ccc"></uni-icons>
<text class="empty-text">未找到相关小区</text> <text class="empty-text">未找到相关小区</text>
<text class="empty-tip">请尝试其他关键词</text> <text class="empty-tip">请尝试其他关键词</text>
</view> </view>
@@ -463,7 +463,7 @@ onMounted(() => {
} }
.empty-text { .empty-text {
font-size: 32rpx; font-size: 28rpx;
color: #999; color: #999;
margin-top: 20rpx; margin-top: 20rpx;
margin-bottom: 10rpx; margin-bottom: 10rpx;

View File

@@ -451,7 +451,7 @@ onUnload(() =>{
} }
.empty-text { .empty-text {
font-size: 32rpx; font-size: 28rpx;
color: #999; color: #999;
margin-top: 20rpx; margin-top: 20rpx;
margin-bottom: 10rpx; margin-bottom: 10rpx;

View File

@@ -165,7 +165,7 @@ const confirmSelect = () => {
} }
.empty-text { .empty-text {
font-size: 32rpx; font-size: 28rpx;
color: #999; color: #999;
margin-top: 20rpx; margin-top: 20rpx;
margin-bottom: 10rpx; margin-bottom: 10rpx;

View File

@@ -14,7 +14,7 @@
<scroll-view class="page" scroll-y> <scroll-view class="page" scroll-y>
<view class="page-container"> <view class="page-container">
<view v-if="dataList.length === 0" class="empty-state"> <view v-if="dataList.length === 0" class="empty-state">
<uni-icons type="info" size="60" color="#ccc"></uni-icons> <uni-icons type="info" size="30" color="#ccc"></uni-icons>
<text class="empty-text">暂无数据</text> <text class="empty-text">暂无数据</text>
</view> </view>
@@ -181,7 +181,7 @@ const goBack = () => {
} }
.empty-text { .empty-text {
font-size: 32rpx; font-size: 28rpx;
color: #999; color: #999;
margin-top: 20rpx; margin-top: 20rpx;
margin-bottom: 10rpx; margin-bottom: 10rpx;

View File

@@ -229,7 +229,7 @@ const addInvitation = () => {
/* 标签切换栏 */ /* 标签切换栏 */
.tab-bar { .tab-bar {
display: flex; display: flex;
border-bottom: 1rpx solid rgba(0, 0, 0, 0.04); /* border-bottom: 1rpx solid rgba(0, 0, 0, 0.04); */
} }
.tab-item { .tab-item {

View File

@@ -656,7 +656,7 @@ const moreClick = () =>{
} }
.empty-text { .empty-text {
font-size: 32rpx; font-size: 28rpx;
color: #999; color: #999;
margin-top: 20rpx; margin-top: 20rpx;
margin-bottom: 10rpx; margin-bottom: 10rpx;