初始化

This commit is contained in:
谢宇宁
2026-09-15 15:44:13 +07:00
commit a23ba685e9
1065 changed files with 101122 additions and 0 deletions
@@ -0,0 +1,173 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hgdj/assets_tool/app_colors.dart';
import 'package:hgdj/hj_utils/pay/pay_manager.dart';
import 'package:hgdj/extension/extensions.dart';
import 'package:hgdj/hj_utils/screen.dart';
import 'package:hgdj/routers/jump_router.dart';
import 'package:hgdj/tools_base/global_store/store.dart';
import 'package:hgdj/tools_base/widget/sheet_handle_bar.dart';
import 'package:provider/provider.dart';
import '../model/im_group_list_model.dart';
class GroupBuyBottomSheet extends StatefulWidget {
final IMGroupItemModel groupModel;
const GroupBuyBottomSheet({super.key, required this.groupModel});
@override
State<GroupBuyBottomSheet> createState() => _GroupBuyBottomSheetState();
}
class _GroupBuyBottomSheetState extends State<GroupBuyBottomSheet> {
@override
void initState() {
super.initState();
globalStore.updateUserInfo();
globalStore.refreshWallet();
}
@override
Widget build(BuildContext context) {
return Consumer<GlobalStore>(
builder: (_, store, __) {
final enough =
(store.wallet?.amount ?? 0) >= (widget.groupModel.price ?? 0);
return _buildNormal(enough, store);
},
);
}
Widget _buildNormal(bool enough, GlobalStore store) {
return Container(
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 18),
decoration: BoxDecoration(
color: AppColors.primaryColor,
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SheetHandleBar(),
18.sizeBoxH,
Text(
'购买',
style: TextStyle(
color: Color(0xE5ffffff),
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
36.sizeBoxH,
Row(
children: [
Text(
'解锁群聊',
style: TextStyle(
color: Color(0xE5ffffff),
fontSize: 14,
),
),
Spacer(),
GestureDetector(
onTap: () => pushToWalletPage(tabPosition: 1),
child: Row(
children: [
Text(
'${widget.groupModel.price ?? 0} 金币',
style:
TextStyle(color: AppColors.actionRed, fontSize: 14),
),
],
),
)
],
),
18.sizeBoxH,
0.5.line,
18.sizeBoxH,
Row(
children: [
Text(
'我的金币',
style: TextStyle(
color: Color(0xE5ffffff),
fontSize: 14,
),
),
Spacer(),
Row(
children: [
Text(
'${GlobalStore().wallet?.amount?.toDouble().fixed(2) ?? 0}',
style: TextStyle(
color: Color(0xE5ffffff),
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
12.sizeBoxW,
InkWell(
enableFeedback: false,
onTap: () => pushToWalletPage(tabPosition: 1),
child: Text(
'充值',
style: TextStyle(
color: Color(0xffA4634D),
fontSize: 14,
fontWeight: FontWeight.w400,
decoration: TextDecoration.underline,
decorationColor: Color(0xffA4634D),
),
),
),
],
),
],
),
18.sizeBoxH,
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () => _doPayAction(enough),
child: Container(
width: double.infinity,
height: 44,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(3),
color: AppColors.actionRed,
),
alignment: Alignment.center,
child: Text(
enough
? '${widget.groupModel.price ?? 0} 金币/立即支付'
: '余额不足,前往充值',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w500),
),
),
),
],
),
);
}
void _doPayAction(bool enough) async {
if (!enough) {
await pushToWalletPage(tabPosition: 1);
return;
}
await PayManager().buy(
widget.groupModel.id,
ProductType.group,
source: 'group_buy',
onSuccess: (data) {
globalStore.refreshWallet();
Get.back(result: true);
},
);
}
}