consumer-app/pages/detail/activitiesDetail.vue

205 lines
4.0 KiB
Vue

<template>
<view class="activities-detail-page">
<!-- 顶部导航栏 -->
<NavHeader title="工会详情" />
<!-- 内容区域 -->
<scroll-view class="content-scroll" scroll-y="true">
<!-- 加载中 -->
<view class="loading-state" v-if="loading">
<text class="loading-text">加载中...</text>
</view>
<!-- 富文本内容 -->
<view class="content-wrapper" v-else-if="activityDetail && activityDetail.content">
<rich-text :nodes="activityDetail.content"></rich-text>
</view>
<!-- 空数据提示 -->
<view class="empty-state" v-else>
<image
class="empty-icon"
src="/static/home/entry_icon.png"
mode="aspectFit"
></image>
<text class="empty-text">暂无内容</text>
</view>
</scroll-view>
</view>
</template>
<script>
import { getGuildDetail } from "@/api/home.js";
import NavHeader from "@/components/NavHeader/NavHeader.vue";
export default {
components: {
NavHeader
},
data() {
return {
activityId: null,
activityDetail: null,
loading: false,
};
},
onLoad(options) {
if (options.id) {
this.activityId = options.id;
this.loadActivityDetail();
} else {
uni.showToast({
title: "参数错误",
icon: "none",
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
}
},
methods: {
// 加载活动详情
async loadActivityDetail() {
if (!this.activityId) {
return;
}
try {
this.loading = true;
const res = await getGuildDetail(this.activityId);
if (res) {
this.activityDetail = res;
}
} catch (error) {
console.error("加载活动详情失败:", error);
uni.showToast({
title: "加载失败,请重试",
icon: "none",
});
} finally {
this.loading = false;
}
},
},
};
</script>
<style lang="scss" scoped>
.activities-detail-page {
height: 100vh;
background-color: #e2e8f1;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* 内容区域 */
.content-scroll {
flex: 1;
height: 0; // 配合 flex: 1 使用,让 scroll-view 可以滚动
}
.content-wrapper {
padding: 30rpx 20rpx;
background-color: #ffffff;
margin: 20rpx;
border-radius: 20rpx;
min-height: 200rpx;
box-sizing: border-box;
overflow: hidden;
// 富文本内容样式
:deep(rich-text) {
font-family: PingFang-SC, PingFang-SC;
font-size: 28rpx;
line-height: 1.8;
color: #333333;
word-wrap: break-word;
word-break: break-all;
display: block;
width: 100%;
box-sizing: border-box;
}
// 富文本内容中的元素样式
:deep(img) {
max-width: 100% !important;
width: auto !important;
height: auto !important;
display: block;
margin: 20rpx auto;
box-sizing: border-box;
}
:deep(p) {
margin: 20rpx 0;
line-height: 1.8;
}
:deep(h1),
:deep(h2),
:deep(h3),
:deep(h4),
:deep(h5),
:deep(h6) {
margin: 30rpx 0 20rpx 0;
font-weight: bold;
}
:deep(ul),
:deep(ol) {
margin: 20rpx 0;
padding-left: 40rpx;
}
:deep(li) {
margin: 10rpx 0;
}
:deep(a) {
color: #004294;
text-decoration: underline;
}
}
/* 加载状态 */
.loading-state {
display: flex;
justify-content: center;
align-items: center;
padding: 200rpx 0;
min-height: 500rpx;
.loading-text {
font-family: PingFang-SC, PingFang-SC;
font-weight: 500;
font-size: 28rpx;
color: #999999;
}
}
/* 空数据提示 */
.empty-state {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 200rpx 0;
min-height: 500rpx;
.empty-icon {
width: 200rpx;
height: 200rpx;
margin-bottom: 40rpx;
opacity: 0.5;
}
.empty-text {
font-family: PingFang-SC, PingFang-SC;
font-weight: 500;
font-size: 28rpx;
color: #999999;
}
}
</style>