reserve btn

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-15 13:24:43 +08:00
parent d35c85f389
commit 205ae2bf55
2 changed files with 55 additions and 37 deletions

View File

@@ -499,6 +499,8 @@ class ReserveBtn {
String? checkText; String? checkText;
String? uncheckText; String? uncheckText;
int? disable; int? disable;
String? jumpText;
String? jumpUrl;
ReserveBtn.fromJson(Map<String, dynamic> json) { ReserveBtn.fromJson(Map<String, dynamic> json) {
status = json['status']; status = json['status'];
@@ -506,6 +508,8 @@ class ReserveBtn {
checkText = json['check']?['text'] ?? '已预约'; checkText = json['check']?['text'] ?? '已预约';
uncheckText = json['uncheck']?['text'] ?? '预约'; uncheckText = json['uncheck']?['text'] ?? '预约';
disable = json['uncheck']?['disable']; disable = json['uncheck']?['disable'];
jumpText = json['jump_style']?['text'];
jumpUrl = json['jump_url'];
} }
} }

View File

@@ -108,13 +108,18 @@ Widget addWidget(
builder: (context) { builder: (context) {
final btn = content.button!; final btn = content.button!;
final isReserved = btn.status == btn.type; final isReserved = btn.status == btn.type;
final bool canJump = btn.jumpUrl != null;
return FilledButton.tonal( return FilledButton.tonal(
style: FilledButton.styleFrom( style: FilledButton.styleFrom(
foregroundColor: isReserved foregroundColor: canJump
? null
: isReserved
? theme.colorScheme.onSurface ? theme.colorScheme.onSurface
.withOpacity(0.38) .withOpacity(0.38)
: null, : null,
backgroundColor: isReserved backgroundColor: canJump
? null
: isReserved
? theme.colorScheme.onSurface ? theme.colorScheme.onSurface
.withOpacity(0.12) .withOpacity(0.12)
: null, : null,
@@ -124,7 +129,12 @@ Widget addWidget(
tapTargetSize: tapTargetSize:
MaterialTapTargetSize.shrinkWrap, MaterialTapTargetSize.shrinkWrap,
), ),
onPressed: btn.disable == 1 onPressed: canJump
? () {
PiliScheme.routePushFromUrl(
btn.jumpUrl!);
}
: btn.disable == 1
? null ? null
: () async { : () async {
var res = var res =
@@ -132,14 +142,15 @@ Widget addWidget(
reserveId: content.rid, reserveId: content.rid,
curBtnStatus: btn.status, curBtnStatus: btn.status,
dynamicIdStr: item.idStr, dynamicIdStr: item.idStr,
reserveTotal: content.reserveTotal, reserveTotal:
content.reserveTotal,
); );
if (res['status']) { if (res['status']) {
content content
..desc2?.text = ..desc2?.text =
res['data']['desc_update'] res['data']['desc_update']
..reserveTotal = ..reserveTotal = res['data']
res['data']['reserve_update'] ['reserve_update']
..button!.status = res['data'] ..button!.status = res['data']
['final_btn_status']; ['final_btn_status'];
if (context.mounted) { if (context.mounted) {
@@ -147,11 +158,14 @@ Widget addWidget(
?.markNeedsBuild(); ?.markNeedsBuild();
} }
} else { } else {
SmartDialog.showToast(res['msg']); SmartDialog.showToast(
res['msg']);
} }
}, },
child: Text( child: Text(
isReserved btn.jumpText != null
? btn.jumpText!
: isReserved
? btn.checkText! ? btn.checkText!
: btn.uncheckText!, : btn.uncheckText!,
), ),