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,52 +108,66 @@ 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
? theme.colorScheme.onSurface ? null
.withOpacity(0.38) : isReserved
: null, ? theme.colorScheme.onSurface
backgroundColor: isReserved .withOpacity(0.38)
? theme.colorScheme.onSurface : null,
.withOpacity(0.12) backgroundColor: canJump
: null, ? null
: isReserved
? theme.colorScheme.onSurface
.withOpacity(0.12)
: null,
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 16), horizontal: 16),
tapTargetSize: tapTargetSize:
MaterialTapTargetSize.shrinkWrap, MaterialTapTargetSize.shrinkWrap,
), ),
onPressed: btn.disable == 1 onPressed: canJump
? null ? () {
: () async { PiliScheme.routePushFromUrl(
var res = btn.jumpUrl!);
await DynamicsHttp.dynReserve( }
reserveId: content.rid, : btn.disable == 1
curBtnStatus: btn.status, ? null
dynamicIdStr: item.idStr, : () async {
reserveTotal: content.reserveTotal, var res =
); await DynamicsHttp.dynReserve(
if (res['status']) { reserveId: content.rid,
content curBtnStatus: btn.status,
..desc2?.text = dynamicIdStr: item.idStr,
res['data']['desc_update'] reserveTotal:
..reserveTotal = content.reserveTotal,
res['data']['reserve_update'] );
..button!.status = res['data'] if (res['status']) {
['final_btn_status']; content
if (context.mounted) { ..desc2?.text =
(context as Element?) res['data']['desc_update']
?.markNeedsBuild(); ..reserveTotal = res['data']
} ['reserve_update']
} else { ..button!.status = res['data']
SmartDialog.showToast(res['msg']); ['final_btn_status'];
} if (context.mounted) {
}, (context as Element?)
?.markNeedsBuild();
}
} else {
SmartDialog.showToast(
res['msg']);
}
},
child: Text( child: Text(
isReserved btn.jumpText != null
? btn.checkText! ? btn.jumpText!
: btn.uncheckText!, : isReserved
? btn.checkText!
: btn.uncheckText!,
), ),
); );
}, },