支付接口

master
戴余标 2 years ago
parent c6d424ceaa
commit 73224dcd0f

@ -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"

@ -6,12 +6,11 @@ class API {
///HOST
static String get host {
if (DevEV.instance.dev) {
return 'http://10.0.2.2:8088/';
// return 'http://api.dxbs.vip';
// return 'http://10.0.2.2:8088/';
return 'http://api.dxbs.vip';
} else {
return 'http://10.0.2.2:8088/';
// return 'http://api.dxbs.vip/';
// return 'http://10.0.2.2:8088/';
return 'http://api.dxbs.vip/';
}
}

@ -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<MembersPage> {
@override
int nowPrice=1;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
@ -84,15 +90,16 @@ class _MembersPageState extends State<MembersPage> {
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<MembersPage> {
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<MembersPage> {
// }
// }
//
// 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<MembersPage> {
mainAxisSpacing: 20.w,
callback: (item, index) {
_chooseItem = item;
// print(_piceList[index].pice);
nowPrice=_piceList[index].pice;
setState(() {});
},
pickItem: _chooseItem,

@ -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';
@ -104,7 +105,9 @@ class _UserPageState extends State<UserPage> {
children: [
GestureDetector(
onTap: () {
Get.to(() => const LoginPage());
if(!userProvider.isLogin){
Get.to(() => const LoginPage());
}
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -180,8 +183,11 @@ class _UserPageState extends State<UserPage> {
_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),

@ -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,

Loading…
Cancel
Save