207 lines
5.9 KiB
Vue
207 lines
5.9 KiB
Vue
<template>
|
|
<view class="ritual-list-page">
|
|
<ModulePageBackground module="records" />
|
|
<view class="page-header"
|
|
><PageHeader
|
|
title="礼仪活动"
|
|
:action="valid ? '新建' : ''"
|
|
custom-back
|
|
@back="returnToFamily"
|
|
@action="createCeremony"
|
|
/></view>
|
|
<view class="page-content">
|
|
<view v-if="!valid" class="state-card"
|
|
><text>暂时无法打开礼仪活动</text
|
|
><AppButton block label="返回上一页" @click="returnToFamily"
|
|
/></view>
|
|
<view v-else-if="ceremonyListState === 'loading'" class="state-card"
|
|
><AppLoading text="正在读取礼仪活动"
|
|
/></view>
|
|
<view v-else-if="ceremonyListState === 'error'" class="state-card"
|
|
><text>暂时无法读取礼仪活动</text
|
|
><AppButton
|
|
block
|
|
type="secondary"
|
|
label="重新加载"
|
|
@click="loadCeremonies"
|
|
/></view>
|
|
<view v-else-if="ceremonyListState === 'empty'" class="state-card"
|
|
><text>还没有礼仪活动</text
|
|
><AppButton block label="新建礼仪活动" @click="createCeremony"
|
|
/></view>
|
|
<view v-else class="ceremony-list"
|
|
><view
|
|
v-for="item in ceremonies"
|
|
:key="item.id"
|
|
class="ceremony-card"
|
|
@click="openCeremony(item)"
|
|
><image
|
|
v-if="item.coverFile?.accessUrl"
|
|
class="ceremony-card__cover"
|
|
:src="item.coverFile.accessUrl"
|
|
mode="aspectFill"
|
|
aria-hidden="true"
|
|
/><view
|
|
><text>{{ item.title }}</text
|
|
><text>{{ item.typeLabel }}{{ item.time ? ` · ${item.time}` : "" }}</text
|
|
><text v-if="item.createTime">创建于 {{ formatMinuteTimestamp(item.createTime) }}</text
|
|
><text v-if="item.description" class="ceremony-card__description">{{ item.description }}</text></view
|
|
><text>{{ item.giftCount }} 笔献礼</text></view
|
|
></view
|
|
>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { computed, ref } from "vue";
|
|
import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";
|
|
import AppButton from "@/components/AppButton.vue";
|
|
import AppLoading from "@/components/AppLoading.vue";
|
|
import ModulePageBackground from "@/components/ModulePageBackground.vue";
|
|
import PageHeader from "@/components/PageHeader.vue";
|
|
import {
|
|
createRequestController,
|
|
isRequestCancelled
|
|
} from "@/services/api/request-controller.js";
|
|
import { ceremonyApi } from "@/services/api/ceremony-service.js";
|
|
import { formatMinuteTimestamp } from "@/utils/display-time.js";
|
|
import { goBack, openPage, returnTo } from "@/utils/navigation/gateway.js";
|
|
|
|
const genealogyId = ref("");
|
|
const ceremonies = ref([]);
|
|
const ceremonyListState = ref("loading");
|
|
const ceremonyListRequestController = createRequestController();
|
|
let pageActive = true;
|
|
const valid = computed(() => /^[1-9]\d*$/.test(genealogyId.value));
|
|
const loadCeremonies = async () => {
|
|
if (!valid.value) return;
|
|
ceremonyListRequestController.abort();
|
|
ceremonyListState.value = "loading";
|
|
try {
|
|
const rows = await ceremonyApi.getCeremonies(genealogyId.value, {
|
|
requestController: ceremonyListRequestController,
|
|
});
|
|
if (!pageActive) return;
|
|
ceremonies.value = rows;
|
|
ceremonyListState.value = ceremonies.value.length ? "ready" : "empty";
|
|
} catch (error) {
|
|
if (!pageActive || isRequestCancelled(error)) return;
|
|
ceremonyListState.value = "error";
|
|
}
|
|
};
|
|
const returnToFamily = () =>
|
|
valid.value ? returnTo("F01", { genealogyId: genealogyId.value }) : goBack();
|
|
const createCeremony = () =>
|
|
valid.value
|
|
? openPage("R07", { genealogyId: genealogyId.value, mode: "create" }, "R05")
|
|
: Promise.resolve(false);
|
|
const openCeremony = (item) =>
|
|
openPage(
|
|
"R06",
|
|
{ genealogyId: genealogyId.value, ceremonyId: item.id },
|
|
"R05",
|
|
);
|
|
onLoad((query) => {
|
|
genealogyId.value = String(query?.genealogyId || "");
|
|
if (valid.value) loadCeremonies();
|
|
});
|
|
onShow(() => {
|
|
if (valid.value && ceremonyListState.value !== "loading") loadCeremonies();
|
|
});
|
|
onUnload(() => {
|
|
pageActive = false;
|
|
ceremonyListRequestController.abort();
|
|
});
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
@import "../../styles/adaptive-frame-profiles.scss";
|
|
.ritual-list-page {
|
|
display: flex;
|
|
min-height: 100vh;
|
|
flex-direction: column;
|
|
background: $paper;
|
|
}
|
|
.page-header,
|
|
.page-content {
|
|
z-index: 1;
|
|
}
|
|
.page-content {
|
|
flex: 1;
|
|
padding: 18rpx 24rpx calc(72rpx + env(safe-area-inset-bottom));
|
|
}
|
|
.state-card,
|
|
.ceremony-card {
|
|
@include adaptive-records-content;
|
|
background-color: rgba($paper, 0.82);
|
|
}
|
|
.state-card {
|
|
display: flex;
|
|
min-height: 320rpx;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 42rpx;
|
|
text-align: center;
|
|
color: $ink;
|
|
font-size: clamp(16px, 28rpx, 20px);
|
|
}
|
|
.state-card .app-button {
|
|
width: 100%;
|
|
margin-top: 24rpx;
|
|
}
|
|
.ceremony-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 20rpx;
|
|
}
|
|
.ceremony-card {
|
|
display: flex;
|
|
min-height: 138rpx;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 18rpx;
|
|
padding: 28rpx 32rpx;
|
|
}
|
|
.ceremony-card > view {
|
|
min-width: 0;
|
|
flex: 1;
|
|
}
|
|
.ceremony-card__cover {
|
|
width: 150rpx;
|
|
height: 118rpx;
|
|
flex: 0 0 auto;
|
|
border-radius: 10rpx;
|
|
background: rgba(128, 89, 49, 0.12);
|
|
}
|
|
.ceremony-card text {
|
|
display: block;
|
|
}
|
|
.ceremony-card > view text:first-child {
|
|
color: $ink;
|
|
font-family: STKaiti, KaiTi, serif;
|
|
font-size: clamp(17px, 30rpx, 22px);
|
|
font-weight: 700;
|
|
overflow-wrap: anywhere;
|
|
}
|
|
.ceremony-card > view text:not(:first-child) {
|
|
margin-top: 7rpx;
|
|
color: $ink-muted;
|
|
font-size: clamp(13px, 21rpx, 16px);
|
|
line-height: 1.45;
|
|
overflow-wrap: anywhere;
|
|
}
|
|
.ceremony-card__description {
|
|
display: -webkit-box !important;
|
|
overflow: hidden;
|
|
-webkit-box-orient: vertical;
|
|
-webkit-line-clamp: 2;
|
|
}
|
|
.ceremony-card > text {
|
|
flex: 0 0 auto;
|
|
color: $brand-red;
|
|
font-size: clamp(13px, 21rpx, 16px);
|
|
}
|
|
</style>
|