feat: 协议的生效时间添加

This commit is contained in:
zoujing
2026-09-18 16:02:26 +08:00
parent d0a1427e12
commit cc9fdf3475
2 changed files with 14 additions and 3 deletions

View File

@@ -122,12 +122,13 @@ export const getContent = async (key) => {
return clone(info);
};
/** 协议页:标题 + 正文段落 + 更新日期 */
/** 协议页:标题 + 正文段落 + 生效日期 + 更新日期 */
export const getAgreement = async (type = "privacy") => {
const info = await getContent(type);
return {
title: (info && info.title) || FALLBACK_TITLE[type] || "",
blocks: toContentBlocks(info && info.body),
validFrom: cnDate(info && info.valid_from),
updatedAt: cnDate(info && info.updated_at) || AGREEMENT_DATE,
};
};

View File

@@ -3,20 +3,30 @@
* 协议页:?type=privacy | terms
* 合规必备页,「我的」与登录页均可直达。
*/
import { ref } from "vue";
import { computed, ref } from "vue";
import { onLoad, onShareAppMessage } from "@dcloudio/uni-app";
import contentApi from "@/api/content";
const type = ref("privacy");
const blocks = ref([]);
const title = ref("");
const validFrom = ref("");
const updatedAt = ref("");
/** 页眉日期行:生效日期 + 更新日期(接口缺哪项就不显示哪项) */
const metaText = computed(() => {
const parts = [];
if (validFrom.value) parts.push(`生效日期:${validFrom.value}`);
if (updatedAt.value) parts.push(`更新日期:${updatedAt.value}`);
return parts.join(" · ");
});
onLoad(async (options) => {
type.value = options?.type === "terms" ? "terms" : "privacy";
const res = await contentApi.getAgreement(type.value);
title.value = res.title;
blocks.value = res.blocks || [];
validFrom.value = res.validFrom;
updatedAt.value = res.updatedAt;
});
@@ -38,7 +48,7 @@ onShareAppMessage(() => ({
<view class="h-[46px]" />
<view class="px-5 pt-[18px] pb-10">
<view class="text-[11.5px] text-ink3 mb-[18px]">更新日期:{{ updatedAt }}</view>
<view class="text-[11.5px] text-ink3 mb-[18px]">{{ metaText }}</view>
<view class="text-[19px] font-semibold mb-[6px] text-ink">{{ title }}</view>
<template v-for="(block, i) in blocks" :key="i">