diff --git a/android/app/build.gradle b/android/app/build.gradle index d89382c..f652ce3 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -20,11 +20,13 @@ def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } + def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } + apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" diff --git a/lib/ui/user/members_page.dart b/lib/ui/user/members_page.dart index 61dd763..b4d318e 100644 --- a/lib/ui/user/members_page.dart +++ b/lib/ui/user/members_page.dart @@ -10,6 +10,12 @@ import 'package:project_telephony/utils/headers.dart'; import 'package:tobias/tobias.dart'; import 'package:fluwx/fluwx.dart' as fluwx; +import '../../constants/api.dart'; +import '../../model/network/api_client.dart'; +import '../../model/pay/wx_pay_model.dart'; +import '../../utils/pay_util.dart'; +import '../../utils/toast/cloud_toast.dart'; + class MembersPage extends StatefulWidget { const MembersPage({Key? key}) : super(key: key); @@ -40,9 +46,9 @@ List payWay = [ ]; class _MembersPageState extends State { - @override - + int nowPrice=1; + @override Widget build(BuildContext context) { return Scaffold( body: Stack( @@ -84,15 +90,16 @@ class _MembersPageState extends State { if(!result){ Get.snackbar('提示', "请先安装支付宝"); }else{ - aliPay("paySign").then((payResult) { - // map["paySign"]是请求接口返回的字符串直接放进去就好了 - print("支付宝:$payResult"); - if (payResult['resultStatus'] == '9000') { - Get.snackbar('提示', "充值成功"); - } else { - Get.snackbar('提示', payResult['memo']); - } - }); + _aliPay(); + // aliPay("paySign").then((payResult) { + // // map["paySign"]是请求接口返回的字符串直接放进去就好了 + // print("支付宝:$payResult"); + // if (payResult['resultStatus'] == '9000') { + // Get.snackbar('提示', "充值成功"); + // } else { + // Get.snackbar('提示', payResult['memo']); + // } + // }); } } } @@ -206,20 +213,7 @@ class _MembersPageState extends State { return ; } //调起支付 - fluwx.payWithWeChat( - appId: "wxd930ea5d5a228f5f", - partnerId: "partnerId", - prepayId: "prepayId", - packageValue: "packageValue", - nonceStr: "nonceStr", - timeStamp: 1597927308, - sign: "sign"); - fluwx.weChatResponseEventHandler.listen((event) { if(event.isSuccessful){ - BotToast.showText(text: "微信支付成功"); - }else{ - BotToast.showText(text: "微信支付失败"); - } - }); + _wxPay(); // var wxPayModel = WxPayModel.fromJson({ // "prepayId": "wx121434071826969924754d7d3309520000", // "partnerId": "1622850618", @@ -253,22 +247,31 @@ class _MembersPageState extends State { // } // } // - // Future _aliPayFunc() async { - // var base = await apiClient.request(API.user.wallet.assessRecharge, data: { - // 'count': widget.count, - // 'payType': 1, - // }); - // if (base.code == 0) { - // var re = await PayUtil().callAliPay(base.data['content']); - // if (re) { - // _paySuccess(); - // } else { - // BotToast.closeAllLoading(); - // } - // } else { - // CloudToast.show(base.msg); - // } - // } + Future _aliPay() async { + var base = await apiClient.request(API.pay.alipay, data: { + // 'amount': nowPrice,//注释 + 'amount': 0.01, + }); + if (base.code == 0) { + await PayUtil().callAliPay(base.data); + } else { + CloudToast.show(base.msg); + } + } + Future _wxPay() async { + var base = await apiClient.request(API.pay.wxpay, data: { + // 'amount': nowPrice,//注释 + 'amount': 0.1, + }); + if (base.code == 0) { + var wxPayModel = WxPayModel.fromJson(base.data); + await PayUtil().callWxPay( + payModel: wxPayModel, + ); + } else { + CloudToast.show(base.msg); + } + } //充值金额 _getRecharge() { @@ -289,7 +292,7 @@ class _MembersPageState extends State { mainAxisSpacing: 20.w, callback: (item, index) { _chooseItem = item; - // print(_piceList[index].pice); + nowPrice=_piceList[index].pice; setState(() {}); }, pickItem: _chooseItem, diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index 5e16542..9ca90a8 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -1,3 +1,4 @@ +import 'package:bot_toast/bot_toast.dart'; import 'package:flustars/flustars.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -107,7 +108,9 @@ class _UserPageState extends State { children: [ GestureDetector( onTap: () { - Get.to(() => const LoginPage()); + if(!userProvider.isLogin){ + Get.to(() => const LoginPage()); + } }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -184,8 +187,11 @@ class _UserPageState extends State { _getBotton() { return GestureDetector( onTap: () { - // print(vle); - Get.to(() => const MembersPage()); + if(userProvider.isLogin){ + Get.to(() => const MembersPage()); + }else{ + BotToast.showText(text: '您还未登录,请先登录!'); + } }, child: Container( padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 16.w), diff --git a/lib/utils/pay_util.dart b/lib/utils/pay_util.dart index fb7672f..193a03d 100644 --- a/lib/utils/pay_util.dart +++ b/lib/utils/pay_util.dart @@ -155,7 +155,7 @@ class PayUtil { required WxPayModel payModel, }) async { await payWithWeChat( - appId: 'wx9bc3ffb23a749254', + appId: 'wx3a0b41d12afef4e2', partnerId: payModel.partnerId, prepayId: payModel.prepayId, packageValue: payModel.package,