diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 2bd3eaa7..1e28bf20 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -117,9 +117,15 @@ class _Settlement extends State { actProductSkuId ?? "", ); } else - queryOrderInfo(null, selectedBtn, null, 0, null, + queryOrderInfo( + null, + selectedBtn, + null, + 0, + null, actProductId ?? "", - actProductSkuId ?? "",); + actProductSkuId ?? "", + ); }); weChatResponseEventHandler.listen((event) async { @@ -170,7 +176,7 @@ class _Settlement extends State { setState(() { minOrderInfo = baseData.data; }); - }else{ + } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } } @@ -180,9 +186,15 @@ class _Settlement extends State { this.selectedBtn = selectedBtn; }); if (address != null) { - queryOrderInfo(address.id, selectedBtn, null, 0, null, + queryOrderInfo( + address.id, + selectedBtn, + null, + 0, + null, actProductId ?? "", - actProductSkuId ?? "",); + actProductSkuId ?? "", + ); return; } BaseData> baseDate = @@ -226,9 +238,15 @@ class _Settlement extends State { } } - queryOrderInfo(address.id, selectedBtn, null, 0, null, + queryOrderInfo( + address.id, + selectedBtn, + null, + 0, + null, actProductId ?? "", - actProductSkuId ?? "",); + actProductSkuId ?? "", + ); } } @@ -244,9 +262,15 @@ class _Settlement extends State { }); }); - queryOrderInfo(address.id, selectedBtn, null, 0, null, + queryOrderInfo( + address.id, + selectedBtn, + null, + 0, + null, actProductId ?? "", - actProductSkuId ?? "",); + actProductSkuId ?? "", + ); } } @@ -306,11 +330,12 @@ class _Settlement extends State { if (baseData != null && baseData.isSuccess) { placeOrder = true; this.downOrder = baseData.data; - querySettlement(); + pageType != null ? activityPay() : querySettlement(); } else { - baseData?.isSuccess ?? false ? - SmartDialog.showToast("下单失败:订单实付金额不能为0", alignment: Alignment.center) : - SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + baseData?.isSuccess ?? false + ? SmartDialog.showToast("下单失败:订单实付金额不能为0", + alignment: Alignment.center) + : SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } } else { ///火锅店下单, 等待结算 @@ -358,7 +383,7 @@ class _Settlement extends State { ? minOrderInfo.orderProductVOList : downOrder.orderProductVOList; if (placeOrderFirst.payChannel == 1) { - if(Platform.isAndroid){ + if (Platform.isAndroid) { if (!(await Min.isInitialize())) { // 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调, // 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针, @@ -408,6 +433,68 @@ class _Settlement extends State { } } + ///活动结算 + activityPay() async { + placeOrderFirst.id = widget.arguments["orderId"] != "" + ? widget.arguments["orderId"] + : downOrder.id; + placeOrderFirst.orderProductVOList = downOrder == null + ? minOrderInfo.orderProductVOList + : downOrder.orderProductVOList; + if (placeOrderFirst.payChannel == 1) { + if (Platform.isAndroid) { + if (!(await Min.isInitialize())) { + // 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调, + // 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针, + // 故而在此初始化一下 + await Min.initialize(); + } + } + BaseData baseData = await minService + .actPay({ + "orderId": widget.arguments["orderId"], + "payChannel":placeOrderFirst.payChannel + }).catchError((error) { + print(error); + }); + if (baseData != null && baseData.isSuccess) { + WxPay wxPay = baseData.data; + await registerWxApi( + appId: wxPay.appId, + doOnAndroid: true, + universalLink: "https://hx.lotus-wallet.com/app/", + ); + payWithWeChat( + appId: wxPay.appId, + partnerId: wxPay.partnerId, + prepayId: wxPay.prepayId, + packageValue: wxPay.packageValue, + nonceStr: wxPay.nonceStr, + timeStamp: int.tryParse(wxPay.timeStamp), + sign: wxPay.sign, + ); + } + } else { + BaseData baseData = await minService.actPay({ + "orderId": widget.arguments["orderId"], + "payChannel":placeOrderFirst.payChannel + }).catchError((error) { + print(error); + }); + if (baseData != null && baseData.isSuccess) { + toOrderDetails(placeOrderFirst.id); + } else { + SmartDialog.show( + widget: Tips( + () { + toOrderDetails(placeOrderFirst.id); + }, + text: "${baseData.msg}", + )); + } + } + } + toOrderDetails(String orderId) { Navigator.of(context).popAndPushNamed( '/router/order_details', @@ -460,10 +547,15 @@ class _Settlement extends State { setState(() { this.selectedBtn = 0; }); - queryOrderInfo(addressId, isTake, - memberCouponId, orderId, promotionId, + queryOrderInfo( + addressId, + isTake, + memberCouponId, + orderId, + promotionId, actProductId ?? "", - actProductSkuId ?? "",); + actProductSkuId ?? "", + ); }, queryAddress, storeInfo, address, selectedAddress, pageType), diff --git a/lib/store/shopping/shopping_goods_details.dart b/lib/store/shopping/shopping_goods_details.dart index 7b59f45f..eb50a5a9 100644 --- a/lib/store/shopping/shopping_goods_details.dart +++ b/lib/store/shopping/shopping_goods_details.dart @@ -5,8 +5,6 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:flutter_html/flutter_html.dart'; -import 'package:flutter_html/image_render.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/generated/l10n.dart'; @@ -15,7 +13,6 @@ import 'package:huixiang/retrofit/data/activity_details.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/launch_join_act.dart'; import 'package:huixiang/retrofit/data/miNiDetail.dart'; -import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart';