|
...
|
...
|
@@ -3,8 +3,10 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:one_key/models/sms_info.dart';
|
|
|
|
import 'package:one_key/pages/my/sms_recharge_item_page.dart';
|
|
|
|
import 'package:one_key/provider/sms_recharge_provider.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/event_bus.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/round_button.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
...
|
...
|
@@ -24,6 +26,25 @@ class _SmsRechargePageState extends State<SmsRechargePage> { |
|
|
|
ScrollController controller = ScrollController();
|
|
|
|
Meals mealsSelected;
|
|
|
|
SmsRechargeModel rechargeModel;
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
fluwx.weChatResponseEventHandler.listen((res) {
|
|
|
|
if (res is fluwx.WeChatPaymentResponse) {
|
|
|
|
print("pay :${res.isSuccessful}");
|
|
|
|
if (res.errCode == 0) {
|
|
|
|
// Utils.showToast('购买成功');
|
|
|
|
bus.emit('refreshSmsNum');
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
Navigator.pop(context);
|
|
|
|
} else if (res.errCode == -1) {
|
|
|
|
Utils.showToast('支付错误');
|
|
|
|
} else if (res.errCode == -2) {
|
|
|
|
Utils.showToast('您已取消支付');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
...
|
...
|
@@ -129,26 +150,45 @@ class _SmsRechargePageState extends State<SmsRechargePage> { |
|
|
|
height: ScreenUtil().setWidth(70),
|
|
|
|
textColor: MyColours.color_F0F0F0,
|
|
|
|
onPressed: () async {
|
|
|
|
if (mealsSelected == null) {
|
|
|
|
Utils.showToast('请选择您要购买的短信套餐');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//1.接口请求微信支付所需参数
|
|
|
|
//2.成功后掉起微信支付
|
|
|
|
Map<String, String> params;
|
|
|
|
Map<String, String> params = {
|
|
|
|
'sellerid':
|
|
|
|
Provider.of<UserModel>(context, listen: false)
|
|
|
|
.user
|
|
|
|
.sellerid,
|
|
|
|
'meal_id': mealsSelected.id,
|
|
|
|
// 'price': '0.01'
|
|
|
|
'price': mealsSelected.price
|
|
|
|
};
|
|
|
|
bool success = await rechargeModel.getWechatPayInfo(
|
|
|
|
context, params);
|
|
|
|
if (success) {
|
|
|
|
print(rechargeModel.sunModel.package.substring(10));
|
|
|
|
//掉起微信支付
|
|
|
|
// fluwx
|
|
|
|
// .payWithWeChat(
|
|
|
|
// appId: result['appid'].toString(),
|
|
|
|
// partnerId: result['partnerid'].toString(),
|
|
|
|
// prepayId: result['prepayid'].toString(),
|
|
|
|
// packageValue: result['package'].toString(),
|
|
|
|
// nonceStr: result['noncestr'].toString(),
|
|
|
|
// timeStamp: result['timestamp'],
|
|
|
|
// sign: result['sign'].toString(),
|
|
|
|
// )
|
|
|
|
// .then((data) {
|
|
|
|
// print("---》$data");
|
|
|
|
// });
|
|
|
|
fluwx
|
|
|
|
.payWithWeChat(
|
|
|
|
// appId: 'wx85aa3cdd0f791e65',
|
|
|
|
// appId: 'wx71921f840e8f1c34',
|
|
|
|
appId: rechargeModel.sunModel.appId,
|
|
|
|
partnerId: '1489405762',
|
|
|
|
prepayId: rechargeModel.sunModel.package
|
|
|
|
.substring(10),
|
|
|
|
packageValue: 'Sign=WXPay',
|
|
|
|
nonceStr: rechargeModel.sunModel.nonceStr,
|
|
|
|
timeStamp: int.parse(
|
|
|
|
rechargeModel.sunModel.timeStamp),
|
|
|
|
// sign: rechargeModel.sunModel.paySign,
|
|
|
|
sign: 'MD5')
|
|
|
|
.then((data) {
|
|
|
|
print("---》$data");
|
|
|
|
}).catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
//给用户提示错误
|
|
|
|
}
|
...
|
...
|
|