Bläddra i källkod

feat(trial): reissue 再开通 + Matrix 到期切断 + 三档时长 + 7 天留存标识

- reissue:轮换凭证/Matrix 密码并下发新提示词,7 天宽限外拒绝
- 到期判据顺带切断 Matrix(幂等,不依赖定时作业)
- App 套餐页月/季/年三档(默认月 30 天),随开通提交 planBilling
- 数据留存 7 天文案落 4 处;新增 billing-period 单测

Co-Authored-By: Claude Code <noreply@anthropic.com>
Huccct 8 timmar sedan
förälder
incheckning
274ec77dc0

+ 69 - 0
cloud/functions/fmode-provisioning.js

@@ -837,6 +837,74 @@ function _failedStep(steps) {
 
 // ---------- 主流程 ----------
 
+/**
+ * 再开通(2026-12-03 用户裁决「再开通生成新密钥 + 新提示词」)。
+ *
+ * 场景:试用/套餐到期后用户付费。
+ *   ① 7 天内:同一条记录恢复 —— 轮换 accessToken(旧提示词立即作废)、
+ *      重置 Matrix 密码(旧密码立即登不上)、有效期从**现在**起算,
+ *      然后返回**新的接入提示词**,用户贴给现有 Hermes 即可恢复。
+ *   ② 超过 7 天:按新开通处理(调用方应走 start),这里直接拒绝。
+ *
+ * 只允许记录 owner 调用。
+ */
+async function _reissue(user, p) {
+  var agentId = String((p && p.agentId) || '').trim();
+  if (!agentId) return _fail(400, '缺少 agentId');
+  var Agent = Parse.Object.extend('FmodeAgent');
+  var rec = null;
+  try { rec = await new Parse.Query(Agent).equalTo('agentId', agentId).first({ useMasterKey: true }); } catch (e) { rec = null; }
+  if (!rec) { try { rec = await new Parse.Query(Agent).get(agentId, { useMasterKey: true }); } catch (e) { rec = null; } }
+  if (!rec || rec.get('isDeleted') === true) return _fail(404, '容器不存在');
+  var owner = rec.get('user');
+  if (!owner || owner.id !== user.id) return _fail(403, '只能为本人名下的容器续费');
+
+  /* 7 天宽限:过期超过 7 天不再恢复,必须按新开通处理 */
+  var exp = rec.get('accessExpiresAt');
+  var expMs = exp ? new Date(exp).getTime() : 0;
+  var GRACE_MS = 7 * 86400000;
+  if (expMs && Date.now() - expMs > GRACE_MS) {
+    return _fail(409, '已超过 7 天保留期,请重新开通', { reasonCode: 'GRACE_EXCEEDED' });
+  }
+
+  var planCode = rec.get('planCode') || 'starter';
+  var billing = String((p && p.planBilling) || rec.get('planBilling') || 'monthly');
+  var accessExpiresAt = new Date(Date.now() + (planCode === 'trial' ? TRIAL_MS : _billingDays(billing) * 86400000));
+
+  /* ① 轮换凭证:版本 +1,旧提示词中的 accessToken 立即失效 */
+  rec.set('accessToken', _newAccessToken());
+  rec.set('accessTokenVer', (rec.get('accessTokenVer') || 1) + 1);
+  rec.set('accessExpiresAt', accessExpiresAt);
+  rec.set('accessState', 'active');
+  rec.set('planBilling', billing);
+  await rec.save(null, { useMasterKey: true });
+
+  var token0 = _sessionToken();
+  var ownerMx = '@' + String(user.id).toLowerCase() + ':fmode.cn';
+
+  /* ② 重置 Matrix 密码(到期时被切掉的账号在这里恢复) */
+  var prov0 = null;
+  try { prov0 = await _callFn(FN_PROVISION, token0, { agentId: rec.id }); } catch (e) { prov0 = null; }
+  if (!prov0 || !prov0.agentMxId) return _fail(500, 'Matrix 身份恢复失败,请稍后重试', { reasonCode: 'MATRIX_RESTORE_FAILED', retryable: true });
+
+  /* ③ 生成新提示词 */
+  var derivedPass = await _agentMxPassword(rec.id);
+  var instruction = _buildSelfHostedInstruction(rec.id, rec.get('name') || '', prov0, derivedPass,
+    rec.get('accessToken'), accessExpiresAt.toISOString().slice(0, 16).replace('T', ' ') + '(UTC)',
+    ownerMx, CONTAINER_ONBOARDING_BUNDLE);
+
+  return _ok({
+    mode: 'onboarding',
+    reissued: true,
+    onboardingBundle: CONTAINER_ONBOARDING_BUNDLE,
+    message: '已续期,请用新的接入提示词重新接入(原有模型与历史不受影响)。',
+    instruction: instruction,
+    agentId: rec.id,
+    accessExpiresAt: accessExpiresAt.toISOString(),
+    matrixInfo: { agentMxId: prov0.agentMxId, roomId: prov0.roomId, homeserver: prov0.homeserver },
+  });
+}
+
 async function _start(user, p) {
   var planCode = _str(p.planCode, 20);
   /*
@@ -1337,6 +1405,7 @@ async function handler(request, response) {
     if (op === 'status') return await _status(user, p);
     if (op === 'retry') return await _retry(user, p);
     if (op === 'list') return await _list(user);
+    if (op === 'reissue') return await _reissue(user, p);
 
     return _fail(400, '未知 op:' + op);
   } catch (e) {

+ 49 - 0
cloud/functions/fmodeagent-status.js

@@ -534,6 +534,53 @@ function _sumUsage(list) {
   return s;
 }
 
+/**
+ * 到期切断 Matrix(2026-12-03)—— 判据判到过期时**顺带执行一次**,幂等。
+ *
+ * 用户裁决「密钥和 Matrix 到期自动停」。做法:用 homeserver admin 把该容器
+ * Matrix 账号的密码重置为一段随机串(不告知任何人)→ 容器手里的旧密码立即登不上。
+ * 同时把绑定置为 revoked,App 侧不会再认为它可以开会话。
+ *
+ * 幂等标记:FmodeAgent.matrixRevokedVer = accessTokenVer,同一版本只切一次。
+ * 失败一律吞掉(切断是尽力而为,不能因为它阻塞正常的拒绝返回)。
+ */
+async function _revokeMatrixOnExpiry(agent) {
+  try {
+    if (!agent || !agent.get) return false;
+    var ver = agent.get('accessTokenVer') || 1;
+    if (agent.get('matrixRevokedVer') === ver) return true; // 已切过
+    var HS = 'https://matrix.fmode.cn';
+    var ADMIN_USER = 'admin';
+    var ADMIN_PASS = 'Fmode@2026';
+    var login = await fetch(HS + '/_matrix/client/v3/login', {
+      method: 'POST', headers: { 'Content-Type': 'application/json' },
+      body: JSON.stringify({ type: 'm.login.password', identifier: { type: 'm.id.user', user: ADMIN_USER }, password: ADMIN_PASS }),
+    }).then(function (r) { return r.json(); }).catch(function () { return null; });
+    if (!login || !login.access_token) return false;
+    var local = String(agent.id || '').toLowerCase();
+    var random = 'rev' + Math.random().toString(36).slice(2) + Date.now().toString(36);
+    var cmd = encodeURIComponent('!admin users reset-password ' + local + ' ' + random);
+    await fetch(HS + '/_matrix/client/v3/rooms/!admin:fmode.cn/send/m.room.message/rv' + Date.now() +
+      '?access_token=' + encodeURIComponent(login.access_token), {
+      method: 'PUT', headers: { 'Content-Type': 'application/json' },
+      body: JSON.stringify({ msgtype: 'm.text', body: '!admin users reset-password ' + local + ' ' + random }),
+    }).catch(function () { return null; });
+    agent.set('matrixRevokedVer', ver);
+    agent.set('accessState', 'expired');
+    await agent.save(null, { useMasterKey: true });
+    try {
+      var bq = new Parse.Query('FmodeMatrixBinding');
+      bq.equalTo('agentId', 'agent-node-app-' + local);
+      bq.containedIn('status', ['active']);
+      var bs = await bq.find({ useMasterKey: true });
+      for (var i = 0; i < bs.length; i++) { bs[i].set('status', 'revoked'); await bs[i].save(null, { useMasterKey: true }); }
+    } catch (e) { /* 绑定停用失败不阻塞 */ }
+    return true;
+  } catch (e) {
+    return false;
+  }
+}
+
 function _agentAccess(agent, providedToken, opts) {
   var o = opts || {};
   if (!agent) return { ok: false, reason: 'NOT_FOUND', message: '容器不存在' };
@@ -547,6 +594,8 @@ function _agentAccess(agent, providedToken, opts) {
 
   /* 已过期:统一拒绝(顺带标记,供作业与 App 使用) */
   if (expired || state === 'expired') {
+    /* 顺带切断 Matrix(幂等,不阻塞拒绝返回)——用户裁决「到期自动停」 */
+    try { _revokeMatrixOnExpiry(agent); } catch (e) { /* 忽略 */ }
     return { ok: false, reason: 'ACCESS_EXPIRED', message: '已到期,请开通或续费套餐', expired: true };
   }
 

+ 8 - 0
docs/00-tracking/操作追踪.md

@@ -10596,3 +10596,11 @@ Call log:
   - 注入脚本 `onboarding-cloud-patch.mjs` 适配新调用(多行 + 正则),并修复此前一次误替换导致的提示词区替换逻辑损坏。
   - 回归:`test-onboarding-prompt` 6/6、`test-onboarding-input` 4/4、`test-onboarding-apply` 5/5、`test-provision-entry` 11/11 全绿。
   - 未做:`reissue`(再开通发新提示词)、Matrix 到期切断、App 三档时长 UI 与 7 天标识、两个每日作业——按清单后续步骤推进。
+
+- 2026-12-03 22:30:00+08:00:**试用期失效改造 · 第 5~8 步完成**
+  - 5 `reissue`:`fmode-provisioning.js` 新增 `op:'reissue'`——仅 owner 可调;7 天宽限内轮换 `accessToken`(旧提示词立即作废)、`accessTokenVer+1`、有效期从现在起算、重新下发 Matrix 凭据,返回**新提示词**;超 7 天返回 `GRACE_EXCEEDED` 要求重新开通。
+  - 6 Matrix 切断:新增 `_revokeMatrixOnExpiry()`(admin `reset-password` 随机密码 + 绑定 `revoked` + `matrixRevokedVer` 幂等标记),挂在判据的过期分支上**顺带执行**,不依赖每日作业;失败不阻塞拒绝返回。
+  - 7 三档时长:新增 `src/app/core/billing-period.ts`(月 30/季 90/年 365,默认月,与云函数 `BILLING_DAYS` 同口径);两端套餐卡加分段控件,选择随开通提交(`planBilling`)。浏览器实测:三档可见、默认「按月付开通 · 30 天」、切年付后变「365 天」。
+  - 8 数据留存 7 天:4 处落位(套餐页底部卡、两端到期提示条、移动通讯录到期徽标 tooltip、桌面我的容器「已到期」pill);提示词正文已含该文案。
+  - 验证:build 通过;单测 **2255 SUCCESS**(3 个失败仍为 SafeArea 既知偶发项);新增 `billing-period.spec.ts` 3 条。
+  - 踩坑:`title="中文…"` 会被 Angular 当表达式解析 → 必须用 `[attr.title]="'…'"`;桌面套餐页在顶层 `/plans` 不是 `/desktop/plans`。

+ 4 - 4
docs/02-design/plans/2026-12-03-试用期失效-完整执行计划.md

@@ -21,10 +21,10 @@
 | 2 | 四个入口接入判据(状态/交付/上传/文件) | 🟡 2/4 已改(status、file-read);deliverables、upload-url 在 `cloud/functions-pending/` **待部署** |
 | 3 | 开通:写有效期与凭证、试用按账号一次 | ✅ 完成 |
 | 4 | 提示词携带 `FMODE_ACCESS_TOKEN` + 有效期说明 | ✅ 完成 |
-| 5 | `reissue` 再开通:轮换凭证 + 新提示词 | ⬜ 未开始 |
-| 6 | Matrix 到期切断(admin reset-password,幂等) | ⬜ 未开始 |
-| 7 | App:三档时长选择(月/季/年) | ⬜ 未开始 |
-| 8 | App:数据留存 7 天标识(4 处)+ 到期态 | ⬜ 未开始 |
+| 5 | `reissue` 再开通:轮换凭证 + 新提示词 | ✅ 完成 |
+| 6 | Matrix 到期切断(admin reset-password,幂等) | ✅ 完成 |
+| 7 | App:三档时长选择(月/季/年) | ✅ 完成 |
+| 8 | App:数据留存 7 天标识(4 处)+ 到期态 | ✅ 完成 |
 | 9 | 每日作业:到期扫描 + 7 天回收(先干跑出清单) | ⬜ 未开始 |
 | 10 | 端到端验证 10 条 + 发布 | ⬜ 未开始 |
 

+ 23 - 0
src/app/core/billing-period.spec.ts

@@ -0,0 +1,23 @@
+import { BILLING_OPTIONS, billingDays, billingExpiry, DEFAULT_BILLING } from './billing-period';
+
+describe('billing-period(2026-12-03 用户裁决:月/季/年三档,默认月)', () => {
+  it('三档齐全且默认月付', () => {
+    expect(BILLING_OPTIONS.map((o) => o.value)).toEqual(['monthly', 'quarterly', 'yearly']);
+    expect(DEFAULT_BILLING).toBe('monthly');
+  });
+
+  it('折算按固定天数:月 30 / 季 90 / 年 365', () => {
+    expect(billingDays('monthly')).toBe(30);
+    expect(billingDays('quarterly')).toBe(90);
+    expect(billingDays('yearly')).toBe(365);
+    /* 未知值一律按月,与云函数缺省一致 */
+    expect(billingDays(undefined)).toBe(30);
+    expect(billingDays('unknown' as never)).toBe(30);
+  });
+
+  it('到期时间从起点按天数累加', () => {
+    const now = Date.parse('2026-12-03T00:00:00Z');
+    expect(billingExpiry(now, 'monthly')).toBe(now + 30 * 86400_000);
+    expect(billingExpiry(now, 'yearly')).toBe(now + 365 * 86400_000);
+  });
+});

+ 34 - 0
src/app/core/billing-period.ts

@@ -0,0 +1,34 @@
+/**
+ * 付费时长选择(2026-12-03 用户裁决:「年/季/月三档,默认一个月 30 天」)。
+ *
+ * 🔴 折算按**固定天数**(用户确认):月 30 / 季 90 / 年 365,
+ *    与云函数 `BILLING_DAYS` 保持同一口径(`cloud/functions/fmode-provisioning.js`)。
+ *    改一处必须同步另一处,否则 App 展示与到期时间会对不上。
+ */
+export type BillingPeriod = 'monthly' | 'quarterly' | 'yearly';
+
+export interface BillingOption {
+  value: BillingPeriod;
+  label: string;
+  days: number;
+  /** 单位文案(替代原来的 `/ 月` `/ 年`) */
+  unit: string;
+}
+
+export const BILLING_OPTIONS: readonly BillingOption[] = [
+  { value: 'monthly', label: '月付', days: 30, unit: '/ 月' },
+  { value: 'quarterly', label: '季付', days: 90, unit: '/ 季' },
+  { value: 'yearly', label: '年付', days: 365, unit: '/ 年' },
+];
+
+export const DEFAULT_BILLING: BillingPeriod = 'monthly';
+
+/** 时长天数(未知值一律按月,与云函数缺省一致) */
+export function billingDays(period: BillingPeriod | null | undefined): number {
+  return BILLING_OPTIONS.find((o) => o.value === period)?.days ?? 30;
+}
+
+/** 到期时间(从 `from` 起算,单位毫秒时间戳) */
+export function billingExpiry(from: number, period: BillingPeriod | null | undefined): number {
+  return from + billingDays(period) * 86400_000;
+}

+ 6 - 2
src/app/core/provision.service.ts

@@ -65,6 +65,8 @@ interface PendingProvisionStart {
   planCode: string;
   containerName: string;
   idempotencyKey: string;
+  /** 付费时长(2026-12-03):monthly/quarterly/yearly;试用可为空 */
+  planBilling?: string;
 }
 
 /**
@@ -338,7 +340,7 @@ export class ProvisionService {
     }
   }
 
-  async start(planCode: string, containerName: string): Promise<ProvisionStartResult | null> {
+  async start(planCode: string, containerName: string, planBilling?: string): Promise<ProvisionStartResult | null> {
     /*
      * 🔴 防重入(2026-11-27):已在开通中时直接忽略。
      *
@@ -358,7 +360,9 @@ export class ProvisionService {
     const request = {
       planCode,
       containerName,
-      idempotencyKey: `${planCode}-${Date.now()}`,
+      idempotencyKey: `${planCode}-${planBilling || ''}-${Date.now()}`,
+      /* 付费时长(2026-12-03):云函数据此算 accessExpiresAt;试用不传 */
+      ...(planBilling ? { planBilling } : {}),
     };
     if (!this.writePendingStart(request)) {
       this._recoveryFailed.set(true);

+ 9 - 0
src/app/desktop/pages/my-containers/my-containers.ts

@@ -80,6 +80,9 @@ import { EditionService } from '../../../core/edition.service';
                   <h3>{{ agent.name }}</h3>
                   <small>{{ edition.containerKind(agent) }}</small>
                 </div>
+                @if (agent.trialExpired) {
+                  <span class="container-pill container-pill--expired" [attr.title]="'到期后数据保留 7 天,7 天后容器与数据将被回收'">已到期</span>
+                }
                 <span class="container-pill" [class.container-pill--ok]="isOnline(agent)">
                   {{ statusText(agent) }}
                 </span>
@@ -283,6 +286,12 @@ import { EditionService } from '../../../core/edition.service';
         font-size: var(--fs-11);
         white-space: nowrap;
       }
+      .container-pill--expired {
+        /* 试用/套餐已到期(2026-12-03):提示数据保留 7 天 */
+        background: var(--warning-subtle);
+        color: var(--warning);
+        border-color: var(--warning);
+      }
       .container-pill--ok {
         background: var(--success-subtle);
         color: var(--success);

+ 49 - 7
src/app/desktop/pages/plans/plans.ts

@@ -2,6 +2,7 @@ import { UserNoticePipe } from '../../../components/feedback/user-notice.pipe';
 import { ChangeDetectionStrategy, Component, computed, inject, OnInit, signal } from '@angular/core';
 import { Router } from '@angular/router';
 import { PaidPlanCode } from '../../../core/api/models';
+import { BILLING_OPTIONS, BillingPeriod, DEFAULT_BILLING, billingDays } from '../../../core/billing-period';
 import { LoadingOverlayComponent } from '../../../components/domain/loading-overlay/loading-overlay';
 import { ProvisionInstructionComponent } from '../../../components/domain/provision-instruction/provision-instruction';
 import { PlanService } from '../../../core/plan.service';
@@ -42,7 +43,7 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
       @if (trialExpiredName(); as expired) {
         <div class="quota-full quota-full--expired" role="alert">
           <p>「{{ expired }}」的两天试用已到期。</p>
-          <p>开通入门版(本地容器 + App)或进阶版(平台容器)后即可继续使用。</p>
+          <p>开通入门版(本地容器 + App)或进阶版(平台容器)后即可继续使用;到期后数据保留 7 天,7 天后容器与数据将被回收。</p>
         </div>
       }
       <header class="plans-head">
@@ -171,13 +172,20 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
               <span>{{ item.quotaLabel }}</span>
             </p>
 
+            <!-- 付费时长三档(2026-12-03 用户裁决:月/季/年,默认月 30 天;价格仍待定不出现金额) -->
+            <div class="plan-periods" role="radiogroup" [attr.aria-label]="item.name + ' 计费周期'">
+              @for (opt of billingOptions; track opt.value) {
+                <button type="button" role="radio"
+                  [attr.aria-checked]="billingOf(item.code) === opt.value"
+                  [class.on]="billingOf(item.code) === opt.value"
+                  (click)="setBilling(item.code, opt.value)">{{ opt.label }}</button>
+              }
+            </div>
             <div class="plan-price">
               <strong>价格待定</strong>
-              @if (item.billingUnit) {
-                <span>{{ item.billingUnit }}</span>
-              }
+              <span>{{ periodUnit(item.code) }}</span>
             </div>
-            <p class="plan-billing">{{ item.billingNote }}</p>
+            <p class="plan-billing">按{{ periodLabel(item.code) }}开通 · {{ periodDays(item.code) }} 天</p>
 
             <button
               type="button"
@@ -220,7 +228,7 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
           <i class="fa-solid fa-shield-halved" aria-hidden="true"></i>
           <div>
             <h3>数据为你保留</h3>
-            <p>试用结束后,开通套餐即可继续使用原有容器</p>
+            <p>试用结束后,开通套餐即可继续使用原有容器;到期后数据保留 7 天,7 天后容器与数据将被回收</p>
           </div>
         </section>
       </div>
@@ -499,6 +507,29 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
         color: var(--muted);
         font-size: var(--fs-12);
       }
+      .plan-periods {
+        display: flex;
+        gap: 2px;
+        margin: var(--sp-2) 0 0;
+        padding: 2px;
+        border-radius: 8px;
+        background: var(--surface-2);
+      }
+      .plan-periods button {
+        flex: 1;
+        min-height: 30px;
+        border: 0;
+        border-radius: 6px;
+        background: transparent;
+        color: var(--muted);
+        font-size: var(--fs-12);
+        cursor: pointer;
+      }
+      .plan-periods button.on {
+        background: var(--surface);
+        color: var(--ink);
+        font-weight: 600;
+      }
       .plan-price {
         display: flex;
         align-items: baseline;
@@ -749,6 +780,17 @@ export class DkPlansPage implements OnInit {
     void this.live.ensureLoaded();
   }
 
+  /* 付费时长三档(2026-12-03):每张卡各自记住选择,默认月 */
+  protected readonly billingOptions = BILLING_OPTIONS;
+  private readonly billingSel = signal<Record<string, BillingPeriod>>({});
+  protected billingOf(code: string): BillingPeriod { return this.billingSel()[code] ?? DEFAULT_BILLING; }
+  protected setBilling(code: string, v: BillingPeriod): void {
+    this.billingSel.update((m) => ({ ...m, [code]: v }));
+  }
+  protected periodLabel(code: string): string { return BILLING_OPTIONS.find((o) => o.value === this.billingOf(code))?.label ?? '月付'; }
+  protected periodUnit(code: string): string { return BILLING_OPTIONS.find((o) => o.value === this.billingOf(code))?.unit ?? '/ 月'; }
+  protected periodDays(code: string): number { return billingDays(this.billingOf(code)); }
+
   protected readonly plans = computed(() => this.plan.catalog);
 
   /** 运行中的容器数(资产概览用;状态口径与通讯录一致) */
@@ -843,7 +885,7 @@ export class DkPlansPage implements OnInit {
     if (!code) return;
     this.submitting.set(true);
     try {
-      const result = await this.provision.start(code, name);
+      const result = await this.provision.start(code, name, this.billingOf(code));
       this.confirmOpen.set(false);
       this.pendingCode.set(null);
 

+ 1 - 1
src/app/mobile/pages/contacts/contacts.ts

@@ -152,7 +152,7 @@ import { MSearchComponent } from '../../components/m-search/m-search';
                           <app-m-badge tone="info">{{ localBadge(a) }}</app-m-badge>
                         }
                         @if (a.trialExpired) {
-                          <app-m-badge tone="warning">已到期</app-m-badge>
+                          <app-m-badge tone="warning" [attr.title]="'到期后数据保留 7 天,7 天后容器与数据将被回收'">已到期</app-m-badge>
                         }
                         <app-m-badge [tone]="toneOf(a)" [dot]="true">{{ statusText(a) }}</app-m-badge>
                       </button>

+ 46 - 3
src/app/mobile/pages/plans/plans.ts

@@ -2,6 +2,7 @@ import { UserNoticePipe } from '../../../components/feedback/user-notice.pipe';
 import { ChangeDetectionStrategy, Component, computed, inject, OnInit, signal } from '@angular/core';
 import { Router } from '@angular/router';
 import { PlanCode } from '../../../core/api/models';
+import { BILLING_OPTIONS, BillingPeriod, DEFAULT_BILLING, billingDays } from '../../../core/billing-period';
 import { PlanService } from '../../../core/plan.service';
 import { ProvisionService } from '../../../core/provision.service';
 import { LiveService } from '../../../core/live.service';
@@ -50,7 +51,7 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
       @if (trialExpiredName(); as expired) {
         <div class="quota-full quota-full--expired" role="alert">
           <p>「{{ expired }}」的两天试用已到期。</p>
-          <p>开通入门版(本地容器 + App)或进阶版(平台容器)后即可继续使用。</p>
+          <p>开通入门版(本地容器 + App)或进阶版(平台容器)后即可继续使用;到期后数据保留 7 天,7 天后容器与数据将被回收。</p>
         </div>
       }
 
@@ -151,8 +152,17 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
                 }
                 <span>{{ plan.quotaLabel }}</span>
               </p>
+              <!-- 付费时长三档(2026-12-03 用户裁决:月/季/年,默认月 30 天;价格仍待定不出现金额) -->
+              <div class="plan-periods" role="radiogroup" [attr.aria-label]="plan.name + ' 计费周期'">
+                @for (opt of billingOptions; track opt.value) {
+                  <button type="button" role="radio"
+                    [attr.aria-checked]="billingOf(plan.code) === opt.value"
+                    [class.on]="billingOf(plan.code) === opt.value"
+                    (click)="setBilling(plan.code, opt.value)">{{ opt.label }}</button>
+                }
+              </div>
               <p class="plan-price">价格待定</p>
-              <p class="plan-unit">{{ plan.billingUnit || plan.billingNote }}</p>
+              <p class="plan-unit">按{{ periodLabel(plan.code) }}开通 · {{ periodDays(plan.code) }} 天</p>
               <button
                 type="button"
                 class="plan-btn"
@@ -578,6 +588,29 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
         color: var(--muted);
         font-size: var(--fs-10, 11px);
       }
+      .plan-periods {
+        display: flex;
+        gap: 2px;
+        margin: var(--sp-2) 0 0;
+        padding: 2px;
+        border-radius: 8px;
+        background: var(--surface-2);
+      }
+      .plan-periods button {
+        flex: 1;
+        min-height: 28px;
+        border: 0;
+        border-radius: 6px;
+        background: transparent;
+        color: var(--muted);
+        font-size: var(--fs-11, 11px);
+        cursor: pointer;
+      }
+      .plan-periods button.on {
+        background: var(--surface);
+        color: var(--ink);
+        font-weight: 600;
+      }
       .plan-price {
         margin: var(--sp-1) 0 0;
         color: var(--ink-2);
@@ -720,6 +753,16 @@ export class MbPlansPage implements OnInit {
   protected readonly drawerOpen = signal(false);
 
   /** 付费三档(试用单独走横幅) */
+  /* 付费时长三档(2026-12-03):每张卡各自记住选择,默认月 */
+  protected readonly billingOptions = BILLING_OPTIONS;
+  private readonly billingSel = signal<Record<string, BillingPeriod>>({});
+  protected billingOf(code: string): BillingPeriod { return this.billingSel()[code] ?? DEFAULT_BILLING; }
+  protected setBilling(code: string, v: BillingPeriod): void {
+    this.billingSel.update((m) => ({ ...m, [code]: v }));
+  }
+  protected periodLabel(code: string): string { return BILLING_OPTIONS.find((o) => o.value === this.billingOf(code))?.label ?? '月付'; }
+  protected periodDays(code: string): number { return billingDays(this.billingOf(code)); }
+
   protected readonly plans = computed(() => this.plan.catalog);
 
   /**
@@ -811,7 +854,7 @@ export class MbPlansPage implements OnInit {
     if (!code) return;
     this.submitting.set(true);
     try {
-      const result = await this.provision.start(code, name);
+      const result = await this.provision.start(code, name, this.billingOf(code));
       this.confirmOpen.set(false);
       this.pendingCode.set(null);