diff --git a/assets/icons/alipay_round.png b/assets/icons/alipay_round.png new file mode 100644 index 00000000..7fbe0730 Binary files /dev/null and b/assets/icons/alipay_round.png differ diff --git a/lib/const/resource.dart b/lib/const/resource.dart index 6eaf8755..3b0b1765 100644 --- a/lib/const/resource.dart +++ b/lib/const/resource.dart @@ -113,6 +113,10 @@ class R { /// ![preview](file:///Users/zhangmeng/aku_community/assets/icons/alarm.png) static const String ASSETS_ICONS_ALARM_PNG = 'assets/icons/alarm.png'; + /// ![preview](file:///Users/zhangmeng/aku_community/assets/icons/alipay_round.png) + static const String ASSETS_ICONS_ALIPAY_ROUND_PNG = + 'assets/icons/alipay_round.png'; + /// ![preview](file:///Users/zhangmeng/aku_community/assets/icons/app_add.png) static const String ASSETS_ICONS_APP_ADD_PNG = 'assets/icons/app_add.png'; diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 3e817404..57cea225 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -209,6 +209,10 @@ class _Manager { ///生活缴费:查询当前用户的房屋是否缴费 String get findEstatelsPament => '/user/dailyPayment/findEstateIsPayment'; + ///生活缴费:根据房产id查询对应的预付款充值金额 + String get dailyPaymentPrePay => + '/user/dailyPayment/findAdvancePaymentPriceByEstateId'; + ///活动投票:app查询所有活动投票信息 String get enventVotingList => '/user/eventVoting/list'; @@ -501,6 +505,13 @@ class _Pay { ///我的房屋-合同终止:app 房屋租赁-剩余需结清租金支付(当剩余需结清租金 小于等于 0 时调用): String get leaseRentOrderNegative => '/user/myHouse/leaseRentOrderAlipay'; + + ///支付宝支付:app 生活缴费-预充值支付 完成订单支付宝支付(生成 APP 支付订单信息) + String get dailPaymentPrePay => '/user/alipay/advancePaymentOrderAlipay'; + + ///支付宝支付:生活缴费-预充值支付 向支付宝发起订单查询请求 + String get dailPaymentPrePayCheck => + '/user/alipay/advancePaymentOrderCheckAlipay'; } class _House { diff --git a/lib/pages/life_pay/life_pay_page.dart b/lib/pages/life_pay/life_pay_page.dart index 90372392..dc52832f 100644 --- a/lib/pages/life_pay/life_pay_page.dart +++ b/lib/pages/life_pay/life_pay_page.dart @@ -1,4 +1,5 @@ import 'package:aku_community/pages/life_pay/life_pre_pay_page.dart'; +import 'package:aku_community/widget/others/user_tool.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -47,6 +48,7 @@ class _LifePayPageState extends State { List _models = []; //原model,禁止修改 int _page = 0; int _size = 10; + double _prePrice = 0; List _selectModels = []; //选中的models @@ -232,7 +234,7 @@ class _LifePayPageState extends State { children: [ '¥'.text.size(28.sp).black.make(), 16.w.widthBox, - '2300'.text.size(40.sp).black.bold.make(), + _prePrice.text.size(40.sp).black.bold.make(), Spacer(), MaterialButton( elevation: 0, @@ -243,7 +245,7 @@ class _LifePayPageState extends State { side: BorderSide(color: Color(0xFF979797), width: 1.w)), color: Colors.white, onPressed: () { - Get.to(() => LifePrePayPage()); + Get.to(() => LifePrePayPage(prePay: _prePrice,)); }, child: '预缴充值'.text.size(28.sp).black.make(), ) @@ -254,6 +256,18 @@ class _LifePayPageState extends State { ); } + Future _dailyPaymentPrePay() async { + BaseModel baseModel = + await NetUtil().get(API.manager.dailyPaymentPrePay, params: { + "estateId": UserTool.appProveider.selectedHouse!.estateId, + }); + if (baseModel.status ?? false) { + return (baseModel.data as num).toDouble(); + } else { + return 0; + } + } + @override Widget build(BuildContext context) { final appProvider = Provider.of(context); @@ -295,6 +309,7 @@ class _LifePayPageState extends State { for (var i = 0; i < _selectModels.length; i++) { _selectYears.add(i); } + _prePrice = await _dailyPaymentPrePay(); if (mounted) setState(() {}); }, child: Column( diff --git a/lib/pages/life_pay/life_pre_pay_page.dart b/lib/pages/life_pay/life_pre_pay_page.dart index 8188b735..de2277b6 100644 --- a/lib/pages/life_pay/life_pre_pay_page.dart +++ b/lib/pages/life_pay/life_pre_pay_page.dart @@ -1,18 +1,26 @@ import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/pages/life_pay/pay_finish_page.dart'; +import 'package:aku_community/pages/life_pay/pay_util.dart'; +import 'package:aku_community/utils/network/base_model.dart'; +import 'package:aku_community/utils/network/net_util.dart'; import 'package:aku_community/widget/bee_divider.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/bottom_sheets/pay_mothod_bottom_sheet.dart'; import 'package:aku_community/widget/buttons/bottom_button.dart'; -import 'package:aku_community/widget/others/bee_input_row.dart'; import 'package:aku_community/widget/others/house_head_card.dart'; +import 'package:aku_community/widget/others/user_tool.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; +import 'package:power_logger/power_logger.dart'; class LifePrePayPage extends StatefulWidget { - LifePrePayPage({Key? key}) : super(key: key); + final double prePay; + LifePrePayPage({Key? key, required this.prePay}) : super(key: key); @override _LifePrePayPageState createState() => _LifePrePayPageState(); @@ -72,7 +80,10 @@ class _LifePrePayPageState extends State { fontWeight: FontWeight.bold, color: Colors.black, ), - inputFormatters: [FilteringTextInputFormatter.digitsOnly], + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(r"^[0-9][\.\d]*(,\d+)?$")) + ], keyboardType: TextInputType.number, ).expand(), ], @@ -83,7 +94,8 @@ class _LifePrePayPageState extends State { '当前房屋下的预缴金额为 ' .richText .withTextSpanChildren([ - '2300' + widget.prePay + .toDoubleStringAsFixed() .textSpan .bold .size(28.sp) @@ -104,45 +116,64 @@ class _LifePrePayPageState extends State { ), ), 16.w.heightBox, - // Container( - // width: double.infinity, - // color: Colors.white, - // padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 32.w), - // child: Row( - // children: [ - // '缴费方式'.text.size(28.sp).black.make(), - // Spacer(), - // TextButton( - // onPressed: () async { - // Get.bottomSheet(PayMethodBottomSheet(onChoose: (value) { - // _paymethod = value; - // Get.back(); - // setState(() {}); - // })); - // }, - // child: _paymethod.text.size(28.sp).black.make()), - // 24.w.widthBox, - // Icon( - // CupertinoIcons.chevron_right, - // size: 40.w, - // ), - // ], - // ), - // ), - BeeInputRow.button( - title: '支付方式', - hintText: _payMethod, - onPressed: () { - Get.bottomSheet(PayMethodBottomSheet(onChoose: (value) { - _payMethod = value; - Get.back(); - setState(() {}); - })); - }), + Container( + width: double.infinity, + color: Colors.white, + padding: EdgeInsets.symmetric(vertical: 32.w, horizontal: 32.w), + child: Row( + children: [ + '缴费方式'.text.size(28.sp).black.make(), + Spacer(), + Image.asset( + R.ASSETS_ICONS_ALIPAY_ROUND_PNG, + width: 48.w, + height: 48.w, + ), + 16.w.widthBox, + TextButton( + onPressed: () async { + Get.bottomSheet(PayMethodBottomSheet(onChoose: (value) { + _payMethod = value; + Get.back(); + setState(() {}); + })); + }, + child: _payMethod.text.size(28.sp).black.make()), + 24.w.widthBox, + Icon( + CupertinoIcons.chevron_right, + size: 40.w, + ), + ], + ), + ), ], ), bottomNavi: BottomButton( - onPressed: () {}, child: '立即充值'.text.size(32.sp).bold.black.make()), + onPressed: () async { + Function cancel = BotToast.showLoading(); + try { + BaseModel baseModel = + await NetUtil().post(API.pay.dailPaymentPrePay, params: { + "estateId": UserTool.appProveider.selectedHouse!.estateId, + "payType": 1, + "payPrice": _editingController.text + }); + if (baseModel.status ?? false) { + bool result = await PayUtil().callAliPay( + baseModel.message!, API.pay.dailPaymentPrePayCheck); + if (result) { + Get.off(() => PayFinishPage()); + } + } else { + BotToast.showText(text: baseModel.message??""); + } + } catch (e) { + LoggerData.addData(e); + } + cancel(); + }, + child: '立即充值'.text.size(32.sp).bold.black.make()), ); } } diff --git a/lib/widget/bottom_sheets/pay_mothod_bottom_sheet.dart b/lib/widget/bottom_sheets/pay_mothod_bottom_sheet.dart index f4474c4f..127392b8 100644 --- a/lib/widget/bottom_sheets/pay_mothod_bottom_sheet.dart +++ b/lib/widget/bottom_sheets/pay_mothod_bottom_sheet.dart @@ -18,7 +18,7 @@ class PayMethodBottomSheet extends StatelessWidget { '支付方式'.text.size(32.sp).bold.color(ktextPrimary).isIntrinsic.make(), actions: [ CupertinoActionSheetAction( - onPressed: onChoose('支付宝'), + onPressed:()=> onChoose('支付宝'), child: '支付宝'.text.size(32.sp).color(ktextPrimary).isIntrinsic.make()) ],