对接我的活动接口,修改其他页面样式
This commit is contained in:
@@ -65,7 +65,7 @@
|
||||
<up-row justify="space-between" customStyle="margin-bottom: 10px">
|
||||
<up-col span="4">
|
||||
<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>
|
||||
</up-col>
|
||||
<up-col span="8">
|
||||
@@ -123,25 +123,25 @@
|
||||
import { ref, watch } from 'vue'
|
||||
import { onLoad, onUnload, onShow } from '@dcloudio/uni-app'
|
||||
import moment from 'moment';
|
||||
import { getActivityList } from '../api/api.js'
|
||||
import { getActivityList,getMyActivityList} from '../api/api.js'
|
||||
|
||||
// ===================== 响应式数据 =====================
|
||||
const activeTab = ref('list') // 'list' 或 'my'
|
||||
const myFilter = ref('reviewing') // 我的活动筛选条件
|
||||
const myFilter = ref('') // 我的活动筛选条件:''审核中, '0'未开始, '1'进行中, '2'已结束
|
||||
const isLoading = ref(false)
|
||||
const hasMoreData = ref(true)
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(5)
|
||||
const pageSize = ref(10)
|
||||
const total = ref(0)
|
||||
const displayedActivities = ref([]) // 当前显示的活动列表
|
||||
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
|
||||
|
||||
// 筛选条件
|
||||
// 筛选条件:status ''全部, '0'未开始, '1'进行中, '2'已结束
|
||||
const filters = ref([
|
||||
{ label: '审核中', value: 'reviewing' },
|
||||
{ label: '已通过', value: 'passed' },
|
||||
{ label: '未通过', value: 'rejected' },
|
||||
{ label: '已结束', value: 'ended' }
|
||||
{ label: '审核中', value: '' },
|
||||
{ label: '未开始', value: '0' },
|
||||
{ label: '进行中', value: '1' },
|
||||
{ label: '已结束', value: '2' }
|
||||
])
|
||||
|
||||
// ===================== 核心方法 =====================
|
||||
@@ -178,20 +178,27 @@ const switchTab = (tab) => {
|
||||
if (tab === 'list') {
|
||||
resetAndLoad()
|
||||
} else {
|
||||
// 暂无审核功能,"我的活动"默认显示暂无数据
|
||||
displayedActivities.value = []
|
||||
hasMoreData.value = false
|
||||
currentPage.value = 1
|
||||
resetAndLoadMy()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置并刷新我的活动第一页数据
|
||||
*/
|
||||
const resetAndLoadMy = () => {
|
||||
currentPage.value = 1
|
||||
displayedActivities.value = []
|
||||
hasMoreData.value = true
|
||||
getMyActivityListData(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换我的活动筛选条件
|
||||
* @param {string} filter - 筛选值
|
||||
*/
|
||||
const switchFilter = (filter) => {
|
||||
myFilter.value = filter
|
||||
// resetAndLoad()
|
||||
resetAndLoadMy()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,12 +211,10 @@ const getActivityListData = async (pageNum = 1) => {
|
||||
isLoading.value = true
|
||||
|
||||
try {
|
||||
// 构造请求参数(区分活动列表/我的活动 + 筛选条件)
|
||||
// 构造请求参数(活动列表)
|
||||
const params = {
|
||||
pageNum: pageNum,
|
||||
pageSize: pageSize.value,
|
||||
//tabType: activeTab.value, // 传给后端:list/my
|
||||
//filterType: activeTab.value === 'my' ? myFilter.value : '' // 我的活动筛选条件
|
||||
}
|
||||
|
||||
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 = () => {
|
||||
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(() => {
|
||||
if (activeTab.value === 'list') {
|
||||
getActivityListData(1) // 强制刷新第一页
|
||||
getActivityListData(1)
|
||||
} else {
|
||||
getMyActivityListData(1)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -304,7 +359,6 @@ onShow(() => {
|
||||
onLoad(() => {
|
||||
// 监听详情页报名/取消报名后的刷新通知
|
||||
uni.$on('refreshActivityList', (data) => {
|
||||
// console.log('收到活动列表刷新通知:', data)
|
||||
getActivityListData(1)
|
||||
})
|
||||
})
|
||||
@@ -320,7 +374,9 @@ onUnload(() => {
|
||||
* 监听我的活动筛选条件变化
|
||||
*/
|
||||
watch(() => myFilter.value, () => {
|
||||
// 暂无审核功能,筛选条件暂不触发加载
|
||||
if (activeTab.value === 'my') {
|
||||
resetAndLoadMy()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -451,7 +507,7 @@ watch(() => myFilter.value, () => {
|
||||
.activity-card {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
padding: 12rpx;
|
||||
margin-bottom: 30rpx;
|
||||
/* box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05); */
|
||||
position: relative;
|
||||
@@ -461,8 +517,8 @@ watch(() => myFilter.value, () => {
|
||||
/* 活动状态标签 */
|
||||
.status-badge {
|
||||
position: absolute;
|
||||
top: 10rpx;
|
||||
left: 20rpx;
|
||||
top: 33rpx;
|
||||
left: 11rpx;
|
||||
padding: 6rpx 20rpx;
|
||||
font-size: 22rpx;
|
||||
border-radius: 15rpx 0rpx 15rpx 0rpx;
|
||||
@@ -492,7 +548,7 @@ watch(() => myFilter.value, () => {
|
||||
|
||||
/* 活动信息 */
|
||||
.activity-info {
|
||||
padding-top: 50rpx;
|
||||
padding-top: 24rpx;
|
||||
}
|
||||
|
||||
/* 活动信息 */
|
||||
@@ -633,7 +689,7 @@ watch(() => myFilter.value, () => {
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 10rpx;
|
||||
|
||||
@@ -84,8 +84,8 @@ export const cancelActivity = (id) =>{
|
||||
return post(`/api/resident/activity/${id}/cancel`)
|
||||
}
|
||||
// =========我的活动========
|
||||
export const getMyActivityList = () =>{
|
||||
return get("/api/resident/activity/my")
|
||||
export const getMyActivityList = (data) =>{
|
||||
return get("/api/resident/activity/my",data)
|
||||
}
|
||||
// ===========活动实况============
|
||||
// 活动实况列表
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</view>
|
||||
<!-- 空状态 -->
|
||||
<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>
|
||||
</view>
|
||||
|
||||
@@ -298,7 +298,7 @@ onLoad(() =>{
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 10rpx;
|
||||
|
||||
@@ -64,13 +64,13 @@
|
||||
|
||||
<!-- 空状态 -->
|
||||
<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>
|
||||
</view>
|
||||
|
||||
<!-- 搜索无结果 -->
|
||||
<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-tip">请尝试其他关键词</text>
|
||||
</view>
|
||||
@@ -463,7 +463,7 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 10rpx;
|
||||
|
||||
@@ -451,7 +451,7 @@ onUnload(() =>{
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 10rpx;
|
||||
|
||||
@@ -165,7 +165,7 @@ const confirmSelect = () => {
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 10rpx;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<scroll-view class="page" scroll-y>
|
||||
<view class="page-container">
|
||||
<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>
|
||||
</view>
|
||||
|
||||
@@ -181,7 +181,7 @@ const goBack = () => {
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 10rpx;
|
||||
|
||||
@@ -229,7 +229,7 @@ const addInvitation = () => {
|
||||
/* 标签切换栏 */
|
||||
.tab-bar {
|
||||
display: flex;
|
||||
border-bottom: 1rpx solid rgba(0, 0, 0, 0.04);
|
||||
/* border-bottom: 1rpx solid rgba(0, 0, 0, 0.04); */
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
|
||||
@@ -656,7 +656,7 @@ const moreClick = () =>{
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 10rpx;
|
||||
|
||||
Reference in New Issue
Block a user