|
@@ -2,6 +2,7 @@ import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:bbyyy/beans/alipay_result_bean_entity.dart';
|
|
import 'package:bbyyy/beans/alipay_result_bean_entity.dart';
|
|
|
import 'package:bbyyy/beans/my_shop_bean_entity.dart';
|
|
import 'package:bbyyy/beans/my_shop_bean_entity.dart';
|
|
|
|
|
+import 'package:bbyyy/beans/offline_payment_bean_entity.dart';
|
|
|
import 'package:bbyyy/beans/pay_by_alipay_bean_entity.dart';
|
|
import 'package:bbyyy/beans/pay_by_alipay_bean_entity.dart';
|
|
|
import 'package:bbyyy/beans/store_bean_entity.dart';
|
|
import 'package:bbyyy/beans/store_bean_entity.dart';
|
|
|
import 'package:bbyyy/beans/user_balance_entity.dart';
|
|
import 'package:bbyyy/beans/user_balance_entity.dart';
|
|
@@ -16,10 +17,10 @@ import 'package:bbyyy/my_tools/my_colors.dart';
|
|
|
import 'package:bbyyy/my_tools/my_cookie.dart';
|
|
import 'package:bbyyy/my_tools/my_cookie.dart';
|
|
|
import 'package:bbyyy/my_tools/my_tools.dart';
|
|
import 'package:bbyyy/my_tools/my_tools.dart';
|
|
|
import 'package:bbyyy/my_tools/my_views.dart';
|
|
import 'package:bbyyy/my_tools/my_views.dart';
|
|
|
|
|
+import 'package:bbyyy/paegs/alipay_page/alipay_page.dart';
|
|
|
import 'package:bbyyy/pay/pay_tools.dart';
|
|
import 'package:bbyyy/pay/pay_tools.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
-import 'package:bbyyy/beans/offline_payment_bean_entity.dart';
|
|
|
|
|
import 'package:tobias/tobias.dart';
|
|
import 'package:tobias/tobias.dart';
|
|
|
|
|
|
|
|
class PayToTheHelperPage extends StatefulWidget {
|
|
class PayToTheHelperPage extends StatefulWidget {
|
|
@@ -118,7 +119,8 @@ class _PayToTheHelperPageState extends State<PayToTheHelperPage> {
|
|
|
fontWeight: FontWeight.bold,
|
|
fontWeight: FontWeight.bold,
|
|
|
height: 1.3,
|
|
height: 1.3,
|
|
|
letterSpacing: 0.2),
|
|
letterSpacing: 0.2),
|
|
|
- keyboardType: TextInputType.numberWithOptions(decimal: true),
|
|
|
|
|
|
|
+ keyboardType: TextInputType.numberWithOptions(
|
|
|
|
|
+ decimal: true),
|
|
|
onChanged: (t) {
|
|
onChanged: (t) {
|
|
|
setState(() {});
|
|
setState(() {});
|
|
|
},
|
|
},
|
|
@@ -178,7 +180,8 @@ class _PayToTheHelperPageState extends State<PayToTheHelperPage> {
|
|
|
}
|
|
}
|
|
|
}, (response, hasError) {
|
|
}, (response, hasError) {
|
|
|
if (!hasError) {
|
|
if (!hasError) {
|
|
|
- OfflinePaymentBeanEntity entity = OfflinePaymentBeanEntity().fromJson(json.decode(response.data.toString()));
|
|
|
|
|
|
|
+ OfflinePaymentBeanEntity entity = OfflinePaymentBeanEntity()
|
|
|
|
|
+ .fromJson(json.decode(response.data.toString()));
|
|
|
payTheOrder(entity.data);
|
|
payTheOrder(entity.data);
|
|
|
}
|
|
}
|
|
|
}, (error) {});
|
|
}, (error) {});
|
|
@@ -210,62 +213,25 @@ class _PayToTheHelperPageState extends State<PayToTheHelperPage> {
|
|
|
void payTheOrder(int orderUID) {
|
|
void payTheOrder(int orderUID) {
|
|
|
getUserWalletBalance((re, hE) {
|
|
getUserWalletBalance((re, hE) {
|
|
|
if (!hE) {
|
|
if (!hE) {
|
|
|
- UserBalanceEntity balance = UserBalanceEntity()
|
|
|
|
|
- .fromJson(json.decode(re.data.toString()));
|
|
|
|
|
|
|
+ UserBalanceEntity balance =
|
|
|
|
|
+ UserBalanceEntity().fromJson(json.decode(re.data.toString()));
|
|
|
if (balance.data >= amount) {
|
|
if (balance.data >= amount) {
|
|
|
- payOrder(payWayWallet, orderUID,
|
|
|
|
|
- (re, hE) {
|
|
|
|
|
- if (!hE) {
|
|
|
|
|
- showToast('支付成功');
|
|
|
|
|
- EventBus().emit('payAnOrder');
|
|
|
|
|
- Navigator.pop(context);
|
|
|
|
|
- }
|
|
|
|
|
- }, (e) {}, context);
|
|
|
|
|
|
|
+ payOrder(payWayWallet, orderUID, (re, hE) {
|
|
|
|
|
+ if (!hE) {
|
|
|
|
|
+ showToast('支付成功');
|
|
|
|
|
+ EventBus().emit('payAnOrder');
|
|
|
|
|
+ Navigator.pop(context);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, (e) {}, context);
|
|
|
} else {
|
|
} else {
|
|
|
- payOrder(payWayAliPay, orderUID,
|
|
|
|
|
- (re, hE) {
|
|
|
|
|
- if (!hE) {
|
|
|
|
|
- PayByAlipayBeanEntity entity =
|
|
|
|
|
- PayByAlipayBeanEntity().fromJson(
|
|
|
|
|
- json.decode(re.data.toString()));
|
|
|
|
|
- EventBus().on('alipayPaymentCallback',
|
|
|
|
|
- (arg) {
|
|
|
|
|
- EventBus().off('alipayPaymentCallback');
|
|
|
|
|
- EasyLoading.dismiss();
|
|
|
|
|
- showToast('支付成功');
|
|
|
|
|
- EventBus().emit('reNoPayOrder');
|
|
|
|
|
- Navigator.pop(context);
|
|
|
|
|
- });
|
|
|
|
|
- print(entity.data);
|
|
|
|
|
- EasyLoading.instance
|
|
|
|
|
- ..contentPadding = EdgeInsets.symmetric(
|
|
|
|
|
- horizontal: 20, vertical: 12)
|
|
|
|
|
- ..alignment = Alignment.center
|
|
|
|
|
- ..loadingStyle = EasyLoadingStyle.light
|
|
|
|
|
- ..contentMargin = EdgeInsets.all(20);
|
|
|
|
|
- EasyLoading.show();
|
|
|
|
|
- aliPay(entity.data).then((value) {
|
|
|
|
|
- print(json.encode(value));
|
|
|
|
|
- AlipayResultBeanEntity e =
|
|
|
|
|
- AlipayResultBeanEntity().fromJson(
|
|
|
|
|
- json.decode(json.encode(value)));
|
|
|
|
|
- try {
|
|
|
|
|
- int r = int.parse(e.resultStatus);
|
|
|
|
|
- if (r == 9000) {
|
|
|
|
|
- showToast('支付成功');
|
|
|
|
|
- Navigator.pop(context);
|
|
|
|
|
- } else {
|
|
|
|
|
- showToast(aliPayResultStatus(r));
|
|
|
|
|
- revokePayOrder(orderUID);
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- EasyLoading.dismiss();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- // EventBus().emit('payAnOrder');
|
|
|
|
|
- }
|
|
|
|
|
- }, (e) {}, context);
|
|
|
|
|
- // showToast('积分余额不足');
|
|
|
|
|
|
|
+ _controller.clear();
|
|
|
|
|
+ MyTools().toPage(context, AlipayPage(orderUID), (then){
|
|
|
|
|
+ if(then is String){
|
|
|
|
|
+ if(then == '支付成功'){
|
|
|
|
|
+ Navigator.pop(context);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}, (e) {}, context);
|
|
}, (e) {}, context);
|