feat(client): 授权管理独立一级屏——授权/购买续费/订单管理三 tab(桌面+移动)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
// screens/settings/license_panel.dart — 授权管理面板(自 settings_screen.dart 抽取为公共组件)。
|
||||
// 四卡:授权信息 / 在线购买续费(PurchaseCard, admin only) / 兑换券 / 到期降级规则。
|
||||
// 桌面:SettingsScreen 授权 tab 内嵌;移动:独立屏 LicenseScreen(/me/license)复用。
|
||||
// screens/settings/license_panel.dart — 授权管理「授权信息」tab 内容
|
||||
// (2026-07-10 独立一级屏三 tab 化:本组件收窄为原四卡去掉「在线购买续费」,
|
||||
// 该卡已提升为 LicenseScreen 的独立 tab2,见 screens/license/license_screen.dart)。
|
||||
// 三卡:授权信息三格 / 兑换券 / 到期降级规则 + iOS 合规态「联系客服」卡。
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../core/auth/auth_state.dart';
|
||||
import '../../core/config/license_copy.dart';
|
||||
import '../../core/config/store_compliance.dart';
|
||||
import '../../core/utils/web_launch.dart';
|
||||
import '../../core/responsive/responsive.dart';
|
||||
import '../../core/theme/app_dims.g.dart';
|
||||
import '../../core/theme/app_fonts.dart';
|
||||
@@ -20,7 +19,6 @@ import '../../providers/license_provider.dart';
|
||||
import '../../widgets/ds/ds_atoms.dart';
|
||||
import '../../widgets/ds/ds_toast.dart';
|
||||
import '../../widgets/write_guard.dart';
|
||||
import 'purchase_card.dart';
|
||||
import 'settings_card.dart';
|
||||
|
||||
class LicensePanel extends ConsumerStatefulWidget {
|
||||
@@ -67,8 +65,6 @@ class _LicensePanelState extends ConsumerState<LicensePanel> {
|
||||
Widget build(BuildContext context) {
|
||||
final t = context.tokens;
|
||||
final lic = ref.watch(licenseProvider).valueOrNull;
|
||||
final role = ref.watch(authStateProvider.select((s) => s.user?.role));
|
||||
final isAdmin = role == 'admin' || role == 'superadmin';
|
||||
final expires = lic?.expiresAt != null
|
||||
? DateFormat('yyyy-MM-dd').format(lic!.expiresAt!)
|
||||
: '—';
|
||||
@@ -79,10 +75,12 @@ class _LicensePanelState extends ConsumerState<LicensePanel> {
|
||||
? lic!.expiresAt!.difference(appNow()).inDays.clamp(0, 99999)
|
||||
: null;
|
||||
final licCells = [
|
||||
// 值为中文词(已授权/未授权):不走等宽字体(JetBrains Mono 无 CJK 字形,
|
||||
// 回退链缺 NotoSansSC 会在 golden 环境 tofu),其余两格是纯数字/日期保留 mono。
|
||||
_licCell(t, '授权状态', active ? '已授权' : '未授权',
|
||||
color: active ? t.success : t.warn),
|
||||
color: active ? t.success : t.warn, mono: false),
|
||||
_licCell(t, '到期日', expires),
|
||||
_licCell(t, '剩余天数', days != null ? '$days 天' : '—'),
|
||||
_licCell(t, '剩余天数', days != null ? '$days 天' : '—', mono: false),
|
||||
];
|
||||
|
||||
return Column(
|
||||
@@ -100,36 +98,7 @@ class _LicensePanelState extends ConsumerState<LicensePanel> {
|
||||
]),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// ── 卡2:在线购买 / 续费(后端 purchase 接口 admin only,
|
||||
// 非管理员引导看官网价格页)。iOS App Store 包整卡不渲染 ──
|
||||
if (!hideExternalPurchaseUi) ...[
|
||||
if (isAdmin)
|
||||
const SettingsCard(
|
||||
title: '在线购买 / 续费',
|
||||
desc: '选择套餐支付宝支付,到账后授权自动续期',
|
||||
child: PurchaseCard(),
|
||||
)
|
||||
else
|
||||
SettingsCard(
|
||||
title: '在线购买 / 续费',
|
||||
desc: '在线购买仅门店管理员可操作',
|
||||
child: Row(children: [
|
||||
Text('在线购买请联系门店管理员 · ',
|
||||
style: TextStyle(fontSize: AppDims.fsSm, color: t.muted)),
|
||||
InkWell(
|
||||
// 免登跳官网(一次性换票 SSO):浏览器落地即已登录,可直接购买
|
||||
onTap: () => launchAuthedWebPath(ref, '/#pricing'),
|
||||
child: Text('查看套餐价格 →',
|
||||
style: TextStyle(
|
||||
fontSize: AppDims.fsSm,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: t.primary)),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
// ── 卡3:兑换券(原型 .redeem:input + 按钮,max 520)──
|
||||
// ── 卡2:兑换券(原型 .redeem:input + 按钮,max 520)──
|
||||
SettingsCard(
|
||||
title: '兑换券',
|
||||
desc: '输入兑换券短码续期',
|
||||
@@ -208,7 +177,10 @@ class _LicensePanelState extends ConsumerState<LicensePanel> {
|
||||
}
|
||||
|
||||
/// 原型 .lic-cell(与「关于我们」同款):lk 11 muted + lv 17/700/mono。
|
||||
Widget _licCell(dynamic t, String label, String value, {Color? color}) =>
|
||||
/// [mono] 为 false 时值不走等宽字体(CJK 词如「已授权」,mono 回退链无
|
||||
/// CJK 字形会 tofu)。
|
||||
Widget _licCell(dynamic t, String label, String value,
|
||||
{Color? color, bool mono = true}) =>
|
||||
Container(
|
||||
// 窄屏三格横排时收窄内距,值文本按格宽缩放防溢出(如 2026-06-25)
|
||||
padding: context.isMobile
|
||||
@@ -234,8 +206,8 @@ class _LicensePanelState extends ConsumerState<LicensePanel> {
|
||||
style: TextStyle(
|
||||
fontSize: AppDims.fsH2,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontFamily: AppFonts.mono,
|
||||
fontFamilyFallback: AppFonts.monoFallback,
|
||||
fontFamily: mono ? AppFonts.mono : null,
|
||||
fontFamilyFallback: mono ? AppFonts.monoFallback : null,
|
||||
color: color ?? t.heading)),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user