feat(client): 授权管理独立一级屏——授权/购买续费/订单管理三 tab(桌面+移动)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-07-11 00:24:59 +08:00
parent 9fe1e2766f
commit 22e07613a1
60 changed files with 1598 additions and 96 deletions
+15 -43
View File
@@ -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:兑换券(原型 .redeeminput + 按钮,max 520)──
// ── 卡2兑换券(原型 .redeeminput + 按钮,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)),
),
],
@@ -1,11 +1,12 @@
// screens/settings/settings_screen.dart — 系统设置(照原型 settings.html 重建)。
// 布局:.head + .settings grid(左 .subnav 200px + 右面板卡)。子导航 5 项 =
// 原型 4(门店信息/用户管理/授权管理/偏好设置)+ 保留真实功能「编号规则」。
// 布局:.head + .settings grid(左 .subnav 200px + 右面板卡)。子导航 4 项 =
// 原型 3(门店信息/用户管理/偏好设置)+ 保留真实功能「编号规则」。
// 用户管理面板 = 预览表 + 「管理全部用户」→ /settings/users 独立页(原型 users.html)。
// 原「系统参数」假设置(本地 state 不落后端)已按用户口径删除。
// 窄屏(原型 m-settings.html):hub 形态三组(门店/偏好/数据),标题在壳顶栏;
// 门店信息/编号规则/默认仓库走底部 sheet;?tab= 深链窄屏忽略(无面板可落)。
// 授权入口不在此(拍板:授权在「我的」系统组 /me/license)。
// 授权管理 2026-07-10 提升为独立一级屏(桌面侧边栏「系统组 /license
// 移动「我的」系统组 /me/license),已从本屏子导航摘除。
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -32,14 +33,13 @@ import '../../widgets/ds/m_hub.dart';
import '../../widgets/ds/m_sheet.dart';
import '../../widgets/theme_sheet.dart';
import '../../widgets/write_guard.dart';
import 'license_panel.dart';
import 'settings_card.dart';
import 'users_screen.dart' show userRoleBadge, userStatusBadge;
import '../../core/theme/app_fonts.dart';
import '../../widgets/ds/ds_toast.dart';
class SettingsScreen extends ConsumerStatefulWidget {
/// 初始面板:{shop:0, users:1, number:2, license:3, pref:4}
/// 初始面板:{shop:0, users:1, number:2, pref:3}
final int initialTab;
const SettingsScreen({super.key, this.initialTab = 0});
@@ -50,11 +50,10 @@ class SettingsScreen extends ConsumerStatefulWidget {
class _SettingsScreenState extends ConsumerState<SettingsScreen> {
static const _navs = [
// 图标对齐原型 subnav spritei-ic44=house / i-ic45=user-plus /
// i-ic07=trending-up / i-ic46=contrast(编号规则为 app 专属项,用 hash)
// i-ic46=contrast(编号规则为 app 专属项,用 hash)
(LucideIcons.house, '门店信息'),
(LucideIcons.userPlus, '用户管理'),
(LucideIcons.hash, '编号规则'),
(LucideIcons.trendingUp, '授权管理'),
(LucideIcons.contrast, '偏好设置'),
];
late int _panel = widget.initialTab.clamp(0, _navs.length - 1);
@@ -355,8 +354,7 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
0 => const _StoreInfoPanel(),
1 => _usersPanel(),
2 => _numberPanel(),
3 => const LicensePanel(),
4 => const _PrefPanel(),
3 => const _PrefPanel(),
_ => const SizedBox(),
};